@opentag/github 0.2.0 → 0.3.0

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/dist/index.js CHANGED
@@ -978,7 +978,10 @@ function renderVerificationParams(params) {
978
978
  if (!item || typeof item !== "object" || Array.isArray(item)) return void 0;
979
979
  const command = item["command"];
980
980
  const outcome = item["outcome"];
981
- return typeof command === "string" && typeof outcome === "string" ? ` - \`${command}\`: ${outcome}` : void 0;
981
+ const summary = item["summary"];
982
+ if (typeof outcome !== "string") return void 0;
983
+ const prefix = typeof command === "string" && command.length > 0 ? `\`${command}\`: ${outcome}` : outcome;
984
+ return typeof summary === "string" && summary.length > 0 ? ` - ${prefix} - ${summary}` : ` - ${prefix}`;
982
985
  }).filter((line) => Boolean(line));
983
986
  }
984
987
  function renderSuggestedActionDetails(params, action) {
@@ -990,17 +993,17 @@ function renderSuggestedActionDetails(params, action) {
990
993
  const changedFiles = stringArrayParam2(params, "changedFiles");
991
994
  const risks = stringArrayParam2(params, "risks");
992
995
  const verification = renderVerificationParams(params);
993
- if (title) lines.push(` Title: ${title}`);
994
- if (head || base) lines.push(` Branch: \`${head ?? "unknown"}\` -> \`${base ?? "main"}\``);
995
- if (changedFiles.length > 0) lines.push(` Changed files: ${changedFiles.map((file) => `\`${file}\``).join(", ")}`);
996
+ if (title) lines.push(`- Title: ${title}`);
997
+ if (head || base) lines.push(`- Branch: \`${head ?? "unknown"}\` -> \`${base ?? "main"}\``);
998
+ if (changedFiles.length > 0) lines.push(`- Changed files: ${changedFiles.map((file) => `\`${file}\``).join(", ")}`);
996
999
  if (risks.length > 0) {
997
- lines.push(" Risks:");
1000
+ lines.push("- Risks:");
998
1001
  for (const risk of risks) {
999
- lines.push(` - ${risk}`);
1002
+ lines.push(` - ${risk}`);
1000
1003
  }
1001
1004
  }
1002
1005
  if (verification.length > 0) {
1003
- lines.push(" Verification:");
1006
+ lines.push("- Verification:");
1004
1007
  lines.push(...verification);
1005
1008
  }
1006
1009
  return lines;
@@ -1008,31 +1011,40 @@ function renderSuggestedActionDetails(params, action) {
1008
1011
  function renderSuggestedActions(result) {
1009
1012
  const candidates = suggestedActionCandidatesFromResult(result);
1010
1013
  if (candidates.length === 0) return [];
1011
- const lines = ["Suggested actions:"];
1014
+ const lines = [
1015
+ "### Suggested actions:",
1016
+ "",
1017
+ "Source-thread approval: choose one command in this GitHub thread to apply a protocolized mutation or PR action to the system of record."
1018
+ ];
1012
1019
  for (const candidate of candidates) {
1013
1020
  lines.push(
1014
1021
  "",
1015
- `${candidate.index}. **${candidate.intent.summary}**`,
1016
- ` Intent: \`${candidate.intent.action}\` (\`${candidate.intent.domain}\`)`,
1017
- ` Proposal: \`${candidate.proposalId}\``,
1018
- ` Intent ID: \`${candidate.intent.intentId}\``
1022
+ `#### Action ${candidate.index}: ${candidate.intent.summary}`,
1023
+ "",
1024
+ `- System-of-record action: \`${candidate.intent.action}\` (\`${candidate.intent.domain}\`)`,
1025
+ `- Proposal: \`${candidate.proposalId}\``,
1026
+ `- Intent ID: \`${candidate.intent.intentId}\``
1019
1027
  );
1020
1028
  lines.push(...renderSuggestedActionDetails(candidate.intent.params, candidate.intent.action));
1021
1029
  if (candidate.proposalPreconditions?.length) {
1022
- lines.push(" Preconditions:");
1030
+ lines.push("- Preconditions:");
1023
1031
  for (const precondition of candidate.proposalPreconditions) {
1024
- lines.push(` - ${precondition}`);
1032
+ lines.push(` - ${precondition}`);
1025
1033
  }
1026
1034
  }
1035
+ lines.push(
1036
+ "",
1037
+ "**Approve in this thread**",
1038
+ "",
1039
+ `| Decision | Comment command | Effect |`,
1040
+ `| --- | --- | --- |`,
1041
+ `| Apply now | \`apply ${candidate.index}\` | Applies this action to the system of record. |`,
1042
+ `| Approve only | \`approve ${candidate.index}\` | Records approval without applying yet. |`,
1043
+ `| Continue | \`continue ${candidate.index}\` | Starts a follow-up run from this proposal. |`,
1044
+ `| Reject | \`reject ${candidate.index}\` | Rejects this action. |`
1045
+ );
1027
1046
  }
1028
- lines.push(
1029
- "",
1030
- "Reply with:",
1031
- "- `approve 1` to record approval without applying yet",
1032
- "- `apply 1` or `apply all` to apply supported actions",
1033
- "- `continue 1` to continue with a follow-up run",
1034
- "- `reject 1` to reject an action"
1035
- );
1047
+ lines.push("", "Bulk shortcut: comment `apply all` to apply every supported approved action in this thread.");
1036
1048
  return lines;
1037
1049
  }
