@moo.md/hum 0.0.0-stage → 0.1.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/defaults/hum.json +321 -0
- package/defaults/kinds/check.json +183 -0
- package/defaults/kinds/docs.json +151 -0
- package/defaults/kinds/feature.json +202 -0
- package/defaults/kinds/fix.json +183 -0
- package/defaults/kinds/hotfix.json +164 -0
- package/defaults/roles/build.md +3 -0
- package/defaults/roles/fix.md +1 -0
- package/defaults/roles/plan.md +3 -0
- package/defaults/roles/review.md +3 -0
- package/evals/alignment/RESULTS.md +8 -0
- package/evals/alignment/cases.jsonl +128 -0
- package/evals/alignment/sample.jsonl +20 -0
- package/evals/kind/RESULTS.md +5 -0
- package/evals/kind/cases.jsonl +24 -0
- package/evals/plan-outcome/RESULTS.md +4 -0
- package/evals/plan-outcome/cases.jsonl +12 -0
- package/evals/repeat-pair/RESULTS.md +4 -0
- package/evals/repeat-pair/cases.jsonl +51 -0
- package/evals/reply-option/RESULTS.md +3 -0
- package/evals/reply-option/cases.jsonl +45 -0
- package/evals/review-verdict/RESULTS.md +4 -0
- package/evals/review-verdict/cases.jsonl +12 -0
- package/package.json +88 -4
- package/schema/hum.schema.json +1355 -0
- package/scripts/eval.ts +244 -0
- package/src/adapter-api.ts +134 -0
- package/src/adapters/admit.ts +111 -0
- package/src/adapters/argument.ts +11 -0
- package/src/adapters/claim.ts +93 -0
- package/src/adapters/claude-bg.ts +392 -0
- package/src/adapters/claude-p.ts +599 -0
- package/src/adapters/contract.ts +231 -0
- package/src/adapters/fake.ts +157 -0
- package/src/adapters/git.ts +156 -0
- package/src/adapters/github.ts +479 -0
- package/src/adapters/guard.ts +152 -0
- package/src/adapters/history.ts +215 -0
- package/src/adapters/item-file.ts +102 -0
- package/src/adapters/limit.ts +67 -0
- package/src/adapters/markdown.ts +365 -0
- package/src/adapters/marked.ts +127 -0
- package/src/adapters/model-call.ts +75 -0
- package/src/adapters/once.ts +45 -0
- package/src/adapters/owner-commit.ts +60 -0
- package/src/adapters/pull-requests.ts +253 -0
- package/src/adapters/registry.ts +156 -0
- package/src/adapters/roundup.ts +293 -0
- package/src/adapters/serial.ts +22 -0
- package/src/adapters/transcript.ts +99 -0
- package/src/cli/commands.ts +46 -0
- package/src/cli/main.ts +8 -0
- package/src/cli/ops.ts +224 -0
- package/src/cli/service.ts +156 -0
- package/src/cli/setup.ts +141 -0
- package/src/cli/shared-watch.ts +127 -0
- package/src/config/change.ts +54 -0
- package/src/config/checks.ts +217 -0
- package/src/config/git-ref-name.d.ts +3 -0
- package/src/config/hash.ts +6 -0
- package/src/config/json.ts +6 -0
- package/src/config/load.ts +88 -0
- package/src/config/machine.ts +20 -0
- package/src/config/migrate.ts +61 -0
- package/src/config/refusal.ts +58 -0
- package/src/config/schema.ts +465 -0
- package/src/config/settings.ts +6 -0
- package/src/config/state-map.ts +76 -0
- package/src/decide/alignment.ts +79 -0
- package/src/decide/answer.ts +131 -0
- package/src/decide/kind.ts +39 -0
- package/src/decide/labels.ts +137 -0
- package/src/decide/merge.ts +102 -0
- package/src/decide/prose.ts +109 -0
- package/src/decide/question.ts +159 -0
- package/src/decide/review.ts +10 -0
- package/src/decide/risk.ts +216 -0
- package/src/decide/taste.ts +37 -0
- package/src/exec.ts +85 -0
- package/src/index.ts +200 -0
- package/src/loop/breaks.ts +8 -0
- package/src/loop/check-item.ts +76 -0
- package/src/loop/ci.ts +8 -0
- package/src/loop/github.ts +81 -0
- package/src/loop/groups.ts +108 -0
- package/src/loop/memory.ts +70 -0
- package/src/loop/notes.ts +76 -0
- package/src/loop/pair.ts +39 -0
- package/src/loop/pass.ts +99 -0
- package/src/loop/proof.ts +85 -0
- package/src/loop/prove-item.ts +33 -0
- package/src/loop/records.ts +75 -0
- package/src/loop/signals.ts +130 -0
- package/src/measure/inputs.ts +28 -0
- package/src/measure/measure.ts +68 -0
- package/src/service/cards.ts +24 -0
- package/src/service/ci-tick.ts +28 -0
- package/src/service/launchd.ts +16 -0
- package/src/service/supervise.ts +145 -0
- package/src/service/systemd.ts +44 -0
- package/src/service/token.ts +21 -0
- package/src/service/unit.ts +29 -0
- package/src/service/wake.ts +30 -0
- package/src/service/workflows.ts +97 -0
- package/src/setup/propose.ts +120 -0
- package/src/setup/prove.ts +216 -0
- package/src/setup/scan.ts +186 -0
- package/src/setup/scratch.ts +81 -0
- package/src/setup/shipped.ts +15 -0
- package/src/setup/tables.ts +101 -0
- package/src/setup/waits.ts +58 -0
- package/src/setup/write.ts +161 -0
- package/src/slots/env.ts +42 -0
- package/src/slots/pool.ts +329 -0
- package/src/slots/scan.ts +26 -0
- package/src/slots/worktree.ts +17 -0
- package/src/state/events.ts +52 -0
- package/src/state/faults.ts +73 -0
- package/src/state/format.ts +50 -0
- package/src/state/fs.ts +100 -0
- package/src/state/items.ts +195 -0
- package/src/state/open.ts +80 -0
- package/src/state/ops.ts +76 -0
- package/src/state/records.ts +35 -0
- package/src/state/runs.ts +99 -0
- package/src/state/saved.ts +119 -0
- package/src/status/file.ts +49 -0
- package/src/status/format.ts +132 -0
- package/src/status/sections.ts +14 -0
- package/src/status/version.ts +2 -0
- package/src/time.ts +7 -0
- package/src/worker/alignment-report.ts +18 -0
- package/src/worker/answers.ts +153 -0
- package/src/worker/base-check.ts +45 -0
- package/src/worker/checks.ts +40 -0
- package/src/worker/kind.ts +68 -0
- package/src/worker/land.ts +509 -0
- package/src/worker/lifecycle.ts +97 -0
- package/src/worker/merged.ts +29 -0
- package/src/worker/open.ts +100 -0
- package/src/worker/prose-run.ts +56 -0
- package/src/worker/questions.ts +89 -0
- package/src/worker/scheduler.ts +135 -0
- package/src/worker/signature.ts +41 -0
- package/src/worker/tally.ts +25 -0
- package/src/worker/taste.ts +38 -0
- package/src/worker/thin-path.ts +886 -0
- package/src/worker/worker.ts +750 -0
- package/surface.json +8787 -0
- package/README.md +0 -3
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/core";
|
|
2
|
+
import { GraphqlResponseError } from "@octokit/graphql";
|
|
3
|
+
import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
|
|
4
|
+
import { type ThrottlingOptions, throttling } from "@octokit/plugin-throttling";
|
|
5
|
+
import { RequestError } from "@octokit/request-error";
|
|
6
|
+
import hostedGitInfo from "hosted-git-info";
|
|
7
|
+
import pMemoize from "p-memoize";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { type Adapter, type AdapterContext, type Answers, type Claim, type Item, ItemId, PermanentError, type Questions, type Release, type Watch, type WorkSource } from "../adapter-api.ts";
|
|
10
|
+
import type { Json } from "../config/json.ts";
|
|
11
|
+
import type { MERGE_METHODS } from "../config/schema.ts";
|
|
12
|
+
import { exec } from "../exec.ts";
|
|
13
|
+
import { parseArgument } from "./argument.ts";
|
|
14
|
+
import { claimCommit, claimCommitMessage, claimer, claimOfCommit, isLive } from "./claim.ts";
|
|
15
|
+
import { answerMarker, commentText, filedFollowUp, followUpBody, followUpNote, isFollowUpOf, type Marker, marked, parseComment, questionMarker, questionText } from "./marked.ts";
|
|
16
|
+
|
|
17
|
+
const RATE_LIMIT_RETRIES = 1;
|
|
18
|
+
const NOT_MODIFIED = 304;
|
|
19
|
+
const READY_LABEL_COLOR = "0e8a16";
|
|
20
|
+
const READY_LABEL_DESCRIPTION = "hum may take this item";
|
|
21
|
+
|
|
22
|
+
const HumOctokit = Octokit.plugin(throttling, paginateGraphQL);
|
|
23
|
+
|
|
24
|
+
export type GitHubClient = InstanceType<typeof HumOctokit>;
|
|
25
|
+
|
|
26
|
+
type Variables = Readonly<Record<string, Json>>;
|
|
27
|
+
|
|
28
|
+
/** The GraphQL name of each merge method. */
|
|
29
|
+
export const MERGE_METHOD = { merge: "MERGE", squash: "SQUASH", rebase: "REBASE" } as const satisfies Record<(typeof MERGE_METHODS)[number], string>;
|
|
30
|
+
|
|
31
|
+
const IssueNumber = ItemId.pipe(z.string().regex(/^[1-9]\d*$/, "a GitHub issue number is a whole number above 0")).transform(Number);
|
|
32
|
+
|
|
33
|
+
const Repo = z.string().regex(/^[\w.-]+\/[\w.-]+$/, "a GitHub repo is owner/name");
|
|
34
|
+
|
|
35
|
+
const Commit = z.object({ oid: z.string(), message: z.string() });
|
|
36
|
+
|
|
37
|
+
const Labels = z.object({ nodes: z.array(z.object({ name: z.string() })) });
|
|
38
|
+
|
|
39
|
+
const ReadyItems = z.object({
|
|
40
|
+
repository: z.object({
|
|
41
|
+
issues: z.object({ nodes: z.array(z.object({ number: z.int().positive(), title: z.string() })) }),
|
|
42
|
+
refs: z.object({ totalCount: z.int(), nodes: z.array(z.object({ name: z.string(), target: Commit.partial() })) }),
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const ItemReply = z.object({
|
|
47
|
+
repository: z.object({
|
|
48
|
+
issue: z.object({
|
|
49
|
+
id: z.string(),
|
|
50
|
+
title: z.string(),
|
|
51
|
+
body: z.string(),
|
|
52
|
+
state: z.enum(["OPEN", "CLOSED"]),
|
|
53
|
+
labels: Labels,
|
|
54
|
+
comments: z.object({ nodes: z.array(z.object({ body: z.string(), createdAt: z.string() })) }),
|
|
55
|
+
}),
|
|
56
|
+
ref: z.object({ target: Commit.partial() }).nullable(),
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const ClaimReply = z.object({ repository: z.object({ ref: z.object({ target: Commit }).nullable() }) });
|
|
61
|
+
|
|
62
|
+
const IssueStateReply = z.object({ repository: z.object({ issue: z.object({ id: z.string(), state: z.enum(["OPEN", "CLOSED"]), labels: Labels }) }) });
|
|
63
|
+
|
|
64
|
+
const BaseReply = z.object({ repository: z.object({ id: z.string(), ref: z.object({ target: z.object({ oid: z.string(), tree: z.object({ oid: z.string() }) }) }) }) });
|
|
65
|
+
|
|
66
|
+
const LabelReply = z.object({ repository: z.object({ id: z.string(), label: z.object({ id: z.string() }).nullable() }) });
|
|
67
|
+
|
|
68
|
+
const CreatedLabel = z.object({ createLabel: z.object({ label: z.object({ id: z.string() }) }) });
|
|
69
|
+
|
|
70
|
+
const CreatedIssue = z.object({ createIssue: z.object({ issue: z.object({ number: z.int().positive() }) }) });
|
|
71
|
+
|
|
72
|
+
const RecentIssuesReply = z.object({ repository: z.object({ issues: z.object({ nodes: z.array(z.object({ number: z.int().positive(), title: z.string(), body: z.string() })) }) }) });
|
|
73
|
+
|
|
74
|
+
const PullsReply = z.object({
|
|
75
|
+
repository: z.object({
|
|
76
|
+
id: z.string(),
|
|
77
|
+
issue: z.object({ title: z.string() }),
|
|
78
|
+
pullRequests: z.object({ nodes: z.array(z.object({ id: z.string(), state: z.enum(["OPEN", "MERGED", "CLOSED"]) })) }),
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const CreatedCommit = z.object({ sha: z.string() });
|
|
83
|
+
|
|
84
|
+
/** The reply of a write whose result hum does not read. */
|
|
85
|
+
const Acknowledged = z.looseObject({});
|
|
86
|
+
|
|
87
|
+
const READY_ITEMS = `query ReadyItems($owner: String!, $name: String!, $label: String!, $claimRefs: String!, $cursor: String) {
|
|
88
|
+
repository(owner: $owner, name: $name) {
|
|
89
|
+
issues(states: OPEN, labels: [$label], first: 100, after: $cursor, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
90
|
+
nodes { number title }
|
|
91
|
+
pageInfo { hasNextPage endCursor }
|
|
92
|
+
}
|
|
93
|
+
refs(refPrefix: $claimRefs, first: 100) { totalCount nodes { name target { ... on Commit { message } } } }
|
|
94
|
+
}
|
|
95
|
+
}`;
|
|
96
|
+
|
|
97
|
+
const ITEM = `query Item($owner: String!, $name: String!, $number: Int!, $claimRef: String!, $cursor: String) {
|
|
98
|
+
repository(owner: $owner, name: $name) {
|
|
99
|
+
issue(number: $number) {
|
|
100
|
+
id title body state
|
|
101
|
+
labels(first: 100) { nodes { name } }
|
|
102
|
+
comments(first: 100, after: $cursor) { nodes { body createdAt } pageInfo { hasNextPage endCursor } }
|
|
103
|
+
}
|
|
104
|
+
ref(qualifiedName: $claimRef) { target { ... on Commit { message } } }
|
|
105
|
+
}
|
|
106
|
+
}`;
|
|
107
|
+
|
|
108
|
+
const CLAIM = `query Claim($owner: String!, $name: String!, $claimRef: String!) {
|
|
109
|
+
repository(owner: $owner, name: $name) { ref(qualifiedName: $claimRef) { target { ... on Commit { oid message } } } }
|
|
110
|
+
}`;
|
|
111
|
+
|
|
112
|
+
const ISSUE_STATE = `query IssueState($owner: String!, $name: String!, $number: Int!) {
|
|
113
|
+
repository(owner: $owner, name: $name) { issue(number: $number) { id state labels(first: 100) { nodes { name } } } }
|
|
114
|
+
}`;
|
|
115
|
+
|
|
116
|
+
const BASE = `query Base($owner: String!, $name: String!, $baseRef: String!) {
|
|
117
|
+
repository(owner: $owner, name: $name) { id ref(qualifiedName: $baseRef) { target { ... on Commit { oid tree { oid } } } } }
|
|
118
|
+
}`;
|
|
119
|
+
|
|
120
|
+
const LABEL = `query Label($owner: String!, $name: String!, $label: String!) {
|
|
121
|
+
repository(owner: $owner, name: $name) { id label(name: $label) { id } }
|
|
122
|
+
}`;
|
|
123
|
+
|
|
124
|
+
const PULLS = `query Pulls($owner: String!, $name: String!, $number: Int!, $head: String!) {
|
|
125
|
+
repository(owner: $owner, name: $name) {
|
|
126
|
+
id
|
|
127
|
+
issue(number: $number) { title }
|
|
128
|
+
pullRequests(headRefName: $head, states: [OPEN, MERGED], first: 1) { nodes { id state } }
|
|
129
|
+
}
|
|
130
|
+
}`;
|
|
131
|
+
|
|
132
|
+
const ADD_COMMENT = `mutation AddComment($subject: ID!, $body: String!) {
|
|
133
|
+
addComment(input: { subjectId: $subject, body: $body }) { clientMutationId }
|
|
134
|
+
}`;
|
|
135
|
+
|
|
136
|
+
const CREATE_REF = `mutation CreateRef($repository: ID!, $name: String!, $oid: GitObjectID!) {
|
|
137
|
+
createRef(input: { repositoryId: $repository, name: $name, oid: $oid }) { clientMutationId }
|
|
138
|
+
}`;
|
|
139
|
+
|
|
140
|
+
const COMMIT_ON_BRANCH = `mutation CommitOnBranch($branch: CommittableBranch!, $expected: GitObjectID!, $message: CommitMessage!) {
|
|
141
|
+
createCommitOnBranch(input: { branch: $branch, expectedHeadOid: $expected, message: $message, fileChanges: {} }) { clientMutationId }
|
|
142
|
+
}`;
|
|
143
|
+
|
|
144
|
+
const CREATE_LABEL = `mutation CreateLabel($repository: ID!, $name: String!, $color: String!, $description: String!) {
|
|
145
|
+
createLabel(input: { repositoryId: $repository, name: $name, color: $color, description: $description }) { label { id } }
|
|
146
|
+
}`;
|
|
147
|
+
|
|
148
|
+
/** The newest issues: a follow-up whose note was never written is among them, since the note is written right after it. */
|
|
149
|
+
const RECENT_ISSUES = `query RecentIssues($owner: String!, $name: String!) {
|
|
150
|
+
repository(owner: $owner, name: $name) { issues(first: 20, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { number title body } } }
|
|
151
|
+
}`;
|
|
152
|
+
|
|
153
|
+
const CREATE_ISSUE = `mutation CreateIssue($repository: ID!, $title: String!, $body: String!, $labels: [ID!]!) {
|
|
154
|
+
createIssue(input: { repositoryId: $repository, title: $title, body: $body, labelIds: $labels }) { issue { number } }
|
|
155
|
+
}`;
|
|
156
|
+
|
|
157
|
+
const CREATE_PULL = `mutation CreatePull($repository: ID!, $base: String!, $head: String!, $title: String!, $body: String!) {
|
|
158
|
+
createPullRequest(input: { repositoryId: $repository, baseRefName: $base, headRefName: $head, title: $title, body: $body }) { clientMutationId }
|
|
159
|
+
}`;
|
|
160
|
+
|
|
161
|
+
const MERGE_PULL = `mutation MergePull($pull: ID!, $mergeMethod: PullRequestMergeMethod!) {
|
|
162
|
+
mergePullRequest(input: { pullRequestId: $pull, mergeMethod: $mergeMethod }) { clientMutationId }
|
|
163
|
+
}`;
|
|
164
|
+
|
|
165
|
+
/** What a failed request means to hum. */
|
|
166
|
+
type Failure =
|
|
167
|
+
/** GitHub answered 304 to a conditional request: nothing changed, and no rate limit was spent. */
|
|
168
|
+
| { readonly kind: "not-modified" }
|
|
169
|
+
/** Another writer took the ref first: it already exists, or it moved since it was read. */
|
|
170
|
+
| { readonly kind: "lost-race" }
|
|
171
|
+
/** No retry fixes it: a 4xx other than a rate limit, or a GraphQL error about the request itself. */
|
|
172
|
+
| { readonly kind: "permanent"; readonly message: string }
|
|
173
|
+
| { readonly kind: "transient" };
|
|
174
|
+
|
|
175
|
+
/** GraphQL errors about the request itself; any other, such as a timeout GitHub reports, may pass on a retry. */
|
|
176
|
+
const PERMANENT_GRAPHQL_ERRORS: ReadonlySet<string> = new Set(["NOT_FOUND", "FORBIDDEN", "UNPROCESSABLE"]);
|
|
177
|
+
|
|
178
|
+
const isRateLimited = (error: RequestError): boolean => error.status === 429 || (error.status === 403 && error.response?.headers["x-ratelimit-remaining"] === "0");
|
|
179
|
+
|
|
180
|
+
const failureOf = (cause: unknown): Failure => {
|
|
181
|
+
if (cause instanceof RequestError) {
|
|
182
|
+
if (cause.status === NOT_MODIFIED) return { kind: "not-modified" };
|
|
183
|
+
|
|
184
|
+
return cause.status >= 400 && cause.status < 500 && !isRateLimited(cause) ? { kind: "permanent", message: cause.message } : { kind: "transient" };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const found = cause instanceof GraphqlResponseError ? cause.errors?.[0] : undefined;
|
|
188
|
+
|
|
189
|
+
if (found?.type === "STALE_DATA" || (found?.type === "UNPROCESSABLE" && /already exists/i.test(found.message))) return { kind: "lost-race" };
|
|
190
|
+
|
|
191
|
+
return found && PERMANENT_GRAPHQL_ERRORS.has(found.type ?? "") ? { kind: "permanent", message: found.message } : { kind: "transient" };
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** Throws `cause`, marked permanent when no retry can fix it. */
|
|
195
|
+
export const raise = (cause: unknown): never => {
|
|
196
|
+
const failure = failureOf(cause);
|
|
197
|
+
|
|
198
|
+
throw failure.kind === "permanent" ? new PermanentError(failure.message, { cause }) : cause;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** The `owner/name` of a GitHub remote URL, or undefined for any other host. */
|
|
202
|
+
export const repoFromRemote = (url: string): string | undefined => {
|
|
203
|
+
const remote = hostedGitInfo.fromUrl(url.trim());
|
|
204
|
+
|
|
205
|
+
return remote?.type === "github" ? `${remote.user}/${remote.project}` : undefined;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/** The owner's own login: `GH_TOKEN` or `GITHUB_TOKEN`, else the token `gh` holds. */
|
|
209
|
+
export const ownerToken = async (timeoutMs: number): Promise<string> => {
|
|
210
|
+
const fromEnv = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
|
|
211
|
+
|
|
212
|
+
if (fromEnv) return fromEnv;
|
|
213
|
+
|
|
214
|
+
const gh = await exec("gh", ["auth", "token"], { stdin: "", timeoutMs });
|
|
215
|
+
const token = gh.stdout.trim();
|
|
216
|
+
|
|
217
|
+
if (gh.exitCode !== 0 || token === "") throw new PermanentError("no GitHub login: run `gh auth login`, or set GH_TOKEN");
|
|
218
|
+
|
|
219
|
+
return token;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const retryOnce: NonNullable<ThrottlingOptions["onRateLimit"]> = (_retryAfter, _options, _octokit, retryCount) => retryCount < RATE_LIMIT_RETRIES;
|
|
223
|
+
|
|
224
|
+
type Send = (url: string, init?: RequestInit) => Promise<Response>;
|
|
225
|
+
|
|
226
|
+
export type GitHubClientOptions = {
|
|
227
|
+
readonly token: string;
|
|
228
|
+
readonly baseUrl?: string;
|
|
229
|
+
/** Replaces `fetch`, for a GitHub that is not github.com. */
|
|
230
|
+
readonly fetch?: Send;
|
|
231
|
+
/** Whether writes are spaced as GitHub asks; only a GitHub with no secondary rate limit may go without. */
|
|
232
|
+
readonly spaced?: boolean;
|
|
233
|
+
/** The owner's `commandTimeoutSeconds` in milliseconds: how long one request may wait for GitHub's answer. */
|
|
234
|
+
readonly timeoutMs: number;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const bounded =
|
|
238
|
+
(send: Send, timeoutMs: number): Send =>
|
|
239
|
+
(url, init) =>
|
|
240
|
+
send(url, { ...init, signal: AbortSignal.any([AbortSignal.timeout(timeoutMs), ...(init?.signal ? [init.signal] : [])]) });
|
|
241
|
+
|
|
242
|
+
/** A GitHub client that waits out rate limits, spaces its writes as GitHub asks, and gives up on a request GitHub has not answered within `timeoutMs`. */
|
|
243
|
+
export const gitHubClient = ({ token, baseUrl, fetch = globalThis.fetch, spaced = true, timeoutMs }: GitHubClientOptions): GitHubClient =>
|
|
244
|
+
new HumOctokit({
|
|
245
|
+
auth: token,
|
|
246
|
+
userAgent: "hum",
|
|
247
|
+
baseUrl,
|
|
248
|
+
request: { fetch: bounded(fetch, timeoutMs) },
|
|
249
|
+
throttle: { enabled: spaced, onRateLimit: retryOnce, onSecondaryRateLimit: retryOnce },
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
export type GitHubOptions = {
|
|
253
|
+
/** `owner/name`. */
|
|
254
|
+
readonly repo: string;
|
|
255
|
+
/** Where claims branch from and pull requests land. */
|
|
256
|
+
readonly base: string;
|
|
257
|
+
/** A claim is the first push of the branch this prefix and the issue number make. */
|
|
258
|
+
readonly claimPrefix: string;
|
|
259
|
+
/** Open issues with this label are the ready items. */
|
|
260
|
+
readonly readyLabel: string;
|
|
261
|
+
readonly mergeMethod: (typeof MERGE_METHODS)[number];
|
|
262
|
+
/** The client to use; by default one on the owner's own login. */
|
|
263
|
+
readonly client?: GitHubClient;
|
|
264
|
+
/** The owner's `commandTimeoutSeconds` in milliseconds: the limit of the `gh auth token` that reads the owner's login. */
|
|
265
|
+
readonly timeoutMs: number;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
type Whole = Adapter & {
|
|
269
|
+
readonly workSource: WorkSource;
|
|
270
|
+
readonly questions: Questions;
|
|
271
|
+
readonly answers: Answers;
|
|
272
|
+
readonly release: Release;
|
|
273
|
+
/** Requests so far that spent rate limit; a 304 spends none. */
|
|
274
|
+
readonly spent: () => number;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
type StandingClaim = { readonly claim: Claim; readonly sha: string };
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* GitHub on the owner's own login: issues are items, comments are the thread. Each read is one GraphQL query,
|
|
281
|
+
* each write one mutation. A claim is a branch: its first commit is made through REST, since no mutation makes a
|
|
282
|
+
* bare commit, and created with `createRef`; a renewal or an expired take is `createCommitOnBranch` on the head it
|
|
283
|
+
* read. `watch` is one REST request with `If-None-Match`, because GitHub answers 304 free of rate limit.
|
|
284
|
+
*/
|
|
285
|
+
export const githubAdapter = (options: GitHubOptions, { now }: AdapterContext): Whole => {
|
|
286
|
+
const { base, claimPrefix, readyLabel, mergeMethod, timeoutMs } = options;
|
|
287
|
+
const repo = parseArgument(Repo, options.repo);
|
|
288
|
+
const [owner = "", name = ""] = repo.split("/");
|
|
289
|
+
const where = { owner, name };
|
|
290
|
+
const claimRefs = `refs/heads/${claimPrefix}`;
|
|
291
|
+
const issueIds = new Map<number, string>();
|
|
292
|
+
let spent = 0;
|
|
293
|
+
|
|
294
|
+
const client = pMemoize(async () => {
|
|
295
|
+
const made = options.client ?? gitHubClient({ token: await ownerToken(timeoutMs), timeoutMs });
|
|
296
|
+
|
|
297
|
+
made.hook.after("request", () => void spent++);
|
|
298
|
+
made.hook.error("request", (error) => {
|
|
299
|
+
if (failureOf(error).kind !== "not-modified") spent++;
|
|
300
|
+
|
|
301
|
+
throw error;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
return made;
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const query = async <T>(schema: z.ZodType<T>, document: string, variables: Variables): Promise<T> =>
|
|
308
|
+
schema.parse(await (await client()).graphql(document, { ...where, ...variables }).catch(raise));
|
|
309
|
+
|
|
310
|
+
const paged = async <T>(schema: z.ZodType<T>, document: string, variables: Variables): Promise<T> =>
|
|
311
|
+
schema.parse(await (await client()).graphql.paginate(document, { ...where, ...variables }).catch(raise));
|
|
312
|
+
|
|
313
|
+
const mutate = async <T>(schema: z.ZodType<T>, document: string, variables: Variables): Promise<T> => schema.parse(await (await client()).graphql(document, variables).catch(raise));
|
|
314
|
+
|
|
315
|
+
/** A write that may lose a race: false when another writer took the ref first. */
|
|
316
|
+
const mutateUnlessRaced = async (document: string, variables: Variables): Promise<boolean> =>
|
|
317
|
+
(await client())
|
|
318
|
+
.graphql(document, variables)
|
|
319
|
+
.then(() => true)
|
|
320
|
+
.catch((cause: unknown) => (failureOf(cause).kind === "lost-race" ? false : raise(cause)));
|
|
321
|
+
|
|
322
|
+
const isReadyIssue = ({ state, labels }: { state: string; labels: z.infer<typeof Labels> }): boolean => state === "OPEN" && labels.nodes.some((label) => label.name === readyLabel);
|
|
323
|
+
|
|
324
|
+
const issueState = async (number: number) => {
|
|
325
|
+
const { issue } = (await query(IssueStateReply, ISSUE_STATE, { number })).repository;
|
|
326
|
+
|
|
327
|
+
issueIds.set(number, issue.id);
|
|
328
|
+
|
|
329
|
+
return issue;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const issueId = async (number: number): Promise<string> => issueIds.get(number) ?? (await issueState(number)).id;
|
|
333
|
+
|
|
334
|
+
const fetchItem = async (number: number) => {
|
|
335
|
+
const { repository } = await paged(ItemReply, ITEM, { number, claimRef: `${claimRefs}${number}` });
|
|
336
|
+
|
|
337
|
+
issueIds.set(number, repository.issue.id);
|
|
338
|
+
|
|
339
|
+
return repository;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const comment = async (id: string, body: string): Promise<void> => {
|
|
343
|
+
await mutate(Acknowledged, ADD_COMMENT, { subject: await issueId(parseArgument(IssueNumber, id)), body });
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const commentMarked = (id: string, marker: Marker, text: string) => comment(id, marked(marker, text));
|
|
347
|
+
|
|
348
|
+
/** The repository's node id and the ready label's, made on first use. */
|
|
349
|
+
const labelled = pMemoize(async () => {
|
|
350
|
+
const { repository } = await query(LabelReply, LABEL, { label: readyLabel });
|
|
351
|
+
const made = async () => (await mutate(CreatedLabel, CREATE_LABEL, { repository: repository.id, name: readyLabel, color: READY_LABEL_COLOR, description: READY_LABEL_DESCRIPTION })).createLabel.label.id;
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
return { repository: repository.id, label: repository.label?.id ?? (await made()) };
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const claimFrom = (item: string, target: { oid?: string; message?: string } | undefined): Claim | undefined => claimOfCommit(item, target?.message ?? "");
|
|
358
|
+
|
|
359
|
+
const firstClaim = async (claim: Claim): Promise<boolean> => {
|
|
360
|
+
const { repository } = await query(BaseReply, BASE, { baseRef: `refs/heads/${base}` });
|
|
361
|
+
const { target } = repository.ref;
|
|
362
|
+
|
|
363
|
+
const made = await (await client())
|
|
364
|
+
.request("POST /repos/{owner}/{repo}/git/commits", { owner, repo: name, message: claimCommitMessage(claim), tree: target.tree.oid, parents: [target.oid] })
|
|
365
|
+
.catch(raise);
|
|
366
|
+
|
|
367
|
+
return mutateUnlessRaced(CREATE_REF, { repository: repository.id, name: `${claimRefs}${claim.item}`, oid: CreatedCommit.parse(made.data).sha });
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const take = claimer<StandingClaim>(
|
|
371
|
+
{
|
|
372
|
+
standing: async (id) => {
|
|
373
|
+
const target = (await query(ClaimReply, CLAIM, { claimRef: `${claimRefs}${id}` })).repository.ref?.target;
|
|
374
|
+
const claim = claimFrom(id, target);
|
|
375
|
+
|
|
376
|
+
return target && claim && { claim, sha: target.oid };
|
|
377
|
+
},
|
|
378
|
+
isReady: async (id) => isReadyIssue(await issueState(parseArgument(IssueNumber, id))),
|
|
379
|
+
write: (claim, over) =>
|
|
380
|
+
over
|
|
381
|
+
? mutateUnlessRaced(COMMIT_ON_BRANCH, { branch: { repositoryNameWithOwner: repo, branchName: `${claimPrefix}${claim.item}` }, expected: over.sha, message: claimCommit(claim) })
|
|
382
|
+
: firstClaim(claim),
|
|
383
|
+
},
|
|
384
|
+
now,
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
const pullFor = async (id: string, head: string) => {
|
|
388
|
+
const { repository } = await query(PullsReply, PULLS, { number: parseArgument(IssueNumber, id), head });
|
|
389
|
+
|
|
390
|
+
return { ...repository, pull: repository.pullRequests.nodes[0] };
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
apiVersion: 1,
|
|
395
|
+
spent: () => spent,
|
|
396
|
+
workSource: {
|
|
397
|
+
listReady: async () => {
|
|
398
|
+
const { issues, refs } = (await paged(ReadyItems, READY_ITEMS, { label: readyLabel, claimRefs })).repository;
|
|
399
|
+
|
|
400
|
+
if (refs.totalCount > refs.nodes.length) throw new PermanentError(`${repo} holds ${refs.totalCount} claim branches; hum reads ${refs.nodes.length}`);
|
|
401
|
+
|
|
402
|
+
const claims = new Map(refs.nodes.map((ref) => [ref.name, claimFrom(ref.name, ref.target)]));
|
|
403
|
+
|
|
404
|
+
return issues.nodes.flatMap(({ number, title }) => (isLive(claims.get(String(number)), now()) ? [] : [{ id: String(number), title }]));
|
|
405
|
+
},
|
|
406
|
+
read: async (id): Promise<Item> => {
|
|
407
|
+
const { issue, ref } = await fetchItem(parseArgument(IssueNumber, id));
|
|
408
|
+
|
|
409
|
+
return {
|
|
410
|
+
id,
|
|
411
|
+
title: issue.title,
|
|
412
|
+
body: issue.body,
|
|
413
|
+
ready: isReadyIssue(issue) && !isLive(claimFrom(id, ref?.target), now()),
|
|
414
|
+
thread: issue.comments.nodes.map((found) => parseComment(found.body, Date.parse(found.createdAt))),
|
|
415
|
+
labels: issue.labels.nodes.map((label) => label.name),
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
claim: (id, holder, ttlMs) => take("claim", String(parseArgument(IssueNumber, id)), holder, ttlMs),
|
|
419
|
+
renew: (id, holder, ttlMs) => take("renew", String(parseArgument(IssueNumber, id)), holder, ttlMs),
|
|
420
|
+
comment: (id, text) => comment(id, commentText(text)),
|
|
421
|
+
fileFollowUp: async (from, { title, body }) => {
|
|
422
|
+
const { issue } = await fetchItem(parseArgument(IssueNumber, from));
|
|
423
|
+
const filed = filedFollowUp(issue.comments.nodes.map((found) => found.body), title);
|
|
424
|
+
|
|
425
|
+
if (filed !== undefined) return { id: filed, title };
|
|
426
|
+
|
|
427
|
+
const created = async () => {
|
|
428
|
+
const { repository, label } = await labelled();
|
|
429
|
+
|
|
430
|
+
return (await mutate(CreatedIssue, CREATE_ISSUE, { repository, title, body: followUpBody(body, `#${from}`), labels: [label] })).createIssue.issue.number;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const recent = (await query(RecentIssuesReply, RECENT_ISSUES, {})).repository.issues.nodes;
|
|
434
|
+
const id = String(recent.find(isFollowUpOf(`#${from}`, title))?.number ?? (await created()));
|
|
435
|
+
const note = followUpNote(title, id);
|
|
436
|
+
|
|
437
|
+
await commentMarked(from, note.marker, note.text);
|
|
438
|
+
|
|
439
|
+
return { id, title };
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
questions: {
|
|
443
|
+
ask: (id, question) => commentMarked(id, questionMarker(question.options), questionText(question)),
|
|
444
|
+
decide: (id, text) => commentMarked(id, { kind: "decision" }, text),
|
|
445
|
+
},
|
|
446
|
+
answers: {
|
|
447
|
+
answer: (id, { text, option }) => commentMarked(id, answerMarker(option), text),
|
|
448
|
+
/** Any comment or issue change moves the newest issue's `updated_at`, so the list's ETag moves. */
|
|
449
|
+
watch: async (since?: string): Promise<Watch> => {
|
|
450
|
+
const token = await (await client())
|
|
451
|
+
.request("GET /repos/{owner}/{repo}/issues", { owner, repo: name, state: "all", sort: "updated", direction: "desc", per_page: 1, headers: since === undefined ? {} : { "if-none-match": since } })
|
|
452
|
+
.then(
|
|
453
|
+
(reply) => reply.headers.etag,
|
|
454
|
+
(cause: unknown) => (failureOf(cause).kind === "not-modified" ? since : raise(cause)),
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
if (!token) throw new PermanentError("GitHub sent no ETag on the issue list, so watch has nothing to compare");
|
|
458
|
+
|
|
459
|
+
return { token, changed: token !== since };
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
release: {
|
|
463
|
+
publish: async (id, ref) => {
|
|
464
|
+
const { pull, issue, id: repository } = await pullFor(id, ref);
|
|
465
|
+
|
|
466
|
+
if (pull) return;
|
|
467
|
+
|
|
468
|
+
await mutate(Acknowledged, CREATE_PULL, { repository, base, head: ref, title: issue.title, body: `Closes #${id}` });
|
|
469
|
+
},
|
|
470
|
+
release: async (id, ref) => {
|
|
471
|
+
const { pull } = await pullFor(id, ref);
|
|
472
|
+
|
|
473
|
+
if (!pull) throw new PermanentError(`no pull request from ${ref} to release for item ${id}`);
|
|
474
|
+
|
|
475
|
+
if (pull.state === "OPEN") await mutate(Acknowledged, MERGE_PULL, { pull: pull.id, mergeMethod: MERGE_METHOD[mergeMethod] });
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import pRetry, { AbortError, type RetryContext } from "p-retry";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type Adapter, ClaimResult, Item, ItemRef, PermanentError, Watch, type WorkSource } from "../adapter-api.ts";
|
|
4
|
+
import { type HumConfig, SHIPPED_DEFAULTS } from "../config/schema.ts";
|
|
5
|
+
import type { Faults } from "../state/faults.ts";
|
|
6
|
+
import { SECOND_MS } from "../time.ts";
|
|
7
|
+
|
|
8
|
+
type Backoff = { readonly first: number; readonly max: number };
|
|
9
|
+
|
|
10
|
+
export type GuardOptions = {
|
|
11
|
+
/** The integration's name; each card names it and is scoped to it. */
|
|
12
|
+
readonly provider: string;
|
|
13
|
+
readonly faults: Faults;
|
|
14
|
+
/** A failure that outlasts this shows one card; a shorter one shows nothing. */
|
|
15
|
+
readonly timeoutMs: number;
|
|
16
|
+
/** The pause before the first retry, doubled each retry up to the longest pause. */
|
|
17
|
+
readonly backoffMs?: Backoff;
|
|
18
|
+
/** Where the last ready list is kept, so a restarted worker still sees an empty list that contradicts it. Memory only when absent. */
|
|
19
|
+
readonly lastReady?: { readonly load: () => string[]; readonly save: (ids: string[]) => void };
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The guard's timings from the owner's provider settings. */
|
|
23
|
+
export const guardTimings = ({ providerTimeoutSeconds, providerBackoff }: Pick<HumConfig, "providerTimeoutSeconds" | "providerBackoff">): Pick<Required<GuardOptions>, "timeoutMs" | "backoffMs"> => ({
|
|
24
|
+
timeoutMs: providerTimeoutSeconds * SECOND_MS,
|
|
25
|
+
backoffMs: { first: providerBackoff.firstSeconds * SECOND_MS, max: providerBackoff.maxSeconds * SECOND_MS },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const SHIPPED_BACKOFF_MS = guardTimings(SHIPPED_DEFAULTS).backoffMs;
|
|
29
|
+
|
|
30
|
+
const none = z.void();
|
|
31
|
+
|
|
32
|
+
const messageOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));
|
|
33
|
+
|
|
34
|
+
/** A retry cannot fix a permanent failure, so it skips every retry. */
|
|
35
|
+
const abortIfPermanent = (cause: unknown): never => {
|
|
36
|
+
throw cause instanceof PermanentError ? new AbortError(cause) : cause;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The engine's side of every adapter call.
|
|
41
|
+
* - A reply of the wrong shape is refused at once with one card, and never retried.
|
|
42
|
+
* - A transient failure is retried inside the timeout; one that outlasts it raises one card and throws.
|
|
43
|
+
* - An empty ready list that contradicts the last read is a fault, not "no work".
|
|
44
|
+
* - A call that would double on a retry (`comment`, `ask`, `decide`, `answer`) runs once; its caller retries it under an op key.
|
|
45
|
+
*/
|
|
46
|
+
export const guarded = (adapter: Adapter, { provider, faults, timeoutMs, backoffMs = SHIPPED_BACKOFF_MS, lastReady: remembered }: GuardOptions): Adapter => {
|
|
47
|
+
const unavailable = `provider-unavailable:${provider}`;
|
|
48
|
+
const contradicted = `empty-list:${provider}`;
|
|
49
|
+
|
|
50
|
+
const refuseChangedReply = (error: z.ZodError): never => {
|
|
51
|
+
const [issue] = error.issues;
|
|
52
|
+
|
|
53
|
+
faults.raise({
|
|
54
|
+
code: "integration-shape-changed",
|
|
55
|
+
item: provider,
|
|
56
|
+
cause: `${provider} replied in a shape hum does not know: ${issue?.path.join(".") || "(root)"}: ${issue?.message}`,
|
|
57
|
+
fix: `Run /hum to set ${provider} up again, or update its adapter.`,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
throw new PermanentError(`${provider} replied in a changed shape`);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const raiseWhenGivingUp = ({ error, attemptNumber, retryDelay }: RetryContext): void => {
|
|
64
|
+
if (retryDelay > 0) return;
|
|
65
|
+
|
|
66
|
+
faults.raise({
|
|
67
|
+
code: "provider-unavailable",
|
|
68
|
+
item: provider,
|
|
69
|
+
cause: `${provider} failed ${attemptNumber} times in a row: ${messageOf(error)}`,
|
|
70
|
+
fix: "hum keeps retrying on its own; check the provider's status if this stays.",
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const once = async <T>(call: () => Promise<T>, schema: z.ZodType<T>): Promise<T> => {
|
|
75
|
+
const reply = await call();
|
|
76
|
+
const parsed = schema.safeParse(reply);
|
|
77
|
+
|
|
78
|
+
return parsed.success ? parsed.data : refuseChangedReply(parsed.error);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const retried = async <T>(call: () => Promise<T>, schema: z.ZodType<T>): Promise<T> => {
|
|
82
|
+
const value = await pRetry(() => once(call, schema).catch(abortIfPermanent), {
|
|
83
|
+
retries: Number.POSITIVE_INFINITY,
|
|
84
|
+
maxRetryTime: timeoutMs,
|
|
85
|
+
minTimeout: backoffMs.first,
|
|
86
|
+
maxTimeout: backoffMs.max,
|
|
87
|
+
onFailedAttempt: raiseWhenGivingUp,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
faults.clear(unavailable);
|
|
91
|
+
|
|
92
|
+
return value;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const { workSource, questions, answers, release } = adapter;
|
|
96
|
+
let lastReadyIds: string[] = remembered?.load() ?? [];
|
|
97
|
+
|
|
98
|
+
const firstStillReady = async (source: WorkSource, ids: readonly string[]): Promise<string | undefined> => {
|
|
99
|
+
for (const id of ids) if ((await retried(() => source.read(id), Item)).ready) return id;
|
|
100
|
+
|
|
101
|
+
return undefined;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const refuseContradictingEmptyList = async (source: WorkSource): Promise<void> => {
|
|
105
|
+
const stillReady = await firstStillReady(source, lastReadyIds);
|
|
106
|
+
|
|
107
|
+
if (stillReady === undefined) return;
|
|
108
|
+
|
|
109
|
+
faults.raise({
|
|
110
|
+
code: "empty-list",
|
|
111
|
+
item: provider,
|
|
112
|
+
cause: `${provider} listed no ready items, yet "${stillReady}" is still ready`,
|
|
113
|
+
fix: "No item was marked gone; hum reads the list again on its next tick.",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
throw new PermanentError(`${provider} returned an empty list that contradicts its last read`);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
apiVersion: adapter.apiVersion,
|
|
121
|
+
workSource: workSource && {
|
|
122
|
+
listReady: async () => {
|
|
123
|
+
const list = await retried(() => workSource.listReady(), ItemRef.array());
|
|
124
|
+
|
|
125
|
+
if (list.length === 0) await refuseContradictingEmptyList(workSource);
|
|
126
|
+
|
|
127
|
+
faults.clear(contradicted);
|
|
128
|
+
lastReadyIds = list.map((ref) => ref.id);
|
|
129
|
+
remembered?.save(lastReadyIds);
|
|
130
|
+
|
|
131
|
+
return list;
|
|
132
|
+
},
|
|
133
|
+
read: (id) => retried(() => workSource.read(id), Item),
|
|
134
|
+
claim: (id, holder, ttlMs) => retried(() => workSource.claim(id, holder, ttlMs), ClaimResult),
|
|
135
|
+
renew: (id, holder, ttlMs) => retried(() => workSource.renew(id, holder, ttlMs), ClaimResult),
|
|
136
|
+
comment: (id, text) => once(() => workSource.comment(id, text), none),
|
|
137
|
+
fileFollowUp: (from, followUp) => retried(() => workSource.fileFollowUp(from, followUp), ItemRef),
|
|
138
|
+
},
|
|
139
|
+
questions: questions && {
|
|
140
|
+
ask: (id, question) => once(() => questions.ask(id, question), none),
|
|
141
|
+
decide: (id, text) => once(() => questions.decide(id, text), none),
|
|
142
|
+
},
|
|
143
|
+
answers: answers && {
|
|
144
|
+
answer: (id, answer) => once(() => answers.answer(id, answer), none),
|
|
145
|
+
watch: (since) => retried(() => answers.watch(since), Watch),
|
|
146
|
+
},
|
|
147
|
+
release: release && {
|
|
148
|
+
publish: (id, ref) => retried(() => release.publish(id, ref), none),
|
|
149
|
+
release: (id, ref) => retried(() => release.release(id, ref), none),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
};
|