@aviaratech/ai-delivery 0.3.36 → 0.3.37
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 +5 -6
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -3
- package/dist/agent.js.map +2 -2
- package/dist/callerErrors.test.js +0 -14
- package/dist/callerErrors.test.js.map +2 -2
- package/dist/cli.js +0 -15
- package/dist/cli.js.map +2 -2
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +1 -15
- package/dist/dispatch.js.map +2 -2
- package/dist/fixtures/discovery.d.ts +16 -16
- package/dist/git.d.ts +0 -3
- package/dist/git.js +2 -25
- package/dist/git.js.map +2 -2
- package/dist/github/commandIdentityPolicy.js +0 -2
- package/dist/github/commandIdentityPolicy.js.map +2 -2
- package/dist/issueIntake.test.js +0 -7
- package/dist/issueIntake.test.js.map +2 -2
- package/dist/mcp/tools.d.ts +0 -36
- package/dist/mcp/tools.js +0 -34
- package/dist/mcp/tools.js.map +2 -2
- package/dist/pluginPackaging.test.js +0 -47
- package/dist/pluginPackaging.test.js.map +2 -2
- package/dist/pr.d.ts +0 -55
- package/dist/pr.js +0 -211
- package/dist/pr.js.map +3 -3
- package/dist/pr.test.js +5 -737
- package/dist/pr.test.js.map +3 -3
- package/dist/prAssociation.test.js +1 -1
- package/dist/prAssociation.test.js.map +2 -2
- package/dist/prDispatch.test.js +4 -31
- package/dist/prDispatch.test.js.map +2 -2
- package/dist/readView.d.ts +1 -0
- package/dist/readView.js +1 -0
- package/dist/readView.js.map +2 -2
- package/dist/readView.test.js +29 -2
- package/dist/readView.test.js.map +2 -2
- package/dist/stdoutRegression.test.js +0 -38
- package/dist/stdoutRegression.test.js.map +2 -2
- package/dist/targetPolicyRoutes.test.js +1 -32
- package/dist/targetPolicyRoutes.test.js.map +2 -2
- package/dist/targetRepositoryExecution.test.js +0 -12
- package/dist/targetRepositoryExecution.test.js.map +2 -2
- package/dist/utils/atomicJson.d.ts +0 -2
- package/dist/utils/atomicJson.js +0 -4
- package/dist/utils/atomicJson.js.map +2 -2
- package/dist/utils/filesystem.d.ts +0 -8
- package/dist/utils/filesystem.js +1 -12
- package/dist/utils/filesystem.js.map +2 -2
- package/dist/verification.d.ts +0 -35
- package/dist/verification.js +1 -47
- package/dist/verification.js.map +2 -2
- package/dist/version.js +24 -2
- 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 +108 -115
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +4 -4
- package/dist/services/deliveryAdmission.d.ts +0 -49
- package/dist/services/deliveryAdmission.js +0 -142
- package/dist/services/deliveryAdmission.js.map +0 -7
- package/dist/services/worktreeRegistry.d.ts +0 -342
- package/dist/services/worktreeRegistry.js +0 -831
- package/dist/services/worktreeRegistry.js.map +0 -7
- package/dist/worktree.d.ts +0 -16
- package/dist/worktree.js +0 -108
- package/dist/worktree.js.map +0 -7
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 { deliveryHealth, type DeliveryHealthRequest } from './services/deliveryHealthService.js';\nimport { collectDeliveryBoard, parseDeliveryBoardRequest } from './deliveryBoard.js';\nimport {\n boardReconcile,\n boardReconcileGap,\n parseBoardReconcileRequest,\n incompleteBoardReconcile,\n} from './services/boardReconcileService.js';\nimport { loadDeliverySettings, type LoadedDeliverySettings } from './config/deliveryConfig.js';\nimport { DeliveryError } from './errors.js';\nimport { digestValue } from './delivery/common.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 ListIssuesInput,\n type UpdateIssueInput,\n} from './issue.js';\nimport type { JournalInput } from './issueJournal.js';\nimport { finishIssue, mergePr, 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 if (name === 'delivery_board')\n return collectDeliveryBoard(parseDeliveryBoardRequest(definition.inputSchema.parse(raw)), execution);\n if (name === 'board_reconcile') {\n let request = parseBoardReconcileRequest(raw);\n if (execution.repo !== undefined) {\n if (request.repo !== undefined && request.repo.toLowerCase() !== execution.repo.trim().toLowerCase())\n throw new DeliveryError('Tool and execution repository selectors disagree.');\n request = parseBoardReconcileRequest({ ...request, repo: execution.repo });\n }\n if (request.mode === 'apply' && execution.personalAuth === true)\n throw new DeliveryError(\n 'Board apply forbids the legacy personal-auth development override; use the configured author.',\n );\n let repository = request.repositories[0]!;\n let checkoutRoots: readonly string[] = [];\n const contexts: Awaited<ReturnType<typeof loadDeliveryContext>>[] = [];\n try {\n const settings = await loadDeliverySettings();\n checkoutRoots = settings.checkoutRoots;\n for (const selected of request.repositories) {\n repository = selected;\n contexts.push(\n await contextFor({ ...execution, repoRoot: '', repo: selected }, definition.commandName, 'author', 20, false),\n );\n }\n } catch (error) {\n const failure = boardReconcileGap(repository, 'context', error);\n return incompleteBoardReconcile(request, failure);\n }\n return boardReconcile(contexts, request, {\n checkoutRoots,\n ...(execution.signal === undefined ? {} : { signal: execution.signal }),\n });\n }\n const { repo: selected, verbose: _verbose, ...input } = definition.inputSchema.parse(raw) as Record<string, unknown>;\n if (name === 'issue_finish' && input.nonClosing === true)\n throw new DeliveryError('Non-closing delivery cannot finish or close its retained issue.');\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 'delivery_health':\n return deliveryHealth(context, { ...input, repo: repo! } as DeliveryHealthRequest);\n case 'issue_comment':\n return commentIssue(context, input as JournalInput);\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.reconcileNonClosingReference === undefined\n ? {}\n : { reconcileNonClosingReference: input.reconcileNonClosingReference === true }),\n ...(input.expectedHeadSha === undefined ? {} : { expectedHeadSha: requireString(input, 'expectedHeadSha') }),\n ...(input.expectedBaseSha === undefined ? {} : { expectedBaseSha: requireString(input, 'expectedBaseSha') }),\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 '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 case 'issue_pr_merge':\n case 'issue_finish': {\n const merge = {\n issueNumber: requiredNumber(input, 'issueNumber'),\n ...(input.nonClosing === undefined ? {} : { nonClosing: input.nonClosing === true }),\n prNumber: requiredNumber(input, 'prNumber'),\n ...(input.strategy === undefined ? {} : { strategy: input.strategy as 'merge' | 'squash' | 'rebase' }),\n ...(input.reviewedHeadSha === undefined ? {} : { reviewedHeadSha: requireString(input, 'reviewedHeadSha') }),\n dryRun: input.dryRun === true,\n };\n return name === 'issue_finish'\n ? finishIssue({ ...context, root: execution.repoRoot }, merge)\n : mergePr(context, merge);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,sBAAkD;AAC3D,SAAS,sBAAsB,iCAAiC;AAChE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAAyD;AAClE,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,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,OAKK;AAEP,SAAS,
|
|
4
|
+
"sourcesContent": ["import { issueView, prView } from './readView.js';\nimport { deliveryHealth, type DeliveryHealthRequest } from './services/deliveryHealthService.js';\nimport { collectDeliveryBoard, parseDeliveryBoardRequest } from './deliveryBoard.js';\nimport {\n boardReconcile,\n boardReconcileGap,\n parseBoardReconcileRequest,\n incompleteBoardReconcile,\n} from './services/boardReconcileService.js';\nimport { loadDeliverySettings, type LoadedDeliverySettings } from './config/deliveryConfig.js';\nimport { DeliveryError } from './errors.js';\nimport { digestValue } from './delivery/common.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 ListIssuesInput,\n type UpdateIssueInput,\n} from './issue.js';\nimport type { JournalInput } from './issueJournal.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 if (name === 'delivery_board')\n return collectDeliveryBoard(parseDeliveryBoardRequest(definition.inputSchema.parse(raw)), execution);\n if (name === 'board_reconcile') {\n let request = parseBoardReconcileRequest(raw);\n if (execution.repo !== undefined) {\n if (request.repo !== undefined && request.repo.toLowerCase() !== execution.repo.trim().toLowerCase())\n throw new DeliveryError('Tool and execution repository selectors disagree.');\n request = parseBoardReconcileRequest({ ...request, repo: execution.repo });\n }\n if (request.mode === 'apply' && execution.personalAuth === true)\n throw new DeliveryError(\n 'Board apply forbids the legacy personal-auth development override; use the configured author.',\n );\n let repository = request.repositories[0]!;\n let checkoutRoots: readonly string[] = [];\n const contexts: Awaited<ReturnType<typeof loadDeliveryContext>>[] = [];\n try {\n const settings = await loadDeliverySettings();\n checkoutRoots = settings.checkoutRoots;\n for (const selected of request.repositories) {\n repository = selected;\n contexts.push(\n await contextFor({ ...execution, repoRoot: '', repo: selected }, definition.commandName, 'author', 20, false),\n );\n }\n } catch (error) {\n const failure = boardReconcileGap(repository, 'context', error);\n return incompleteBoardReconcile(request, failure);\n }\n return boardReconcile(contexts, request, {\n checkoutRoots,\n ...(execution.signal === undefined ? {} : { signal: execution.signal }),\n });\n }\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 'delivery_health':\n return deliveryHealth(context, { ...input, repo: repo! } as DeliveryHealthRequest);\n case 'issue_comment':\n return commentIssue(context, input as JournalInput);\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.reconcileNonClosingReference === undefined\n ? {}\n : { reconcileNonClosingReference: input.reconcileNonClosingReference === true }),\n ...(input.expectedHeadSha === undefined ? {} : { expectedHeadSha: requireString(input, 'expectedHeadSha') }),\n ...(input.expectedBaseSha === undefined ? {} : { expectedBaseSha: requireString(input, 'expectedBaseSha') }),\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 '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,sBAAkD;AAC3D,SAAS,sBAAsB,iCAAiC;AAChE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAAyD;AAClE,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,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,OAKK;AAEP,SAAS,WAAW,0BAA0B;AAC9C,SAAS,4BAAwD;AACjE,SAAS,4BAA4B;AAcrC,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,MAAM,GAAG,MAAM,WAAW,MAAM,GAAG,IAAI;AACvD;AACA,SAAS,cAAc,OAAgC,KAAqB;AAC1E,QAAM,QAAQ,eAAe,OAAO,GAAG;AACvC,MAAI,CAAC,OAAO,KAAK,EAAG,OAAM,IAAI,cAAc,GAAG,GAAG,eAAe;AACjE,SAAO;AACT;AAEO,SAAS,mBAAmB,OAAkD;AACnF,QAAM;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AA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AAE,iBAAiB,cAAc,OAAO,iBAAiB,EAAE;AAAA,QAC1G,GAAI,MAAM,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,cAAc,OAAO,MAAM,EAAE;AAAA,QACzE,GAAI,MAAM,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,cAAc,OAAO,OAAO,EAAE;AAAA,QAC5E,GAAI,MAAM,SAAS,UAAa,MAAM,eAAe,SACjD,CAAC,IACD,EAAE,YAAY,cAAc,OAAO,MAAM,SAAS,SAAY,eAAe,MAAM,EAAE;AAAA,QACzF,GAAI,MAAM,SAAS,SAAY,CAAC,IAAI,EAAE,YAAY,cAAc,OAAO,MAAM,EAAE;AAAA,QAC/E,OAAO,MAAM,UAAU;AAAA,QACvB,QAAQ,MAAM,WAAW;AAAA,MAC3B,CAAC;AAAA,IACH,KAAK;AACH,aAAO,OAAO,SAAS,KAA0E;AAAA,IACnG,KAAK;AACH,aAAO,mBAAmB,SAAS;AAAA,QACjC,UAAU,cAAc,OAAO,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", "selected"]
|
|
7
7
|
}
|
|
@@ -65,6 +65,20 @@ export declare function syntheticDiscoveryClients(config?: Pick<{
|
|
|
65
65
|
repository: string;
|
|
66
66
|
roles: {
|
|
67
67
|
author: {
|
|
68
|
+
authSource: "personal";
|
|
69
|
+
credentialEnv: {
|
|
70
|
+
token: string;
|
|
71
|
+
};
|
|
72
|
+
identity: string;
|
|
73
|
+
} | {
|
|
74
|
+
authSource?: "app" | undefined;
|
|
75
|
+
credentialEnv: {
|
|
76
|
+
appId: string;
|
|
77
|
+
installationId: string;
|
|
78
|
+
privateKeyPath: string;
|
|
79
|
+
};
|
|
80
|
+
identity: string;
|
|
81
|
+
} | {
|
|
68
82
|
authSource: "app";
|
|
69
83
|
identity: string;
|
|
70
84
|
appId: number;
|
|
@@ -84,7 +98,8 @@ export declare function syntheticDiscoveryClients(config?: Pick<{
|
|
|
84
98
|
encoding?: "base64" | "pem" | undefined;
|
|
85
99
|
env?: string[] | undefined;
|
|
86
100
|
} | undefined;
|
|
87
|
-
}
|
|
101
|
+
};
|
|
102
|
+
reviewer: {
|
|
88
103
|
authSource?: "app" | undefined;
|
|
89
104
|
credentialEnv: {
|
|
90
105
|
appId: string;
|
|
@@ -93,13 +108,6 @@ export declare function syntheticDiscoveryClients(config?: Pick<{
|
|
|
93
108
|
};
|
|
94
109
|
identity: string;
|
|
95
110
|
} | {
|
|
96
|
-
authSource: "personal";
|
|
97
|
-
credentialEnv: {
|
|
98
|
-
token: string;
|
|
99
|
-
};
|
|
100
|
-
identity: string;
|
|
101
|
-
};
|
|
102
|
-
reviewer: {
|
|
103
111
|
authSource: "app";
|
|
104
112
|
identity: string;
|
|
105
113
|
appId: number;
|
|
@@ -119,14 +127,6 @@ export declare function syntheticDiscoveryClients(config?: Pick<{
|
|
|
119
127
|
encoding?: "base64" | "pem" | undefined;
|
|
120
128
|
env?: string[] | undefined;
|
|
121
129
|
} | undefined;
|
|
122
|
-
} | {
|
|
123
|
-
authSource?: "app" | undefined;
|
|
124
|
-
credentialEnv: {
|
|
125
|
-
appId: string;
|
|
126
|
-
installationId: string;
|
|
127
|
-
privateKeyPath: string;
|
|
128
|
-
};
|
|
129
|
-
identity: string;
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
132
|
schemaVersion: "ai-delivery.config@2";
|
package/dist/git.d.ts
CHANGED
|
@@ -4,10 +4,7 @@ export interface GitCoordinate {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function git(cwd: string, ...args: string[]): string;
|
|
6
6
|
export declare function gitExitCode(cwd: string, ...args: string[]): number;
|
|
7
|
-
export declare function gitRoot(cwd: string): string;
|
|
8
7
|
export declare function gitCommonDir(cwd: string): string;
|
|
9
|
-
export declare function primaryGitRoot(cwd: string): string;
|
|
10
8
|
export declare function coordinate(cwd: string, ref?: string): GitCoordinate;
|
|
11
9
|
export declare function assertClean(cwd: string): void;
|
|
12
10
|
export declare function changedPaths(cwd: string, baseSha: string, headSha: string): string[];
|
|
13
|
-
export declare function defaultBaseRef(cwd: string, selectedRemote?: string): string;
|
package/dist/git.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
4
|
import { GIT_EXECUTABLE, inertGitArguments, gitEnvironment } from "./gitProcess.js";
|
|
5
5
|
import { DeliveryError } from "./errors.js";
|
|
6
|
-
import { resolveGitRemoteName } from "./github/repo.js";
|
|
7
6
|
function git(cwd, ...args) {
|
|
8
7
|
try {
|
|
9
8
|
return execFileSync(GIT_EXECUTABLE, [...inertGitArguments(cwd), ...args], {
|
|
@@ -29,17 +28,9 @@ function gitExitCode(cwd, ...args) {
|
|
|
29
28
|
if (result.error) throw result.error;
|
|
30
29
|
return result.status ?? 1;
|
|
31
30
|
}
|
|
32
|
-
function gitRoot(cwd) {
|
|
33
|
-
return realpathSync(resolve(cwd, git(cwd, "rev-parse", "--show-toplevel")));
|
|
34
|
-
}
|
|
35
31
|
function gitCommonDir(cwd) {
|
|
36
32
|
return realpathSync(resolve(cwd, git(cwd, "rev-parse", "--git-common-dir")));
|
|
37
33
|
}
|
|
38
|
-
function primaryGitRoot(cwd) {
|
|
39
|
-
const common = gitCommonDir(cwd);
|
|
40
|
-
if (basename(common) !== ".git") throw new DeliveryError("Expected a conventional non-bare Git repository.");
|
|
41
|
-
return dirname(common);
|
|
42
|
-
}
|
|
43
34
|
function coordinate(cwd, ref = "HEAD") {
|
|
44
35
|
const sha = git(cwd, "rev-parse", "--verify", ref);
|
|
45
36
|
const tree = git(cwd, "rev-parse", `${sha}^{tree}`);
|
|
@@ -57,26 +48,12 @@ function changedPaths(cwd, baseSha, headSha) {
|
|
|
57
48
|
const output = git(cwd, "diff", "--no-ext-diff", "--no-textconv", "--name-only", "-z", baseSha, headSha);
|
|
58
49
|
return output.split("\0").filter(Boolean).sort();
|
|
59
50
|
}
|
|
60
|
-
function defaultBaseRef(cwd, selectedRemote) {
|
|
61
|
-
const remote = resolveGitRemoteName(cwd, selectedRemote);
|
|
62
|
-
const prefix = `refs/remotes/${remote}/`;
|
|
63
|
-
if (gitExitCode(cwd, "symbolic-ref", "--quiet", `${prefix}HEAD`) === 0) {
|
|
64
|
-
const ref = git(cwd, "symbolic-ref", "--quiet", `${prefix}HEAD`);
|
|
65
|
-
if (!ref.startsWith(prefix)) throw new DeliveryError("Selected remote HEAD points outside its tracking refs.");
|
|
66
|
-
return ref;
|
|
67
|
-
}
|
|
68
|
-
if (gitExitCode(cwd, "show-ref", "--verify", "--quiet", `${prefix}main`) === 0) return `${prefix}main`;
|
|
69
|
-
throw new DeliveryError(`Fetch the selected remote ${remote} and set its default branch before delivery.`);
|
|
70
|
-
}
|
|
71
51
|
export {
|
|
72
52
|
assertClean,
|
|
73
53
|
changedPaths,
|
|
74
54
|
coordinate,
|
|
75
|
-
defaultBaseRef,
|
|
76
55
|
git,
|
|
77
56
|
gitCommonDir,
|
|
78
|
-
gitExitCode
|
|
79
|
-
gitRoot,
|
|
80
|
-
primaryGitRoot
|
|
57
|
+
gitExitCode
|
|
81
58
|
};
|
|
82
59
|
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/git.ts"],
|
|
4
|
-
"sourcesContent": ["import { execFileSync, spawnSync } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc,iBAAiB;AACxC,SAAS,oBAAoB;AAC7B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { execFileSync, spawnSync } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nimport { GIT_EXECUTABLE, inertGitArguments, gitEnvironment } from './gitProcess.js';\n\nimport { DeliveryError } from './errors.js';\n\nexport interface GitCoordinate {\n sha: string;\n tree: string;\n}\n\nexport function git(cwd: string, ...args: string[]): string {\n try {\n return execFileSync(GIT_EXECUTABLE, [...inertGitArguments(cwd), ...args], {\n env: gitEnvironment(),\n cwd,\n encoding: 'utf8',\n maxBuffer: 4 * 1024 * 1024,\n stdio: ['ignore', 'pipe', 'pipe'],\n }).trim();\n } catch (cause) {\n const error = cause as Error & { stderr?: Buffer | string };\n const detail = String(error.stderr ?? '').trim();\n throw new DeliveryError(`git ${args[0] ?? ''} failed${detail ? `: ${detail}` : ''}`);\n }\n}\n\nexport function gitExitCode(cwd: string, ...args: string[]): number {\n const result = spawnSync(GIT_EXECUTABLE, [...inertGitArguments(cwd), ...args], {\n env: gitEnvironment(),\n cwd,\n encoding: 'utf8',\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n if (result.error) throw result.error;\n return result.status ?? 1;\n}\n\nexport function gitCommonDir(cwd: string): string {\n return realpathSync(resolve(cwd, git(cwd, 'rev-parse', '--git-common-dir')));\n}\n\nexport function coordinate(cwd: string, ref = 'HEAD'): GitCoordinate {\n const sha = git(cwd, 'rev-parse', '--verify', ref);\n const tree = git(cwd, 'rev-parse', `${sha}^{tree}`);\n if (!/^[a-f0-9]{40}$/u.test(sha) || !/^[a-f0-9]{40}$/u.test(tree)) {\n throw new DeliveryError('Git coordinate is not a SHA-1 commit and tree.');\n }\n return { sha, tree };\n}\n\nexport function assertClean(cwd: string): void {\n if (git(cwd, 'status', '--porcelain', '--untracked-files=all') !== '') {\n throw new DeliveryError('Delivery requires an exact clean worktree.');\n }\n}\n\nexport function changedPaths(cwd: string, baseSha: string, headSha: string): string[] {\n const output = git(cwd, 'diff', '--no-ext-diff', '--no-textconv', '--name-only', '-z', baseSha, headSha);\n return output.split('\\0').filter(Boolean).sort();\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc,iBAAiB;AACxC,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AAExB,SAAS,gBAAgB,mBAAmB,sBAAsB;AAElE,SAAS,qBAAqB;AAOvB,SAAS,IAAI,QAAgB,MAAwB;AAC1D,MAAI;AACF,WAAO,aAAa,gBAAgB,CAAC,GAAG,kBAAkB,GAAG,GAAG,GAAG,IAAI,GAAG;AAAA,MACxE,KAAK,eAAe;AAAA,MACpB;AAAA,MACA,UAAU;AAAA,MACV,WAAW,IAAI,OAAO;AAAA,MACtB,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,IAClC,CAAC,EAAE,KAAK;AAAA,EACV,SAAS,OAAO;AACd,UAAM,QAAQ;AACd,UAAM,SAAS,OAAO,MAAM,UAAU,EAAE,EAAE,KAAK;AAC/C,UAAM,IAAI,cAAc,OAAO,KAAK,CAAC,KAAK,EAAE,UAAU,SAAS,KAAK,MAAM,KAAK,EAAE,EAAE;AAAA,EACrF;AACF;AAEO,SAAS,YAAY,QAAgB,MAAwB;AAClE,QAAM,SAAS,UAAU,gBAAgB,CAAC,GAAG,kBAAkB,GAAG,GAAG,GAAG,IAAI,GAAG;AAAA,IAC7E,KAAK,eAAe;AAAA,IACpB;AAAA,IACA,UAAU;AAAA,IACV,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,EAClC,CAAC;AACD,MAAI,OAAO,MAAO,OAAM,OAAO;AAC/B,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,aAAa,KAAqB;AAChD,SAAO,aAAa,QAAQ,KAAK,IAAI,KAAK,aAAa,kBAAkB,CAAC,CAAC;AAC7E;AAEO,SAAS,WAAW,KAAa,MAAM,QAAuB;AACnE,QAAM,MAAM,IAAI,KAAK,aAAa,YAAY,GAAG;AACjD,QAAM,OAAO,IAAI,KAAK,aAAa,GAAG,GAAG,SAAS;AAClD,MAAI,CAAC,kBAAkB,KAAK,GAAG,KAAK,CAAC,kBAAkB,KAAK,IAAI,GAAG;AACjE,UAAM,IAAI,cAAc,gDAAgD;AAAA,EAC1E;AACA,SAAO,EAAE,KAAK,KAAK;AACrB;AAEO,SAAS,YAAY,KAAmB;AAC7C,MAAI,IAAI,KAAK,UAAU,eAAe,uBAAuB,MAAM,IAAI;AACrE,UAAM,IAAI,cAAc,4CAA4C;AAAA,EACtE;AACF;AAEO,SAAS,aAAa,KAAa,SAAiB,SAA2B;AACpF,QAAM,SAAS,IAAI,KAAK,QAAQ,iBAAiB,iBAAiB,eAAe,MAAM,SAAS,OAAO;AACvG,SAAO,OAAO,MAAM,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK;AACjD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/github/commandIdentityPolicy.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DeliveryConfig, DeliveryRole } from '../config/deliveryConfig.js';\n\nexport interface CommandIdentityPolicyEvaluation {\n error: null | string;\n normalizedCommandName: string;\n requiredRole: DeliveryRole | null;\n requiresExplicitIdentity: boolean;\n}\n\nconst AUTHOR_COMMANDS = new Set([\n 'board:reconcile',\n 'cleanup',\n 'close',\n 'comment',\n 'create',\n 'develop',\n '
|
|
5
|
-
"mappings": "AASA,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;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;
|
|
4
|
+
"sourcesContent": ["import type { DeliveryConfig, DeliveryRole } from '../config/deliveryConfig.js';\n\nexport interface CommandIdentityPolicyEvaluation {\n error: null | string;\n normalizedCommandName: string;\n requiredRole: DeliveryRole | null;\n requiresExplicitIdentity: boolean;\n}\n\nconst AUTHOR_COMMANDS = new Set([\n 'board:reconcile',\n 'cleanup',\n 'close',\n 'comment',\n 'create',\n 'develop',\n 'start',\n 'update',\n 'batch:update',\n 'pr:create',\n 'worktree',\n 'worktree:create',\n 'worktrees:cleanup',\n 'pr:checkout',\n]);\nconst REVIEWER_COMMANDS = new Set(['pr:review']);\n\nexport function evaluateCommandIdentityPolicy(input: {\n commandName: string;\n deliveryConfig: Pick<DeliveryConfig, 'roles'>;\n identity: null | string;\n personalAuth?: boolean;\n}): CommandIdentityPolicyEvaluation {\n const normalizedCommandName = input.commandName.trim().toLowerCase();\n const requiredRole: DeliveryRole | null = REVIEWER_COMMANDS.has(normalizedCommandName)\n ? 'reviewer'\n : AUTHOR_COMMANDS.has(normalizedCommandName)\n ? 'author'\n : null;\n if (requiredRole === null) {\n return { error: null, normalizedCommandName, requiredRole, requiresExplicitIdentity: false };\n }\n const identity = input.identity?.trim().toLowerCase() ?? '';\n let error: string | null = null;\n if (!identity) {\n error = `Command \"${normalizedCommandName}\" requires an explicit ${requiredRole} identity.`;\n } else if (identity === input.deliveryConfig.roles[requiredRole].identity.toLowerCase()) {\n if (input.personalAuth === true && input.deliveryConfig.roles[requiredRole].authSource !== 'personal') {\n error = 'Personal-token override requires the explicit personal identity.';\n }\n } else if (identity === 'personal') {\n if (requiredRole !== 'author' || input.personalAuth !== true) {\n error = `Command \"${normalizedCommandName}\" requires its configured identity; personal-token override requires explicit author opt-in.`;\n }\n } else if (input.personalAuth === true) {\n error = 'Personal-token opt-in requires the explicit personal identity.';\n } else {\n error = `Command \"${normalizedCommandName}\" requires configured ${requiredRole} identity \"${input.deliveryConfig.roles[requiredRole].identity}\".`;\n }\n return { error, normalizedCommandName, requiredRole, requiresExplicitIdentity: true };\n}\n"],
|
|
5
|
+
"mappings": "AASA,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;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;AACF,CAAC;AACD,MAAM,oBAAoB,oBAAI,IAAI,CAAC,WAAW,CAAC;AAExC,SAAS,8BAA8B,OAKV;AAClC,QAAM,wBAAwB,MAAM,YAAY,KAAK,EAAE,YAAY;AACnE,QAAM,eAAoC,kBAAkB,IAAI,qBAAqB,IACjF,aACA,gBAAgB,IAAI,qBAAqB,IACvC,WACA;AACN,MAAI,iBAAiB,MAAM;AACzB,WAAO,EAAE,OAAO,MAAM,uBAAuB,cAAc,0BAA0B,MAAM;AAAA,EAC7F;AACA,QAAM,WAAW,MAAM,UAAU,KAAK,EAAE,YAAY,KAAK;AACzD,MAAI,QAAuB;AAC3B,MAAI,CAAC,UAAU;AACb,YAAQ,YAAY,qBAAqB,0BAA0B,YAAY;AAAA,EACjF,WAAW,aAAa,MAAM,eAAe,MAAM,YAAY,EAAE,SAAS,YAAY,GAAG;AACvF,QAAI,MAAM,iBAAiB,QAAQ,MAAM,eAAe,MAAM,YAAY,EAAE,eAAe,YAAY;AACrG,cAAQ;AAAA,IACV;AAAA,EACF,WAAW,aAAa,YAAY;AAClC,QAAI,iBAAiB,YAAY,MAAM,iBAAiB,MAAM;AAC5D,cAAQ,YAAY,qBAAqB;AAAA,IAC3C;AAAA,EACF,WAAW,MAAM,iBAAiB,MAAM;AACtC,YAAQ;AAAA,EACV,OAAO;AACL,YAAQ,YAAY,qBAAqB,yBAAyB,YAAY,cAAc,MAAM,eAAe,MAAM,YAAY,EAAE,QAAQ;AAAA,EAC/I;AACA,SAAO,EAAE,OAAO,uBAAuB,cAAc,0BAA0B,KAAK;AACtF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/issueIntake.test.js
CHANGED
|
@@ -1528,13 +1528,6 @@ test("joined MCP start modes preserve ordinary input and reject mixed investigat
|
|
|
1528
1528
|
),
|
|
1529
1529
|
/selectors disagree/u
|
|
1530
1530
|
);
|
|
1531
|
-
const finish = getAiDeliveryMcpTool("issue_finish").inputSchema;
|
|
1532
|
-
assert(finish.safeParse({ issueNumber: 17, prNumber: 23 }).success);
|
|
1533
|
-
assert.equal(finish.safeParse({ issueNumber: 17 }).success, false);
|
|
1534
|
-
assert.equal(
|
|
1535
|
-
finish.safeParse({ issueNumber: 17, investigation: true, resultPath: "/fictional/result", prNumber: 23 }).success,
|
|
1536
|
-
false
|
|
1537
|
-
);
|
|
1538
1531
|
});
|
|
1539
1532
|
test("created readiness refusal returns exact retry markers through safe resume and original request retry", async () => {
|
|
1540
1533
|
const f = fixture();
|