@aviaratech/ai-delivery 0.3.48 → 0.3.49
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 +1 -1
- package/dist/dispatch.js +6 -2
- package/dist/dispatch.js.map +2 -2
- package/dist/mcp/index.js +1 -5
- package/dist/mcp/index.js.map +2 -2
- package/dist/pr.d.ts +2 -0
- package/dist/pr.js +6 -1
- package/dist/pr.js.map +2 -2
- package/dist/pr.test.js +44 -0
- package/dist/pr.test.js.map +2 -2
- package/dist/staleServer.test.js +39 -1
- package/dist/staleServer.test.js.map +2 -2
- package/dist/version.d.ts +2 -0
- package/dist/version.js +6 -1
- package/dist/version.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 +90 -90
- package/plugins/ai-delivery/runtime/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,4 +117,4 @@ Release still requires the exact mandatory archive inventory, complete release/c
|
|
|
117
117
|
|
|
118
118
|
Release is manual, main-only and uses npm trusted publishing. A packaged README edit changes the release candidate: retain accepted archives and independently qualify the new exact source/archive before dispatching.
|
|
119
119
|
|
|
120
|
-
Source version **0.3.
|
|
120
|
+
Source version **0.3.49** and green PR checks do not establish its qualification; see [#199](https://github.com/aviaratech/ai-delivery/issues/199). Wrappers and workflow definitions do not prove [#200](https://github.com/aviaratech/ai-delivery/issues/200)'s **under-60-second regular checks / under-five-minute qualification** targets. Functional removals and remaining documentation obligations stay with [#201](https://github.com/aviaratech/ai-delivery/issues/201).
|
package/dist/dispatch.js
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { publishPr, submitFormalReview } from "./pr.js";
|
|
24
24
|
import { getAiDeliveryMcpTool } from "./mcp/tools.js";
|
|
25
25
|
import { IssueValidationError } from "./issueContract.js";
|
|
26
|
+
import { staleServerNotice } from "./version.js";
|
|
26
27
|
function requiredNumber(input, key) {
|
|
27
28
|
const value = input[key];
|
|
28
29
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
@@ -254,7 +255,8 @@ async function executeTool(name, raw, execution) {
|
|
|
254
255
|
return issueView(context, requiredNumber(input, "issueNumber"), { verbose: execution.verbose === true });
|
|
255
256
|
case "issue_ready_check":
|
|
256
257
|
return readyCheck(context, requiredNumber(input, "issueNumber"));
|
|
257
|
-
case "issue_pr_create":
|
|
258
|
+
case "issue_pr_create": {
|
|
259
|
+
const staleNotice = staleServerNotice(execution.runtimeEntryPath);
|
|
258
260
|
return publishPr(context, {
|
|
259
261
|
...input.prNumber === void 0 ? {} : { prNumber: requiredNumber(input, "prNumber") },
|
|
260
262
|
issueNumber: requiredNumber(input, "issueNumber"),
|
|
@@ -265,8 +267,10 @@ async function executeTool(name, raw, execution) {
|
|
|
265
267
|
...input.head === void 0 && input.headBranch === void 0 ? {} : { headBranch: requireString(input, input.head === void 0 ? "headBranch" : "head") },
|
|
266
268
|
...input.base === void 0 ? {} : { baseBranch: requireString(input, "base") },
|
|
267
269
|
draft: input.draft !== false,
|
|
268
|
-
dryRun: input.dryRun === true
|
|
270
|
+
dryRun: input.dryRun === true,
|
|
271
|
+
...staleNotice === void 0 ? {} : { staleNotice }
|
|
269
272
|
});
|
|
273
|
+
}
|
|
270
274
|
case "milestone_create":
|
|
271
275
|
return createMilestone(context, {
|
|
272
276
|
title: requireString(input, "title"),
|
package/dist/dispatch.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dispatch.ts"],
|
|
4
|
-
"sourcesContent": ["import { issueView, prView } from './readView.js';\nimport { loadDeliverySettings, type LoadedDeliverySettings } from './config/deliveryConfig.js';\nimport { DeliveryError } from './errors.js';\nimport { digestValue } from './delivery/common.js';\nimport { createMilestone } from './milestone.js';\nimport { evaluateCommandIdentityPolicy } from './github/commandIdentityPolicy.js';\nimport {\n CreatedTrackingIssueError,\n createIssue,\n canonicalIssueBody,\n commentIssue,\n listIssues,\n journalIssueStart,\n loadDeliveryContext,\n readyCheck,\n resumeCreatedIssue,\n startIssueBranch,\n startIssueProject,\n assertIssueStartCapacity,\n updateIssue,\n batchUpdateIssues,\n type BatchUpdateIssueInput,\n type CreateIssueInput,\n type IssueCommentInput,\n type ListIssuesInput,\n type UpdateIssueInput,\n} from './issue.js';\nimport { publishPr, submitFormalReview } from './pr.js';\nimport { getAiDeliveryMcpTool, type AiDeliveryMcpToolName } from './mcp/tools.js';\nimport { IssueValidationError } from './issueContract.js';\n\nexport interface ExecutionContext {\n settings?: LoadedDeliverySettings;\n reviewSubmission?: boolean;\n identity?: string;\n personalAuth?: boolean;\n repo?: string;\n repoRoot: string;\n runtimeEntryPath?: string;\n signal?: AbortSignal;\n /** Presentation only: lets issue_info skip the per-child rollup unless the caller asked for the full readback. */\n verbose?: boolean;\n}\nfunction requiredNumber(input: Record<string, unknown>, key: string): number {\n const value = input[key];\n if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0)\n throw new DeliveryError(`${key} must be positive.`);\n return value;\n}\nfunction optionalString(input: Record<string, unknown>, key: string): string | undefined {\n return typeof input[key] === 'string' ? input[key] : undefined;\n}\nfunction requireString(input: Record<string, unknown>, key: string): string {\n const value = optionalString(input, key);\n if (!value?.trim()) throw new DeliveryError(`${key} is required.`);\n return value;\n}\n/** Preserve every accepted tracking field when completing a partially created issue. */\nexport function resumedIssueUpdate(input: Record<string, unknown>): UpdateIssueInput {\n const {\n issueNumber,\n request: _request,\n requestId: _requestId,\n repo: _repo,\n resumeCreated: _resume,\n branch: _branch,\n ...fields\n } = input;\n return { ...fields, issueNumber: requiredNumber({ issueNumber }, 'issueNumber') } as UpdateIssueInput;\n}\nexport async function contextFor(\n input: ExecutionContext,\n commandName: string,\n role: 'author' | 'reviewer' = 'author',\n readPageLimit?: number,\n requireWritableProject?: boolean,\n) {\n const settings =\n input.settings ??\n (await loadDeliverySettings(\n undefined,\n input.reviewSubmission === true\n ? { reviewerIdentity: input.identity ?? '', prepareEnvironment: true }\n : undefined,\n ));\n if (input.reviewSubmission === true && role === 'author' && settings.roles.author.authSource !== 'personal')\n throw new DeliveryError(\n 'review submit requires the configured personal author for pre-key reads; another App key will not be loaded.',\n );\n const identity =\n input.reviewSubmission === true && role === 'author'\n ? settings.roles.author.identity\n : (input.identity ?? settings.roles[role].identity);\n const policy = evaluateCommandIdentityPolicy({\n commandName,\n deliveryConfig: settings,\n identity,\n ...(input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }),\n });\n if (policy.error) throw new DeliveryError(policy.error);\n return loadDeliveryContext({\n settings,\n ...(settings.environment === undefined ? {} : { env: settings.environment }),\n identity,\n repoRoot: input.repoRoot,\n role,\n ...(input.repo === undefined ? {} : { repository: input.repo }),\n ...(input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }),\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n ...(readPageLimit === undefined ? {} : { readPageLimit }),\n ...(requireWritableProject === undefined ? {} : { requireWritableProject }),\n });\n}\n/** GitHub owns branch linkage; hosts own worktree preparation. */\nexport async function startTrackedIssue(\n context: Awaited<ReturnType<typeof loadDeliveryContext>>,\n input: Record<string, unknown>,\n) {\n let number = input.issueNumber === undefined ? undefined : requiredNumber(input, 'issueNumber');\n let created: { number: number; title: string; url: string } | undefined;\n let createdBody: string | undefined;\n let branch: Awaited<ReturnType<typeof startIssueBranch>> | undefined;\n let branchAttempted = false;\n let phase = 'branch-or-journal';\n const registration = (phase: string, error: unknown) => ({\n status: 'created-not-started' as const,\n repository: context.config.repository,\n createdIssue: created,\n failure: { phase, message: error instanceof Error ? error.message : String(error) },\n safeResume: {\n tool: 'issue_start',\n arguments: {\n // Replay tracking only when that phase is incomplete; later recovery preserves native edits/parking.\n ...(phase === 'tracking'\n ? { ...input, ...(createdBody === undefined ? {} : { body: createdBody }), resumeCreated: true }\n : {}),\n repo: context.config.repository,\n issueNumber: number,\n ...(input.overrideReason === undefined ? {} : { overrideReason: input.overrideReason }),\n ...((branch?.branch ?? optionalString(input, 'branch')) === undefined\n ? {}\n : { branch: branch?.branch ?? optionalString(input, 'branch') }),\n },\n },\n });\n if (number === undefined) {\n const title = optionalString(input, 'title') ?? requireString(input, 'request');\n const tracking = {\n ...input,\n title,\n body: optionalString(input, 'body') ?? optionalString(input, 'request') ?? title,\n } as unknown as CreateIssueInput;\n tracking.body = canonicalIssueBody(tracking);\n const intent = digestValue(\n Object.fromEntries(\n Object.entries({\n title,\n body: tracking.body,\n issueType: tracking.issueType,\n points: tracking.points,\n priority: tracking.priority,\n labels: tracking.labels,\n blockedBy: tracking.blockedBy,\n blocks: tracking.blocks,\n overrideReason: tracking.overrideReason,\n parentIssueNumber: tracking.parentIssueNumber,\n milestone: tracking.milestone,\n branch: input.branch,\n }).filter(([, value]) => value !== undefined),\n ),\n );\n const requestKey = optionalString(input, 'requestId') ?? intent;\n const marker = `<!-- ai-delivery-start: ${digestValue({ repository: context.config.repository.toLowerCase(), requestKey })} -->`;\n tracking.body = `${tracking.body}\\n\\n<!-- ai-delivery-start-intent: ${intent} -->\\n${marker}`;\n createdBody = tracking.body;\n let completed = false;\n const matches: Awaited<ReturnType<typeof context.clients.rest.issues.listForRepo>>['data'] = [];\n for (let page = 1; page <= 20; page++) {\n const batch = (\n await context.clients.rest.issues.listForRepo({ ...context.repo, state: 'all', page, per_page: 100 })\n ).data;\n matches.push(...batch.filter((value) => !('pull_request' in value) && value.body?.includes(marker)));\n if (batch.length < 100) {\n completed = true;\n break;\n }\n }\n if (!completed)\n throw new DeliveryError(\n 'Issue-start retry search exceeds the bounded readback window; select a known issue number.',\n );\n if (matches.length > 1) throw new DeliveryError('Conflicting issues claim the same start request.');\n const prior = matches[0];\n if (\n prior &&\n (prior.title !== title ||\n canonicalIssueBody({ title: prior.title, body: prior.body ?? '' }) !== tracking.body ||\n prior.state !== 'open')\n )\n throw new DeliveryError('Prior issue-start request conflicts with the requested intent or state.');\n try {\n if (prior) {\n createdBody = prior.body ?? '';\n created = { number: prior.number, title: prior.title, url: prior.html_url };\n number = prior.number;\n await resumeCreatedIssue(context, { ...tracking, issueNumber: number });\n } else {\n const result = await createIssue(context, tracking);\n created = result.created;\n createdBody = result.body;\n number = created.number;\n }\n } catch (error) {\n if (error instanceof CreatedTrackingIssueError) {\n created = error.created;\n number = created.number;\n } else if (!created) throw error;\n return registration('tracking', error);\n }\n } else if (input.resumeCreated === true) {\n const issue = (await context.clients.rest.issues.get({ ...context.repo, issue_number: number })).data;\n if (issue.number !== number || 'pull_request' in issue)\n throw new DeliveryError('Known-created issue readback disagrees.');\n created = { number, title: issue.title, url: issue.html_url };\n try {\n await resumeCreatedIssue(context, resumedIssueUpdate(input));\n } catch (error) {\n return registration('tracking', error);\n }\n }\n try {\n const readiness = await readyCheck(context, number);\n if (!readiness.ready) throw new IssueValidationError(readiness.failures);\n await assertIssueStartCapacity(context, number, optionalString(input, 'overrideReason'));\n branchAttempted = true;\n branch = await startIssueBranch(context, number, optionalString(input, 'branch'));\n phase = 'project-status';\n await startIssueProject(context, number, optionalString(input, 'overrideReason'));\n phase = 'journal';\n await journalIssueStart(context, number);\n return {\n issueNumber: number,\n repository: context.config.repository,\n branch: branch.branch,\n headSha: branch.headSha,\n reused: branch.reused,\n };\n } catch (error) {\n if (created) return registration(phase, error);\n if (!branchAttempted) throw error;\n return {\n status: 'start-incomplete' as const,\n issueNumber: number,\n repository: context.config.repository,\n failure: { phase, message: error instanceof Error ? error.message : String(error) },\n safeResume: {\n tool: 'issue_start',\n arguments: {\n repo: context.config.repository,\n issueNumber: number,\n ...(input.overrideReason === undefined ? {} : { overrideReason: input.overrideReason }),\n ...((branch?.branch ?? optionalString(input, 'branch')) === undefined\n ? {}\n : { branch: branch?.branch ?? optionalString(input, 'branch') }),\n },\n },\n };\n }\n}\n\nexport async function executeTool(\n name: AiDeliveryMcpToolName,\n raw: unknown,\n execution: ExecutionContext,\n): Promise<unknown> {\n const definition = getAiDeliveryMcpTool(name);\n if (!definition) throw new DeliveryError(`Unknown ai-delivery tool ${name}.`);\n const { repo: selected, verbose: _verbose, ...input } = definition.inputSchema.parse(raw) as Record<string, unknown>;\n if (selected !== undefined && execution.repo !== undefined && selected !== execution.repo)\n throw new DeliveryError('Tool and execution repository selectors disagree.');\n // Ready diagnostics need no repository checkout, configuration or credential lookup.\n if (name === 'issue_create') canonicalIssueBody(input as unknown as CreateIssueInput);\n const repo = typeof selected === 'string' ? selected : execution.repo;\n const selectedExecution = { ...execution, ...(repo === undefined ? {} : { repo }) };\n const requestedIdentity = name === 'issue_pr_review' ? optionalString(input, 'identity') : undefined;\n const context = await contextFor(\n { ...selectedExecution, ...(requestedIdentity === undefined ? {} : { identity: requestedIdentity }) },\n definition.commandName,\n name === 'issue_pr_review' ? 'reviewer' : 'author',\n );\n switch (name) {\n case 'issue_comment':\n return commentIssue(context, input as IssueCommentInput);\n case 'issue_create':\n return createIssue(context, input as unknown as CreateIssueInput);\n case 'issue_start':\n return startTrackedIssue(context, input);\n case 'issue_batch_update':\n return batchUpdateIssues(context, input as unknown as BatchUpdateIssueInput, selectedExecution.signal);\n case 'issue_update':\n return updateIssue(context, input as unknown as UpdateIssueInput);\n case 'issue_list':\n case 'issue_search':\n return listIssues(context, input as ListIssuesInput);\n case 'issue_info':\n return issueView(context, requiredNumber(input, 'issueNumber'), { verbose: execution.verbose === true });\n case 'issue_ready_check':\n return readyCheck(context, requiredNumber(input, 'issueNumber'));\n case 'issue_pr_create':\n return publishPr(context, {\n ...(input.prNumber === undefined ? {} : { prNumber: requiredNumber(input, 'prNumber') }),\n issueNumber: requiredNumber(input, 'issueNumber'),\n ...(input.nonClosing === undefined ? {} : { nonClosing: input.nonClosing === true }),\n ...(input.expectedHeadSha === undefined ? {} : { expectedHeadSha: requireString(input, 'expectedHeadSha') }),\n ...(input.body === undefined ? {} : { body: requireString(input, 'body') }),\n ...(input.title === undefined ? {} : { title: requireString(input, 'title') }),\n ...(input.head === undefined && input.headBranch === undefined\n ? {}\n : { headBranch: requireString(input, input.head === undefined ? 'headBranch' : 'head') }),\n ...(input.base === undefined ? {} : { baseBranch: requireString(input, 'base') }),\n draft: input.draft !== false,\n dryRun: input.dryRun === true,\n });\n case 'milestone_create':\n return createMilestone(context, {\n title: requireString(input, 'title'),\n ...(input.description === undefined ? {} : { description: requireString(input, 'description') }),\n ...(input.dueOn === undefined ? {} : { dueOn: requireString(input, 'dueOn') }),\n });\n case 'issue_pr_info':\n return prView(context, input as { issueNumber?: number; prNumber?: number; nonClosing?: boolean });\n case 'issue_pr_review':\n return submitFormalReview(context, {\n artifact: requireString(input, 'artifact'),\n issueNumber: requiredNumber(input, 'issueNumber'),\n ...(input.nonClosing === undefined ? {} : { nonClosing: input.nonClosing === true }),\n prNumber: requiredNumber(input, 'prNumber'),\n dryRun: input.dryRun === true,\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,4BAAyD;AAClE,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,qCAAqC;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,WAAW,0BAA0B;AAC9C,SAAS,4BAAwD;AACjE,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["import { issueView, prView } from './readView.js';\nimport { loadDeliverySettings, type LoadedDeliverySettings } from './config/deliveryConfig.js';\nimport { DeliveryError } from './errors.js';\nimport { digestValue } from './delivery/common.js';\nimport { createMilestone } from './milestone.js';\nimport { evaluateCommandIdentityPolicy } from './github/commandIdentityPolicy.js';\nimport {\n CreatedTrackingIssueError,\n createIssue,\n canonicalIssueBody,\n commentIssue,\n listIssues,\n journalIssueStart,\n loadDeliveryContext,\n readyCheck,\n resumeCreatedIssue,\n startIssueBranch,\n startIssueProject,\n assertIssueStartCapacity,\n updateIssue,\n batchUpdateIssues,\n type BatchUpdateIssueInput,\n type CreateIssueInput,\n type IssueCommentInput,\n type ListIssuesInput,\n type UpdateIssueInput,\n} from './issue.js';\nimport { publishPr, submitFormalReview } from './pr.js';\nimport { getAiDeliveryMcpTool, type AiDeliveryMcpToolName } from './mcp/tools.js';\nimport { IssueValidationError } from './issueContract.js';\nimport { staleServerNotice } from './version.js';\n\nexport interface ExecutionContext {\n settings?: LoadedDeliverySettings;\n reviewSubmission?: boolean;\n identity?: string;\n personalAuth?: boolean;\n repo?: string;\n repoRoot: string;\n runtimeEntryPath?: string;\n signal?: AbortSignal;\n /** Presentation only: lets issue_info skip the per-child rollup unless the caller asked for the full readback. */\n verbose?: boolean;\n}\nfunction requiredNumber(input: Record<string, unknown>, key: string): number {\n const value = input[key];\n if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0)\n throw new DeliveryError(`${key} must be positive.`);\n return value;\n}\nfunction optionalString(input: Record<string, unknown>, key: string): string | undefined {\n return typeof input[key] === 'string' ? input[key] : undefined;\n}\nfunction requireString(input: Record<string, unknown>, key: string): string {\n const value = optionalString(input, key);\n if (!value?.trim()) throw new DeliveryError(`${key} is required.`);\n return value;\n}\n/** Preserve every accepted tracking field when completing a partially created issue. */\nexport function resumedIssueUpdate(input: Record<string, unknown>): UpdateIssueInput {\n const {\n issueNumber,\n request: _request,\n requestId: _requestId,\n repo: _repo,\n resumeCreated: _resume,\n branch: _branch,\n ...fields\n } = input;\n return { ...fields, issueNumber: requiredNumber({ issueNumber }, 'issueNumber') } as UpdateIssueInput;\n}\nexport async function contextFor(\n input: ExecutionContext,\n commandName: string,\n role: 'author' | 'reviewer' = 'author',\n readPageLimit?: number,\n requireWritableProject?: boolean,\n) {\n const settings =\n input.settings ??\n (await loadDeliverySettings(\n undefined,\n input.reviewSubmission === true\n ? { reviewerIdentity: input.identity ?? '', prepareEnvironment: true }\n : undefined,\n ));\n if (input.reviewSubmission === true && role === 'author' && settings.roles.author.authSource !== 'personal')\n throw new DeliveryError(\n 'review submit requires the configured personal author for pre-key reads; another App key will not be loaded.',\n );\n const identity =\n input.reviewSubmission === true && role === 'author'\n ? settings.roles.author.identity\n : (input.identity ?? settings.roles[role].identity);\n const policy = evaluateCommandIdentityPolicy({\n commandName,\n deliveryConfig: settings,\n identity,\n ...(input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }),\n });\n if (policy.error) throw new DeliveryError(policy.error);\n return loadDeliveryContext({\n settings,\n ...(settings.environment === undefined ? {} : { env: settings.environment }),\n identity,\n repoRoot: input.repoRoot,\n role,\n ...(input.repo === undefined ? {} : { repository: input.repo }),\n ...(input.personalAuth === undefined ? {} : { personalAuth: input.personalAuth }),\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n ...(readPageLimit === undefined ? {} : { readPageLimit }),\n ...(requireWritableProject === undefined ? {} : { requireWritableProject }),\n });\n}\n/** GitHub owns branch linkage; hosts own worktree preparation. */\nexport async function startTrackedIssue(\n context: Awaited<ReturnType<typeof loadDeliveryContext>>,\n input: Record<string, unknown>,\n) {\n let number = input.issueNumber === undefined ? undefined : requiredNumber(input, 'issueNumber');\n let created: { number: number; title: string; url: string } | undefined;\n let createdBody: string | undefined;\n let branch: Awaited<ReturnType<typeof startIssueBranch>> | undefined;\n let branchAttempted = false;\n let phase = 'branch-or-journal';\n const registration = (phase: string, error: unknown) => ({\n status: 'created-not-started' as const,\n repository: context.config.repository,\n createdIssue: created,\n failure: { phase, message: error instanceof Error ? error.message : String(error) },\n safeResume: {\n tool: 'issue_start',\n arguments: {\n // Replay tracking only when that phase is incomplete; later recovery preserves native edits/parking.\n ...(phase === 'tracking'\n ? { ...input, ...(createdBody === undefined ? {} : { body: createdBody }), resumeCreated: true }\n : {}),\n repo: context.config.repository,\n issueNumber: number,\n ...(input.overrideReason === undefined ? {} : { overrideReason: input.overrideReason }),\n ...((branch?.branch ?? optionalString(input, 'branch')) === undefined\n ? {}\n : { branch: branch?.branch ?? optionalString(input, 'branch') }),\n },\n },\n });\n if (number === undefined) {\n const title = optionalString(input, 'title') ?? requireString(input, 'request');\n const tracking = {\n ...input,\n title,\n body: optionalString(input, 'body') ?? optionalString(input, 'request') ?? title,\n } as unknown as CreateIssueInput;\n tracking.body = canonicalIssueBody(tracking);\n const intent = digestValue(\n Object.fromEntries(\n Object.entries({\n title,\n body: tracking.body,\n issueType: tracking.issueType,\n points: tracking.points,\n priority: tracking.priority,\n labels: tracking.labels,\n blockedBy: tracking.blockedBy,\n blocks: tracking.blocks,\n overrideReason: tracking.overrideReason,\n parentIssueNumber: tracking.parentIssueNumber,\n milestone: tracking.milestone,\n branch: input.branch,\n }).filter(([, value]) => value !== undefined),\n ),\n );\n const requestKey = optionalString(input, 'requestId') ?? intent;\n const marker = `<!-- ai-delivery-start: ${digestValue({ repository: context.config.repository.toLowerCase(), requestKey })} -->`;\n tracking.body = `${tracking.body}\\n\\n<!-- ai-delivery-start-intent: ${intent} -->\\n${marker}`;\n createdBody = tracking.body;\n let completed = false;\n const matches: Awaited<ReturnType<typeof context.clients.rest.issues.listForRepo>>['data'] = [];\n for (let page = 1; page <= 20; page++) {\n const batch = (\n await context.clients.rest.issues.listForRepo({ ...context.repo, state: 'all', page, per_page: 100 })\n ).data;\n matches.push(...batch.filter((value) => !('pull_request' in value) && value.body?.includes(marker)));\n if (batch.length < 100) {\n completed = true;\n break;\n }\n }\n if (!completed)\n throw new DeliveryError(\n 'Issue-start retry search exceeds the bounded readback window; select a known issue number.',\n );\n if (matches.length > 1) throw new DeliveryError('Conflicting issues claim the same start request.');\n const prior = matches[0];\n if (\n prior &&\n (prior.title !== title ||\n canonicalIssueBody({ title: prior.title, body: prior.body ?? '' }) !== tracking.body ||\n prior.state !== 'open')\n )\n throw new DeliveryError('Prior issue-start request conflicts with the requested intent or state.');\n try {\n if (prior) {\n createdBody = prior.body ?? '';\n created = { number: prior.number, title: prior.title, url: prior.html_url };\n number = prior.number;\n await resumeCreatedIssue(context, { ...tracking, issueNumber: number });\n } else {\n const result = await createIssue(context, tracking);\n created = result.created;\n createdBody = result.body;\n number = created.number;\n }\n } catch (error) {\n if (error instanceof CreatedTrackingIssueError) {\n created = error.created;\n number = created.number;\n } else if (!created) throw error;\n return registration('tracking', error);\n }\n } else if (input.resumeCreated === true) {\n const issue = (await context.clients.rest.issues.get({ ...context.repo, issue_number: number })).data;\n if (issue.number !== number || 'pull_request' in issue)\n throw new DeliveryError('Known-created issue readback disagrees.');\n created = { number, title: issue.title, url: issue.html_url };\n try {\n await resumeCreatedIssue(context, resumedIssueUpdate(input));\n } catch (error) {\n return registration('tracking', error);\n }\n }\n try {\n const readiness = await readyCheck(context, number);\n if (!readiness.ready) throw new IssueValidationError(readiness.failures);\n await assertIssueStartCapacity(context, number, optionalString(input, 'overrideReason'));\n branchAttempted = true;\n branch = await startIssueBranch(context, number, optionalString(input, 'branch'));\n phase = 'project-status';\n await startIssueProject(context, number, optionalString(input, 'overrideReason'));\n phase = 'journal';\n await journalIssueStart(context, number);\n return {\n issueNumber: number,\n repository: context.config.repository,\n branch: branch.branch,\n headSha: branch.headSha,\n reused: branch.reused,\n };\n } catch (error) {\n if (created) return registration(phase, error);\n if (!branchAttempted) throw error;\n return {\n status: 'start-incomplete' as const,\n issueNumber: number,\n repository: context.config.repository,\n failure: { phase, message: error instanceof Error ? error.message : String(error) },\n safeResume: {\n tool: 'issue_start',\n arguments: {\n repo: context.config.repository,\n issueNumber: number,\n ...(input.overrideReason === undefined ? {} : { overrideReason: input.overrideReason }),\n ...((branch?.branch ?? optionalString(input, 'branch')) === undefined\n ? {}\n : { branch: branch?.branch ?? optionalString(input, 'branch') }),\n },\n },\n };\n }\n}\n\nexport async function executeTool(\n name: AiDeliveryMcpToolName,\n raw: unknown,\n execution: ExecutionContext,\n): Promise<unknown> {\n const definition = getAiDeliveryMcpTool(name);\n if (!definition) throw new DeliveryError(`Unknown ai-delivery tool ${name}.`);\n const { repo: selected, verbose: _verbose, ...input } = definition.inputSchema.parse(raw) as Record<string, unknown>;\n if (selected !== undefined && execution.repo !== undefined && selected !== execution.repo)\n throw new DeliveryError('Tool and execution repository selectors disagree.');\n // Ready diagnostics need no repository checkout, configuration or credential lookup.\n if (name === 'issue_create') canonicalIssueBody(input as unknown as CreateIssueInput);\n const repo = typeof selected === 'string' ? selected : execution.repo;\n const selectedExecution = { ...execution, ...(repo === undefined ? {} : { repo }) };\n const requestedIdentity = name === 'issue_pr_review' ? optionalString(input, 'identity') : undefined;\n const context = await contextFor(\n { ...selectedExecution, ...(requestedIdentity === undefined ? {} : { identity: requestedIdentity }) },\n definition.commandName,\n name === 'issue_pr_review' ? 'reviewer' : 'author',\n );\n switch (name) {\n case 'issue_comment':\n return commentIssue(context, input as IssueCommentInput);\n case 'issue_create':\n return createIssue(context, input as unknown as CreateIssueInput);\n case 'issue_start':\n return startTrackedIssue(context, input);\n case 'issue_batch_update':\n return batchUpdateIssues(context, input as unknown as BatchUpdateIssueInput, selectedExecution.signal);\n case 'issue_update':\n return updateIssue(context, input as unknown as UpdateIssueInput);\n case 'issue_list':\n case 'issue_search':\n return listIssues(context, input as ListIssuesInput);\n case 'issue_info':\n return issueView(context, requiredNumber(input, 'issueNumber'), { verbose: execution.verbose === true });\n case 'issue_ready_check':\n return readyCheck(context, requiredNumber(input, 'issueNumber'));\n case 'issue_pr_create': {\n const staleNotice = staleServerNotice(execution.runtimeEntryPath);\n return publishPr(context, {\n ...(input.prNumber === undefined ? {} : { prNumber: requiredNumber(input, 'prNumber') }),\n issueNumber: requiredNumber(input, 'issueNumber'),\n ...(input.nonClosing === undefined ? {} : { nonClosing: input.nonClosing === true }),\n ...(input.expectedHeadSha === undefined ? {} : { expectedHeadSha: requireString(input, 'expectedHeadSha') }),\n ...(input.body === undefined ? {} : { body: requireString(input, 'body') }),\n ...(input.title === undefined ? {} : { title: requireString(input, 'title') }),\n ...(input.head === undefined && input.headBranch === undefined\n ? {}\n : { headBranch: requireString(input, input.head === undefined ? 'headBranch' : 'head') }),\n ...(input.base === undefined ? {} : { baseBranch: requireString(input, 'base') }),\n draft: input.draft !== false,\n dryRun: input.dryRun === true,\n ...(staleNotice === undefined ? {} : { staleNotice }),\n });\n }\n case 'milestone_create':\n return createMilestone(context, {\n title: requireString(input, 'title'),\n ...(input.description === undefined ? {} : { description: requireString(input, 'description') }),\n ...(input.dueOn === undefined ? {} : { dueOn: requireString(input, 'dueOn') }),\n });\n case 'issue_pr_info':\n return prView(context, input as { issueNumber?: number; prNumber?: number; nonClosing?: boolean });\n case 'issue_pr_review':\n return submitFormalReview(context, {\n artifact: requireString(input, 'artifact'),\n issueNumber: requiredNumber(input, 'issueNumber'),\n ...(input.nonClosing === undefined ? {} : { nonClosing: input.nonClosing === true }),\n prNumber: requiredNumber(input, 'prNumber'),\n dryRun: input.dryRun === true,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,4BAAyD;AAClE,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,qCAAqC;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,WAAW,0BAA0B;AAC9C,SAAS,4BAAwD;AACjE,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAclC,SAAS,eAAe,OAAgC,KAAqB;AAC3E,QAAM,QAAQ,MAAM,GAAG;AACvB,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS;AACxE,UAAM,IAAI,cAAc,GAAG,GAAG,oBAAoB;AACpD,SAAO;AACT;AACA,SAAS,eAAe,OAAgC,KAAiC;AACvF,SAAO,OAAO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O,UAAU;AAAA,QACzC,aAAa,eAAe,OAAO,aAAa;AAAA,QAChD,GAAI,MAAM,eAAe,SAAY,CAAC,IAAI,EAAE,YAAY,MAAM,eAAe,KAAK;AAAA,QAClF,UAAU,eAAe,OAAO,UAAU;AAAA,QAC1C,QAAQ,MAAM,WAAW;AAAA,MAC3B,CAAC;AAAA,EACL;AACF;",
|
|
6
6
|
"names": ["phase"]
|
|
7
7
|
}
|
package/dist/mcp/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { executeTool } from "../dispatch.js";
|
|
5
5
|
import { setLogsSuppressed } from "../logger.js";
|
|
6
|
-
import { PACKAGE_VERSION,
|
|
6
|
+
import { PACKAGE_VERSION, staleServerNotice } from "../version.js";
|
|
7
7
|
import { acceptedKeysError } from "../issueContract.js";
|
|
8
8
|
import {
|
|
9
9
|
JOURNAL_SCHEMA_METADATA,
|
|
@@ -16,10 +16,6 @@ import { projectToolOutput } from "../toolOutput.js";
|
|
|
16
16
|
import { AI_DELIVERY_MCP_TOOLS } from "./tools.js";
|
|
17
17
|
import { AI_DELIVERY_MCP_CONTRACT_VERSION, AI_DELIVERY_MCP_TOOLS as AI_DELIVERY_MCP_TOOLS2 } from "./tools.js";
|
|
18
18
|
const SERVER_INSTRUCTIONS = "Use issue_info with an explicit repo; follow repository policy for checks and authorization, and respect requested providers and read-only intent.";
|
|
19
|
-
function staleServerNotice(runtimeEntryPath) {
|
|
20
|
-
const installed = runtimeEntryPath === void 0 ? void 0 : installedPluginVersion(runtimeEntryPath);
|
|
21
|
-
return installed === void 0 || installed === PACKAGE_VERSION ? void 0 : `This session's ai-delivery MCP server is ${PACKAGE_VERSION} but ${installed} is installed, so its rules may differ. Start a new session to load ${installed}; /clear and /reload-plugins keep this server.`;
|
|
22
|
-
}
|
|
23
19
|
function createAiDeliveryMcpServer(context, activeCalls) {
|
|
24
20
|
const withNotice = (text) => {
|
|
25
21
|
const notice = staleServerNotice(context.runtimeEntryPath);
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\n\nimport { executeTool, type ExecutionContext } from '../dispatch.js';\nimport { setLogsSuppressed } from '../logger.js';\nimport { PACKAGE_VERSION,
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAElB,SAAS,mBAA0C;AACnD,SAAS,yBAAyB;AAClC,SAAS,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\n\nimport { executeTool, type ExecutionContext } from '../dispatch.js';\nimport { setLogsSuppressed } from '../logger.js';\nimport { PACKAGE_VERSION, staleServerNotice } from '../version.js';\nimport { acceptedKeysError } from '../issueContract.js';\nimport {\n JOURNAL_SCHEMA_METADATA,\n NEXT_DATE_REFUSAL,\n PLAIN_COMMENT_REFUSAL,\n missingJournalFields,\n} from '../issueJournal.js';\nimport { getIncompleteIssueUpdate } from '../issue.js';\nimport { projectToolOutput } from '../toolOutput.js';\nimport { AI_DELIVERY_MCP_TOOLS, type AiDeliveryMcpToolName } from './tools.js';\n\nexport { AI_DELIVERY_MCP_CONTRACT_VERSION, AI_DELIVERY_MCP_TOOLS } from './tools.js';\n\nconst SERVER_INSTRUCTIONS =\n 'Use issue_info with an explicit repo; follow repository policy for checks and authorization, and respect requested providers and read-only intent.';\n\nexport function createAiDeliveryMcpServer(context: ExecutionContext, activeCalls?: Set<Promise<unknown>>): McpServer {\n const withNotice = (text: string) => {\n const notice = staleServerNotice(context.runtimeEntryPath);\n return [\n { type: 'text' as const, text },\n ...(notice === undefined ? [] : [{ type: 'text' as const, text: notice }]),\n ];\n };\n const server = new McpServer(\n { name: 'ai-delivery', version: PACKAGE_VERSION },\n { instructions: SERVER_INSTRUCTIONS },\n );\n const tools: readonly {\n name: string;\n description: string;\n inputSchema: z.ZodObject<z.ZodRawShape>;\n readOnly?: true;\n }[] = AI_DELIVERY_MCP_TOOLS;\n for (const tool of tools) {\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n ...(tool.readOnly ? { annotations: { readOnlyHint: true } } : {}),\n // The SDK must leave journal kind refinements to the handler so missing\n // conditional fields receive a safe, actionable contract refusal. Unknown\n // property names stay private through a schema-local error message.\n inputSchema:\n tool.name === 'issue_comment'\n ? z\n .strictObject(tool.inputSchema.shape, { error: acceptedKeysError })\n .partial()\n .meta(JOURNAL_SCHEMA_METADATA)\n : tool.inputSchema,\n },\n async (args, extra) => {\n const parsed = tool.inputSchema.safeParse(args);\n if (!parsed.success) {\n const journal = tool.name === 'issue_comment';\n const missing = journal && args.body === undefined ? missingJournalFields(args) : [];\n // A missing-field list comes first; these refusals already say what to send, so they replace the generic text.\n const stated = journal\n ? parsed.error.issues\n .map((issue) => issue.message)\n .filter((m) => [NEXT_DATE_REFUSAL, PLAIN_COMMENT_REFUSAL].includes(m))\n : [];\n return {\n content: withNotice(\n `Invalid arguments for ${tool.name}.${missing.length ? ` Missing required fields: ${missing.join(', ')}. Provide every missing field.` : stated.length ? ` ${stated.join(' ')}` : journal ? ` ${tool.description}` : ''}`,\n ),\n isError: true,\n };\n }\n try {\n const signal = context.signal === undefined ? extra.signal : AbortSignal.any([context.signal, extra.signal]);\n const { verbose, ...input } = parsed.data;\n const pending = executeTool(tool.name as AiDeliveryMcpToolName, input, {\n ...context,\n signal,\n ...(verbose === true ? { verbose } : {}),\n });\n activeCalls?.add(pending);\n let value: unknown;\n try {\n value = await pending;\n } finally {\n activeCalls?.delete(pending);\n }\n return {\n content: withNotice(JSON.stringify(projectToolOutput(tool.name, value, verbose === true))),\n };\n } catch (error) {\n const incomplete = getIncompleteIssueUpdate(error);\n if (incomplete !== undefined)\n return {\n content: withNotice(\n JSON.stringify(projectToolOutput(tool.name, incomplete, 'verbose' in args && args.verbose === true)),\n ),\n isError: true,\n };\n const message = error instanceof Error ? error.message : String(error);\n return { content: withNotice(message), isError: true };\n }\n },\n );\n }\n return server;\n}\n\nexport async function serveAiDeliveryMcp(context: ExecutionContext): Promise<void> {\n setLogsSuppressed(true);\n const shutdown = new AbortController();\n const activeCalls = new Set<Promise<unknown>>();\n const server = createAiDeliveryMcpServer({ ...context, signal: shutdown.signal }, activeCalls);\n let closing: Promise<void> | undefined;\n const close = (): Promise<void> => {\n closing ??= (async () => {\n shutdown.abort();\n await Promise.allSettled(activeCalls);\n await server.close();\n process.exit(0);\n })();\n return closing;\n };\n process.once('SIGINT', () => {\n void close();\n });\n process.once('SIGTERM', () => {\n void close();\n });\n await server.connect(new StdioServerTransport());\n process.stderr.write('ai-delivery MCP server started\\n');\n await new Promise<void>(() => {});\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAElB,SAAS,mBAA0C;AACnD,SAAS,yBAAyB;AAClC,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;AAClC,SAAS,6BAAyD;AAElE,SAAS,kCAAkC,yBAAAA,8BAA6B;AAExE,MAAM,sBACJ;AAEK,SAAS,0BAA0B,SAA2B,aAAgD;AACnH,QAAM,aAAa,CAAC,SAAiB;AACnC,UAAM,SAAS,kBAAkB,QAAQ,gBAAgB;AACzD,WAAO;AAAA,MACL,EAAE,MAAM,QAAiB,KAAK;AAAA,MAC9B,G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;AAAA,IAChB,GAAG;AACH,WAAO;AAAA,EACT;AACA,UAAQ,KAAK,UAAU,MAAM;AAC3B,SAAK,MAAM;AAAA,EACb,CAAC;AACD,UAAQ,KAAK,WAAW,MAAM;AAC5B,SAAK,MAAM;AAAA,EACb,CAAC;AACD,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAC/C,UAAQ,OAAO,MAAM,kCAAkC;AACvD,QAAM,IAAI,QAAc,MAAM;AAAA,EAAC,CAAC;AAClC;",
|
|
6
6
|
"names": ["AI_DELIVERY_MCP_TOOLS"]
|
|
7
7
|
}
|
package/dist/pr.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export declare function publishPr(context: DeliveryContext, input: {
|
|
|
84
84
|
headBranch?: string;
|
|
85
85
|
baseBranch?: string;
|
|
86
86
|
dryRun?: boolean;
|
|
87
|
+
/** Set when the running MCP server is older than the installed plugin; refuses a ready PR on a moneyPath issue. */
|
|
88
|
+
staleNotice?: string;
|
|
87
89
|
}): Promise<{
|
|
88
90
|
dryRun: boolean;
|
|
89
91
|
body?: string;
|
package/dist/pr.js
CHANGED
|
@@ -847,8 +847,13 @@ async function publishPr(context, input) {
|
|
|
847
847
|
if ("pull_request" in issue || issue.number !== input.issueNumber || issue.state !== "open")
|
|
848
848
|
throw new DeliveryError("PR creation requires the requested open GitHub issue.");
|
|
849
849
|
if (input.draft === false) {
|
|
850
|
-
const
|
|
850
|
+
const fields = parseIssueBody(issue.body ?? "", { title: issue.title }).issue;
|
|
851
|
+
const owed = ownerOkOwed(fields);
|
|
851
852
|
if (owed) throw new IssueValidationError([owed]);
|
|
853
|
+
if (fields.moneyPath === true && input.staleNotice !== void 0)
|
|
854
|
+
throw new IssueValidationError([
|
|
855
|
+
{ code: "stale-server", field: "server", message: input.staleNotice, fixHint: input.staleNotice }
|
|
856
|
+
]);
|
|
852
857
|
}
|
|
853
858
|
const repository = (await context.clients.rest.repos.get({ ...context.repo })).data;
|
|
854
859
|
if (repository.full_name?.toLowerCase() !== context.config.repository.toLowerCase() || context.config.repository.toLowerCase() !== `${context.repo.owner}/${context.repo.repo}`.toLowerCase())
|