@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
package/dist/mcp/tools.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { NativeIssueDateFields } from "../github/nativeIssueMetadata.js";
|
|
3
|
+
import { ProjectTradeFields } from "../github/projectNumbers.js";
|
|
3
4
|
import { OverrideReason } from "../services/blockerGuardService.js";
|
|
4
5
|
import { JournalInputSchema, JOURNAL_SCHEMA_METADATA } from "../issueJournal.js";
|
|
5
6
|
import {
|
|
@@ -10,7 +11,8 @@ import {
|
|
|
10
11
|
CreateIssueStatus,
|
|
11
12
|
IssueStatusPatch,
|
|
12
13
|
ProjectStatusPatch,
|
|
13
|
-
IssueDeferralPatch
|
|
14
|
+
IssueDeferralPatch,
|
|
15
|
+
acceptedKeysError
|
|
14
16
|
} from "../issueContract.js";
|
|
15
17
|
const Verbose = z.boolean().optional().describe("Return the full payload, including bodies, diffs and routing.");
|
|
16
18
|
const Positive = z.number().int().positive();
|
|
@@ -19,31 +21,34 @@ const REPO_HELP = "GitHub owner/name. Pass the repository named by the user. An
|
|
|
19
21
|
const Repo = z.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u).optional().describe(REPO_HELP);
|
|
20
22
|
const AI_DELIVERY_MCP_CONTRACT_VERSION = "ai-delivery.mcp@2";
|
|
21
23
|
const IssueUpdateInput = issueInputSchema(
|
|
22
|
-
z.strictObject(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
z.strictObject(
|
|
25
|
+
{
|
|
26
|
+
...IssueWriteFields,
|
|
27
|
+
...NativeIssueDateFields,
|
|
28
|
+
status: IssueStatusPatch.optional(),
|
|
29
|
+
projectStatus: ProjectStatusPatch.optional(),
|
|
30
|
+
repo: Repo,
|
|
31
|
+
blockedBy: z.array(Positive).optional(),
|
|
32
|
+
blocks: z.array(Positive).optional(),
|
|
33
|
+
overrideReason: OverrideReason.optional(),
|
|
34
|
+
body: z.string().optional(),
|
|
35
|
+
issueNumber: Positive,
|
|
36
|
+
issueType: IssueWriteFields.issueType,
|
|
37
|
+
labels: Labels.optional(),
|
|
38
|
+
milestone: Positive.nullable().optional(),
|
|
39
|
+
parentIssueNumber: Positive.nullable().optional(),
|
|
40
|
+
park: z.literal(true).optional(),
|
|
41
|
+
...IssueDeferralPatch,
|
|
42
|
+
points: IssueWriteFields.points,
|
|
43
|
+
priority: z.string().min(1).optional(),
|
|
44
|
+
state: z.enum(["open", "closed"]).optional(),
|
|
45
|
+
preserveHistory: z.boolean().optional(),
|
|
46
|
+
closeReason: z.enum(["completed", "not_planned", "duplicate"]).optional(),
|
|
47
|
+
supersededBy: Positive.optional(),
|
|
48
|
+
title: IssueWriteFields.title
|
|
49
|
+
},
|
|
50
|
+
{ error: acceptedKeysError }
|
|
51
|
+
).superRefine((input, ctx) => {
|
|
47
52
|
if (input.defer !== void 0 && input.undefer !== void 0)
|
|
48
53
|
ctx.addIssue({ code: "custom", message: "Choose defer or undefer, never both.", path: ["defer"] });
|
|
49
54
|
if ((input.closeReason !== void 0 || input.supersededBy !== void 0) && input.state !== "closed")
|
|
@@ -70,15 +75,18 @@ const Tracking = {
|
|
|
70
75
|
repo: z.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u).optional().describe(REPO_HELP),
|
|
71
76
|
title: z.string().trim().min(1, "Issue title is empty; enter a title.").max(256, "Issue title exceeds 256 characters; shorten the title.").describe(IssueFields.shape.title.description ?? "")
|
|
72
77
|
};
|
|
73
|
-
const NormalStart = z.strictObject(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const NormalStart = z.strictObject(
|
|
79
|
+
{
|
|
80
|
+
...Tracking,
|
|
81
|
+
title: Tracking.title.optional(),
|
|
82
|
+
issueNumber: Positive.optional(),
|
|
83
|
+
request: z.string().min(1).optional(),
|
|
84
|
+
requestId: z.string().trim().min(1).max(256).optional(),
|
|
85
|
+
resumeCreated: z.boolean().optional(),
|
|
86
|
+
branch: z.string().min(1).optional()
|
|
87
|
+
},
|
|
88
|
+
{ error: acceptedKeysError }
|
|
89
|
+
);
|
|
82
90
|
const IssueListing = {
|
|
83
91
|
repo: Repo,
|
|
84
92
|
verbose: Verbose,
|
|
@@ -99,7 +107,7 @@ const AI_DELIVERY_MCP_TOOLS = [
|
|
|
99
107
|
name: "issue_comment",
|
|
100
108
|
commandName: "comment",
|
|
101
109
|
description: "Post a typed issue journal with authoritative comment readback. Provide the fields required by kind: start: outcome; progress: done, decisionNeeded and non-empty evidence; decision: non-empty decision and rationale; blocker: blocker and resolution; closeout: acceptance and followUps. Omit fields belonging to other kinds.",
|
|
102
|
-
inputSchema: z.strictObject({ ...JournalInputSchema.shape, repo: Repo, verbose: Verbose }).superRefine(({ repo: _repo, verbose: _verbose, ...journal }, ctx) => {
|
|
110
|
+
inputSchema: z.strictObject({ ...JournalInputSchema.shape, repo: Repo, verbose: Verbose }, { error: acceptedKeysError }).superRefine(({ repo: _repo, verbose: _verbose, ...journal }, ctx) => {
|
|
103
111
|
const parsed = JournalInputSchema.safeParse(journal);
|
|
104
112
|
if (!parsed.success)
|
|
105
113
|
for (const issue of parsed.error.issues)
|
|
@@ -112,16 +120,19 @@ const AI_DELIVERY_MCP_TOOLS = [
|
|
|
112
120
|
description: "Create a native GitHub tracking issue with configured metadata and relationships",
|
|
113
121
|
issueContract: ISSUE_JSON_SCHEMAS,
|
|
114
122
|
inputSchema: issueInputSchema(
|
|
115
|
-
z.strictObject(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
z.strictObject(
|
|
124
|
+
{
|
|
125
|
+
...Tracking,
|
|
126
|
+
...NativeIssueDateFields,
|
|
127
|
+
...IssueWriteFields,
|
|
128
|
+
title: IssueFields.shape.title,
|
|
129
|
+
opId: z.string().trim().min(1).max(256).optional().describe(
|
|
130
|
+
"Stable retry identity: repeat the same original arguments to complete a partial create without another issue."
|
|
131
|
+
),
|
|
132
|
+
status: CreateIssueStatus.optional()
|
|
133
|
+
},
|
|
134
|
+
{ error: acceptedKeysError }
|
|
135
|
+
)
|
|
125
136
|
)
|
|
126
137
|
},
|
|
127
138
|
{
|
|
@@ -132,99 +143,134 @@ const AI_DELIVERY_MCP_TOOLS = [
|
|
|
132
143
|
},
|
|
133
144
|
{
|
|
134
145
|
name: "issue_list",
|
|
146
|
+
readOnly: true,
|
|
135
147
|
commandName: "list",
|
|
136
148
|
description: "List repository issues with native filters, named organization fields and pagination",
|
|
137
|
-
inputSchema: z.strictObject({ ...IssueListing, query: SearchText.optional() })
|
|
149
|
+
inputSchema: z.strictObject({ ...IssueListing, query: SearchText.optional() }, { error: acceptedKeysError })
|
|
138
150
|
},
|
|
139
151
|
{
|
|
140
152
|
name: "issue_search",
|
|
153
|
+
readOnly: true,
|
|
141
154
|
commandName: "search",
|
|
142
155
|
description: "Search literal issue text in the selected repository with native filters and pagination",
|
|
143
|
-
inputSchema: z.strictObject({ ...IssueListing, query: SearchText })
|
|
156
|
+
inputSchema: z.strictObject({ ...IssueListing, query: SearchText }, { error: acceptedKeysError })
|
|
144
157
|
},
|
|
145
158
|
{
|
|
146
159
|
name: "issue_update",
|
|
147
160
|
commandName: "update",
|
|
148
161
|
description: "Update native issue fields and exact relationship sets with readback",
|
|
149
|
-
inputSchema: IssueUpdateInput.safeExtend({ verbose: Verbose })
|
|
162
|
+
inputSchema: IssueUpdateInput.safeExtend({ ...ProjectTradeFields, verbose: Verbose })
|
|
150
163
|
},
|
|
151
164
|
{
|
|
152
165
|
name: "issue_batch_update",
|
|
153
166
|
commandName: "batch:update",
|
|
154
167
|
description: "Plan or apply 1\u201350 issue updates in one repository, with ordered partial results and readback",
|
|
155
168
|
inputSchema: issueInputSchema(
|
|
156
|
-
z.strictObject(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
z.strictObject(
|
|
170
|
+
{
|
|
171
|
+
repo: Repo,
|
|
172
|
+
verbose: Verbose,
|
|
173
|
+
items: z.array(IssueUpdateInput).min(1).max(50),
|
|
174
|
+
dryRun: z.boolean().optional()
|
|
175
|
+
},
|
|
176
|
+
{ error: acceptedKeysError }
|
|
177
|
+
)
|
|
162
178
|
)
|
|
163
179
|
},
|
|
164
180
|
{
|
|
165
181
|
name: "issue_info",
|
|
182
|
+
readOnly: true,
|
|
166
183
|
commandName: "info",
|
|
167
|
-
description: "Read live GitHub issue metadata, relationships, Project status, linked PRs (state, checks, reviews) and the latest journal in one call. Child counts by default; verbose adds the body, routing and full child progress. Pass the requested owner/name as repo; an explicit repo works outside Git without a checkout. This read does not start or update the issue.",
|
|
168
|
-
inputSchema: z.strictObject({ issueNumber: Positive, repo: Repo, verbose: Verbose })
|
|
184
|
+
description: "Read live GitHub issue metadata, relationships, Project status, linked PRs (state, merge commit, checks, reviews) and the latest journal in one call. Child counts by default; verbose adds the body, every journal in full, routing and full child progress. Pass the requested owner/name as repo; an explicit repo works outside Git without a checkout. This read does not start or update the issue.",
|
|
185
|
+
inputSchema: z.strictObject({ issueNumber: Positive, repo: Repo, verbose: Verbose }, { error: acceptedKeysError })
|
|
169
186
|
},
|
|
170
187
|
{
|
|
171
188
|
name: "issue_ready_check",
|
|
189
|
+
readOnly: true,
|
|
172
190
|
commandName: "ready:check",
|
|
173
191
|
description: "Evaluate deterministic readiness from live native issue state",
|
|
174
|
-
inputSchema: z.strictObject(
|
|
192
|
+
inputSchema: z.strictObject(
|
|
193
|
+
{ issueNumber: Positive, repo: Tracking.repo, verbose: Verbose },
|
|
194
|
+
{ error: acceptedKeysError }
|
|
195
|
+
)
|
|
175
196
|
},
|
|
176
197
|
{
|
|
177
198
|
name: "issue_pr_create",
|
|
178
199
|
commandName: "pr:create",
|
|
179
|
-
description: "Create or reuse a PR from any directory using repo, issueNumber and a pushed head. By default it closes the issue and restores a missing closing link on reuse. nonClosing opens a draft that references the issue and leaves it open. expectedHeadSha refuses a different pushed head.",
|
|
180
|
-
inputSchema: z.strictObject(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
description: "Create or reuse a PR from any directory using repo, issueNumber and a pushed head. By default it closes the issue and restores a missing closing link on reuse. On an existing closing PR, a new title or body edits it and draft: false marks it ready. nonClosing opens a draft that references the issue and leaves it open. expectedHeadSha refuses a different pushed head.",
|
|
201
|
+
inputSchema: z.strictObject(
|
|
202
|
+
{
|
|
203
|
+
repo: Repo,
|
|
204
|
+
verbose: Verbose,
|
|
205
|
+
issueNumber: Positive,
|
|
206
|
+
prNumber: Positive.optional(),
|
|
207
|
+
nonClosing: z.boolean().optional(),
|
|
208
|
+
expectedHeadSha: z.string().regex(
|
|
209
|
+
/^[a-f0-9]{40}$/u,
|
|
210
|
+
"expectedHeadSha must be a full 40-character commit SHA; pass the pushed head or omit it."
|
|
211
|
+
).optional(),
|
|
212
|
+
body: z.string().min(1, "PR body is empty; enter a body or omit it to use the default body.").optional(),
|
|
213
|
+
draft: z.boolean().optional(),
|
|
214
|
+
dryRun: z.boolean().optional(),
|
|
215
|
+
title: z.string().min(1, "PR title is empty; enter a title or omit it to use the issue title.").optional(),
|
|
216
|
+
headBranch: z.string().min(1).optional(),
|
|
217
|
+
head: z.string().min(1).optional(),
|
|
218
|
+
base: z.string().min(1).optional()
|
|
219
|
+
},
|
|
220
|
+
{ error: acceptedKeysError }
|
|
221
|
+
).refine(
|
|
198
222
|
(input) => input.head === void 0 || input.headBranch === void 0 || input.head === input.headBranch,
|
|
199
223
|
"PR head selectors disagree; use the same branch for head and headBranch."
|
|
200
224
|
)
|
|
201
225
|
},
|
|
202
226
|
{
|
|
203
227
|
name: "issue_pr_info",
|
|
228
|
+
readOnly: true,
|
|
204
229
|
commandName: "pr:info",
|
|
205
|
-
description: "Inspect a PR by number or its GitHub-linked issue branch: state, merge state, checks, reviews and each linked issue's state, Project status and latest journal, in one call",
|
|
206
|
-
inputSchema: z.strictObject(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
230
|
+
description: "Inspect a PR by number or its GitHub-linked issue branch: state, merge state, merge commit, checks, reviews and each linked issue's state, Project status and latest journal, in one call",
|
|
231
|
+
inputSchema: z.strictObject(
|
|
232
|
+
{
|
|
233
|
+
repo: Repo,
|
|
234
|
+
verbose: Verbose,
|
|
235
|
+
issueNumber: Positive.optional(),
|
|
236
|
+
prNumber: Positive.optional(),
|
|
237
|
+
nonClosing: z.boolean().optional()
|
|
238
|
+
},
|
|
239
|
+
{ error: acceptedKeysError }
|
|
240
|
+
)
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "milestone_create",
|
|
244
|
+
commandName: "milestone:create",
|
|
245
|
+
description: "Create a repository milestone (title, optional ISO due date and description) with readback. Repeating the same call returns the milestone it made; a same-titled milestone with different details is refused.",
|
|
246
|
+
inputSchema: z.strictObject(
|
|
247
|
+
{
|
|
248
|
+
repo: Repo,
|
|
249
|
+
verbose: Verbose,
|
|
250
|
+
title: z.string().trim().min(1).max(256),
|
|
251
|
+
dueOn: z.iso.date().optional(),
|
|
252
|
+
description: z.string().max(1e4).optional()
|
|
253
|
+
},
|
|
254
|
+
{ error: acceptedKeysError }
|
|
255
|
+
)
|
|
213
256
|
},
|
|
214
257
|
{
|
|
215
258
|
name: "issue_pr_review",
|
|
216
259
|
commandName: "pr:review",
|
|
217
260
|
description: "Submit one existing exact-head independent review with the reviewer App role",
|
|
218
|
-
inputSchema: z.strictObject(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
261
|
+
inputSchema: z.strictObject(
|
|
262
|
+
{
|
|
263
|
+
repo: Repo,
|
|
264
|
+
verbose: Verbose,
|
|
265
|
+
issueNumber: Positive,
|
|
266
|
+
prNumber: Positive,
|
|
267
|
+
nonClosing: z.boolean().optional(),
|
|
268
|
+
artifact: z.string().min(1, "Review artifact is empty; provide the independent review artifact JSON."),
|
|
269
|
+
identity: z.string().min(1).optional(),
|
|
270
|
+
dryRun: z.boolean().optional()
|
|
271
|
+
},
|
|
272
|
+
{ error: acceptedKeysError }
|
|
273
|
+
)
|
|
228
274
|
}
|
|
229
275
|
];
|
|
230
276
|
function getAiDeliveryMcpTool(name) {
|
package/dist/mcp/tools.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/tools.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod';\nimport { NativeIssueDateFields } from '../github/nativeIssueMetadata.js';\nimport { OverrideReason } from '../services/blockerGuardService.js';\nimport { JournalInputSchema, JOURNAL_SCHEMA_METADATA } from '../issueJournal.js';\nimport {\n IssueFields,\n IssueWriteFields,\n ISSUE_JSON_SCHEMAS,\n issueInputSchema,\n CreateIssueStatus,\n IssueStatusPatch,\n ProjectStatusPatch,\n IssueDeferralPatch,\n} from '../issueContract.js';\n\nconst Verbose = z.boolean().optional().describe('Return the full payload, including bodies, diffs and routing.');\nconst Positive = z.number().int().positive();\nconst Labels = z.array(z.string().trim().min(1));\nconst REPO_HELP =\n 'GitHub owner/name. Pass the repository named by the user. An explicit repo avoids launch-directory Git for ordinary remote issue/PR work; retained local modes keep their own checkout requirements.';\nconst Repo = z\n .string()\n .regex(/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/u)\n .optional()\n .describe(REPO_HELP);\nexport const AI_DELIVERY_MCP_CONTRACT_VERSION = 'ai-delivery.mcp@2' as const;\nconst IssueUpdateInput = issueInputSchema(\n z\n .strictObject({\n ...IssueWriteFields,\n ...NativeIssueDateFields,\n status: IssueStatusPatch.optional(),\n projectStatus: ProjectStatusPatch.optional(),\n repo: Repo,\n blockedBy: z.array(Positive).optional(),\n blocks: z.array(Positive).optional(),\n overrideReason: OverrideReason.optional(),\n body: z.string().optional(),\n issueNumber: Positive,\n issueType: IssueWriteFields.issueType,\n labels: Labels.optional(),\n milestone: Positive.nullable().optional(),\n parentIssueNumber: Positive.nullable().optional(),\n park: z.literal(true).optional(),\n ...IssueDeferralPatch,\n points: IssueWriteFields.points,\n priority: z.string().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n preserveHistory: z.boolean().optional(),\n closeReason: z.enum(['completed', 'not_planned', 'duplicate']).optional(),\n supersededBy: Positive.optional(),\n title: IssueWriteFields.title,\n })\n .superRefine((input, ctx) => {\n if (input.defer !== undefined && input.undefer !== undefined)\n ctx.addIssue({ code: 'custom', message: 'Choose defer or undefer, never both.', path: ['defer'] });\n if ((input.closeReason !== undefined || input.supersededBy !== undefined) && input.state !== 'closed')\n ctx.addIssue({\n code: 'custom',\n path: ['state'],\n message: 'Closure details require a closed issue; set state to closed.',\n params: { issueCode: 'closure.state' },\n });\n }),\n);\n\nconst Tracking = {\n verbose: Verbose,\n blockedBy: z.array(Positive).optional(),\n blocks: z.array(Positive).optional(),\n overrideReason: OverrideReason.optional(),\n body: z.string().optional(),\n issueType: z.string().min(1).optional(),\n labels: Labels.optional(),\n milestone: Positive.optional(),\n parentIssueNumber: Positive.optional(),\n points: Positive.optional().describe(IssueFields.shape.points.description ?? ''),\n priority: z.string().min(1).optional(),\n repo: z\n .string()\n .regex(/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/u)\n .optional()\n .describe(REPO_HELP),\n title: z\n .string()\n .trim()\n .min(1, 'Issue title is empty; enter a title.')\n .max(256, 'Issue title exceeds 256 characters; shorten the title.')\n .describe(IssueFields.shape.title.description ?? ''),\n};\nconst NormalStart = z.strictObject({\n ...Tracking,\n title: Tracking.title.optional(),\n issueNumber: Positive.optional(),\n request: z.string().min(1).optional(),\n requestId: z.string().trim().min(1).max(256).optional(),\n resumeCreated: z.boolean().optional(),\n branch: z.string().min(1).optional(),\n});\nconst IssueListing = {\n repo: Repo,\n verbose: Verbose,\n state: z.enum(['open', 'closed', 'all']).optional(),\n labels: z\n .array(\n z\n .string()\n .min(1)\n .regex(/^[^\"\\\\\\r\\n]+$/u),\n )\n .optional(),\n parentIssueNumber: Positive.nullable().optional(),\n issueType: z.string().min(1).optional(),\n projectStatus: z.enum(['Todo', 'In Progress', 'Blocked', 'Done']).nullable().optional(),\n updatedSince: z.iso.datetime({ offset: true }).optional(),\n page: Positive.optional(),\n perPage: Positive.max(100).optional(),\n};\nconst SearchText = z\n .string()\n .trim()\n .min(1)\n .max(256)\n .regex(/^[^\"\\\\\\r\\n]+$/u);\n\nexport const AI_DELIVERY_MCP_TOOLS = [\n {\n name: 'issue_comment',\n commandName: 'comment',\n description:\n 'Post a typed issue journal with authoritative comment readback. Provide the fields required by kind: start: outcome; progress: done, decisionNeeded and non-empty evidence; decision: non-empty decision and rationale; blocker: blocker and resolution; closeout: acceptance and followUps. Omit fields belonging to other kinds.',\n inputSchema: z\n .strictObject({ ...JournalInputSchema.shape, repo: Repo, verbose: Verbose })\n .superRefine(({ repo: _repo, verbose: _verbose, ...journal }, ctx) => {\n // Repository routing belongs to the MCP envelope, not the strict journal variants.\n const parsed = JournalInputSchema.safeParse(journal);\n if (!parsed.success)\n for (const issue of parsed.error.issues)\n ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });\n })\n .meta(JOURNAL_SCHEMA_METADATA),\n },\n {\n name: 'issue_create',\n commandName: 'create',\n description: 'Create a native GitHub tracking issue with configured metadata and relationships',\n issueContract: ISSUE_JSON_SCHEMAS,\n inputSchema: issueInputSchema(\n z.strictObject({\n ...Tracking,\n ...NativeIssueDateFields,\n ...IssueWriteFields,\n title: IssueFields.shape.title,\n opId: z\n .string()\n .trim()\n .min(1)\n .max(256)\n .optional()\n .describe(\n 'Stable retry identity: repeat the same original arguments to complete a partial create without another issue.',\n ),\n status: CreateIssueStatus.optional(),\n }),\n ),\n },\n {\n name: 'issue_start',\n commandName: 'start',\n description:\n 'Start a linked issue. Prefer issueNumber of an open issue that already meets the ready contract: title, Points and, for Bug issues, the bug fields (see issue_create). A new issue from title or request cannot carry bug fields.',\n inputSchema: NormalStart,\n },\n {\n name: 'issue_list',\n commandName: 'list',\n description: 'List repository issues with native filters, named organization fields and pagination',\n inputSchema: z.strictObject({ ...IssueListing, query: SearchText.optional() }),\n },\n {\n name: 'issue_search',\n commandName: 'search',\n description: 'Search literal issue text in the selected repository with native filters and pagination',\n inputSchema: z.strictObject({ ...IssueListing, query: SearchText }),\n },\n {\n name: 'issue_update',\n commandName: 'update',\n description: 'Update native issue fields and exact relationship sets with readback',\n inputSchema: IssueUpdateInput.safeExtend({ verbose: Verbose }),\n },\n {\n name: 'issue_batch_update',\n commandName: 'batch:update',\n description: 'Plan or apply 1\u201350 issue updates in one repository, with ordered partial results and readback',\n inputSchema: issueInputSchema(\n z.strictObject({\n repo: Repo,\n verbose: Verbose,\n items: z.array(IssueUpdateInput).min(1).max(50),\n dryRun: z.boolean().optional(),\n }),\n ),\n },\n {\n name: 'issue_info',\n commandName: 'info',\n description:\n 'Read live GitHub issue metadata, relationships, Project status, linked PRs (state, checks, reviews) and the latest journal in one call. Child counts by default; verbose adds the body, routing and full child progress. Pass the requested owner/name as repo; an explicit repo works outside Git without a checkout. This read does not start or update the issue.',\n inputSchema: z.strictObject({ issueNumber: Positive, repo: Repo, verbose: Verbose }),\n },\n {\n name: 'issue_ready_check',\n commandName: 'ready:check',\n description: 'Evaluate deterministic readiness from live native issue state',\n inputSchema: z.strictObject({ issueNumber: Positive, repo: Tracking.repo, verbose: Verbose }),\n },\n {\n name: 'issue_pr_create',\n commandName: 'pr:create',\n description:\n 'Create or reuse a PR from any directory using repo, issueNumber and a pushed head. By default it closes the issue and restores a missing closing link on reuse. nonClosing opens a draft that references the issue and leaves it open. expectedHeadSha refuses a different pushed head.',\n inputSchema: z\n .strictObject({\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive,\n prNumber: Positive.optional(),\n nonClosing: z.boolean().optional(),\n expectedHeadSha: z\n .string()\n .regex(\n /^[a-f0-9]{40}$/u,\n 'expectedHeadSha must be a full 40-character commit SHA; pass the pushed head or omit it.',\n )\n .optional(),\n body: z.string().min(1, 'PR body is empty; enter a body or omit it to use the default body.').optional(),\n draft: z.boolean().optional(),\n dryRun: z.boolean().optional(),\n title: z.string().min(1, 'PR title is empty; enter a title or omit it to use the issue title.').optional(),\n headBranch: z.string().min(1).optional(),\n head: z.string().min(1).optional(),\n base: z.string().min(1).optional(),\n })\n .refine(\n (input) => input.head === undefined || input.headBranch === undefined || input.head === input.headBranch,\n 'PR head selectors disagree; use the same branch for head and headBranch.',\n ),\n },\n {\n name: 'issue_pr_info',\n commandName: 'pr:info',\n description:\n \"Inspect a PR by number or its GitHub-linked issue branch: state, merge state, checks, reviews and each linked issue's state, Project status and latest journal, in one call\",\n inputSchema: z.strictObject({\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive.optional(),\n prNumber: Positive.optional(),\n nonClosing: z.boolean().optional(),\n }),\n },\n {\n name: 'issue_pr_review',\n commandName: 'pr:review',\n description: 'Submit one existing exact-head independent review with the reviewer App role',\n inputSchema: z.strictObject({\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive,\n prNumber: Positive,\n nonClosing: z.boolean().optional(),\n artifact: z.string().min(1, 'Review artifact is empty; provide the independent review artifact JSON.'),\n identity: z.string().min(1).optional(),\n dryRun: z.boolean().optional(),\n }),\n },\n] as const;\n\nexport type AiDeliveryMcpToolName = (typeof AI_DELIVERY_MCP_TOOLS)[number]['name'];\n\nexport function getAiDeliveryMcpTool(name: string): (typeof AI_DELIVERY_MCP_TOOLS)[number] | null {\n return AI_DELIVERY_MCP_TOOLS.find((tool) => tool.name === name) ?? null;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,+BAA+B;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,+DAA+D;AAC/G,MAAM,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAC3C,MAAM,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC/C,MAAM,YACJ;AACF,MAAM,OAAO,EACV,OAAO,EACP,MAAM,qCAAqC,EAC3C,SAAS,EACT,SAAS,SAAS;AACd,MAAM,mCAAmC;AAChD,MAAM,mBAAmB;AAAA,EACvB,EACG,
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod';\nimport { NativeIssueDateFields } from '../github/nativeIssueMetadata.js';\nimport { ProjectTradeFields } from '../github/projectNumbers.js';\nimport { OverrideReason } from '../services/blockerGuardService.js';\nimport { JournalInputSchema, JOURNAL_SCHEMA_METADATA } from '../issueJournal.js';\nimport {\n IssueFields,\n IssueWriteFields,\n ISSUE_JSON_SCHEMAS,\n issueInputSchema,\n CreateIssueStatus,\n IssueStatusPatch,\n ProjectStatusPatch,\n IssueDeferralPatch,\n acceptedKeysError,\n} from '../issueContract.js';\n\nconst Verbose = z.boolean().optional().describe('Return the full payload, including bodies, diffs and routing.');\nconst Positive = z.number().int().positive();\nconst Labels = z.array(z.string().trim().min(1));\nconst REPO_HELP =\n 'GitHub owner/name. Pass the repository named by the user. An explicit repo avoids launch-directory Git for ordinary remote issue/PR work; retained local modes keep their own checkout requirements.';\nconst Repo = z\n .string()\n .regex(/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/u)\n .optional()\n .describe(REPO_HELP);\nexport const AI_DELIVERY_MCP_CONTRACT_VERSION = 'ai-delivery.mcp@2' as const;\nconst IssueUpdateInput = issueInputSchema(\n z\n .strictObject(\n {\n ...IssueWriteFields,\n ...NativeIssueDateFields,\n status: IssueStatusPatch.optional(),\n projectStatus: ProjectStatusPatch.optional(),\n repo: Repo,\n blockedBy: z.array(Positive).optional(),\n blocks: z.array(Positive).optional(),\n overrideReason: OverrideReason.optional(),\n body: z.string().optional(),\n issueNumber: Positive,\n issueType: IssueWriteFields.issueType,\n labels: Labels.optional(),\n milestone: Positive.nullable().optional(),\n parentIssueNumber: Positive.nullable().optional(),\n park: z.literal(true).optional(),\n ...IssueDeferralPatch,\n points: IssueWriteFields.points,\n priority: z.string().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n preserveHistory: z.boolean().optional(),\n closeReason: z.enum(['completed', 'not_planned', 'duplicate']).optional(),\n supersededBy: Positive.optional(),\n title: IssueWriteFields.title,\n },\n { error: acceptedKeysError },\n )\n .superRefine((input, ctx) => {\n if (input.defer !== undefined && input.undefer !== undefined)\n ctx.addIssue({ code: 'custom', message: 'Choose defer or undefer, never both.', path: ['defer'] });\n if ((input.closeReason !== undefined || input.supersededBy !== undefined) && input.state !== 'closed')\n ctx.addIssue({\n code: 'custom',\n path: ['state'],\n message: 'Closure details require a closed issue; set state to closed.',\n params: { issueCode: 'closure.state' },\n });\n }),\n);\n\nconst Tracking = {\n verbose: Verbose,\n blockedBy: z.array(Positive).optional(),\n blocks: z.array(Positive).optional(),\n overrideReason: OverrideReason.optional(),\n body: z.string().optional(),\n issueType: z.string().min(1).optional(),\n labels: Labels.optional(),\n milestone: Positive.optional(),\n parentIssueNumber: Positive.optional(),\n points: Positive.optional().describe(IssueFields.shape.points.description ?? ''),\n priority: z.string().min(1).optional(),\n repo: z\n .string()\n .regex(/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/u)\n .optional()\n .describe(REPO_HELP),\n title: z\n .string()\n .trim()\n .min(1, 'Issue title is empty; enter a title.')\n .max(256, 'Issue title exceeds 256 characters; shorten the title.')\n .describe(IssueFields.shape.title.description ?? ''),\n};\nconst NormalStart = z.strictObject(\n {\n ...Tracking,\n title: Tracking.title.optional(),\n issueNumber: Positive.optional(),\n request: z.string().min(1).optional(),\n requestId: z.string().trim().min(1).max(256).optional(),\n resumeCreated: z.boolean().optional(),\n branch: z.string().min(1).optional(),\n },\n { error: acceptedKeysError },\n);\nconst IssueListing = {\n repo: Repo,\n verbose: Verbose,\n state: z.enum(['open', 'closed', 'all']).optional(),\n labels: z\n .array(\n z\n .string()\n .min(1)\n .regex(/^[^\"\\\\\\r\\n]+$/u),\n )\n .optional(),\n parentIssueNumber: Positive.nullable().optional(),\n issueType: z.string().min(1).optional(),\n projectStatus: z.enum(['Todo', 'In Progress', 'Blocked', 'Done']).nullable().optional(),\n updatedSince: z.iso.datetime({ offset: true }).optional(),\n page: Positive.optional(),\n perPage: Positive.max(100).optional(),\n};\nconst SearchText = z\n .string()\n .trim()\n .min(1)\n .max(256)\n .regex(/^[^\"\\\\\\r\\n]+$/u);\n\nexport const AI_DELIVERY_MCP_TOOLS = [\n {\n name: 'issue_comment',\n commandName: 'comment',\n description:\n 'Post a typed issue journal with authoritative comment readback. Provide the fields required by kind: start: outcome; progress: done, decisionNeeded and non-empty evidence; decision: non-empty decision and rationale; blocker: blocker and resolution; closeout: acceptance and followUps. Omit fields belonging to other kinds.',\n inputSchema: z\n .strictObject({ ...JournalInputSchema.shape, repo: Repo, verbose: Verbose }, { error: acceptedKeysError })\n .superRefine(({ repo: _repo, verbose: _verbose, ...journal }, ctx) => {\n // Repository routing belongs to the MCP envelope, not the strict journal variants.\n const parsed = JournalInputSchema.safeParse(journal);\n if (!parsed.success)\n for (const issue of parsed.error.issues)\n ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });\n })\n .meta(JOURNAL_SCHEMA_METADATA),\n },\n {\n name: 'issue_create',\n commandName: 'create',\n description: 'Create a native GitHub tracking issue with configured metadata and relationships',\n issueContract: ISSUE_JSON_SCHEMAS,\n inputSchema: issueInputSchema(\n z.strictObject(\n {\n ...Tracking,\n ...NativeIssueDateFields,\n ...IssueWriteFields,\n title: IssueFields.shape.title,\n opId: z\n .string()\n .trim()\n .min(1)\n .max(256)\n .optional()\n .describe(\n 'Stable retry identity: repeat the same original arguments to complete a partial create without another issue.',\n ),\n status: CreateIssueStatus.optional(),\n },\n { error: acceptedKeysError },\n ),\n ),\n },\n {\n name: 'issue_start',\n commandName: 'start',\n description:\n 'Start a linked issue. Prefer issueNumber of an open issue that already meets the ready contract: title, Points and, for Bug issues, the bug fields (see issue_create). A new issue from title or request cannot carry bug fields.',\n inputSchema: NormalStart,\n },\n {\n name: 'issue_list',\n readOnly: true,\n commandName: 'list',\n description: 'List repository issues with native filters, named organization fields and pagination',\n inputSchema: z.strictObject({ ...IssueListing, query: SearchText.optional() }, { error: acceptedKeysError }),\n },\n {\n name: 'issue_search',\n readOnly: true,\n commandName: 'search',\n description: 'Search literal issue text in the selected repository with native filters and pagination',\n inputSchema: z.strictObject({ ...IssueListing, query: SearchText }, { error: acceptedKeysError }),\n },\n {\n name: 'issue_update',\n commandName: 'update',\n description: 'Update native issue fields and exact relationship sets with readback',\n inputSchema: IssueUpdateInput.safeExtend({ ...ProjectTradeFields, verbose: Verbose }),\n },\n {\n name: 'issue_batch_update',\n commandName: 'batch:update',\n description: 'Plan or apply 1\u201350 issue updates in one repository, with ordered partial results and readback',\n inputSchema: issueInputSchema(\n z.strictObject(\n {\n repo: Repo,\n verbose: Verbose,\n items: z.array(IssueUpdateInput).min(1).max(50),\n dryRun: z.boolean().optional(),\n },\n { error: acceptedKeysError },\n ),\n ),\n },\n {\n name: 'issue_info',\n readOnly: true,\n commandName: 'info',\n description:\n 'Read live GitHub issue metadata, relationships, Project status, linked PRs (state, merge commit, checks, reviews) and the latest journal in one call. Child counts by default; verbose adds the body, every journal in full, routing and full child progress. Pass the requested owner/name as repo; an explicit repo works outside Git without a checkout. This read does not start or update the issue.',\n inputSchema: z.strictObject({ issueNumber: Positive, repo: Repo, verbose: Verbose }, { error: acceptedKeysError }),\n },\n {\n name: 'issue_ready_check',\n readOnly: true,\n commandName: 'ready:check',\n description: 'Evaluate deterministic readiness from live native issue state',\n inputSchema: z.strictObject(\n { issueNumber: Positive, repo: Tracking.repo, verbose: Verbose },\n { error: acceptedKeysError },\n ),\n },\n {\n name: 'issue_pr_create',\n commandName: 'pr:create',\n description:\n 'Create or reuse a PR from any directory using repo, issueNumber and a pushed head. By default it closes the issue and restores a missing closing link on reuse. On an existing closing PR, a new title or body edits it and draft: false marks it ready. nonClosing opens a draft that references the issue and leaves it open. expectedHeadSha refuses a different pushed head.',\n inputSchema: z\n .strictObject(\n {\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive,\n prNumber: Positive.optional(),\n nonClosing: z.boolean().optional(),\n expectedHeadSha: z\n .string()\n .regex(\n /^[a-f0-9]{40}$/u,\n 'expectedHeadSha must be a full 40-character commit SHA; pass the pushed head or omit it.',\n )\n .optional(),\n body: z.string().min(1, 'PR body is empty; enter a body or omit it to use the default body.').optional(),\n draft: z.boolean().optional(),\n dryRun: z.boolean().optional(),\n title: z.string().min(1, 'PR title is empty; enter a title or omit it to use the issue title.').optional(),\n headBranch: z.string().min(1).optional(),\n head: z.string().min(1).optional(),\n base: z.string().min(1).optional(),\n },\n { error: acceptedKeysError },\n )\n .refine(\n (input) => input.head === undefined || input.headBranch === undefined || input.head === input.headBranch,\n 'PR head selectors disagree; use the same branch for head and headBranch.',\n ),\n },\n {\n name: 'issue_pr_info',\n readOnly: true,\n commandName: 'pr:info',\n description:\n \"Inspect a PR by number or its GitHub-linked issue branch: state, merge state, merge commit, checks, reviews and each linked issue's state, Project status and latest journal, in one call\",\n inputSchema: z.strictObject(\n {\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive.optional(),\n prNumber: Positive.optional(),\n nonClosing: z.boolean().optional(),\n },\n { error: acceptedKeysError },\n ),\n },\n {\n name: 'milestone_create',\n commandName: 'milestone:create',\n description:\n 'Create a repository milestone (title, optional ISO due date and description) with readback. Repeating the same call returns the milestone it made; a same-titled milestone with different details is refused.',\n inputSchema: z.strictObject(\n {\n repo: Repo,\n verbose: Verbose,\n title: z.string().trim().min(1).max(256),\n dueOn: z.iso.date().optional(),\n description: z.string().max(10000).optional(),\n },\n { error: acceptedKeysError },\n ),\n },\n {\n name: 'issue_pr_review',\n commandName: 'pr:review',\n description: 'Submit one existing exact-head independent review with the reviewer App role',\n inputSchema: z.strictObject(\n {\n repo: Repo,\n verbose: Verbose,\n issueNumber: Positive,\n prNumber: Positive,\n nonClosing: z.boolean().optional(),\n artifact: z.string().min(1, 'Review artifact is empty; provide the independent review artifact JSON.'),\n identity: z.string().min(1).optional(),\n dryRun: z.boolean().optional(),\n },\n { error: acceptedKeysError },\n ),\n },\n] as const;\n\nexport type AiDeliveryMcpToolName = (typeof AI_DELIVERY_MCP_TOOLS)[number]['name'];\n\nexport function getAiDeliveryMcpTool(name: string): (typeof AI_DELIVERY_MCP_TOOLS)[number] | null {\n return AI_DELIVERY_MCP_TOOLS.find((tool) => tool.name === name) ?? null;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,+BAA+B;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,+DAA+D;AAC/G,MAAM,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAC3C,MAAM,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC/C,MAAM,YACJ;AACF,MAAM,OAAO,EACV,OAAO,EACP,MAAM,qCAAqC,EAC3C,SAAS,EACT,SAAS,SAAS;AACd,MAAM,mCAAmC;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AAAA,MACA,EAAE,OAAO,kBAAkB;AAAA,IAC7B;AAAA,EACF;AACF;AAIO,SAAS,qBAAqB,MAA6D;AAChG,SAAO,sBAAsB,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DeliveryContext } from './issue.js';
|
|
2
|
+
export interface CreateMilestoneInput {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
/** ISO date (YYYY-MM-DD). */
|
|
6
|
+
dueOn?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MilestoneReadback {
|
|
9
|
+
/** False when a milestone with this exact title and the same description and due date already existed. */
|
|
10
|
+
created: boolean;
|
|
11
|
+
description: string;
|
|
12
|
+
dueOn: string | null;
|
|
13
|
+
number: number;
|
|
14
|
+
/** A repeat of the call can match a closed milestone, so say which. */
|
|
15
|
+
state: 'closed' | 'open';
|
|
16
|
+
title: string;
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
/** Create a repository milestone, or return the identical one a retry already created; read it back either way. */
|
|
20
|
+
export declare function createMilestone(context: DeliveryContext, input: CreateMilestoneInput): Promise<MilestoneReadback>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DeliveryError } from "./errors.js";
|
|
2
|
+
async function createMilestone(context, input) {
|
|
3
|
+
const { rest } = context.clients;
|
|
4
|
+
const description = input.description ?? "";
|
|
5
|
+
const dueOn = input.dueOn ?? null;
|
|
6
|
+
const same = (milestone2) => (milestone2.description ?? "") === description && (milestone2.due_on?.slice(0, 10) ?? null) === dueOn;
|
|
7
|
+
const listed = (await rest.issues.listMilestones({ ...context.repo, per_page: 100, state: "all" })).data;
|
|
8
|
+
if (listed.length >= 100)
|
|
9
|
+
throw new DeliveryError(
|
|
10
|
+
"This repository has 100 or more milestones, so a duplicate title cannot be ruled out. Create it on GitHub."
|
|
11
|
+
);
|
|
12
|
+
const existing = listed.find((milestone2) => milestone2.title === input.title);
|
|
13
|
+
if (existing !== void 0 && !same(existing))
|
|
14
|
+
throw new DeliveryError(
|
|
15
|
+
`Milestone #${existing.number} is already titled "${input.title}" with a different description or due date. Pick another title or edit that milestone on GitHub.`
|
|
16
|
+
);
|
|
17
|
+
const milestone = existing ?? (await rest.issues.createMilestone({
|
|
18
|
+
...context.repo,
|
|
19
|
+
title: input.title,
|
|
20
|
+
...input.description === void 0 ? {} : { description: input.description },
|
|
21
|
+
...dueOn === null ? {} : { due_on: `${dueOn}T12:00:00Z` }
|
|
22
|
+
})).data;
|
|
23
|
+
const readback = (await rest.issues.getMilestone({ ...context.repo, milestone_number: milestone.number })).data;
|
|
24
|
+
if (readback.title !== input.title || !same(readback))
|
|
25
|
+
throw new DeliveryError(
|
|
26
|
+
`Milestone #${milestone.number} now exists with due date ${readback.due_on?.slice(0, 10) ?? "none"} and does not match the request. Fix it on GitHub.`
|
|
27
|
+
);
|
|
28
|
+
return {
|
|
29
|
+
created: existing === void 0,
|
|
30
|
+
description: readback.description ?? "",
|
|
31
|
+
dueOn: readback.due_on?.slice(0, 10) ?? null,
|
|
32
|
+
number: readback.number,
|
|
33
|
+
state: readback.state === "closed" ? "closed" : "open",
|
|
34
|
+
title: readback.title,
|
|
35
|
+
url: readback.html_url
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
createMilestone
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=milestone.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/milestone.ts"],
|
|
4
|
+
"sourcesContent": ["import { DeliveryError } from './errors.js';\nimport type { DeliveryContext } from './issue.js';\n\nexport interface CreateMilestoneInput {\n title: string;\n description?: string;\n /** ISO date (YYYY-MM-DD). */\n dueOn?: string;\n}\nexport interface MilestoneReadback {\n /** False when a milestone with this exact title and the same description and due date already existed. */\n created: boolean;\n description: string;\n dueOn: string | null;\n number: number;\n /** A repeat of the call can match a closed milestone, so say which. */\n state: 'closed' | 'open';\n title: string;\n url: string;\n}\n\n/** Create a repository milestone, or return the identical one a retry already created; read it back either way. */\nexport async function createMilestone(\n context: DeliveryContext,\n input: CreateMilestoneInput,\n): Promise<MilestoneReadback> {\n const { rest } = context.clients;\n const description = input.description ?? '';\n const dueOn = input.dueOn ?? null;\n const same = (milestone: { description?: string | null; due_on?: string | null }) =>\n (milestone.description ?? '') === description && (milestone.due_on?.slice(0, 10) ?? null) === dueOn;\n const listed = (await rest.issues.listMilestones({ ...context.repo, per_page: 100, state: 'all' })).data;\n if (listed.length >= 100)\n throw new DeliveryError(\n 'This repository has 100 or more milestones, so a duplicate title cannot be ruled out. Create it on GitHub.',\n );\n const existing = listed.find((milestone) => milestone.title === input.title);\n if (existing !== undefined && !same(existing))\n throw new DeliveryError(\n `Milestone #${existing.number} is already titled \"${input.title}\" with a different description or due date. Pick another title or edit that milestone on GitHub.`,\n );\n const milestone =\n existing ??\n (\n await rest.issues.createMilestone({\n ...context.repo,\n title: input.title,\n ...(input.description === undefined ? {} : { description: input.description }),\n ...(dueOn === null ? {} : { due_on: `${dueOn}T12:00:00Z` }),\n })\n ).data;\n const readback = (await rest.issues.getMilestone({ ...context.repo, milestone_number: milestone.number })).data;\n if (readback.title !== input.title || !same(readback))\n throw new DeliveryError(\n `Milestone #${milestone.number} now exists with due date ${readback.due_on?.slice(0, 10) ?? 'none'} and does not match the request. Fix it on GitHub.`,\n );\n return {\n created: existing === undefined,\n description: readback.description ?? '',\n dueOn: readback.due_on?.slice(0, 10) ?? null,\n number: readback.number,\n state: readback.state === 'closed' ? 'closed' : 'open',\n title: readback.title,\n url: readback.html_url,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAsB9B,eAAsB,gBACpB,SACA,OAC4B;AAC5B,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,cAAc,MAAM,e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D,OAAO,SAAS;AAAA,IAChB,KAAK,SAAS;AAAA,EAChB;AACF;",
|
|
6
|
+
"names": ["milestone"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "vitest";
|
|
3
|
+
import { getAiDeliveryMcpTool } from "./mcp/tools.js";
|
|
4
|
+
import { createMilestone } from "./milestone.js";
|
|
5
|
+
function fakeRepository(initial = [], options = {}) {
|
|
6
|
+
const milestones = [...initial];
|
|
7
|
+
const created = [];
|
|
8
|
+
const issues = {
|
|
9
|
+
createMilestone: async (input) => {
|
|
10
|
+
created.push(input);
|
|
11
|
+
const milestone = {
|
|
12
|
+
description: input.description ?? null,
|
|
13
|
+
due_on: options.dropDueDate === true ? null : input.due_on ?? null,
|
|
14
|
+
html_url: `https://github.com/aviaratech/ai/milestone/${milestones.length + 1}`,
|
|
15
|
+
number: milestones.length + 1,
|
|
16
|
+
state: "open",
|
|
17
|
+
title: input.title
|
|
18
|
+
};
|
|
19
|
+
milestones.push(milestone);
|
|
20
|
+
return { data: milestone };
|
|
21
|
+
},
|
|
22
|
+
getMilestone: async (input) => ({
|
|
23
|
+
data: milestones.find((milestone) => milestone.number === input.milestone_number)
|
|
24
|
+
}),
|
|
25
|
+
listMilestones: async () => ({ data: milestones })
|
|
26
|
+
};
|
|
27
|
+
const rest = { issues };
|
|
28
|
+
const context = {
|
|
29
|
+
clients: { rest },
|
|
30
|
+
repo: { owner: "aviaratech", repo: "ai" }
|
|
31
|
+
};
|
|
32
|
+
return { context, created };
|
|
33
|
+
}
|
|
34
|
+
test("milestone_create makes a milestone with a due date and description and reads it back", async () => {
|
|
35
|
+
const repository = fakeRepository();
|
|
36
|
+
const result = await createMilestone(repository.context, {
|
|
37
|
+
description: "R12: speed lane",
|
|
38
|
+
dueOn: "2026-11-27",
|
|
39
|
+
title: "R12"
|
|
40
|
+
});
|
|
41
|
+
assert.deepEqual(result, {
|
|
42
|
+
created: true,
|
|
43
|
+
description: "R12: speed lane",
|
|
44
|
+
dueOn: "2026-11-27",
|
|
45
|
+
number: 1,
|
|
46
|
+
state: "open",
|
|
47
|
+
title: "R12",
|
|
48
|
+
url: "https://github.com/aviaratech/ai/milestone/1"
|
|
49
|
+
});
|
|
50
|
+
assert.equal(repository.created[0].due_on, "2026-11-27T12:00:00Z");
|
|
51
|
+
});
|
|
52
|
+
test("repeating the same milestone_create returns the milestone it made and creates no second one", async () => {
|
|
53
|
+
const repository = fakeRepository();
|
|
54
|
+
const input = { dueOn: "2026-11-27", title: "R12" };
|
|
55
|
+
await createMilestone(repository.context, input);
|
|
56
|
+
const again = await createMilestone(repository.context, input);
|
|
57
|
+
assert.equal(again.created, false);
|
|
58
|
+
assert.equal(again.number, 1);
|
|
59
|
+
assert.equal(repository.created.length, 1);
|
|
60
|
+
});
|
|
61
|
+
test("a same-titled milestone with a different due date is refused with its number", async () => {
|
|
62
|
+
const repository = fakeRepository([
|
|
63
|
+
{ description: null, due_on: "2026-12-01T00:00:00Z", html_url: "https://example.test/1", number: 7, title: "R12" }
|
|
64
|
+
]);
|
|
65
|
+
await assert.rejects(
|
|
66
|
+
createMilestone(repository.context, { dueOn: "2026-11-27", title: "R12" }),
|
|
67
|
+
/Milestone #7 is already titled "R12" with a different description or due date/u
|
|
68
|
+
);
|
|
69
|
+
assert.equal(repository.created.length, 0);
|
|
70
|
+
});
|
|
71
|
+
test("a readback that lost the due date fails instead of reporting success", async () => {
|
|
72
|
+
const repository = fakeRepository([], { dropDueDate: true });
|
|
73
|
+
await assert.rejects(
|
|
74
|
+
createMilestone(repository.context, { dueOn: "2026-11-27", title: "R12" }),
|
|
75
|
+
/Milestone #1 now exists with due date none and does not match the request/u
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
test("the milestone_create tool takes a title, an ISO date and a description and refuses a bad date", () => {
|
|
79
|
+
const tool = getAiDeliveryMcpTool("milestone_create");
|
|
80
|
+
assert.equal(tool.commandName, "milestone:create");
|
|
81
|
+
assert.ok(tool.inputSchema.safeParse({ description: "x", dueOn: "2026-11-27", title: "R12" }).success);
|
|
82
|
+
assert.equal(tool.inputSchema.safeParse({ dueOn: "11/27/2026", title: "R12" }).success, false);
|
|
83
|
+
assert.equal(tool.inputSchema.safeParse({ title: " " }).success, false);
|
|
84
|
+
});
|
|
85
|
+
test("a repeat that matches a closed milestone says it is closed", async () => {
|
|
86
|
+
const repository = fakeRepository([
|
|
87
|
+
{
|
|
88
|
+
description: null,
|
|
89
|
+
due_on: "2026-11-27T08:00:00Z",
|
|
90
|
+
html_url: "https://example.test/3",
|
|
91
|
+
number: 3,
|
|
92
|
+
state: "closed",
|
|
93
|
+
title: "R12"
|
|
94
|
+
}
|
|
95
|
+
]);
|
|
96
|
+
const result = await createMilestone(repository.context, { dueOn: "2026-11-27", title: "R12" });
|
|
97
|
+
assert.equal(result.created, false);
|
|
98
|
+
assert.equal(result.state, "closed");
|
|
99
|
+
assert.equal(repository.created.length, 0);
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=milestone.test.js.map
|