@aviaratech/ai-delivery 0.3.40 → 0.3.42
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/CONTRIBUTING.md +2 -0
- package/README.md +7 -1
- package/dist/callerErrors.test.js +11 -1
- package/dist/callerErrors.test.js.map +2 -2
- package/dist/cli.js +9 -0
- package/dist/cli.js.map +2 -2
- package/dist/dispatch.js +7 -0
- package/dist/dispatch.js.map +2 -2
- package/dist/fixtures/inertTarget.d.ts +33 -0
- package/dist/fixtures/inertTarget.js +42 -0
- package/dist/fixtures/inertTarget.js.map +2 -2
- package/dist/fixtures/readView.d.ts +9 -1
- package/dist/fixtures/readView.js +4 -0
- package/dist/fixtures/readView.js.map +2 -2
- package/dist/github/commandIdentityPolicy.js +1 -0
- package/dist/github/commandIdentityPolicy.js.map +2 -2
- package/dist/github/projectNumbers.d.ts +30 -0
- package/dist/github/projectNumbers.js +87 -0
- package/dist/github/projectNumbers.js.map +7 -0
- package/dist/issue.d.ts +4 -2
- package/dist/issue.js +84 -12
- package/dist/issue.js.map +2 -2
- package/dist/issueContract.d.ts +2 -0
- package/dist/issueContract.js +11 -9
- package/dist/issueContract.js.map +2 -2
- package/dist/issueInfoReadback.test.js +80 -7
- package/dist/issueInfoReadback.test.js.map +2 -2
- package/dist/issueIntake.test.js +30 -0
- package/dist/issueIntake.test.js.map +2 -2
- package/dist/issueJournal.js +4 -2
- package/dist/issueJournal.js.map +2 -2
- package/dist/issueJournal.test.js +22 -0
- package/dist/issueJournal.test.js.map +2 -2
- package/dist/issueTracking.test.js +4 -1
- package/dist/issueTracking.test.js.map +2 -2
- package/dist/mcp/index.js +3 -3
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/tools.d.ts +21 -3
- package/dist/mcp/tools.js +141 -95
- package/dist/mcp/tools.js.map +2 -2
- package/dist/milestone.d.ts +20 -0
- package/dist/milestone.js +41 -0
- package/dist/milestone.js.map +7 -0
- package/dist/milestone.test.d.ts +1 -0
- package/dist/milestone.test.js +101 -0
- package/dist/milestone.test.js.map +7 -0
- package/dist/pr.d.ts +2 -0
- package/dist/pr.js +28 -3
- package/dist/pr.js.map +2 -2
- package/dist/pr.test.js +0 -7
- package/dist/pr.test.js.map +2 -2
- package/dist/prAssociation.test.js +82 -9
- package/dist/prAssociation.test.js.map +2 -2
- package/dist/projectNumbers.test.d.ts +1 -0
- package/dist/projectNumbers.test.js +114 -0
- package/dist/projectNumbers.test.js.map +7 -0
- package/dist/readView.d.ts +31 -3
- package/dist/readView.js +29 -12
- package/dist/readView.js.map +2 -2
- package/dist/readView.test.js +63 -1
- package/dist/readView.test.js.map +2 -2
- package/dist/releaseSmoke.test.d.ts +1 -0
- package/dist/releaseSmoke.test.js +73 -0
- package/dist/releaseSmoke.test.js.map +7 -0
- package/dist/targetPolicyEntrypoints.test.js +1 -1
- package/dist/targetPolicyEntrypoints.test.js.map +2 -2
- package/dist/targetPolicyRoutes.test.js +1 -1
- package/dist/targetPolicyRoutes.test.js.map +2 -2
- package/dist/targetRepositoryExecution.test.js +6 -0
- package/dist/targetRepositoryExecution.test.js.map +2 -2
- package/dist/toolOutput.test.js +14 -0
- package/dist/toolOutput.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 +127 -114
- package/plugins/ai-delivery/runtime/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/milestone.test.ts"],
|
|
4
|
+
"sourcesContent": ["import assert from 'node:assert/strict';\nimport { test } from 'vitest';\nimport type { DeliveryContext } from './issue.js';\nimport { getAiDeliveryMcpTool } from './mcp/tools.js';\nimport { createMilestone } from './milestone.js';\n\ninterface FakeMilestone {\n description: string | null;\n state?: 'closed' | 'open';\n due_on: string | null;\n html_url: string;\n number: number;\n title: string;\n}\n\n/** A repository whose milestones live in a list; records every create call. */\nfunction fakeRepository(initial: FakeMilestone[] = [], options: { dropDueDate?: boolean } = {}) {\n const milestones = [...initial];\n const created: Record<string, unknown>[] = [];\n const issues = {\n createMilestone: async (input: { description?: string; due_on?: string; title: string }) => {\n created.push(input);\n const milestone: FakeMilestone = {\n description: input.description ?? null,\n due_on: options.dropDueDate === true ? null : (input.due_on ?? null),\n html_url: `https://github.com/aviaratech/ai/milestone/${milestones.length + 1}`,\n number: milestones.length + 1,\n state: 'open',\n title: input.title,\n };\n milestones.push(milestone);\n return { data: milestone };\n },\n getMilestone: async (input: { milestone_number: number }) => ({\n data: milestones.find((milestone) => milestone.number === input.milestone_number)!,\n }),\n listMilestones: async () => ({ data: milestones }),\n };\n const rest = { issues };\n const context = {\n clients: { rest },\n repo: { owner: 'aviaratech', repo: 'ai' },\n } as unknown as DeliveryContext;\n return { context, created };\n}\n\ntest('milestone_create makes a milestone with a due date and description and reads it back', async () => {\n const repository = fakeRepository();\n const result = await createMilestone(repository.context, {\n description: 'R12: speed lane',\n dueOn: '2026-11-27',\n title: 'R12',\n });\n assert.deepEqual(result, {\n created: true,\n description: 'R12: speed lane',\n dueOn: '2026-11-27',\n number: 1,\n state: 'open',\n title: 'R12',\n url: 'https://github.com/aviaratech/ai/milestone/1',\n });\n assert.equal(repository.created[0]!.due_on, '2026-11-27T12:00:00Z');\n});\n\ntest('repeating the same milestone_create returns the milestone it made and creates no second one', async () => {\n const repository = fakeRepository();\n const input = { dueOn: '2026-11-27', title: 'R12' };\n await createMilestone(repository.context, input);\n const again = await createMilestone(repository.context, input);\n assert.equal(again.created, false);\n assert.equal(again.number, 1);\n assert.equal(repository.created.length, 1);\n});\n\ntest('a same-titled milestone with a different due date is refused with its number', async () => {\n const repository = fakeRepository([\n { description: null, due_on: '2026-12-01T00:00:00Z', html_url: 'https://example.test/1', number: 7, title: 'R12' },\n ]);\n await assert.rejects(\n createMilestone(repository.context, { dueOn: '2026-11-27', title: 'R12' }),\n /Milestone #7 is already titled \"R12\" with a different description or due date/u,\n );\n assert.equal(repository.created.length, 0);\n});\n\ntest('a readback that lost the due date fails instead of reporting success', async () => {\n const repository = fakeRepository([], { dropDueDate: true });\n await assert.rejects(\n createMilestone(repository.context, { dueOn: '2026-11-27', title: 'R12' }),\n /Milestone #1 now exists with due date none and does not match the request/u,\n );\n});\n\ntest('the milestone_create tool takes a title, an ISO date and a description and refuses a bad date', () => {\n const tool = getAiDeliveryMcpTool('milestone_create')!;\n assert.equal(tool.commandName, 'milestone:create');\n assert.ok(tool.inputSchema.safeParse({ description: 'x', dueOn: '2026-11-27', title: 'R12' }).success);\n assert.equal(tool.inputSchema.safeParse({ dueOn: '11/27/2026', title: 'R12' }).success, false);\n assert.equal(tool.inputSchema.safeParse({ title: ' ' }).success, false);\n});\n\ntest('a repeat that matches a closed milestone says it is closed', async () => {\n const repository = fakeRepository([\n {\n description: null,\n due_on: '2026-11-27T08:00:00Z',\n html_url: 'https://example.test/3',\n number: 3,\n state: 'closed',\n title: 'R12',\n },\n ]);\n const result = await createMilestone(repository.context, { dueOn: '2026-11-27', title: 'R12' });\n assert.equal(result.created, false);\n assert.equal(result.state, 'closed');\n assert.equal(repository.created.length, 0);\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAS,YAAY;AAErB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAYhC,SAAS,eAAe,UAA2B,CAAC,GAAG,UAAqC,CAAC,GAAG;AAC9F,QAAM,aAAa,CAAC,GAAG,OAAO;AAC9B,QAAM,UAAqC,CAAC;AAC5C,QAAM,SAAS;AAAA,IACb,iBAAiB,OAAO,UAAoE;AAC1F,cAAQ,KAAK,KAAK;AAClB,YAAM,YAA2B;AAAA,QAC/B,aAAa,MAAM,eAAe;AAAA,QAClC,QAAQ,QAAQ,gBAAgB,OAAO,OAAQ,MAAM,UAAU;AAAA,QAC/D,UAAU,8CAA8C,WAAW,SAAS,CAAC;AAAA,QAC7E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AAM,WAAW,QAAQ,QAAQ,CAAC;AAC3C,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/pr.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare function publishPr(context: DeliveryContext, input: {
|
|
|
92
92
|
nonClosing?: boolean;
|
|
93
93
|
nonClosingVerified?: boolean;
|
|
94
94
|
bodyTransition?: boolean;
|
|
95
|
+
edited?: ("body" | "title")[];
|
|
95
96
|
headSha: string;
|
|
96
97
|
headBranch: string;
|
|
97
98
|
baseBranch: string;
|
|
@@ -111,6 +112,7 @@ export declare function publishPr(context: DeliveryContext, input: {
|
|
|
111
112
|
headSha: string;
|
|
112
113
|
state: string;
|
|
113
114
|
closingLinkAdded?: boolean;
|
|
115
|
+
edited?: ("body" | "title")[];
|
|
114
116
|
nonClosing?: boolean;
|
|
115
117
|
nonClosingVerified?: boolean;
|
|
116
118
|
referenceRemoval?: "acknowledged" | "not attempted";
|
package/dist/pr.js
CHANGED
|
@@ -859,7 +859,7 @@ async function publishPr(context, input) {
|
|
|
859
859
|
const explicit = input.prNumber === void 0 ? void 0 : await getPr(context, input.prNumber);
|
|
860
860
|
const explicitPromotion = nonClosing && input.draft === false && input.headBranch !== void 0;
|
|
861
861
|
const selectedMatches = explicitPromotion ? await matchingPrs(context, input.headBranch, base, "open") : void 0;
|
|
862
|
-
const branch = explicit ? explicit.head.ref :
|
|
862
|
+
const branch = explicit ? explicit.head.ref : input.headBranch ?? await issueBranch(context, input.issueNumber);
|
|
863
863
|
if (input.headBranch !== void 0 && branch !== input.headBranch)
|
|
864
864
|
throw new DeliveryError("Explicit PR and head selectors disagree.");
|
|
865
865
|
validBranch(branch);
|
|
@@ -888,6 +888,9 @@ async function publishPr(context, input) {
|
|
|
888
888
|
pr?.body
|
|
889
889
|
);
|
|
890
890
|
const closingRepair = !nonClosing && pr !== void 0 && !hasClosingLink(pr.body, input.issueNumber);
|
|
891
|
+
const titleEdit = !nonClosing && pr !== void 0 && input.title !== void 0 && pr.title !== input.title;
|
|
892
|
+
const bodyEdit = !nonClosing && pr !== void 0 && !closingRepair && input.body !== void 0 && pr.body !== body;
|
|
893
|
+
const edited = [...titleEdit ? ["title"] : [], ...bodyEdit ? ["body"] : []];
|
|
891
894
|
const transition = nonClosing && pr !== void 0 && pr.body !== body;
|
|
892
895
|
const referenceUpdate = transition && hasReferenceBody(context, input.issueNumber, pr?.body);
|
|
893
896
|
if (transition && input.body === void 0)
|
|
@@ -895,7 +898,7 @@ async function publishPr(context, input) {
|
|
|
895
898
|
const reconcileReference = nonClosing && !transition && input.draft !== false && (!pr || pr.draft);
|
|
896
899
|
if (reconcileReference && (context.clients.role !== "author" || context.clients.authSource !== (context.config.roles.author.authSource ?? "app") || !context.clients.authenticatedAuthor))
|
|
897
900
|
throw new DeliveryError("Non-closing PR creation needs the configured author credentials; run it as the author.");
|
|
898
|
-
if (pr && (pr.head.sha !== ref.object.sha || pr.head.ref !== branch || pr.base.ref !== base || pr.state !== "open" || pr.merged ||
|
|
901
|
+
if (pr && (pr.head.sha !== ref.object.sha || pr.head.ref !== branch || pr.base.ref !== base || pr.state !== "open" || pr.merged || nonClosing && input.title !== void 0 && pr.title !== input.title))
|
|
899
902
|
throw new DeliveryError("Existing remote PR conflicts with the requested branch, intent or state.");
|
|
900
903
|
const reviewRoute = nonClosing ? await nonClosingRoute(context, base) : { author: await routeAuthor(context, "publication") };
|
|
901
904
|
if (pr && pr.user.login.toLowerCase() !== reviewRoute.author.actorLogin.toLowerCase())
|
|
@@ -910,6 +913,7 @@ async function publishPr(context, input) {
|
|
|
910
913
|
let pendingTransition = transition;
|
|
911
914
|
let pendingClosingRepair = closingRepair;
|
|
912
915
|
let expectedBody = pr?.body;
|
|
916
|
+
let expectedTitle = pr?.title;
|
|
913
917
|
const transitionDraft = pr?.draft;
|
|
914
918
|
let promotionApplied = false;
|
|
915
919
|
let removalState = "not attempted";
|
|
@@ -948,7 +952,7 @@ async function publishPr(context, input) {
|
|
|
948
952
|
existing.number,
|
|
949
953
|
nonClosing && (!pendingTransition || referenceUpdate)
|
|
950
954
|
);
|
|
951
|
-
if (current.state !== "open" || current.merged || current.node_id !== existing.node_id || current.head.sha !== ref.object.sha || current.head.ref !== branch || current.base.ref !== base || current.base.sha !== existing.base.sha || current.user.login.toLowerCase() !== reviewRoute.author.actorLogin.toLowerCase() || (transition || closingRepair) && !promotionApplied && current.draft !== transitionDraft || current.body !== expectedBody || current.title !==
|
|
955
|
+
if (current.state !== "open" || current.merged || current.node_id !== existing.node_id || current.head.sha !== ref.object.sha || current.head.ref !== branch || current.base.ref !== base || current.base.sha !== existing.base.sha || current.user.login.toLowerCase() !== reviewRoute.author.actorLogin.toLowerCase() || (transition || closingRepair) && !promotionApplied && current.draft !== transitionDraft || current.body !== expectedBody || current.title !== expectedTitle)
|
|
952
956
|
throw new DeliveryError("Existing PR publication head, identity, intent or author readback drifted.");
|
|
953
957
|
if (reconcileReference) await readReconciliation(current);
|
|
954
958
|
if (pendingClosingRepair) {
|
|
@@ -1014,6 +1018,7 @@ async function publishPr(context, input) {
|
|
|
1014
1018
|
body,
|
|
1015
1019
|
bodyTransition: pendingTransition
|
|
1016
1020
|
} : {},
|
|
1021
|
+
...edited.length ? { edited } : {},
|
|
1017
1022
|
headSha: ref.object.sha,
|
|
1018
1023
|
headBranch: branch,
|
|
1019
1024
|
baseBranch: base,
|
|
@@ -1044,6 +1049,25 @@ async function publishPr(context, input) {
|
|
|
1044
1049
|
expectedBody = body;
|
|
1045
1050
|
pr = await readExisting();
|
|
1046
1051
|
}
|
|
1052
|
+
if (edited.length) {
|
|
1053
|
+
pr = await readExisting();
|
|
1054
|
+
const number = pr.number;
|
|
1055
|
+
try {
|
|
1056
|
+
await context.clients.rest.pulls.update({
|
|
1057
|
+
...context.repo,
|
|
1058
|
+
pull_number: number,
|
|
1059
|
+
...titleEdit ? { title: input.title } : {},
|
|
1060
|
+
...bodyEdit ? { body } : {}
|
|
1061
|
+
});
|
|
1062
|
+
if (titleEdit) expectedTitle = input.title;
|
|
1063
|
+
if (bodyEdit) expectedBody = body;
|
|
1064
|
+
pr = await readExisting();
|
|
1065
|
+
} catch (error) {
|
|
1066
|
+
throw new DeliveryError(
|
|
1067
|
+
`PR #${number} edit acknowledgement is uncertain; check it with issue_pr_info before calling again. ${error instanceof Error ? error.message : "Unknown failure"}`
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1047
1071
|
if (input.draft === false && pr.draft) {
|
|
1048
1072
|
pr = await readExisting();
|
|
1049
1073
|
if (pr.draft) {
|
|
@@ -1146,6 +1170,7 @@ async function publishPr(context, input) {
|
|
|
1146
1170
|
headSha: pr.head.sha,
|
|
1147
1171
|
state: pr.draft ? "draft" : pr.state,
|
|
1148
1172
|
...closingRepair ? { closingLinkAdded: true } : {},
|
|
1173
|
+
...edited.length ? { edited } : {},
|
|
1149
1174
|
...nonClosing ? { nonClosing: true, nonClosingVerified: true } : {},
|
|
1150
1175
|
...reconcileReference ? { referenceRemoval: removalState } : {},
|
|
1151
1176
|
...warnings.length ? { warnings } : {}
|