@aviaratech/ai-delivery 0.3.42 → 0.3.44
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/README.md +2 -2
- package/dist/agentReadiness.test.js +27 -0
- package/dist/agentReadiness.test.js.map +2 -2
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +2 -2
- package/dist/contributorChecks.test.js +4 -1
- package/dist/contributorChecks.test.js.map +2 -2
- package/dist/currentConsumer.test.js +3 -2
- package/dist/currentConsumer.test.js.map +2 -2
- package/dist/currentTrackingScenario.test.js +3 -2
- package/dist/currentTrackingScenario.test.js.map +2 -2
- package/dist/directoryIndependent.test.js +22 -3
- package/dist/directoryIndependent.test.js.map +3 -3
- package/dist/dispatch.js.map +2 -2
- package/dist/fixtures/builderReady.d.ts +84 -0
- package/dist/fixtures/builderReady.js +58 -0
- package/dist/fixtures/builderReady.js.map +7 -0
- package/dist/fixtures/inertTarget.d.ts +82 -0
- package/dist/fixtures/inertTarget.js +25 -15
- package/dist/fixtures/inertTarget.js.map +2 -2
- package/dist/fixtures/issue63.d.ts +99 -0
- package/dist/fixtures/issue63.js +21 -2
- package/dist/fixtures/issue63.js.map +2 -2
- package/dist/issue.d.ts +23 -2
- package/dist/issue.js +154 -28
- package/dist/issue.js.map +2 -2
- package/dist/issue63Routes.test.js +3 -3
- package/dist/issue63Routes.test.js.map +2 -2
- package/dist/issueBlockerGuard.test.js +16 -5
- package/dist/issueBlockerGuard.test.js.map +2 -2
- package/dist/issueContract.d.ts +247 -2
- package/dist/issueContract.js +188 -24
- package/dist/issueContract.js.map +2 -2
- package/dist/issueContract.test.d.ts +21 -0
- package/dist/issueContract.test.js +276 -17
- package/dist/issueContract.test.js.map +2 -2
- package/dist/issueDates.test.js +5 -6
- package/dist/issueDates.test.js.map +2 -2
- package/dist/issueInfoReadback.test.js +64 -0
- package/dist/issueInfoReadback.test.js.map +2 -2
- package/dist/issueIntake.test.js +190 -35
- package/dist/issueIntake.test.js.map +2 -2
- package/dist/issueJournal.d.ts +13 -9
- package/dist/issueJournal.js +14 -10
- package/dist/issueJournal.js.map +2 -2
- package/dist/issueJournal.test.js +11 -8
- package/dist/issueJournal.test.js.map +2 -2
- package/dist/issueTracking.test.js +135 -2
- package/dist/issueTracking.test.js.map +3 -3
- package/dist/issueWriteRecovery.test.js +12 -12
- package/dist/issueWriteRecovery.test.js.map +2 -2
- package/dist/mcp/index.js +10 -3
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/tools.d.ts +186 -27
- package/dist/mcp/tools.js +25 -7
- package/dist/mcp/tools.js.map +2 -2
- package/dist/pluginPackaging.test.js +6 -3
- package/dist/pluginPackaging.test.js.map +2 -2
- package/dist/readView.d.ts +3 -0
- package/dist/readView.js +1 -1
- package/dist/readView.js.map +2 -2
- package/dist/releaseReconciliation.test.js +20 -6
- package/dist/releaseReconciliation.test.js.map +2 -2
- package/dist/releaseWorkflow.test.js +2 -2
- package/dist/releaseWorkflow.test.js.map +2 -2
- package/dist/review.d.ts +8 -0
- package/dist/review.js +30 -2
- package/dist/review.js.map +2 -2
- package/dist/review.test.js +64 -1
- package/dist/review.test.js.map +2 -2
- package/dist/services/agentReadinessService.d.ts +2 -1
- package/dist/services/agentReadinessService.js +6 -0
- package/dist/services/agentReadinessService.js.map +2 -2
- package/dist/stdoutRegression.test.js +27 -15
- package/dist/stdoutRegression.test.js.map +2 -2
- package/dist/targetRepositoryExecution.test.js +11 -3
- package/dist/targetRepositoryExecution.test.js.map +2 -2
- package/package.json +1 -1
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/cli.js +156 -124
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +1 -11
- package/plugins/ai-delivery/skills/ticket-design/SKILL.md +30 -0
package/dist/issue.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type ProjectTradeKey, type ProjectTradePatch } from './github/projectNu
|
|
|
7
7
|
import { type RepoCoordinates } from './github/repo.js';
|
|
8
8
|
import { type AgentReadinessResult } from './services/agentReadinessService.js';
|
|
9
9
|
import { type JournalInput } from './issueJournal.js';
|
|
10
|
-
import { type ProjectStatusPatchData, type IssueFieldsInput, type IssueDiagnostic, type IssueDeferralData } from './issueContract.js';
|
|
10
|
+
import { type ProjectStatusPatchData, type IssueFieldsInput, type IssueDiagnostic, type IssueDeferralData, type BuilderTierData } from './issueContract.js';
|
|
11
11
|
export interface IssueCommentReadback {
|
|
12
12
|
commentId: number;
|
|
13
13
|
url: string;
|
|
@@ -203,6 +203,11 @@ export interface UpdateIssueInput extends Omit<Partial<IssueFieldsInput>, 'defer
|
|
|
203
203
|
state?: 'open' | 'closed';
|
|
204
204
|
preserveHistory?: boolean;
|
|
205
205
|
closeReason?: 'completed' | 'not_planned' | 'duplicate';
|
|
206
|
+
/** Required to close a study as completed: the verdict and the READOUT's Result section, verbatim. */
|
|
207
|
+
closeout?: {
|
|
208
|
+
verdict: string;
|
|
209
|
+
result: string;
|
|
210
|
+
};
|
|
206
211
|
supersededBy?: number;
|
|
207
212
|
title?: string;
|
|
208
213
|
}
|
|
@@ -221,6 +226,8 @@ export interface UpdateIssueResult extends IssueInfo {
|
|
|
221
226
|
supersededBy: number | null;
|
|
222
227
|
comment: IssueCommentReadback;
|
|
223
228
|
};
|
|
229
|
+
/** Open issues the closed issue was blocking; present on every reasoned close. */
|
|
230
|
+
unblocks?: number[];
|
|
224
231
|
}
|
|
225
232
|
interface IncompleteIssueUpdateResult {
|
|
226
233
|
status: 'update-incomplete';
|
|
@@ -252,6 +259,12 @@ export declare class IssueUpdateIncompleteError extends DeliveryError {
|
|
|
252
259
|
}
|
|
253
260
|
/** Identity-bound results do not inspect hostile error proxies or accessors. */
|
|
254
261
|
export declare function getIncompleteIssueUpdate(error: unknown): IncompleteIssueUpdateResult | undefined;
|
|
262
|
+
export interface IssueArtifact {
|
|
263
|
+
number: number;
|
|
264
|
+
name: string;
|
|
265
|
+
type: string;
|
|
266
|
+
url: string;
|
|
267
|
+
}
|
|
255
268
|
export declare function updateIssue(context: DeliveryContext, input: UpdateIssueInput): Promise<UpdateIssueResult>;
|
|
256
269
|
export interface BatchUpdateIssueInput {
|
|
257
270
|
items: (UpdateIssueInput & {
|
|
@@ -301,6 +314,7 @@ export type IssueChildCounts = Pick<IssueChildProgress, 'childCount' | 'closedCh
|
|
|
301
314
|
export interface IssueInfo {
|
|
302
315
|
childProgress?: IssueChildProgress | IssueChildCounts;
|
|
303
316
|
deferred?: IssueDeferralData | null;
|
|
317
|
+
builder?: BuilderTierData | null;
|
|
304
318
|
routing?: LoadedDeliveryConfig['routing'];
|
|
305
319
|
blockedBy: number[];
|
|
306
320
|
body: string;
|
|
@@ -320,10 +334,17 @@ export interface IssueInfo {
|
|
|
320
334
|
state: string;
|
|
321
335
|
title: string;
|
|
322
336
|
url: string;
|
|
337
|
+
/** Present when the read asked for artifacts and GitHub returned them. */
|
|
338
|
+
artifacts?: IssueArtifact[];
|
|
339
|
+
warnings?: IssueDiagnostic[];
|
|
323
340
|
}
|
|
324
|
-
/**
|
|
341
|
+
/**
|
|
342
|
+
* `childDetail: false` reports child counts only, skipping the per-child Points and status reads.
|
|
343
|
+
* `artifacts: true` adds the issue's artifacts; a failed artifact read leaves them out with a warning.
|
|
344
|
+
*/
|
|
325
345
|
export declare function issueInfo(context: DeliveryContext, issueNumber: number, options?: {
|
|
326
346
|
childDetail?: boolean;
|
|
347
|
+
artifacts?: boolean;
|
|
327
348
|
}): Promise<IssueInfo>;
|
|
328
349
|
export declare function listIssueSubissues(context: DeliveryContext, issueNumber: number): Promise<number[]>;
|
|
329
350
|
export declare function readyCheck(context: DeliveryContext, issueNumber: number, onReadback?: (observation: {
|
package/dist/issue.js
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
} from "./github/projectNumbers.js";
|
|
38
38
|
import {
|
|
39
39
|
getNativeBlockerRelationships,
|
|
40
|
+
getNativeBlockingRelationships,
|
|
40
41
|
hasNativeSubIssues,
|
|
41
42
|
linkBlockedBy,
|
|
42
43
|
replaceBlockedBy,
|
|
@@ -212,13 +213,15 @@ async function labels(context, input) {
|
|
|
212
213
|
}
|
|
213
214
|
throw new DeliveryError("Repository label listing exceeds the bounded readback window.");
|
|
214
215
|
}
|
|
216
|
+
const BLOCKERS_DISAGREE = "status.blockers must name each blockedBy issue as #<n>, or start with None; or send only blockedBy.";
|
|
217
|
+
const blockersAgree = (blockedBy, text) => blockedBy.length === 0 ? /^None\b/u.test(text) : blockedBy.every((number) => new RegExp(`#${String(number)}(?!\\d)`, "u").test(text));
|
|
215
218
|
function prepareIssueWrite(input, current, forIntent = false) {
|
|
216
219
|
const patch = input.status === void 0 ? void 0 : requireIssueStatus(
|
|
217
220
|
IssueStatusPatch,
|
|
218
221
|
current === void 0 ? requireIssueStatus(CreateIssueStatus, input.status) : input.status
|
|
219
222
|
);
|
|
220
|
-
if (input.blockedBy !== void 0 && patch &&
|
|
221
|
-
throw new DeliveryError(
|
|
223
|
+
if (input.blockedBy !== void 0 && patch?.blockers !== void 0 && !blockersAgree(input.blockedBy, patch.blockers))
|
|
224
|
+
throw new DeliveryError(BLOCKERS_DISAGREE);
|
|
222
225
|
const statusOnly = patch !== void 0 && Object.entries(input).every(
|
|
223
226
|
([key, value]) => value === void 0 || ["repo", "issueNumber", "status", "projectStatus"].includes(key)
|
|
224
227
|
);
|
|
@@ -251,17 +254,21 @@ function prepareIssueWrite(input, current, forIntent = false) {
|
|
|
251
254
|
return value === void 0 ? [] : [[key, value]];
|
|
252
255
|
})
|
|
253
256
|
);
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
257
|
+
const requireBuilder = input.requireBuilder === true || currentParsed?.issue.draft === true && input.park !== true && (input.draft ?? parsed.issue.draft) === false;
|
|
258
|
+
const issue = requireIssue(
|
|
259
|
+
{
|
|
260
|
+
...parsed.issue,
|
|
261
|
+
// Body replacements and unrelated typed patches cannot implicitly resume deferred work.
|
|
262
|
+
deferral: input.undefer === true ? void 0 : input.defer ?? (current === void 0 ? parsed.issue.deferral : currentParsed?.issue.deferral),
|
|
263
|
+
...metadata,
|
|
264
|
+
...fields,
|
|
265
|
+
title,
|
|
266
|
+
...legacyBody === void 0 ? {} : { legacyBody },
|
|
267
|
+
...input.retainLegacyBody !== void 0 ? { retainLegacyBody: input.retainLegacyBody } : incomingLegacy ? { retainLegacyBody: true } : current !== void 0 && legacyBody !== void 0 && input.preserveHistory !== false && !statusOnly ? { retainLegacyBody: false } : {},
|
|
268
|
+
...input.park ? { draft: true } : {}
|
|
269
|
+
},
|
|
270
|
+
requireBuilder ? { requireBuilder: true } : {}
|
|
271
|
+
);
|
|
265
272
|
const unchangedContract = currentParsed !== void 0 && JSON.stringify(issue) === JSON.stringify(currentParsed.issue);
|
|
266
273
|
const legacyFormatting = unchangedContract && parsed.legacyFormatting === true;
|
|
267
274
|
const base = parsed.status ?? currentParsed?.status;
|
|
@@ -271,7 +278,7 @@ function prepareIssueWrite(input, current, forIntent = false) {
|
|
|
271
278
|
nextMilestone: patch?.nextMilestone ?? base?.nextMilestone ?? "Not started",
|
|
272
279
|
blockers: patch?.blockers ?? base?.blockers ?? "None",
|
|
273
280
|
latestJournal: patch?.latestJournal ?? base?.latestJournal ?? "None yet",
|
|
274
|
-
...input.blockedBy === void 0 ? {} : {
|
|
281
|
+
...input.blockedBy === void 0 || patch?.blockers !== void 0 ? {} : {
|
|
275
282
|
blockers: input.blockedBy.length ? input.blockedBy.map((number) => "#" + String(number)).join(", ") : "None"
|
|
276
283
|
}
|
|
277
284
|
};
|
|
@@ -295,7 +302,7 @@ function prepareIssueWrite(input, current, forIntent = false) {
|
|
|
295
302
|
body,
|
|
296
303
|
statusOnly,
|
|
297
304
|
preserveHistory: input.preserveHistory ?? ((currentLegacy || parsed.legacy || legacyBody !== void 0 && issue.retainLegacyBody === false && currentParsed?.issue.retainLegacyBody !== false) && !statusOnly),
|
|
298
|
-
warnings: issueWarnings(issue
|
|
305
|
+
warnings: issueWarnings(issue),
|
|
299
306
|
...(currentLegacy || parsed.legacy) && prior !== void 0 ? { conversion: { priorBody: prior, canonicalBody: body, diff: issueBodyDiff(prior, body) } } : {}
|
|
300
307
|
};
|
|
301
308
|
}
|
|
@@ -320,7 +327,7 @@ class CreatedTrackingIssueError extends DeliveryError {
|
|
|
320
327
|
async function createIssue(context, input) {
|
|
321
328
|
if (context.clients.role !== "author") throw new DeliveryError("Issue writes require the configured author role.");
|
|
322
329
|
const canonicalBody = canonicalIssueBody(input);
|
|
323
|
-
const prepared = prepareIssueWrite(input);
|
|
330
|
+
const prepared = prepareIssueWrite({ ...input, requireBuilder: true });
|
|
324
331
|
const originalIntent = digestValue(
|
|
325
332
|
Object.fromEntries(
|
|
326
333
|
Object.entries({ ...input, opId: void 0, body: canonicalBody }).filter(([, value]) => value !== void 0)
|
|
@@ -344,6 +351,14 @@ async function createIssue(context, input) {
|
|
|
344
351
|
if (input.priority !== void 0 && !context.config.native.priority.values.includes(input.priority)) {
|
|
345
352
|
throw new DeliveryError("Unsupported configured Priority value.");
|
|
346
353
|
}
|
|
354
|
+
if (!prepared.issue.draft) {
|
|
355
|
+
const missing = [];
|
|
356
|
+
if (input.issueType === void 0)
|
|
357
|
+
missing.push(missingNativeField("issue-type", "issueType", context.config.native.issueTypes));
|
|
358
|
+
if (input.priority === void 0 && !prepared.issue.epic)
|
|
359
|
+
missing.push(missingNativeField("priority", "priority", context.config.native.priority.values));
|
|
360
|
+
if (missing.length > 0) throw new IssueValidationError(missing);
|
|
361
|
+
}
|
|
347
362
|
const { clients, config, repo } = context;
|
|
348
363
|
const targets = await resolveNativeRelationshipTargets({
|
|
349
364
|
blockers: input.blockedBy ?? [],
|
|
@@ -792,9 +807,11 @@ async function listIssues(context, input, options = {}) {
|
|
|
792
807
|
if (input.parentIssueNumber !== void 0 && (input.parentIssueNumber === null ? relationships.parentNumber !== null : localParent !== input.parentIssueNumber))
|
|
793
808
|
return null;
|
|
794
809
|
if (input.projectStatus !== void 0 && (project?.status ?? null) !== input.projectStatus) return null;
|
|
810
|
+
const readback = deferralReadback(current.body, current.title);
|
|
811
|
+
delete readback.builder;
|
|
795
812
|
const listed = {
|
|
796
813
|
...options.capacityRead ? { nodeId: current.node_id, fieldIds: Object.fromEntries(catalog.map((field) => [field.name, field.id])) } : {},
|
|
797
|
-
...
|
|
814
|
+
...readback,
|
|
798
815
|
number: current.number,
|
|
799
816
|
title: current.title,
|
|
800
817
|
state: current.state,
|
|
@@ -928,10 +945,22 @@ async function assertProjectTransition(context, plan, recordOverride = false, va
|
|
|
928
945
|
}
|
|
929
946
|
}
|
|
930
947
|
const BODY_FREE_KEYS = /* @__PURE__ */ new Set([
|
|
931
|
-
..."repo issueNumber state closeReason supersededBy preserveHistory overrideReason".split(" "),
|
|
948
|
+
..."repo issueNumber state closeReason closeout supersededBy preserveHistory overrideReason".split(" "),
|
|
932
949
|
..."projectStatus milestone labels priority startDate targetDate".split(" "),
|
|
933
950
|
..."expectedTradesPerDay measuredTradesPerDay".split(" ")
|
|
934
951
|
]);
|
|
952
|
+
function oldDataKeys(body) {
|
|
953
|
+
const prefix = "<!-- ai-delivery:issue-data@1 ";
|
|
954
|
+
const start = body.lastIndexOf(prefix);
|
|
955
|
+
const end = body.indexOf(" -->", start);
|
|
956
|
+
try {
|
|
957
|
+
return new Set(
|
|
958
|
+
start < 0 || end < 0 ? [] : Object.keys(JSON.parse(body.slice(start + prefix.length, end)))
|
|
959
|
+
);
|
|
960
|
+
} catch {
|
|
961
|
+
return /* @__PURE__ */ new Set();
|
|
962
|
+
}
|
|
963
|
+
}
|
|
935
964
|
function rebuildableWrite(input, current) {
|
|
936
965
|
try {
|
|
937
966
|
return prepareIssueWrite(input, current);
|
|
@@ -952,7 +981,15 @@ function rebuildableWrite(input, current) {
|
|
|
952
981
|
);
|
|
953
982
|
if (validateIssue(fields, true).failures.length) throw error;
|
|
954
983
|
const prepared = prepareIssueWrite(full, void 0);
|
|
955
|
-
const
|
|
984
|
+
const carried = oldDataKeys(current.body);
|
|
985
|
+
const reset = [
|
|
986
|
+
"draft",
|
|
987
|
+
"openQuestions",
|
|
988
|
+
"context",
|
|
989
|
+
...["builder", "extends", "priorWork", "decisions", "surface", "fences", "proof"].filter(
|
|
990
|
+
(key) => carried.has(key)
|
|
991
|
+
)
|
|
992
|
+
].filter((key) => input[key] === void 0);
|
|
956
993
|
if (reset.length) {
|
|
957
994
|
const message = `Rebuilt the hand-edited body (old one in the history comment); reset because not sent: ${reset.join(", ")}.`;
|
|
958
995
|
prepared.warnings.push({ code: "body.rebuilt", field: "body", message, fixHint: message });
|
|
@@ -982,7 +1019,7 @@ async function prepareIssueUpdate(context, input) {
|
|
|
982
1019
|
throw new DeliveryError("A superseding issue must be a different positive issue number.");
|
|
983
1020
|
const { clients, config, repo } = context;
|
|
984
1021
|
const preserveArchived = Object.keys(input).every(
|
|
985
|
-
(key) => ["issueNumber", "title", "state", "closeReason", "supersededBy", "preserveHistory"].includes(key)
|
|
1022
|
+
(key) => ["issueNumber", "title", "state", "closeReason", "closeout", "supersededBy", "preserveHistory"].includes(key)
|
|
986
1023
|
);
|
|
987
1024
|
const dateChanges = await prepareIssueDates(context, input);
|
|
988
1025
|
const currentContent = await issueInfo(context, input.issueNumber);
|
|
@@ -1070,6 +1107,9 @@ async function prepareIssueUpdate(context, input) {
|
|
|
1070
1107
|
}
|
|
1071
1108
|
}
|
|
1072
1109
|
}
|
|
1110
|
+
const studyClose = await prepareStudyClose(context, input, closeReason, input.title ?? currentContent.title);
|
|
1111
|
+
const unblocks = closeReason === void 0 ? void 0 : await readUnblocks(context, input.issueNumber);
|
|
1112
|
+
if (unblocks?.warning !== void 0) prepared.warnings.push(unblocks.warning);
|
|
1073
1113
|
let historyBody;
|
|
1074
1114
|
let priorContent = input.status === void 0 ? void 0 : { title: currentContent.title, body: currentContent.body };
|
|
1075
1115
|
if (input.preserveHistory === true && (input.title !== void 0 || input.body !== void 0)) {
|
|
@@ -1091,8 +1131,12 @@ async function prepareIssueUpdate(context, input) {
|
|
|
1091
1131
|
historyBody = body;
|
|
1092
1132
|
}
|
|
1093
1133
|
}
|
|
1094
|
-
const closureBody = closeReason === void 0 ? void 0 :
|
|
1095
|
-
|
|
1134
|
+
const closureBody = closeReason === void 0 ? void 0 : [
|
|
1135
|
+
...studyClose ?? [],
|
|
1136
|
+
`Requested closure reason: ${closeReason}.${input.supersededBy === void 0 ? "" : `
|
|
1137
|
+
Superseded by ${repo.owner}/${repo.repo}#${String(input.supersededBy)}.`}`,
|
|
1138
|
+
...unblocks?.numbers.length ? [`**Unblocks:** ${unblocks.numbers.map((n) => `#${String(n)}`).join(", ")}`] : []
|
|
1139
|
+
].join("\n\n");
|
|
1096
1140
|
const target = (await clients.rest.issues.get({ ...repo, issue_number: input.issueNumber })).data;
|
|
1097
1141
|
if (target.number !== input.issueNumber || "pull_request" in target || !target.node_id || target.html_url !== currentContent.url || new URL(target.html_url).pathname.toLowerCase() !== `/${repo.owner}/${repo.repo}/issues/${String(input.issueNumber)}`.toLowerCase())
|
|
1098
1142
|
throw new DeliveryError("History target is not the requested issue.");
|
|
@@ -1119,9 +1163,77 @@ Superseded by ${repo.owner}/${repo.repo}#${String(input.supersededBy)}.`}`;
|
|
|
1119
1163
|
dateChanges,
|
|
1120
1164
|
priorContent,
|
|
1121
1165
|
historyBody,
|
|
1122
|
-
closureBody
|
|
1166
|
+
closureBody,
|
|
1167
|
+
unblocks: unblocks?.numbers
|
|
1123
1168
|
};
|
|
1124
1169
|
}
|
|
1170
|
+
const STUDY_TITLE = /^study\b/iu;
|
|
1171
|
+
async function prepareStudyClose(context, input, closeReason, title) {
|
|
1172
|
+
const study = STUDY_TITLE.test(title);
|
|
1173
|
+
if (study && input.state === "closed" && closeReason === void 0)
|
|
1174
|
+
throw new DeliveryError("Pass closeReason to close a study: 'completed' with closeout, or 'not_planned'.");
|
|
1175
|
+
if (!study || closeReason !== "completed") {
|
|
1176
|
+
if (input.closeout !== void 0)
|
|
1177
|
+
throw new DeliveryError('closeout applies only when closing a study (title starts with "Study") as completed.');
|
|
1178
|
+
return void 0;
|
|
1179
|
+
}
|
|
1180
|
+
const verdict = input.closeout?.verdict.trim() ?? "";
|
|
1181
|
+
const result = input.closeout?.result ?? "";
|
|
1182
|
+
if (!verdict || verdict.split("\n").length > 3 || verdict.length > 600)
|
|
1183
|
+
throw new DeliveryError("Pass closeout.verdict (1\u20133 lines) to close a study.");
|
|
1184
|
+
if (!result.trim() || result.length > 4e3)
|
|
1185
|
+
throw new DeliveryError(
|
|
1186
|
+
"Pass closeout.result (the READOUT's Result section); GitHub search doesn't read artifacts."
|
|
1187
|
+
);
|
|
1188
|
+
const artifacts = await readIssueArtifacts(context, input.issueNumber);
|
|
1189
|
+
if (!artifacts.some((artifact) => /^readout\b/iu.test(artifact.name)))
|
|
1190
|
+
throw new DeliveryError(
|
|
1191
|
+
`Attach the READOUT with gh issue artifact create ${String(input.issueNumber)} READOUT.md, then close again.`
|
|
1192
|
+
);
|
|
1193
|
+
return [
|
|
1194
|
+
`**Verdict:** ${verdict}`,
|
|
1195
|
+
`**Result:**
|
|
1196
|
+
|
|
1197
|
+
${result}`,
|
|
1198
|
+
`**Artifacts:**
|
|
1199
|
+
${artifacts.map((artifact) => `- [${artifact.name}](${artifact.url})`).join("\n")}`
|
|
1200
|
+
];
|
|
1201
|
+
}
|
|
1202
|
+
const IssueArtifactRows = z.array(
|
|
1203
|
+
z.object({ number: z.number().int().positive(), name: z.string(), type: z.string(), html_url: z.url() })
|
|
1204
|
+
);
|
|
1205
|
+
async function readIssueArtifacts(context, issueNumber) {
|
|
1206
|
+
let status;
|
|
1207
|
+
let data;
|
|
1208
|
+
try {
|
|
1209
|
+
const response = await context.clients.rest.request(
|
|
1210
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/artifacts",
|
|
1211
|
+
{ ...context.repo, issue_number: issueNumber, per_page: 100 }
|
|
1212
|
+
);
|
|
1213
|
+
({ status, data } = response);
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
status = error.status ?? "unavailable";
|
|
1216
|
+
}
|
|
1217
|
+
const rows = status === 200 ? IssueArtifactRows.safeParse(data) : void 0;
|
|
1218
|
+
if (!rows?.success)
|
|
1219
|
+
throw new DeliveryError(
|
|
1220
|
+
`Can't read this issue's artifacts (HTTP ${String(status)}); attach the READOUT with gh issue artifact create and retry.`
|
|
1221
|
+
);
|
|
1222
|
+
return rows.data.map((row) => ({ number: row.number, name: row.name, type: row.type, url: row.html_url }));
|
|
1223
|
+
}
|
|
1224
|
+
async function readUnblocks(context, issueNumber) {
|
|
1225
|
+
try {
|
|
1226
|
+
const dependents = await getNativeBlockingRelationships({
|
|
1227
|
+
graphql: context.clients.graphql,
|
|
1228
|
+
issueNumber,
|
|
1229
|
+
repo: context.repo
|
|
1230
|
+
});
|
|
1231
|
+
return { numbers: dependents.filter((issue) => issue.state === "OPEN").map((issue) => issue.number) };
|
|
1232
|
+
} catch (error) {
|
|
1233
|
+
const message = `Couldn't read the issues #${String(issueNumber)} blocks (${error instanceof Error ? error.message : String(error)}); the close has no Unblocks line, so tell their owners yourself.`;
|
|
1234
|
+
return { numbers: [], warning: { code: "close.unblocks", field: "blocking", message, fixHint: message } };
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1125
1237
|
async function updateIssue(context, input) {
|
|
1126
1238
|
const { expectedTradesPerDay, measuredTradesPerDay, ...fields } = input;
|
|
1127
1239
|
const patch = projectTradePatch({ expectedTradesPerDay, measuredTradesPerDay });
|
|
@@ -1411,7 +1523,8 @@ async function applyIssueUpdate(context, plan, changes) {
|
|
|
1411
1523
|
...prepared.conversion === void 0 ? {} : { conversion: prepared.conversion },
|
|
1412
1524
|
...projectStatusComment === void 0 ? {} : { projectStatusComment },
|
|
1413
1525
|
...historyComment === void 0 ? {} : { historyComment },
|
|
1414
|
-
...closure === void 0 || closureComment === void 0 ? {} : { closure: { ...closure, supersededBy: input.supersededBy ?? null, comment: closureComment } }
|
|
1526
|
+
...closure === void 0 || closureComment === void 0 ? {} : { closure: { ...closure, supersededBy: input.supersededBy ?? null, comment: closureComment } },
|
|
1527
|
+
...plan.unblocks === void 0 ? {} : { unblocks: plan.unblocks }
|
|
1415
1528
|
};
|
|
1416
1529
|
}
|
|
1417
1530
|
async function findUpdateComment(context, issueNumber, body) {
|
|
@@ -1615,7 +1728,7 @@ function localBatchFailureReason(error) {
|
|
|
1615
1728
|
if ([
|
|
1616
1729
|
"Choose a valid defer condition or explicit undefer, never both.",
|
|
1617
1730
|
"Use defer or undefer to change deferral state.",
|
|
1618
|
-
|
|
1731
|
+
BLOCKERS_DISAGREE,
|
|
1619
1732
|
"Convert the legacy contract explicitly before a status-only update.",
|
|
1620
1733
|
"Issue labels must be non-empty and unique.",
|
|
1621
1734
|
"Repository label listing exceeds the bounded readback window.",
|
|
@@ -1846,7 +1959,14 @@ async function readIssueInfo(context, issueNumber, includeProject = true, expect
|
|
|
1846
1959
|
return { info, issueNodeId: issue.node_id, issueNumber: issue.number };
|
|
1847
1960
|
}
|
|
1848
1961
|
async function issueInfo(context, issueNumber, options = {}) {
|
|
1849
|
-
|
|
1962
|
+
const info = (await readIssueInfo(context, issueNumber, true, void 0, options.childDetail)).info;
|
|
1963
|
+
if (options.artifacts !== true) return info;
|
|
1964
|
+
try {
|
|
1965
|
+
return { ...info, artifacts: await readIssueArtifacts(context, issueNumber) };
|
|
1966
|
+
} catch (error) {
|
|
1967
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1968
|
+
return { ...info, warnings: [{ code: "artifacts.unread", field: "artifacts", message, fixHint: message }] };
|
|
1969
|
+
}
|
|
1850
1970
|
}
|
|
1851
1971
|
function childCounts(children) {
|
|
1852
1972
|
const closedChildCount = children.filter((child) => child.state === "closed").length;
|
|
@@ -1859,10 +1979,11 @@ function childCounts(children) {
|
|
|
1859
1979
|
function deferralReadback(body, title) {
|
|
1860
1980
|
if (body === void 0) return {};
|
|
1861
1981
|
try {
|
|
1862
|
-
|
|
1982
|
+
const { issue } = parseIssueBody(body ?? "", { title });
|
|
1983
|
+
return { deferred: issue.deferral ?? null, builder: issue.builder ?? null };
|
|
1863
1984
|
} catch (error) {
|
|
1864
1985
|
if (!(error instanceof IssueValidationError)) throw error;
|
|
1865
|
-
return {};
|
|
1986
|
+
return { builder: null };
|
|
1866
1987
|
}
|
|
1867
1988
|
}
|
|
1868
1989
|
const DirectIssueChild = z.object({
|
|
@@ -2007,6 +2128,10 @@ async function listIssueSubissues(context, issueNumber) {
|
|
|
2007
2128
|
if ("pull_request" in issue) throw new DeliveryError("Requested issue number is a pull request.");
|
|
2008
2129
|
return (await readDirectIssueChildren(context, issueNumber, issue)).map((child) => child.number);
|
|
2009
2130
|
}
|
|
2131
|
+
function missingNativeField(code, field, values) {
|
|
2132
|
+
const fixHint = `Choose ${code}: ${values.join(", ")}.`;
|
|
2133
|
+
return { code, field, fixHint, message: fixHint };
|
|
2134
|
+
}
|
|
2010
2135
|
async function readyCheck(context, issueNumber, onReadback) {
|
|
2011
2136
|
const observation = await readIssueInfo(context, issueNumber);
|
|
2012
2137
|
const { info } = observation;
|
|
@@ -2021,6 +2146,7 @@ async function readyCheck(context, issueNumber, onReadback) {
|
|
|
2021
2146
|
blockedBy: info.blockedBy,
|
|
2022
2147
|
body: info.body,
|
|
2023
2148
|
...info.points === void 0 ? {} : { points: info.points },
|
|
2149
|
+
...info.priority === void 0 ? {} : { priority: info.priority },
|
|
2024
2150
|
repoRoot: void 0,
|
|
2025
2151
|
title: info.title,
|
|
2026
2152
|
...info.issueType === null ? {} : { issueType: info.issueType },
|