1038
1050
  function renderAcknowledgement(runId) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/pull-request.ts","../src/apply.ts","../src/ingress.ts","../src/normalize.ts","../src/render.ts"],"sourcesContent":["import type { OpenTagRunResult } from \"@opentag/core\";\n\nexport type CreatePullRequestInput = {\n token: string;\n owner: string;\n repo: string;\n title: string;\n body: string;\n head: string;\n base: string;\n};\n\nexport type FetchLike = typeof fetch;\n\nexport function buildPullRequestBody(result: OpenTagRunResult): string {\n const lines = [\"## Summary\", \"\", result.summary];\n\n if (result.changedFiles?.length) {\n lines.push(\"\", \"## Changed Files\");\n for (const file of result.changedFiles) {\n lines.push(`- \\`${file}\\``);\n }\n }\n\n if (result.verification?.length) {\n lines.push(\"\", \"## Verification\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nexport async function createPullRequestViaFetch(input: CreatePullRequestInput, fetchImpl: FetchLike = fetch): Promise<string> {\n const response = await fetchImpl(`https://api.github.com/repos/${input.owner}/${input.repo}/pulls`, {\n method: \"POST\",\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n },\n body: JSON.stringify({\n title: input.title,\n body: input.body,\n head: input.head,\n base: input.base\n })\n });\n\n if (!response.ok) {\n throw new Error(`create pull request failed: ${response.status} ${await response.text()}`);\n }\n\n const body = (await response.json()) as { html_url?: string };\n if (!body.html_url) {\n throw new Error(\"create pull request response did not include html_url\");\n }\n return body.html_url;\n}\n","import type { AdapterMutationCompiler, AdapterMutationMapping, ApplyIntentOutcome, MutationIntent } from \"@opentag/core\";\nimport { createPullRequestViaFetch, type FetchLike } from \"./pull-request.js\";\n\nexport type GitHubIssueMutationTarget = {\n token: string;\n owner: string;\n repo: string;\n issueNumber?: number;\n pullRequestNumber?: number;\n};\n\nexport type GitHubIssueMutationOperation =\n | {\n kind: \"add_label\";\n intentId: string;\n label: string;\n }\n | {\n kind: \"remove_label\";\n intentId: string;\n label: string;\n }\n | {\n kind: \"replace_mapped_label\";\n intentId: string;\n label: string;\n removeLabels: string[];\n }\n | {\n kind: \"set_labels\";\n intentId: string;\n labels: string[];\n }\n | {\n kind: \"set_assignees\";\n intentId: string;\n assignees: string[];\n }\n | {\n kind: \"add_assignee\";\n intentId: string;\n assignee: string;\n }\n | {\n kind: \"remove_assignee\";\n intentId: string;\n assignee: string;\n }\n | {\n kind: \"request_review\";\n intentId: string;\n reviewers: string[];\n teamReviewers?: string[];\n }\n | {\n kind: \"create_pull_request\";\n intentId: string;\n title: string;\n body: string;\n head: string;\n base: string;\n };\n\nexport type GitHubIssueMutationCompilation =\n | {\n ok: true;\n intentId: string;\n operation: GitHubIssueMutationOperation;\n }\n | {\n ok: false;\n outcome: ApplyIntentOutcome;\n };\n\nfunction labelFromIntent(intent: MutationIntent): string | undefined {\n const value = intent.params?.[\"label\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction labelsFromIntent(intent: MutationIntent): string[] | undefined {\n const value = intent.params?.[\"labels\"];\n if (!Array.isArray(value)) return undefined;\n const labels = value.filter((label): label is string => typeof label === \"string\" && label.length > 0);\n return labels.length > 0 ? labels : undefined;\n}\n\nfunction assigneeFromIntent(intent: MutationIntent): string | undefined {\n const value = intent.params?.[\"assignee\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction assigneesFromIntent(intent: MutationIntent): string[] | undefined {\n const value = intent.params?.[\"assignees\"];\n if (!Array.isArray(value)) return undefined;\n const assignees = value.filter((assignee): assignee is string => typeof assignee === \"string\" && assignee.length > 0);\n return assignees.length > 0 ? assignees : undefined;\n}\n\nfunction reviewersFromIntent(intent: MutationIntent): string[] | undefined {\n const reviewer = intent.params?.[\"reviewer\"];\n const reviewers = intent.params?.[\"reviewers\"];\n const values = [\n ...(typeof reviewer === \"string\" ? [reviewer] : []),\n ...(Array.isArray(reviewers) ? reviewers : [])\n ].filter((value): value is string => typeof value === \"string\" && value.length > 0);\n return values.length > 0 ? [...new Set(values)] : undefined;\n}\n\nfunction teamReviewersFromIntent(intent: MutationIntent): string[] | undefined {\n const reviewer = intent.params?.[\"teamReviewer\"];\n const reviewers = intent.params?.[\"teamReviewers\"] ?? intent.params?.[\"team_reviewers\"];\n const values = [\n ...(typeof reviewer === \"string\" ? [reviewer] : []),\n ...(Array.isArray(reviewers) ? reviewers : [])\n ].filter((value): value is string => typeof value === \"string\" && value.length > 0);\n return values.length > 0 ? [...new Set(values)] : undefined;\n}\n\nfunction stringParam(intent: MutationIntent, ...keys: string[]): string | undefined {\n for (const key of keys) {\n const value = intent.params?.[key];\n if (typeof value === \"string\" && value.length > 0) return value;\n }\n return undefined;\n}\n\nfunction stringArrayParam(intent: MutationIntent, key: string): string[] {\n const value = intent.params?.[key];\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n}\n\nfunction verificationLinesFromIntent(intent: MutationIntent): string[] {\n const value = intent.params?.[\"verification\"];\n if (!Array.isArray(value)) return [];\n return value\n .map((item) => {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const command = (item as Record<string, unknown>)[\"command\"];\n const outcome = (item as Record<string, unknown>)[\"outcome\"];\n return typeof command === \"string\" && typeof outcome === \"string\" ? `- \\`${command}\\`: ${outcome}` : undefined;\n })\n .filter((line): line is string => Boolean(line));\n}\n\nfunction pullRequestBodyFromIntent(intent: MutationIntent): string {\n const explicitBody = stringParam(intent, \"body\");\n const changedFiles = stringArrayParam(intent, \"changedFiles\");\n const risks = stringArrayParam(intent, \"risks\");\n const verification = verificationLinesFromIntent(intent);\n const executorConditions = stringArrayParam(intent, \"executorConditions\");\n const lines = explicitBody ? [explicitBody] : [\"## Summary\", \"\", intent.summary];\n if (changedFiles.length > 0) {\n lines.push(\"\", \"## Changed Files\", ...changedFiles.map((file) => `- \\`${file}\\``));\n }\n if (risks.length > 0) {\n lines.push(\"\", \"## Risks\", ...risks.map((risk) => `- ${risk}`));\n }\n if (verification.length > 0) {\n lines.push(\"\", \"## Verification\", ...verification);\n }\n if (executorConditions.length > 0) {\n lines.push(\"\", \"## Executor Conditions\", ...executorConditions.map((condition) => `- ${condition}`));\n }\n return lines.join(\"\\n\");\n}\n\nfunction mappedValueFromIntent(intent: MutationIntent): string | undefined {\n const key = intent.domain === \"status\" ? \"status\" : \"priority\";\n const value = intent.params?.[key] ?? intent.params?.[\"value\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction labelMappingForIntent(input: { intent: MutationIntent; mappings: AdapterMutationMapping[] }): { label: string; removeLabels: string[] } | undefined {\n const semanticValue = mappedValueFromIntent(input.intent);\n if (!semanticValue) return undefined;\n const mapping = input.mappings.find(\n (candidate) => candidate.adapter === \"github\" && candidate.domain === input.intent.domain && candidate.strategy === \"label\"\n );\n const label = mapping?.values[semanticValue];\n if (!label || !mapping) return undefined;\n return {\n label,\n removeLabels: Object.values(mapping.values).filter((mappedLabel) => mappedLabel !== label)\n };\n}\n\nasync function githubJson(input: {\n target: GitHubIssueMutationTarget;\n fetchImpl: FetchLike;\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n body?: unknown;\n okStatuses?: number[];\n}): Promise<string | undefined> {\n const response = await input.fetchImpl(`https://api.github.com/repos/${input.target.owner}/${input.target.repo}${input.path}`, {\n method: input.method,\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.target.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n },\n ...(input.body ? { body: JSON.stringify(input.body) } : {})\n });\n\n if (!response.ok && !(input.okStatuses ?? []).includes(response.status)) {\n throw new Error(`${input.method} ${input.path} failed: ${response.status} ${await response.text()}`);\n }\n return `https://github.com/${input.target.owner}/${input.target.repo}/issues/${input.target.issueNumber}`;\n}\n\nasync function githubJsonBody<T>(input: {\n target: GitHubIssueMutationTarget;\n fetchImpl: FetchLike;\n method: \"GET\";\n path: string;\n okStatuses?: number[];\n}): Promise<T> {\n const response = await input.fetchImpl(`https://api.github.com/repos/${input.target.owner}/${input.target.repo}${input.path}`, {\n method: input.method,\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.target.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n }\n });\n\n if (!response.ok && !(input.okStatuses ?? []).includes(response.status)) {\n throw new Error(`${input.method} ${input.path} failed: ${response.status} ${await response.text()}`);\n }\n return await response.json() as T;\n}\n\ntype RequestedReviewersResponse = {\n users?: Array<{ login?: unknown }>;\n teams?: Array<{ slug?: unknown; name?: unknown }>;\n};\n\nfunction requestedReviewerLogins(response: RequestedReviewersResponse): Set<string> {\n return new Set((response.users ?? []).map((user) => user.login).filter((login): login is string => typeof login === \"string\"));\n}\n\nfunction requestedTeamReviewerNames(response: RequestedReviewersResponse): Set<string> {\n return new Set(\n (response.teams ?? [])\n .flatMap((team) => [team.slug, team.name])\n .filter((value): value is string => typeof value === \"string\" && value.length > 0)\n );\n}\n\nexport function compileGitHubIssueMutationIntent(\n intent: MutationIntent,\n options: { mappings?: AdapterMutationMapping[]; targetKind?: \"issue\" | \"pull_request\" } = {}\n): GitHubIssueMutationCompilation {\n if (intent.action === \"create_pull_request\") {\n const head = stringParam(intent, \"head\", \"branch\");\n if (!head) {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"failed\",\n message: \"create_pull_request requires params.head or params.branch.\"\n }\n };\n }\n return {\n ok: true,\n intentId: intent.intentId,\n operation: {\n kind: \"create_pull_request\",\n intentId: intent.intentId,\n title: stringParam(intent, \"title\") ?? intent.summary,\n body: pullRequestBodyFromIntent(intent),\n head,\n base: stringParam(intent, \"base\", \"baseBranch\") ?? \"main\"\n }\n };\n }\n\n if (intent.action === \"request_review\" || intent.domain === \"review\") {\n if (options.targetKind !== \"pull_request\") {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub review requests require a pull request target.\"\n }\n };\n }\n const reviewers = reviewersFromIntent(intent);\n const teamReviewers = teamReviewersFromIntent(intent);\n if (!reviewers?.length && !teamReviewers?.length) {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"failed\",\n message: \"request_review requires params.reviewer, params.reviewers, or params.teamReviewers.\"\n }\n };\n }\n return {\n ok: true,\n intentId: intent.intentId,\n operation: {\n kind: \"request_review\",\n intentId: intent.intentId,\n reviewers: reviewers ?? [],\n ...(teamReviewers?.length ? { teamReviewers } : {})\n }\n };\n }\n\n if (intent.domain === \"status\") {\n const mapped = labelMappingForIntent({ intent, mappings: options.mappings ?? [] });\n if (mapped) {\n return { ok: true, intentId: intent.intentId, operation: { kind: \"replace_mapped_label\", intentId: intent.intentId, ...mapped } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub status writes require an explicit Project field or label mapping policy.\"\n }\n };\n }\n if (intent.domain === \"priority\") {\n const mapped = labelMappingForIntent({ intent, mappings: options.mappings ?? [] });\n if (mapped) {\n return { ok: true, intentId: intent.intentId, operation: { kind: \"replace_mapped_label\", intentId: intent.intentId, ...mapped } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub priority writes require an explicit label or Project field mapping policy.\"\n }\n };\n }\n if (intent.domain !== \"labels\" && intent.domain !== \"assignee\") {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply supports labels and assignee only, not ${intent.domain}.`\n }\n };\n }\n\n if (intent.domain === \"assignee\") {\n if (intent.action === \"set_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_assignees\", intentId: intent.intentId, assignees: [assignee] } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_assignee requires params.assignee.\" } };\n }\n if (intent.action === \"set_assignees\") {\n const assignees = assigneesFromIntent(intent);\n return assignees\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_assignees\", intentId: intent.intentId, assignees } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_assignees requires params.assignees.\" } };\n }\n if (intent.action === \"add_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"add_assignee\", intentId: intent.intentId, assignee } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"add_assignee requires params.assignee.\" } };\n }\n if (intent.action === \"remove_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"remove_assignee\", intentId: intent.intentId, assignee } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"remove_assignee requires params.assignee.\" } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply does not support assignee action ${intent.action}.`\n }\n };\n }\n\n if (intent.action === \"add_label\") {\n const label = labelFromIntent(intent);\n return label\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"add_label\", intentId: intent.intentId, label } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"add_label requires params.label.\" } };\n }\n if (intent.action === \"remove_label\") {\n const label = labelFromIntent(intent);\n return label\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"remove_label\", intentId: intent.intentId, label } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"remove_label requires params.label.\" } };\n }\n if (intent.action === \"set_labels\") {\n const labels = labelsFromIntent(intent);\n return labels\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_labels\", intentId: intent.intentId, labels } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_labels requires params.labels.\" } };\n }\n\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply does not support labels action ${intent.action}.`\n }\n };\n}\n\nexport function compileGitHubIssueMutationIntents(\n intents: MutationIntent[],\n options: { mappings?: AdapterMutationMapping[]; targetKind?: \"issue\" | \"pull_request\" } = {}\n): GitHubIssueMutationCompilation[] {\n return intents.map((intent) => compileGitHubIssueMutationIntent(intent, options));\n}\n\nexport function createGitHubIssueMutationCompiler(options: {\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n} = {}): AdapterMutationCompiler<GitHubIssueMutationOperation> {\n return {\n adapter: \"github\",\n compile(intent) {\n const compilation = compileGitHubIssueMutationIntent(intent, options);\n if (!compilation.ok) {\n return {\n ok: false,\n adapter: \"github\",\n outcome: compilation.outcome\n };\n }\n return {\n ok: true,\n adapter: \"github\",\n intentId: compilation.intentId,\n operation: compilation.operation\n };\n }\n };\n}\n\nexport async function applyGitHubIssueMutationOperation(input: {\n target: GitHubIssueMutationTarget;\n operation: GitHubIssueMutationOperation;\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome> {\n const fetchImpl = input.fetchImpl ?? fetch;\n try {\n if (input.operation.kind === \"create_pull_request\") {\n const externalUri = await createPullRequestViaFetch(\n {\n token: input.target.token,\n owner: input.target.owner,\n repo: input.target.repo,\n title: input.operation.title,\n body: input.operation.body,\n head: input.operation.head,\n base: input.operation.base\n },\n fetchImpl\n );\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"request_review\") {\n const pullRequestNumber = input.target.pullRequestNumber;\n if (typeof pullRequestNumber !== \"number\") {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n message: \"request_review requires target.pullRequestNumber.\"\n };\n }\n const requested = await githubJsonBody<RequestedReviewersResponse>({\n target: input.target,\n fetchImpl,\n method: \"GET\",\n path: `/pulls/${pullRequestNumber}/requested_reviewers`\n });\n const existingReviewers = requestedReviewerLogins(requested);\n const existingTeamReviewers = requestedTeamReviewerNames(requested);\n const reviewers = input.operation.reviewers.filter((reviewer) => !existingReviewers.has(reviewer));\n const teamReviewers = input.operation.teamReviewers?.filter((reviewer) => !existingTeamReviewers.has(reviewer));\n if (reviewers.length === 0 && (!teamReviewers || teamReviewers.length === 0)) {\n return {\n intentId: input.operation.intentId,\n outcome: \"applied\",\n externalUri: `https://github.com/${input.target.owner}/${input.target.repo}/pull/${pullRequestNumber}`,\n message: \"Requested reviewers were already present; skipped GitHub notification retry.\"\n };\n }\n await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/pulls/${pullRequestNumber}/requested_reviewers`,\n body: {\n ...(reviewers.length ? { reviewers } : {}),\n ...(teamReviewers?.length ? { team_reviewers: teamReviewers } : {})\n }\n });\n return {\n intentId: input.operation.intentId,\n outcome: \"applied\",\n externalUri: `https://github.com/${input.target.owner}/${input.target.repo}/pull/${pullRequestNumber}`\n };\n }\n\n const issueNumber = input.target.issueNumber;\n if (typeof issueNumber !== \"number\") {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n message: \"GitHub issue mutation requires target.issueNumber.\"\n };\n }\n\n if (input.operation.kind === \"set_assignees\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"PATCH\",\n path: `/issues/${issueNumber}`,\n body: { assignees: input.operation.assignees }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"add_assignee\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/assignees`,\n body: { assignees: [input.operation.assignee] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"remove_assignee\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/assignees`,\n body: { assignees: [input.operation.assignee] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"replace_mapped_label\") {\n for (const label of input.operation.removeLabels) {\n await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/labels/${encodeURIComponent(label)}`,\n okStatuses: [200, 404]\n });\n }\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: [input.operation.label] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"add_label\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: [input.operation.label] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"remove_label\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/labels/${encodeURIComponent(input.operation.label)}`\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"PUT\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: input.operation.labels }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n } catch (error) {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n error: error instanceof Error ? error.message : String(error)\n };\n }\n}\n\nexport async function applyGitHubIssueMutationIntent(input: {\n target: GitHubIssueMutationTarget;\n intent: MutationIntent;\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome> {\n const compiled = compileGitHubIssueMutationIntent(input.intent, {\n ...(input.mappings ? { mappings: input.mappings } : {}),\n ...(input.targetKind ? { targetKind: input.targetKind } : {})\n });\n if (!compiled.ok) return compiled.outcome;\n return applyGitHubIssueMutationOperation({\n target: input.target,\n operation: compiled.operation,\n ...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {})\n });\n}\n\nexport async function applyGitHubIssueMutationIntents(input: {\n target: GitHubIssueMutationTarget;\n intents: MutationIntent[];\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome[]> {\n const outcomes: ApplyIntentOutcome[] = [];\n for (const intent of input.intents) {\n outcomes.push(\n await applyGitHubIssueMutationIntent({\n target: input.target,\n intent,\n ...(input.mappings ? { mappings: input.mappings } : {}),\n ...(input.targetKind ? { targetKind: input.targetKind } : {}),\n ...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {})\n })\n );\n }\n return outcomes;\n}\n","import { createHmac, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport { serve } from \"@hono/node-server\";\nimport { createOpenTagClient } from \"@opentag/client\";\nimport { parseThreadActionCommand, type OpenTagEvent } from \"@opentag/core\";\nimport { Hono } from \"hono\";\nimport { normalizeGitHubIssueComment, normalizeGitHubPullRequestReviewComment } from \"./normalize.js\";\n\ntype GitHubActor = {\n id: number;\n login: string;\n};\n\ntype GitHubRepository = {\n name: string;\n private: boolean;\n owner: { login: string };\n};\n\nexport type GitHubIssueCommentPayload = {\n action?: string;\n comment: { id: number; body: string; html_url: string };\n issue: { html_url: string; comments_url: string; number: number };\n repository: GitHubRepository;\n sender: GitHubActor;\n installation?: { id: number };\n};\n\nexport type GitHubPullRequestReviewCommentPayload = {\n action?: string;\n comment: { id: number; body: string; html_url: string };\n pull_request: { html_url: string; number: number };\n repository: GitHubRepository;\n sender: GitHubActor;\n installation?: { id: number };\n};\n\nexport type GitHubThreadActionInput = {\n id: string;\n rawText: string;\n actor: {\n provider: \"github\";\n providerUserId: string;\n handle: string;\n };\n callback: {\n provider: \"github\";\n uri: string;\n threadKey: string;\n };\n metadata: Record<string, unknown>;\n};\n\nexport type GitHubWebhookAppInput = {\n webhookSecret: string;\n webhookPath?: string;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n};\n\nexport type GitHubIngressConfig = {\n webhookSecret: string;\n dispatcherUrl: string;\n dispatcherToken?: string;\n port?: number;\n hostname?: string;\n webhookPath?: string;\n};\n\nexport type GitHubIngressHandle = {\n url: string;\n webhookPath: string;\n server: ReturnType<typeof serve>;\n close(): Promise<void>;\n};\n\nexport function computeGitHubSignature(input: { webhookSecret: string; rawBody: string }): string {\n const digest = createHmac(\"sha256\", input.webhookSecret).update(input.rawBody).digest(\"hex\");\n return `sha256=${digest}`;\n}\n\nexport function verifyGitHubSignature(input: {\n webhookSecret: string;\n rawBody: string;\n signature: string;\n}): boolean {\n const expected = computeGitHubSignature(input);\n const expectedBuffer = Buffer.from(expected);\n const actualBuffer = Buffer.from(input.signature);\n return expectedBuffer.length === actualBuffer.length && timingSafeEqual(expectedBuffer, actualBuffer);\n}\n\nfunction parseJsonPayload(rawBody: string): unknown {\n try {\n return JSON.parse(rawBody);\n } catch {\n return null;\n }\n}\n\nasync function handleIssueCommentCreated(input: {\n payload: GitHubIssueCommentPayload;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n}): Promise<void> {\n if (input.payload.action && input.payload.action !== \"created\") return;\n if (parseThreadActionCommand(input.payload.comment.body) && input.submitThreadAction) {\n await input.submitThreadAction({\n id: `approval_github_comment_${input.payload.comment.id}`,\n rawText: input.payload.comment.body,\n actor: {\n provider: \"github\",\n providerUserId: String(input.payload.sender.id),\n handle: input.payload.sender.login\n },\n callback: {\n provider: \"github\",\n uri: input.payload.issue.comments_url,\n threadKey: `${input.payload.repository.owner.login}/${input.payload.repository.name}#${input.payload.issue.number}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.payload.repository.owner.login,\n repo: input.payload.repository.name,\n issueNumber: input.payload.issue.number,\n commentUrl: input.payload.comment.html_url\n }\n });\n return;\n }\n\n const event = normalizeGitHubIssueComment({\n id: String(input.payload.comment.id),\n commentBody: input.payload.comment.body,\n commentUrl: input.payload.comment.html_url,\n apiCommentsUrl: input.payload.issue.comments_url,\n issueUrl: input.payload.issue.html_url,\n issueNumber: input.payload.issue.number,\n owner: input.payload.repository.owner.login,\n repo: input.payload.repository.name,\n actorId: input.payload.sender.id,\n actorLogin: input.payload.sender.login,\n private: input.payload.repository.private,\n receivedAt: input.now(),\n ...(input.payload.installation ? { installationId: input.payload.installation.id } : {})\n });\n\n if (event) {\n await input.createRun(event);\n }\n}\n\nasync function handlePullRequestReviewCommentCreated(input: {\n payload: GitHubPullRequestReviewCommentPayload;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n}): Promise<void> {\n if (input.payload.action && input.payload.action !== \"created\") return;\n const owner = input.payload.repository.owner.login;\n const repo = input.payload.repository.name;\n if (parseThreadActionCommand(input.payload.comment.body) && input.submitThreadAction) {\n await input.submitThreadAction({\n id: `approval_github_pr_review_comment_${input.payload.comment.id}`,\n rawText: input.payload.comment.body,\n actor: {\n provider: \"github\",\n providerUserId: String(input.payload.sender.id),\n handle: input.payload.sender.login\n },\n callback: {\n provider: \"github\",\n uri: `https://api.github.com/repos/${owner}/${repo}/issues/${input.payload.pull_request.number}/comments`,\n threadKey: `${owner}/${repo}#${input.payload.pull_request.number}`\n },\n metadata: {\n repoProvider: \"github\",\n owner,\n repo,\n pullRequestNumber: input.payload.pull_request.number,\n commentUrl: input.payload.comment.html_url\n }\n });\n return;\n }\n\n const event = normalizeGitHubPullRequestReviewComment({\n id: String(input.payload.comment.id),\n commentBody: input.payload.comment.body,\n commentUrl: input.payload.comment.html_url,\n pullRequestUrl: input.payload.pull_request.html_url,\n apiCommentsUrl: `https://api.github.com/repos/${owner}/${repo}/issues/${input.payload.pull_request.number}/comments`,\n owner,\n repo,\n pullRequestNumber: input.payload.pull_request.number,\n actorId: input.payload.sender.id,\n actorLogin: input.payload.sender.login,\n private: input.payload.repository.private,\n receivedAt: input.now(),\n ...(input.payload.installation ? { installationId: input.payload.installation.id } : {})\n });\n\n if (event) {\n await input.createRun(event);\n }\n}\n\nexport function createGitHubWebhookApp(input: GitHubWebhookAppInput) {\n const app = new Hono();\n const webhookPath = input.webhookPath ?? \"/github/webhooks\";\n if (!webhookPath.startsWith(\"/\")) {\n throw new Error(\"GitHub webhook path must start with /.\");\n }\n\n app.post(webhookPath, async (c) => {\n const signature = c.req.header(\"x-hub-signature-256\");\n if (!signature) {\n return c.json({ error: \"missing_signature_header\" }, 401);\n }\n const rawBody = await c.req.text();\n if (!verifyGitHubSignature({ webhookSecret: input.webhookSecret, rawBody, signature })) {\n return c.json({ error: \"invalid_signature\" }, 401);\n }\n\n const eventName = c.req.header(\"x-github-event\");\n const payload = parseJsonPayload(rawBody);\n if (!payload || typeof payload !== \"object\") {\n return c.json({ error: \"invalid_json\" }, 400);\n }\n\n if (eventName === \"ping\") {\n return c.json({ ok: true });\n }\n if (eventName === \"issue_comment\") {\n await handleIssueCommentCreated({\n payload: payload as GitHubIssueCommentPayload,\n createRun: input.createRun,\n ...(input.submitThreadAction ? { submitThreadAction: input.submitThreadAction } : {}),\n now: input.now\n });\n return c.json({ ok: true });\n }\n if (eventName === \"pull_request_review_comment\") {\n await handlePullRequestReviewCommentCreated({\n payload: payload as GitHubPullRequestReviewCommentPayload,\n createRun: input.createRun,\n ...(input.submitThreadAction ? { submitThreadAction: input.submitThreadAction } : {}),\n now: input.now\n });\n return c.json({ ok: true });\n }\n\n return c.json({ ok: true, ignored: \"unsupported_event\" });\n });\n\n return app;\n}\n\nexport function startGitHubIngress(config: GitHubIngressConfig): GitHubIngressHandle {\n const dispatcherClient = createOpenTagClient({\n dispatcherUrl: config.dispatcherUrl,\n ...(config.dispatcherToken ? { pairingToken: config.dispatcherToken } : {})\n });\n const port = config.port ?? 3000;\n const hostname = config.hostname ?? \"127.0.0.1\";\n const webhookPath = config.webhookPath ?? \"/github/webhooks\";\n const server = serve({\n fetch: createGitHubWebhookApp({\n webhookSecret: config.webhookSecret,\n webhookPath,\n async createRun(event) {\n const runId = `run_${randomUUID()}`;\n const created = await dispatcherClient.createRun({ runId, event });\n return created.outcome === \"run_created\" ? { runId: created.run.id } : {};\n },\n async submitThreadAction(action) {\n await dispatcherClient.submitThreadAction(action);\n },\n now: () => new Date().toISOString()\n }).fetch,\n port,\n hostname\n });\n\n return {\n url: `http://${hostname}:${port}`,\n webhookPath,\n server,\n close() {\n return new Promise((resolve, reject) => {\n server.close((error?: Error) => {\n if (error) {\n reject(error);\n return;\n }\n resolve();\n });\n });\n }\n };\n}\n","import { parseOpenTagMention, type OpenTagEvent } from \"@opentag/core\";\nimport type { ContextPointer, OpenTagCommand, PermissionGrant, WorkItemReference } from \"@opentag/core\";\n\nexport type GitHubIssueCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n apiCommentsUrl: string;\n issueUrl: string;\n issueNumber: number;\n owner: string;\n repo: string;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nexport type GitHubPullRequestReviewCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n pullRequestUrl: string;\n apiCommentsUrl: string;\n owner: string;\n repo: string;\n pullRequestNumber: number;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nfunction permissionsForIntent(intent: OpenTagCommand[\"intent\"]): PermissionGrant[] {\n const permissions: PermissionGrant[] = [\n {\n scope: \"issue:comment\",\n reason: \"reply to the source GitHub thread\"\n },\n {\n scope: \"runner:local\",\n reason: \"execute the run on a paired local daemon\"\n }\n ];\n if (intent === \"fix\" || intent === \"run\") {\n permissions.push(\n {\n scope: \"repo:read\",\n reason: \"inspect the repository in the paired local checkout\"\n },\n {\n scope: \"repo:write\",\n reason: \"commit code changes on an isolated run branch\"\n },\n {\n scope: \"pr:create\",\n reason: \"open a pull request for completed code changes\"\n }\n );\n }\n return permissions;\n}\n\nfunction permissionsForPullRequestReviewCommentIntent(intent: OpenTagCommand[\"intent\"]): PermissionGrant[] {\n const permissions = permissionsForIntent(intent);\n if (intent === \"review\") {\n permissions.push({\n scope: \"pr:update\",\n reason: \"request reviewers on the source pull request after explicit approval\"\n });\n }\n return permissions;\n}\n\nfunction contextPointersForCommand(command: OpenTagCommand, privateRepo: boolean): ContextPointer[] {\n const visibility = privateRepo ? \"private\" : \"public\";\n const context: ContextPointer[] = [];\n\n for (const reference of command.parsed?.references ?? []) {\n if (reference.kind === \"url\") {\n context.push({\n kind: \"url\",\n uri: reference.uri,\n visibility,\n title: reference.title ?? \"Command URL reference\"\n });\n continue;\n }\n\n if (reference.kind === \"file\" || reference.kind === \"path\" || reference.kind === \"line\" || reference.kind === \"range\") {\n context.push({\n kind: \"file\",\n uri: reference.uri,\n ...(reference.line ? { line: reference.line } : {}),\n ...(reference.startLine ? { startLine: reference.startLine } : {}),\n ...(reference.endLine ? { endLine: reference.endLine } : {}),\n visibility,\n title: referenceTitle(reference)\n });\n }\n }\n\n return context;\n}\n\nfunction referenceTitle(reference: NonNullable<OpenTagCommand[\"parsed\"]>[\"references\"][number]): string {\n return reference.title ?? \"Command file reference\";\n}\n\nfunction githubWorkItem(input: {\n owner: string;\n repo: string;\n kind: \"issue\" | \"pull_request\";\n number: number;\n uri: string;\n}): WorkItemReference {\n return {\n provider: \"github\",\n kind: input.kind,\n externalId: `${input.owner}/${input.repo}#${input.number}`,\n uri: input.uri,\n ownerContainer: {\n provider: \"github\",\n id: `${input.owner}/${input.repo}`,\n uri: `https://github.com/${input.owner}/${input.repo}`\n }\n };\n}\n\nfunction commandMetadata(command: OpenTagCommand): Record<string, unknown> {\n if (!command.parsed) return {};\n return {\n commandParser: command.parsed.version,\n commandDiagnostics: command.parsed.diagnostics,\n ...(command.parsed.approval ? { approval: command.parsed.approval } : {}),\n ...(command.parsed.network ? { network: command.parsed.network } : {})\n };\n}\n\nexport function normalizeGitHubIssueComment(input: GitHubIssueCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n const command = {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args,\n ...(mention.parsed ? { parsed: mention.parsed } : {})\n };\n\n return {\n id: `evt_github_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\",\n ...(mention.parsed?.executorHint ? { executorHint: mention.parsed.executorHint } : {})\n },\n command,\n context: [\n {\n provider: \"github\",\n kind: \"issue\",\n uri: input.issueUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n provider: \"github\",\n kind: \"comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n ...contextPointersForCommand(command, input.private)\n ],\n workItem: githubWorkItem({\n owner: input.owner,\n repo: input.repo,\n kind: \"issue\",\n number: input.issueNumber,\n uri: input.issueUrl\n }),\n permissions: permissionsForIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}#${input.issueNumber}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.owner,\n repo: input.repo,\n issueNumber: input.issueNumber,\n ...commandMetadata(command),\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n\nexport function normalizeGitHubPullRequestReviewComment(input: GitHubPullRequestReviewCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n const command = {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args,\n ...(mention.parsed ? { parsed: mention.parsed } : {})\n };\n\n return {\n id: `evt_github_pr_review_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\",\n ...(mention.parsed?.executorHint ? { executorHint: mention.parsed.executorHint } : {})\n },\n command,\n context: [\n {\n provider: \"github\",\n kind: \"pull_request\",\n uri: input.pullRequestUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n provider: \"github\",\n kind: \"comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n ...contextPointersForCommand(command, input.private)\n ],\n workItem: githubWorkItem({\n owner: input.owner,\n repo: input.repo,\n kind: \"pull_request\",\n number: input.pullRequestNumber,\n uri: input.pullRequestUrl\n }),\n permissions: permissionsForPullRequestReviewCommentIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}#${input.pullRequestNumber}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.owner,\n repo: input.repo,\n pullRequestNumber: input.pullRequestNumber,\n ...commandMetadata(command),\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n","import { suggestedActionCandidatesFromResult, type OpenTagRunResult } from \"@opentag/core\";\n\nfunction nextActionSummary(result: OpenTagRunResult): string | undefined {\n if (!result.nextAction) return undefined;\n if (typeof result.nextAction === \"string\") return result.nextAction;\n return result.nextAction.summary;\n}\n\nfunction stringParam(params: Record<string, unknown> | undefined, key: string): string | undefined {\n const value = params?.[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction stringArrayParam(params: Record<string, unknown> | undefined, key: string): string[] {\n const value = params?.[key];\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n}\n\nfunction renderVerificationParams(params: Record<string, unknown> | undefined): string[] {\n const value = params?.[\"verification\"];\n if (!Array.isArray(value)) return [];\n return value\n .map((item) => {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const command = (item as Record<string, unknown>)[\"command\"];\n const outcome = (item as Record<string, unknown>)[\"outcome\"];\n return typeof command === \"string\" && typeof outcome === \"string\" ? ` - \\`${command}\\`: ${outcome}` : undefined;\n })\n .filter((line): line is string => Boolean(line));\n}\n\nfunction renderSuggestedActionDetails(params: Record<string, unknown> | undefined, action: string): string[] {\n if (action !== \"create_pull_request\") return [];\n const lines: string[] = [];\n const title = stringParam(params, \"title\");\n const head = stringParam(params, \"head\") ?? stringParam(params, \"branch\");\n const base = stringParam(params, \"base\") ?? stringParam(params, \"baseBranch\");\n const changedFiles = stringArrayParam(params, \"changedFiles\");\n const risks = stringArrayParam(params, \"risks\");\n const verification = renderVerificationParams(params);\n if (title) lines.push(` Title: ${title}`);\n if (head || base) lines.push(` Branch: \\`${head ?? \"unknown\"}\\` -> \\`${base ?? \"main\"}\\``);\n if (changedFiles.length > 0) lines.push(` Changed files: ${changedFiles.map((file) => `\\`${file}\\``).join(\", \")}`);\n if (risks.length > 0) {\n lines.push(\" Risks:\");\n for (const risk of risks) {\n lines.push(` - ${risk}`);\n }\n }\n if (verification.length > 0) {\n lines.push(\" Verification:\");\n lines.push(...verification);\n }\n return lines;\n}\n\nfunction renderSuggestedActions(result: OpenTagRunResult): string[] {\n const candidates = suggestedActionCandidatesFromResult(result);\n if (candidates.length === 0) return [];\n\n const lines = [\"Suggested actions:\"];\n for (const candidate of candidates) {\n lines.push(\n \"\",\n `${candidate.index}. **${candidate.intent.summary}**`,\n ` Intent: \\`${candidate.intent.action}\\` (\\`${candidate.intent.domain}\\`)`,\n ` Proposal: \\`${candidate.proposalId}\\``,\n ` Intent ID: \\`${candidate.intent.intentId}\\``\n );\n lines.push(...renderSuggestedActionDetails(candidate.intent.params, candidate.intent.action));\n if (candidate.proposalPreconditions?.length) {\n lines.push(\" Preconditions:\");\n for (const precondition of candidate.proposalPreconditions) {\n lines.push(` - ${precondition}`);\n }\n }\n }\n\n lines.push(\n \"\",\n \"Reply with:\",\n \"- `approve 1` to record approval without applying yet\",\n \"- `apply 1` or `apply all` to apply supported actions\",\n \"- `continue 1` to continue with a follow-up run\",\n \"- `reject 1` to reject an action\"\n );\n return lines;\n}\n\nexport function renderAcknowledgement(runId: string): string {\n return `OpenTag picked this up. Run: \\`${runId}\\``;\n}\n\nexport function renderProgress(input: { runId: string; message: string }): string {\n return `OpenTag progress for \\`${input.runId}\\`: ${input.message}`;\n}\n\nexport function renderFinalResult(result: OpenTagRunResult): string {\n const lines = [`OpenTag finished with **${result.conclusion}**.`, \"\", result.summary];\n\n if (result.verification?.length) {\n lines.push(\"\", \"Verification:\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n const nextAction = nextActionSummary(result);\n if (nextAction) {\n lines.push(\"\", `Next action: ${nextAction}`);\n }\n\n const suggestedActions = renderSuggestedActions(result);\n if (suggestedActions.length > 0) {\n lines.push(\"\", ...suggestedActions);\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAcO,SAAS,qBAAqB,QAAkC;AACrE,QAAM,QAAQ,CAAC,cAAc,IAAI,OAAO,OAAO;AAE/C,MAAI,OAAO,cAAc,QAAQ;AAC/B,UAAM,KAAK,IAAI,kBAAkB;AACjC,eAAW,QAAQ,OAAO,cAAc;AACtC,YAAM,KAAK,OAAO,IAAI,IAAI;AAAA,IAC5B;AAAA,EACF;AAEA,MAAI,OAAO,cAAc,QAAQ;AAC/B,UAAM,KAAK,IAAI,iBAAiB;AAChC,eAAW,SAAS,OAAO,cAAc;AACvC,YAAM,KAAK,OAAO,MAAM,OAAO,OAAO,MAAM,OAAO,EAAE;AAAA,IACvD;A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mB,uBAAuB,MAAM;AACtD,MAAI,iBAAiB,SAAS,GAAG;AAC/B,UAAM,KAAK,IAAI,GAAG,gBAAgB;AAAA,EACpC;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":["externalUri","stringParam","stringArrayParam"]}
1
+ {"version":3,"sources":["../src/pull-request.ts","../src/apply.ts","../src/ingress.ts","../src/normalize.ts","../src/render.ts"],"sourcesContent":["import type { OpenTagRunResult } from \"@opentag/core\";\n\nexport type CreatePullRequestInput = {\n token: string;\n owner: string;\n repo: string;\n title: string;\n body: string;\n head: string;\n base: string;\n};\n\nexport type FetchLike = typeof fetch;\n\nexport function buildPullRequestBody(result: OpenTagRunResult): string {\n const lines = [\"## Summary\", \"\", result.summary];\n\n if (result.changedFiles?.length) {\n lines.push(\"\", \"## Changed Files\");\n for (const file of result.changedFiles) {\n lines.push(`- \\`${file}\\``);\n }\n }\n\n if (result.verification?.length) {\n lines.push(\"\", \"## Verification\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nexport async function createPullRequestViaFetch(input: CreatePullRequestInput, fetchImpl: FetchLike = fetch): Promise<string> {\n const response = await fetchImpl(`https://api.github.com/repos/${input.owner}/${input.repo}/pulls`, {\n method: \"POST\",\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n },\n body: JSON.stringify({\n title: input.title,\n body: input.body,\n head: input.head,\n base: input.base\n })\n });\n\n if (!response.ok) {\n throw new Error(`create pull request failed: ${response.status} ${await response.text()}`);\n }\n\n const body = (await response.json()) as { html_url?: string };\n if (!body.html_url) {\n throw new Error(\"create pull request response did not include html_url\");\n }\n return body.html_url;\n}\n","import type { AdapterMutationCompiler, AdapterMutationMapping, ApplyIntentOutcome, MutationIntent } from \"@opentag/core\";\nimport { createPullRequestViaFetch, type FetchLike } from \"./pull-request.js\";\n\nexport type GitHubIssueMutationTarget = {\n token: string;\n owner: string;\n repo: string;\n issueNumber?: number;\n pullRequestNumber?: number;\n};\n\nexport type GitHubIssueMutationOperation =\n | {\n kind: \"add_label\";\n intentId: string;\n label: string;\n }\n | {\n kind: \"remove_label\";\n intentId: string;\n label: string;\n }\n | {\n kind: \"replace_mapped_label\";\n intentId: string;\n label: string;\n removeLabels: string[];\n }\n | {\n kind: \"set_labels\";\n intentId: string;\n labels: string[];\n }\n | {\n kind: \"set_assignees\";\n intentId: string;\n assignees: string[];\n }\n | {\n kind: \"add_assignee\";\n intentId: string;\n assignee: string;\n }\n | {\n kind: \"remove_assignee\";\n intentId: string;\n assignee: string;\n }\n | {\n kind: \"request_review\";\n intentId: string;\n reviewers: string[];\n teamReviewers?: string[];\n }\n | {\n kind: \"create_pull_request\";\n intentId: string;\n title: string;\n body: string;\n head: string;\n base: string;\n };\n\nexport type GitHubIssueMutationCompilation =\n | {\n ok: true;\n intentId: string;\n operation: GitHubIssueMutationOperation;\n }\n | {\n ok: false;\n outcome: ApplyIntentOutcome;\n };\n\nfunction labelFromIntent(intent: MutationIntent): string | undefined {\n const value = intent.params?.[\"label\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction labelsFromIntent(intent: MutationIntent): string[] | undefined {\n const value = intent.params?.[\"labels\"];\n if (!Array.isArray(value)) return undefined;\n const labels = value.filter((label): label is string => typeof label === \"string\" && label.length > 0);\n return labels.length > 0 ? labels : undefined;\n}\n\nfunction assigneeFromIntent(intent: MutationIntent): string | undefined {\n const value = intent.params?.[\"assignee\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction assigneesFromIntent(intent: MutationIntent): string[] | undefined {\n const value = intent.params?.[\"assignees\"];\n if (!Array.isArray(value)) return undefined;\n const assignees = value.filter((assignee): assignee is string => typeof assignee === \"string\" && assignee.length > 0);\n return assignees.length > 0 ? assignees : undefined;\n}\n\nfunction reviewersFromIntent(intent: MutationIntent): string[] | undefined {\n const reviewer = intent.params?.[\"reviewer\"];\n const reviewers = intent.params?.[\"reviewers\"];\n const values = [\n ...(typeof reviewer === \"string\" ? [reviewer] : []),\n ...(Array.isArray(reviewers) ? reviewers : [])\n ].filter((value): value is string => typeof value === \"string\" && value.length > 0);\n return values.length > 0 ? [...new Set(values)] : undefined;\n}\n\nfunction teamReviewersFromIntent(intent: MutationIntent): string[] | undefined {\n const reviewer = intent.params?.[\"teamReviewer\"];\n const reviewers = intent.params?.[\"teamReviewers\"] ?? intent.params?.[\"team_reviewers\"];\n const values = [\n ...(typeof reviewer === \"string\" ? [reviewer] : []),\n ...(Array.isArray(reviewers) ? reviewers : [])\n ].filter((value): value is string => typeof value === \"string\" && value.length > 0);\n return values.length > 0 ? [...new Set(values)] : undefined;\n}\n\nfunction stringParam(intent: MutationIntent, ...keys: string[]): string | undefined {\n for (const key of keys) {\n const value = intent.params?.[key];\n if (typeof value === \"string\" && value.length > 0) return value;\n }\n return undefined;\n}\n\nfunction stringArrayParam(intent: MutationIntent, key: string): string[] {\n const value = intent.params?.[key];\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n}\n\nfunction verificationLinesFromIntent(intent: MutationIntent): string[] {\n const value = intent.params?.[\"verification\"];\n if (!Array.isArray(value)) return [];\n return value\n .map((item) => {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const command = (item as Record<string, unknown>)[\"command\"];\n const outcome = (item as Record<string, unknown>)[\"outcome\"];\n return typeof command === \"string\" && typeof outcome === \"string\" ? `- \\`${command}\\`: ${outcome}` : undefined;\n })\n .filter((line): line is string => Boolean(line));\n}\n\nfunction pullRequestBodyFromIntent(intent: MutationIntent): string {\n const explicitBody = stringParam(intent, \"body\");\n const changedFiles = stringArrayParam(intent, \"changedFiles\");\n const risks = stringArrayParam(intent, \"risks\");\n const verification = verificationLinesFromIntent(intent);\n const executorConditions = stringArrayParam(intent, \"executorConditions\");\n const lines = explicitBody ? [explicitBody] : [\"## Summary\", \"\", intent.summary];\n if (changedFiles.length > 0) {\n lines.push(\"\", \"## Changed Files\", ...changedFiles.map((file) => `- \\`${file}\\``));\n }\n if (risks.length > 0) {\n lines.push(\"\", \"## Risks\", ...risks.map((risk) => `- ${risk}`));\n }\n if (verification.length > 0) {\n lines.push(\"\", \"## Verification\", ...verification);\n }\n if (executorConditions.length > 0) {\n lines.push(\"\", \"## Executor Conditions\", ...executorConditions.map((condition) => `- ${condition}`));\n }\n return lines.join(\"\\n\");\n}\n\nfunction mappedValueFromIntent(intent: MutationIntent): string | undefined {\n const key = intent.domain === \"status\" ? \"status\" : \"priority\";\n const value = intent.params?.[key] ?? intent.params?.[\"value\"];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction labelMappingForIntent(input: { intent: MutationIntent; mappings: AdapterMutationMapping[] }): { label: string; removeLabels: string[] } | undefined {\n const semanticValue = mappedValueFromIntent(input.intent);\n if (!semanticValue) return undefined;\n const mapping = input.mappings.find(\n (candidate) => candidate.adapter === \"github\" && candidate.domain === input.intent.domain && candidate.strategy === \"label\"\n );\n const label = mapping?.values[semanticValue];\n if (!label || !mapping) return undefined;\n return {\n label,\n removeLabels: Object.values(mapping.values).filter((mappedLabel) => mappedLabel !== label)\n };\n}\n\nasync function githubJson(input: {\n target: GitHubIssueMutationTarget;\n fetchImpl: FetchLike;\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n body?: unknown;\n okStatuses?: number[];\n}): Promise<string | undefined> {\n const response = await input.fetchImpl(`https://api.github.com/repos/${input.target.owner}/${input.target.repo}${input.path}`, {\n method: input.method,\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.target.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n },\n ...(input.body ? { body: JSON.stringify(input.body) } : {})\n });\n\n if (!response.ok && !(input.okStatuses ?? []).includes(response.status)) {\n throw new Error(`${input.method} ${input.path} failed: ${response.status} ${await response.text()}`);\n }\n return `https://github.com/${input.target.owner}/${input.target.repo}/issues/${input.target.issueNumber}`;\n}\n\nasync function githubJsonBody<T>(input: {\n target: GitHubIssueMutationTarget;\n fetchImpl: FetchLike;\n method: \"GET\";\n path: string;\n okStatuses?: number[];\n}): Promise<T> {\n const response = await input.fetchImpl(`https://api.github.com/repos/${input.target.owner}/${input.target.repo}${input.path}`, {\n method: input.method,\n headers: {\n accept: \"application/vnd.github+json\",\n authorization: `Bearer ${input.target.token}`,\n \"content-type\": \"application/json\",\n \"x-github-api-version\": \"2022-11-28\"\n }\n });\n\n if (!response.ok && !(input.okStatuses ?? []).includes(response.status)) {\n throw new Error(`${input.method} ${input.path} failed: ${response.status} ${await response.text()}`);\n }\n return await response.json() as T;\n}\n\ntype RequestedReviewersResponse = {\n users?: Array<{ login?: unknown }>;\n teams?: Array<{ slug?: unknown; name?: unknown }>;\n};\n\nfunction requestedReviewerLogins(response: RequestedReviewersResponse): Set<string> {\n return new Set((response.users ?? []).map((user) => user.login).filter((login): login is string => typeof login === \"string\"));\n}\n\nfunction requestedTeamReviewerNames(response: RequestedReviewersResponse): Set<string> {\n return new Set(\n (response.teams ?? [])\n .flatMap((team) => [team.slug, team.name])\n .filter((value): value is string => typeof value === \"string\" && value.length > 0)\n );\n}\n\nexport function compileGitHubIssueMutationIntent(\n intent: MutationIntent,\n options: { mappings?: AdapterMutationMapping[]; targetKind?: \"issue\" | \"pull_request\" } = {}\n): GitHubIssueMutationCompilation {\n if (intent.action === \"create_pull_request\") {\n const head = stringParam(intent, \"head\", \"branch\");\n if (!head) {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"failed\",\n message: \"create_pull_request requires params.head or params.branch.\"\n }\n };\n }\n return {\n ok: true,\n intentId: intent.intentId,\n operation: {\n kind: \"create_pull_request\",\n intentId: intent.intentId,\n title: stringParam(intent, \"title\") ?? intent.summary,\n body: pullRequestBodyFromIntent(intent),\n head,\n base: stringParam(intent, \"base\", \"baseBranch\") ?? \"main\"\n }\n };\n }\n\n if (intent.action === \"request_review\" || intent.domain === \"review\") {\n if (options.targetKind !== \"pull_request\") {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub review requests require a pull request target.\"\n }\n };\n }\n const reviewers = reviewersFromIntent(intent);\n const teamReviewers = teamReviewersFromIntent(intent);\n if (!reviewers?.length && !teamReviewers?.length) {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"failed\",\n message: \"request_review requires params.reviewer, params.reviewers, or params.teamReviewers.\"\n }\n };\n }\n return {\n ok: true,\n intentId: intent.intentId,\n operation: {\n kind: \"request_review\",\n intentId: intent.intentId,\n reviewers: reviewers ?? [],\n ...(teamReviewers?.length ? { teamReviewers } : {})\n }\n };\n }\n\n if (intent.domain === \"status\") {\n const mapped = labelMappingForIntent({ intent, mappings: options.mappings ?? [] });\n if (mapped) {\n return { ok: true, intentId: intent.intentId, operation: { kind: \"replace_mapped_label\", intentId: intent.intentId, ...mapped } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub status writes require an explicit Project field or label mapping policy.\"\n }\n };\n }\n if (intent.domain === \"priority\") {\n const mapped = labelMappingForIntent({ intent, mappings: options.mappings ?? [] });\n if (mapped) {\n return { ok: true, intentId: intent.intentId, operation: { kind: \"replace_mapped_label\", intentId: intent.intentId, ...mapped } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: \"GitHub priority writes require an explicit label or Project field mapping policy.\"\n }\n };\n }\n if (intent.domain !== \"labels\" && intent.domain !== \"assignee\") {\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply supports labels and assignee only, not ${intent.domain}.`\n }\n };\n }\n\n if (intent.domain === \"assignee\") {\n if (intent.action === \"set_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_assignees\", intentId: intent.intentId, assignees: [assignee] } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_assignee requires params.assignee.\" } };\n }\n if (intent.action === \"set_assignees\") {\n const assignees = assigneesFromIntent(intent);\n return assignees\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_assignees\", intentId: intent.intentId, assignees } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_assignees requires params.assignees.\" } };\n }\n if (intent.action === \"add_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"add_assignee\", intentId: intent.intentId, assignee } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"add_assignee requires params.assignee.\" } };\n }\n if (intent.action === \"remove_assignee\") {\n const assignee = assigneeFromIntent(intent);\n return assignee\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"remove_assignee\", intentId: intent.intentId, assignee } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"remove_assignee requires params.assignee.\" } };\n }\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply does not support assignee action ${intent.action}.`\n }\n };\n }\n\n if (intent.action === \"add_label\") {\n const label = labelFromIntent(intent);\n return label\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"add_label\", intentId: intent.intentId, label } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"add_label requires params.label.\" } };\n }\n if (intent.action === \"remove_label\") {\n const label = labelFromIntent(intent);\n return label\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"remove_label\", intentId: intent.intentId, label } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"remove_label requires params.label.\" } };\n }\n if (intent.action === \"set_labels\") {\n const labels = labelsFromIntent(intent);\n return labels\n ? { ok: true, intentId: intent.intentId, operation: { kind: \"set_labels\", intentId: intent.intentId, labels } }\n : { ok: false, outcome: { intentId: intent.intentId, outcome: \"failed\", message: \"set_labels requires params.labels.\" } };\n }\n\n return {\n ok: false,\n outcome: {\n intentId: intent.intentId,\n outcome: \"unsupported\",\n message: `GitHub apply does not support labels action ${intent.action}.`\n }\n };\n}\n\nexport function compileGitHubIssueMutationIntents(\n intents: MutationIntent[],\n options: { mappings?: AdapterMutationMapping[]; targetKind?: \"issue\" | \"pull_request\" } = {}\n): GitHubIssueMutationCompilation[] {\n return intents.map((intent) => compileGitHubIssueMutationIntent(intent, options));\n}\n\nexport function createGitHubIssueMutationCompiler(options: {\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n} = {}): AdapterMutationCompiler<GitHubIssueMutationOperation> {\n return {\n adapter: \"github\",\n compile(intent) {\n const compilation = compileGitHubIssueMutationIntent(intent, options);\n if (!compilation.ok) {\n return {\n ok: false,\n adapter: \"github\",\n outcome: compilation.outcome\n };\n }\n return {\n ok: true,\n adapter: \"github\",\n intentId: compilation.intentId,\n operation: compilation.operation\n };\n }\n };\n}\n\nexport async function applyGitHubIssueMutationOperation(input: {\n target: GitHubIssueMutationTarget;\n operation: GitHubIssueMutationOperation;\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome> {\n const fetchImpl = input.fetchImpl ?? fetch;\n try {\n if (input.operation.kind === \"create_pull_request\") {\n const externalUri = await createPullRequestViaFetch(\n {\n token: input.target.token,\n owner: input.target.owner,\n repo: input.target.repo,\n title: input.operation.title,\n body: input.operation.body,\n head: input.operation.head,\n base: input.operation.base\n },\n fetchImpl\n );\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"request_review\") {\n const pullRequestNumber = input.target.pullRequestNumber;\n if (typeof pullRequestNumber !== \"number\") {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n message: \"request_review requires target.pullRequestNumber.\"\n };\n }\n const requested = await githubJsonBody<RequestedReviewersResponse>({\n target: input.target,\n fetchImpl,\n method: \"GET\",\n path: `/pulls/${pullRequestNumber}/requested_reviewers`\n });\n const existingReviewers = requestedReviewerLogins(requested);\n const existingTeamReviewers = requestedTeamReviewerNames(requested);\n const reviewers = input.operation.reviewers.filter((reviewer) => !existingReviewers.has(reviewer));\n const teamReviewers = input.operation.teamReviewers?.filter((reviewer) => !existingTeamReviewers.has(reviewer));\n if (reviewers.length === 0 && (!teamReviewers || teamReviewers.length === 0)) {\n return {\n intentId: input.operation.intentId,\n outcome: \"applied\",\n externalUri: `https://github.com/${input.target.owner}/${input.target.repo}/pull/${pullRequestNumber}`,\n message: \"Requested reviewers were already present; skipped GitHub notification retry.\"\n };\n }\n await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/pulls/${pullRequestNumber}/requested_reviewers`,\n body: {\n ...(reviewers.length ? { reviewers } : {}),\n ...(teamReviewers?.length ? { team_reviewers: teamReviewers } : {})\n }\n });\n return {\n intentId: input.operation.intentId,\n outcome: \"applied\",\n externalUri: `https://github.com/${input.target.owner}/${input.target.repo}/pull/${pullRequestNumber}`\n };\n }\n\n const issueNumber = input.target.issueNumber;\n if (typeof issueNumber !== \"number\") {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n message: \"GitHub issue mutation requires target.issueNumber.\"\n };\n }\n\n if (input.operation.kind === \"set_assignees\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"PATCH\",\n path: `/issues/${issueNumber}`,\n body: { assignees: input.operation.assignees }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"add_assignee\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/assignees`,\n body: { assignees: [input.operation.assignee] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"remove_assignee\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/assignees`,\n body: { assignees: [input.operation.assignee] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"replace_mapped_label\") {\n for (const label of input.operation.removeLabels) {\n await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/labels/${encodeURIComponent(label)}`,\n okStatuses: [200, 404]\n });\n }\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: [input.operation.label] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"add_label\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"POST\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: [input.operation.label] }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n if (input.operation.kind === \"remove_label\") {\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"DELETE\",\n path: `/issues/${issueNumber}/labels/${encodeURIComponent(input.operation.label)}`\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n }\n\n const externalUri = await githubJson({\n target: input.target,\n fetchImpl,\n method: \"PUT\",\n path: `/issues/${issueNumber}/labels`,\n body: { labels: input.operation.labels }\n });\n return { intentId: input.operation.intentId, outcome: \"applied\", externalUri };\n } catch (error) {\n return {\n intentId: input.operation.intentId,\n outcome: \"failed\",\n error: error instanceof Error ? error.message : String(error)\n };\n }\n}\n\nexport async function applyGitHubIssueMutationIntent(input: {\n target: GitHubIssueMutationTarget;\n intent: MutationIntent;\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome> {\n const compiled = compileGitHubIssueMutationIntent(input.intent, {\n ...(input.mappings ? { mappings: input.mappings } : {}),\n ...(input.targetKind ? { targetKind: input.targetKind } : {})\n });\n if (!compiled.ok) return compiled.outcome;\n return applyGitHubIssueMutationOperation({\n target: input.target,\n operation: compiled.operation,\n ...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {})\n });\n}\n\nexport async function applyGitHubIssueMutationIntents(input: {\n target: GitHubIssueMutationTarget;\n intents: MutationIntent[];\n mappings?: AdapterMutationMapping[];\n targetKind?: \"issue\" | \"pull_request\";\n fetchImpl?: FetchLike;\n}): Promise<ApplyIntentOutcome[]> {\n const outcomes: ApplyIntentOutcome[] = [];\n for (const intent of input.intents) {\n outcomes.push(\n await applyGitHubIssueMutationIntent({\n target: input.target,\n intent,\n ...(input.mappings ? { mappings: input.mappings } : {}),\n ...(input.targetKind ? { targetKind: input.targetKind } : {}),\n ...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {})\n })\n );\n }\n return outcomes;\n}\n","import { createHmac, randomUUID, timingSafeEqual } from \"node:crypto\";\nimport { serve } from \"@hono/node-server\";\nimport { createOpenTagClient } from \"@opentag/client\";\nimport { parseThreadActionCommand, type OpenTagEvent } from \"@opentag/core\";\nimport { Hono } from \"hono\";\nimport { normalizeGitHubIssueComment, normalizeGitHubPullRequestReviewComment } from \"./normalize.js\";\n\ntype GitHubActor = {\n id: number;\n login: string;\n};\n\ntype GitHubRepository = {\n name: string;\n private: boolean;\n owner: { login: string };\n};\n\nexport type GitHubIssueCommentPayload = {\n action?: string;\n comment: { id: number; body: string; html_url: string };\n issue: { html_url: string; comments_url: string; number: number };\n repository: GitHubRepository;\n sender: GitHubActor;\n installation?: { id: number };\n};\n\nexport type GitHubPullRequestReviewCommentPayload = {\n action?: string;\n comment: { id: number; body: string; html_url: string };\n pull_request: { html_url: string; number: number };\n repository: GitHubRepository;\n sender: GitHubActor;\n installation?: { id: number };\n};\n\nexport type GitHubThreadActionInput = {\n id: string;\n rawText: string;\n actor: {\n provider: \"github\";\n providerUserId: string;\n handle: string;\n };\n callback: {\n provider: \"github\";\n uri: string;\n threadKey: string;\n };\n metadata: Record<string, unknown>;\n};\n\nexport type GitHubWebhookAppInput = {\n webhookSecret: string;\n webhookPath?: string;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n};\n\nexport type GitHubIngressConfig = {\n webhookSecret: string;\n dispatcherUrl: string;\n dispatcherToken?: string;\n port?: number;\n hostname?: string;\n webhookPath?: string;\n};\n\nexport type GitHubIngressHandle = {\n url: string;\n webhookPath: string;\n server: ReturnType<typeof serve>;\n close(): Promise<void>;\n};\n\nexport function computeGitHubSignature(input: { webhookSecret: string; rawBody: string }): string {\n const digest = createHmac(\"sha256\", input.webhookSecret).update(input.rawBody).digest(\"hex\");\n return `sha256=${digest}`;\n}\n\nexport function verifyGitHubSignature(input: {\n webhookSecret: string;\n rawBody: string;\n signature: string;\n}): boolean {\n const expected = computeGitHubSignature(input);\n const expectedBuffer = Buffer.from(expected);\n const actualBuffer = Buffer.from(input.signature);\n return expectedBuffer.length === actualBuffer.length && timingSafeEqual(expectedBuffer, actualBuffer);\n}\n\nfunction parseJsonPayload(rawBody: string): unknown {\n try {\n return JSON.parse(rawBody);\n } catch {\n return null;\n }\n}\n\nasync function handleIssueCommentCreated(input: {\n payload: GitHubIssueCommentPayload;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n}): Promise<void> {\n if (input.payload.action && input.payload.action !== \"created\") return;\n if (parseThreadActionCommand(input.payload.comment.body) && input.submitThreadAction) {\n await input.submitThreadAction({\n id: `approval_github_comment_${input.payload.comment.id}`,\n rawText: input.payload.comment.body,\n actor: {\n provider: \"github\",\n providerUserId: String(input.payload.sender.id),\n handle: input.payload.sender.login\n },\n callback: {\n provider: \"github\",\n uri: input.payload.issue.comments_url,\n threadKey: `${input.payload.repository.owner.login}/${input.payload.repository.name}#${input.payload.issue.number}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.payload.repository.owner.login,\n repo: input.payload.repository.name,\n issueNumber: input.payload.issue.number,\n commentUrl: input.payload.comment.html_url\n }\n });\n return;\n }\n\n const event = normalizeGitHubIssueComment({\n id: String(input.payload.comment.id),\n commentBody: input.payload.comment.body,\n commentUrl: input.payload.comment.html_url,\n apiCommentsUrl: input.payload.issue.comments_url,\n issueUrl: input.payload.issue.html_url,\n issueNumber: input.payload.issue.number,\n owner: input.payload.repository.owner.login,\n repo: input.payload.repository.name,\n actorId: input.payload.sender.id,\n actorLogin: input.payload.sender.login,\n private: input.payload.repository.private,\n receivedAt: input.now(),\n ...(input.payload.installation ? { installationId: input.payload.installation.id } : {})\n });\n\n if (event) {\n await input.createRun(event);\n }\n}\n\nasync function handlePullRequestReviewCommentCreated(input: {\n payload: GitHubPullRequestReviewCommentPayload;\n createRun(event: OpenTagEvent): Promise<{ runId?: string }>;\n submitThreadAction?(action: GitHubThreadActionInput): Promise<unknown>;\n now(): string;\n}): Promise<void> {\n if (input.payload.action && input.payload.action !== \"created\") return;\n const owner = input.payload.repository.owner.login;\n const repo = input.payload.repository.name;\n if (parseThreadActionCommand(input.payload.comment.body) && input.submitThreadAction) {\n await input.submitThreadAction({\n id: `approval_github_pr_review_comment_${input.payload.comment.id}`,\n rawText: input.payload.comment.body,\n actor: {\n provider: \"github\",\n providerUserId: String(input.payload.sender.id),\n handle: input.payload.sender.login\n },\n callback: {\n provider: \"github\",\n uri: `https://api.github.com/repos/${owner}/${repo}/issues/${input.payload.pull_request.number}/comments`,\n threadKey: `${owner}/${repo}#${input.payload.pull_request.number}`\n },\n metadata: {\n repoProvider: \"github\",\n owner,\n repo,\n pullRequestNumber: input.payload.pull_request.number,\n commentUrl: input.payload.comment.html_url\n }\n });\n return;\n }\n\n const event = normalizeGitHubPullRequestReviewComment({\n id: String(input.payload.comment.id),\n commentBody: input.payload.comment.body,\n commentUrl: input.payload.comment.html_url,\n pullRequestUrl: input.payload.pull_request.html_url,\n apiCommentsUrl: `https://api.github.com/repos/${owner}/${repo}/issues/${input.payload.pull_request.number}/comments`,\n owner,\n repo,\n pullRequestNumber: input.payload.pull_request.number,\n actorId: input.payload.sender.id,\n actorLogin: input.payload.sender.login,\n private: input.payload.repository.private,\n receivedAt: input.now(),\n ...(input.payload.installation ? { installationId: input.payload.installation.id } : {})\n });\n\n if (event) {\n await input.createRun(event);\n }\n}\n\nexport function createGitHubWebhookApp(input: GitHubWebhookAppInput) {\n const app = new Hono();\n const webhookPath = input.webhookPath ?? \"/github/webhooks\";\n if (!webhookPath.startsWith(\"/\")) {\n throw new Error(\"GitHub webhook path must start with /.\");\n }\n\n app.post(webhookPath, async (c) => {\n const signature = c.req.header(\"x-hub-signature-256\");\n if (!signature) {\n return c.json({ error: \"missing_signature_header\" }, 401);\n }\n const rawBody = await c.req.text();\n if (!verifyGitHubSignature({ webhookSecret: input.webhookSecret, rawBody, signature })) {\n return c.json({ error: \"invalid_signature\" }, 401);\n }\n\n const eventName = c.req.header(\"x-github-event\");\n const payload = parseJsonPayload(rawBody);\n if (!payload || typeof payload !== \"object\") {\n return c.json({ error: \"invalid_json\" }, 400);\n }\n\n if (eventName === \"ping\") {\n return c.json({ ok: true });\n }\n if (eventName === \"issue_comment\") {\n await handleIssueCommentCreated({\n payload: payload as GitHubIssueCommentPayload,\n createRun: input.createRun,\n ...(input.submitThreadAction ? { submitThreadAction: input.submitThreadAction } : {}),\n now: input.now\n });\n return c.json({ ok: true });\n }\n if (eventName === \"pull_request_review_comment\") {\n await handlePullRequestReviewCommentCreated({\n payload: payload as GitHubPullRequestReviewCommentPayload,\n createRun: input.createRun,\n ...(input.submitThreadAction ? { submitThreadAction: input.submitThreadAction } : {}),\n now: input.now\n });\n return c.json({ ok: true });\n }\n\n return c.json({ ok: true, ignored: \"unsupported_event\" });\n });\n\n return app;\n}\n\nexport function startGitHubIngress(config: GitHubIngressConfig): GitHubIngressHandle {\n const dispatcherClient = createOpenTagClient({\n dispatcherUrl: config.dispatcherUrl,\n ...(config.dispatcherToken ? { pairingToken: config.dispatcherToken } : {})\n });\n const port = config.port ?? 3000;\n const hostname = config.hostname ?? \"127.0.0.1\";\n const webhookPath = config.webhookPath ?? \"/github/webhooks\";\n const server = serve({\n fetch: createGitHubWebhookApp({\n webhookSecret: config.webhookSecret,\n webhookPath,\n async createRun(event) {\n const runId = `run_${randomUUID()}`;\n const created = await dispatcherClient.createRun({ runId, event });\n return created.outcome === \"run_created\" ? { runId: created.run.id } : {};\n },\n async submitThreadAction(action) {\n await dispatcherClient.submitThreadAction(action);\n },\n now: () => new Date().toISOString()\n }).fetch,\n port,\n hostname\n });\n\n return {\n url: `http://${hostname}:${port}`,\n webhookPath,\n server,\n close() {\n return new Promise((resolve, reject) => {\n server.close((error?: Error) => {\n if (error) {\n reject(error);\n return;\n }\n resolve();\n });\n });\n }\n };\n}\n","import { parseOpenTagMention, type OpenTagEvent } from \"@opentag/core\";\nimport type { ContextPointer, OpenTagCommand, PermissionGrant, WorkItemReference } from \"@opentag/core\";\n\nexport type GitHubIssueCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n apiCommentsUrl: string;\n issueUrl: string;\n issueNumber: number;\n owner: string;\n repo: string;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nexport type GitHubPullRequestReviewCommentInput = {\n id: string;\n commentBody: string;\n commentUrl: string;\n pullRequestUrl: string;\n apiCommentsUrl: string;\n owner: string;\n repo: string;\n pullRequestNumber: number;\n actorId: number;\n actorLogin: string;\n private: boolean;\n receivedAt: string;\n installationId?: number;\n};\n\nfunction permissionsForIntent(intent: OpenTagCommand[\"intent\"]): PermissionGrant[] {\n const permissions: PermissionGrant[] = [\n {\n scope: \"issue:comment\",\n reason: \"reply to the source GitHub thread\"\n },\n {\n scope: \"runner:local\",\n reason: \"execute the run on a paired local daemon\"\n }\n ];\n if (intent === \"fix\" || intent === \"run\") {\n permissions.push(\n {\n scope: \"repo:read\",\n reason: \"inspect the repository in the paired local checkout\"\n },\n {\n scope: \"repo:write\",\n reason: \"commit code changes on an isolated run branch\"\n },\n {\n scope: \"pr:create\",\n reason: \"open a pull request for completed code changes\"\n }\n );\n }\n return permissions;\n}\n\nfunction permissionsForPullRequestReviewCommentIntent(intent: OpenTagCommand[\"intent\"]): PermissionGrant[] {\n const permissions = permissionsForIntent(intent);\n if (intent === \"review\") {\n permissions.push({\n scope: \"pr:update\",\n reason: \"request reviewers on the source pull request after explicit approval\"\n });\n }\n return permissions;\n}\n\nfunction contextPointersForCommand(command: OpenTagCommand, privateRepo: boolean): ContextPointer[] {\n const visibility = privateRepo ? \"private\" : \"public\";\n const context: ContextPointer[] = [];\n\n for (const reference of command.parsed?.references ?? []) {\n if (reference.kind === \"url\") {\n context.push({\n kind: \"url\",\n uri: reference.uri,\n visibility,\n title: reference.title ?? \"Command URL reference\"\n });\n continue;\n }\n\n if (reference.kind === \"file\" || reference.kind === \"path\" || reference.kind === \"line\" || reference.kind === \"range\") {\n context.push({\n kind: \"file\",\n uri: reference.uri,\n ...(reference.line ? { line: reference.line } : {}),\n ...(reference.startLine ? { startLine: reference.startLine } : {}),\n ...(reference.endLine ? { endLine: reference.endLine } : {}),\n visibility,\n title: referenceTitle(reference)\n });\n }\n }\n\n return context;\n}\n\nfunction referenceTitle(reference: NonNullable<OpenTagCommand[\"parsed\"]>[\"references\"][number]): string {\n return reference.title ?? \"Command file reference\";\n}\n\nfunction githubWorkItem(input: {\n owner: string;\n repo: string;\n kind: \"issue\" | \"pull_request\";\n number: number;\n uri: string;\n}): WorkItemReference {\n return {\n provider: \"github\",\n kind: input.kind,\n externalId: `${input.owner}/${input.repo}#${input.number}`,\n uri: input.uri,\n ownerContainer: {\n provider: \"github\",\n id: `${input.owner}/${input.repo}`,\n uri: `https://github.com/${input.owner}/${input.repo}`\n }\n };\n}\n\nfunction commandMetadata(command: OpenTagCommand): Record<string, unknown> {\n if (!command.parsed) return {};\n return {\n commandParser: command.parsed.version,\n commandDiagnostics: command.parsed.diagnostics,\n ...(command.parsed.approval ? { approval: command.parsed.approval } : {}),\n ...(command.parsed.network ? { network: command.parsed.network } : {})\n };\n}\n\nexport function normalizeGitHubIssueComment(input: GitHubIssueCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n const command = {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args,\n ...(mention.parsed ? { parsed: mention.parsed } : {})\n };\n\n return {\n id: `evt_github_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\",\n ...(mention.parsed?.executorHint ? { executorHint: mention.parsed.executorHint } : {})\n },\n command,\n context: [\n {\n provider: \"github\",\n kind: \"issue\",\n uri: input.issueUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n provider: \"github\",\n kind: \"comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n ...contextPointersForCommand(command, input.private)\n ],\n workItem: githubWorkItem({\n owner: input.owner,\n repo: input.repo,\n kind: \"issue\",\n number: input.issueNumber,\n uri: input.issueUrl\n }),\n permissions: permissionsForIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}#${input.issueNumber}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.owner,\n repo: input.repo,\n issueNumber: input.issueNumber,\n ...commandMetadata(command),\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n\nexport function normalizeGitHubPullRequestReviewComment(input: GitHubPullRequestReviewCommentInput): OpenTagEvent | null {\n const mention = parseOpenTagMention(input.commentBody);\n if (!mention.matched) return null;\n\n const command = {\n rawText: mention.rawText,\n intent: mention.intent,\n args: mention.args,\n ...(mention.parsed ? { parsed: mention.parsed } : {})\n };\n\n return {\n id: `evt_github_pr_review_comment_${input.id}`,\n source: \"github\",\n sourceEventId: input.id,\n receivedAt: input.receivedAt,\n actor: {\n provider: \"github\",\n providerUserId: String(input.actorId),\n handle: input.actorLogin\n },\n target: {\n mention: \"@opentag\",\n agentId: \"opentag\",\n ...(mention.parsed?.executorHint ? { executorHint: mention.parsed.executorHint } : {})\n },\n command,\n context: [\n {\n provider: \"github\",\n kind: \"pull_request\",\n uri: input.pullRequestUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n {\n provider: \"github\",\n kind: \"comment\",\n uri: input.commentUrl,\n visibility: input.private ? \"private\" : \"public\"\n },\n ...contextPointersForCommand(command, input.private)\n ],\n workItem: githubWorkItem({\n owner: input.owner,\n repo: input.repo,\n kind: \"pull_request\",\n number: input.pullRequestNumber,\n uri: input.pullRequestUrl\n }),\n permissions: permissionsForPullRequestReviewCommentIntent(mention.intent),\n callback: {\n provider: \"github\",\n uri: input.apiCommentsUrl,\n threadKey: `${input.owner}/${input.repo}#${input.pullRequestNumber}`\n },\n metadata: {\n repoProvider: \"github\",\n owner: input.owner,\n repo: input.repo,\n pullRequestNumber: input.pullRequestNumber,\n ...commandMetadata(command),\n ...(typeof input.installationId === \"number\" ? { installationId: input.installationId } : {})\n }\n };\n}\n","import { suggestedActionCandidatesFromResult, type OpenTagRunResult } from \"@opentag/core\";\n\nfunction nextActionSummary(result: OpenTagRunResult): string | undefined {\n if (!result.nextAction) return undefined;\n if (typeof result.nextAction === \"string\") return result.nextAction;\n return result.nextAction.summary;\n}\n\nfunction stringParam(params: Record<string, unknown> | undefined, key: string): string | undefined {\n const value = params?.[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction stringArrayParam(params: Record<string, unknown> | undefined, key: string): string[] {\n const value = params?.[key];\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.length > 0);\n}\n\nfunction renderVerificationParams(params: Record<string, unknown> | undefined): string[] {\n const value = params?.[\"verification\"];\n if (!Array.isArray(value)) return [];\n return value\n .map((item) => {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return undefined;\n const command = (item as Record<string, unknown>)[\"command\"];\n const outcome = (item as Record<string, unknown>)[\"outcome\"];\n const summary = (item as Record<string, unknown>)[\"summary\"];\n if (typeof outcome !== \"string\") return undefined;\n const prefix = typeof command === \"string\" && command.length > 0 ? `\\`${command}\\`: ${outcome}` : outcome;\n return typeof summary === \"string\" && summary.length > 0 ? ` - ${prefix} - ${summary}` : ` - ${prefix}`;\n })\n .filter((line): line is string => Boolean(line));\n}\n\nfunction renderSuggestedActionDetails(params: Record<string, unknown> | undefined, action: string): string[] {\n if (action !== \"create_pull_request\") return [];\n const lines: string[] = [];\n const title = stringParam(params, \"title\");\n const head = stringParam(params, \"head\") ?? stringParam(params, \"branch\");\n const base = stringParam(params, \"base\") ?? stringParam(params, \"baseBranch\");\n const changedFiles = stringArrayParam(params, \"changedFiles\");\n const risks = stringArrayParam(params, \"risks\");\n const verification = renderVerificationParams(params);\n if (title) lines.push(`- Title: ${title}`);\n if (head || base) lines.push(`- Branch: \\`${head ?? \"unknown\"}\\` -> \\`${base ?? \"main\"}\\``);\n if (changedFiles.length > 0) lines.push(`- Changed files: ${changedFiles.map((file) => `\\`${file}\\``).join(\", \")}`);\n if (risks.length > 0) {\n lines.push(\"- Risks:\");\n for (const risk of risks) {\n lines.push(` - ${risk}`);\n }\n }\n if (verification.length > 0) {\n lines.push(\"- Verification:\");\n lines.push(...verification);\n }\n return lines;\n}\n\nfunction renderSuggestedActions(result: OpenTagRunResult): string[] {\n const candidates = suggestedActionCandidatesFromResult(result);\n if (candidates.length === 0) return [];\n\n const lines = [\n \"### Suggested actions:\",\n \"\",\n \"Source-thread approval: choose one command in this GitHub thread to apply a protocolized mutation or PR action to the system of record.\"\n ];\n for (const candidate of candidates) {\n lines.push(\n \"\",\n `#### Action ${candidate.index}: ${candidate.intent.summary}`,\n \"\",\n `- System-of-record action: \\`${candidate.intent.action}\\` (\\`${candidate.intent.domain}\\`)`,\n `- Proposal: \\`${candidate.proposalId}\\``,\n `- Intent ID: \\`${candidate.intent.intentId}\\``\n );\n lines.push(...renderSuggestedActionDetails(candidate.intent.params, candidate.intent.action));\n if (candidate.proposalPreconditions?.length) {\n lines.push(\"- Preconditions:\");\n for (const precondition of candidate.proposalPreconditions) {\n lines.push(` - ${precondition}`);\n }\n }\n lines.push(\n \"\",\n \"**Approve in this thread**\",\n \"\",\n `| Decision | Comment command | Effect |`,\n `| --- | --- | --- |`,\n `| Apply now | \\`apply ${candidate.index}\\` | Applies this action to the system of record. |`,\n `| Approve only | \\`approve ${candidate.index}\\` | Records approval without applying yet. |`,\n `| Continue | \\`continue ${candidate.index}\\` | Starts a follow-up run from this proposal. |`,\n `| Reject | \\`reject ${candidate.index}\\` | Rejects this action. |`\n );\n }\n\n lines.push(\"\", \"Bulk shortcut: comment `apply all` to apply every supported approved action in this thread.\");\n return lines;\n}\n\nexport function renderAcknowledgement(runId: string): string {\n return `OpenTag picked this up. Run: \\`${runId}\\``;\n}\n\nexport function renderProgress(input: { runId: string; message: string }): string {\n return `OpenTag progress for \\`${input.runId}\\`: ${input.message}`;\n}\n\nexport function renderFinalResult(result: OpenTagRunResult): string {\n const lines = [`OpenTag finished with **${result.conclusion}**.`, \"\", result.summary];\n\n if (result.verification?.length) {\n lines.push(\"\", \"Verification:\");\n for (const check of result.verification) {\n lines.push(`- \\`${check.command}\\`: ${check.outcome}`);\n }\n }\n\n const nextAction = nextActionSummary(result);\n if (nextAction) {\n lines.push(\"\", `Next action: ${nextAction}`);\n }\n\n const suggestedActions = renderSuggestedActions(result);\n if (suggestedActions.length > 0) {\n lines.push(\"\", ...suggestedActions);\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAcO,SAAS,qBAAqB,QAAkC;AACrE,QAAM,QAAQ,CAAC,cAAc,IAAI,OAAO,OAAO;AAE/C,MAAI,OAAO,cAAc,QAAQ;AAC/B,UAAM,KAAK,IAAI,k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KAAK;AAAA,IACxC;AAAA,EACF;AAEA,QAAM,KAAK,IAAI,6FAA6F;AAC5G,SAAO;AACT;AAEO,SAAS,sBAAsB,OAAuB;AAC3D,SAAO,kCAAkC,KAAK;AAChD;AAEO,SAAS,eAAe,OAAmD;AAChF,SAAO,0BAA0B,MAAM,KAAK,OAAO,MAAM,OAAO;AAClE;AAEO,SAAS,kBAAkB,QAAkC;AAClE,QAAM,QAAQ,CAAC,2BAA2B,OAAO,UAAU,OAAO,IAAI,OAAO,OAAO;AAEpF,MAAI,OAAO,cAAc,QAAQ;AAC/B,UAAM,KAAK,IAAI,eAAe;AAC9B,eAAW,SAAS,OAAO,cAAc;AACvC,YAAM,KAAK,OAAO,MAAM,OAAO,OAAO,MAAM,OAAO,EAAE;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,aAAa,kBAAkB,MAAM;AAC3C,MAAI,YAAY;AACd,UAAM,KAAK,IAAI,gBAAgB,UAAU,EAAE;AAAA,EAC7C;AAEA,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,iBAAiB,SAAS,GAAG;AAC/B,UAAM,KAAK,IAAI,GAAG,gBAAgB;AAAA,EACpC;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":["externalUri","stringParam","stringArrayParam"]}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AA0F3F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAqBlE"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAsG3F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAqBlE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentag/github",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "GitHub event normalization and callback rendering for OpenTag.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@hono/node-server": "^1.13.7",
35
35
  "hono": "^4.6.15",
36
- "@opentag/client": "0.2.0",
37
- "@opentag/core": "0.2.0"
36
+ "@opentag/client": "0.3.0",
37
+ "@opentag/core": "0.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "tsup": "^8.3.5",