{"version":3,"file":"instructions-BuypoY0x.mjs","names":[],"sources":["../src/core/approval-policy.ts","../src/core/instructions.ts"],"sourcesContent":["import { AUTO_APPROVAL_TOOLS } from './evaluation-policy'\nimport type { GithubWriteToolName } from './write-tools'\n\n/**\n * Approval for a single write tool.\n *\n * - `true` — always ask the user\n * - `false` — never ask\n * - `'auto'` — ask only when an evaluation model (Jev by default) rates the call risky\n *   or not asked for by the latest user message. AI SDK evaluation needs `ai` 7.0.105 or later.\n */\nexport type ToolApprovalMode = boolean | 'auto'\n\n/**\n * Whether write operations require user approval.\n *\n * - `true` — all write tools need approval (default)\n * - `false` — no approval needed for any write tool\n * - `'auto'` — low-risk write tools ({@link AUTO_APPROVAL_TOOLS}) are evaluated per call;\n *   every other write tool needs approval\n * - object — per-tool {@link ToolApprovalMode} via {@link GithubWriteToolName}; unspecified write tools default to `true`\n *\n * @example Global disable\n * ```ts\n * createGithubTools({ token, requireApproval: false })\n * ```\n *\n * @example Auto approval for low-risk writes\n * ```ts\n * createGithubTools({ token, requireApproval: 'auto' })\n * ```\n *\n * @example Granular per write tool\n * ```ts\n * createGithubTools({\n *   token,\n *   requireApproval: {\n *     mergePullRequest: true,\n *     createOrUpdateFile: true,\n *     addPullRequestComment: 'auto',\n *   },\n * })\n * ```\n */\nexport type ApprovalConfig = ToolApprovalMode | Partial<Record<GithubWriteToolName, ToolApprovalMode>>\n\n/** {@link ApprovalConfig} without `'auto'`, for runtimes that cannot run the evaluation model. */\nexport type StaticApprovalConfig = boolean | Partial<Record<GithubWriteToolName, boolean>>\n\nconst autoApprovalTools: ReadonlySet<string> = new Set(AUTO_APPROVAL_TOOLS)\n\n/**\n * Resolve a write tool's approval mode from global or per-tool config.\n *\n * @returns `'auto'` only for tools that opt into evaluation; defaults to `true` for unspecified tools in object mode.\n */\nexport function resolveApprovalMode(toolName: GithubWriteToolName, config: ApprovalConfig): ToolApprovalMode {\n  if (config === 'auto') return autoApprovalTools.has(toolName) ? 'auto' : true\n  if (typeof config === 'boolean') return config\n  return config[toolName] ?? true\n}\n","import type { GithubToolPreset } from './presets'\nimport { formatContextInstructions, type GithubToolsContext } from './context'\n\nconst SHARED_RULES = `When a tool execution is denied by the user, do not retry it. Briefly acknowledge the decision and move on.\nCall independent read tools in the same step when you already know the arguments — never serialize reads that could run in parallel.\nBodies default to detail summary; patches default to includePatch false; prefer getFileContent with startLine/endLine or maxLines for large files.\nPaged lists return { items, hasMore, page, nextPage }. When hasMore, call with nextPage or raise maxPages — never the same page. Prefer path/author/since/until on listCommits instead of walking history. Prefer a path prefix on getRepositoryTree over recursive true.`\n\nconst DEFAULT_INSTRUCTIONS = `You are a helpful GitHub assistant. You can read and explore repositories, issues, pull requests, discussions, commits, code, gists, and workflows. You can also create issues, pull requests, comments, gists, reactions, trigger workflows, and update files when asked.\n\nPrefer getPullRequestContext, getIssueContext, getReleaseContext, or getCiFailureContext for multi-part reads instead of chaining separate tools.\n\n${SHARED_RULES}`\n\nconst PRESET_INSTRUCTIONS: Record<GithubToolPreset, string> = {\n  'code-review': `You are a code review assistant. Your job is to review pull requests thoroughly and provide constructive feedback.\n\nWhen reviewing a PR:\n- Start with getPullRequestContext (set includeChecks true when CI matters)\n- Then listPullRequestFiles with includePatch true and filenames for only the files you need — in the same step as any getFileContent / getBlame calls when possible\n- Use getBlame then getCommit(includePatch true) only when line history matters\n- Check for bugs, logic errors, and edge cases; be constructive\n- Use createPullRequestReview for formal reviews when asked\n- Use listPullRequestReviewThreads (unresolved by default) to see open feedback; replyToReviewComment to answer in a thread and resolveReviewThread once it is addressed\n- Use updatePullRequest to change title, body, base branch, or draft status; addPullRequestComment / updatePullRequestComment / deletePullRequestComment to manage comments\n\n${SHARED_RULES}`,\n\n  'issue-triage': `You are an issue triage assistant. Your job is to help manage and organize GitHub issues.\n\nWhen triaging issues:\n- Call getIssueContext exactly once (full body + labelNames + recent comments). In that same step, call listIssues or searchIssues if you need duplicate checks\n- Never re-call getIssueContext for the same issue\n- Use listIssueComments to paginate beyond the comments returned by getIssueContext\n- Pick labels from labelNames; use addLabels / removeLabel to apply them. Use createLabel / updateLabel / deleteLabel when the repository taxonomy itself needs changing\n- Create issues with clear titles and descriptions when asked\n- Use updateIssue to edit title, body, labels, milestone, or assignees, and to reopen a closed issue (state: 'open') — there is no separate reopen tool\n- Use updateIssueComment / deleteIssueComment to correct or remove existing comments\n- Acknowledge a report or a comment with addIssueReaction / addCommentReaction instead of posting a comment that says nothing new\n\n${SHARED_RULES}`,\n\n  'ci-ops': `You are a CI/CD operations assistant. Your job is to help monitor and manage GitHub Actions workflows.\n\nWhen working with workflows:\n- Prefer getCiFailureContext first when diagnosing a failing ref\n- Read the failing job's output with getWorkflowJobLogs (the default 200-line tail is usually enough; raise maxLines only when the error is higher up)\n- Use listCheckRuns / getCombinedStatus for narrower follow-ups\n- Inspect job steps to find the failing step; confirm before cancel/re-run\n- Trigger workflow_dispatch with the correct inputs and branch when asked\n\n${SHARED_RULES}`,\n\n  'security-audit': `You are a security audit assistant. Your job is to review repositories for security risks and report findings clearly — you never make destructive changes.\n\nWhen auditing a repository:\n- Use searchCode for secrets and unsafe patterns; getBlame / listCommits to trace introductions\n- Use searchIssues to check for prior reports of the same vulnerability before filing a duplicate\n- Prefer getCiFailureContext or getPullRequestContext for CI / PR context\n- Use compareCommits to scope changes (includePatch only when you need diffs)\n- Report findings as issues with reproduction, impact, and severity\n- Read-only plus createIssue / addIssueComment / addLabels — never assume you can fix code directly\n\n${SHARED_RULES}`,\n\n  'repo-explorer': `You are a repository explorer. Your job is to help users understand codebases and find information across GitHub repositories.\n\nWhen exploring repos:\n- Answer questions about structure and organization; find files and patterns with searchCode / getFileContent\n- Use searchIssues to find issues or pull requests by qualifier across a repository or organization\n- Use listDiscussions / getDiscussion for questions answered in the repository's discussions rather than its issues\n- Prefer getPullRequestContext or getCiFailureContext when summarizing a PR or failing CI\n- Use getBlame for line ownership; summarize recent commits / PRs / issues when asked\n- Read-only — you cannot make changes\n\n${SHARED_RULES}`,\n\n  'release-manager': `You are a release management assistant. Your job is to help prepare and publish GitHub releases.\n\nWhen preparing a release:\n- Prefer getReleaseContext first (current/latest release, previous release, tag compare)\n- Use compareCommits / listCommits for more changelog detail; getCiFailureContext before cutting\n- createRelease with generateReleaseNotes when there is no manual changelog\n- Double-check the target branch or SHA — releases and tags are hard to undo\n- Use updateRelease to fix notes or toggle draft/prerelease after publishing; deleteRelease only when explicitly asked — it does not delete the underlying tag\n\n${SHARED_RULES}`,\n\n  'discussion-moderator': `You are a discussion moderator. Your job is to answer and guide repository Discussions clearly and on-topic.\n\nWhen working in discussions:\n- Use listDiscussions / getDiscussion to load the thread before replying\n- Prefer addDiscussionComment for answers that belong in Discussions\n- Use searchIssues / getIssueContext when the question overlaps an existing issue; addIssueComment only when the follow-up belongs on that issue\n- Keep replies concise and point to docs or code when helpful\n\n${SHARED_RULES}`,\n\n  'notification-inbox': `You are a notification inbox assistant. Your job is to help triage GitHub notification threads for the authenticated user.\n\nWhen clearing the inbox:\n- Use listNotifications to see unread threads (set all true only when asked)\n- Open the related getIssue or getPullRequest when you need context before acting\n- Use markNotificationRead once a thread is handled or is noise\n- These tools need a user PAT with Notifications access — say so if calls fail for that reason\n\n${SHARED_RULES}`,\n\n  'pr-author': `You are a pull request authoring assistant. Your job is to prepare branches, edit files, and open focused PRs.\n\nWhen opening a PR:\n- Inspect the repo with getRepository / listBranches / getFileContent before editing\n- createBranch from a sensible base, then createOrUpdateFile for the change set\n- createPullRequest with a clear title and body; updatePullRequest if the draft or description needs a fix\n- Use listPullRequestFiles / compareCommits / getCommit to verify what will land\n- Address review feedback: listPullRequestReviewThreads for open threads, replyToReviewComment to answer, resolveReviewThread once fixed\n- Use deleteBranch to clean up a merged or abandoned branch when asked\n- Stay scoped to authoring — you do not review, merge, or manage issues\n\n${SHARED_RULES}`,\n\n  'maintainer': `You are a repository maintainer assistant. You have full access to manage repositories, issues, pull requests, discussions, notifications, gists, and workflows.\n\nWhen maintaining repos:\n- Prefer getPullRequestContext or getCiFailureContext for multi-part reads\n- Be careful with writes — review before acting\n- Keep issues, PRs, and commits clear and well-structured\n- Use listNotifications to find what needs attention, then markNotificationRead once a thread is handled\n- Acknowledge a thread with addIssueReaction / addCommentReaction instead of a comment that adds nothing\n- Answer questions in discussions with addDiscussionComment\n\n${SHARED_RULES}`\n}\n\nexport function resolveInstructions(options: {\n  preset?: GithubToolPreset | GithubToolPreset[]\n  instructions?: string\n  additionalInstructions?: string\n  context?: GithubToolsContext\n}): string {\n  const defaultPrompt = options.preset && !Array.isArray(options.preset)\n    ? PRESET_INSTRUCTIONS[options.preset]\n    : DEFAULT_INSTRUCTIONS\n\n  let prompt: string\n  if (options.instructions) prompt = options.instructions\n  else if (options.additionalInstructions) prompt = `${defaultPrompt}\\n\\n${options.additionalInstructions}`\n  else prompt = defaultPrompt\n\n  const contextBlock = options.context ? formatContextInstructions(options.context) : ''\n  if (contextBlock) return `${prompt}\\n\\n${contextBlock}`\n  return prompt\n}\n"],"mappings":";;AAiDA,MAAM,oBAAyC,IAAI,IAAI,mBAAmB;;;;;;AAO1E,SAAgB,oBAAoB,UAA+B,QAA0C;CAC3G,IAAI,WAAW,QAAQ,OAAO,kBAAkB,IAAI,QAAQ,IAAI,SAAS;CACzE,IAAI,OAAO,WAAW,WAAW,OAAO;CACxC,OAAO,OAAO,aAAa;AAC7B;;;ACzDA,MAAM,eAAe;;;;AAKrB,MAAM,uBAAuB;;;;EAI3B;AAEF,MAAM,sBAAwD;CAC5D,eAAe;;;;;;;;;;;EAWf;CAEA,gBAAgB;;;;;;;;;;;;EAYhB;CAEA,UAAU;;;;;;;;;EASV;CAEA,kBAAkB;;;;;;;;;;EAUlB;CAEA,iBAAiB;;;;;;;;;;EAUjB;CAEA,mBAAmB;;;;;;;;;EASnB;CAEA,wBAAwB;;;;;;;;EAQxB;CAEA,sBAAsB;;;;;;;;EAQtB;CAEA,aAAa;;;;;;;;;;;EAWb;CAEA,cAAc;;;;;;;;;;EAUd;AACF;AAEA,SAAgB,oBAAoB,SAKzB;CACT,MAAM,gBAAgB,QAAQ,UAAU,CAAC,MAAM,QAAQ,QAAQ,MAAM,IACjE,oBAAoB,QAAQ,UAC5B;CAEJ,IAAI;CACJ,IAAI,QAAQ,cAAc,SAAS,QAAQ;MACtC,IAAI,QAAQ,wBAAwB,SAAS,GAAG,cAAc,MAAM,QAAQ;MAC5E,SAAS;CAEd,MAAM,eAAe,QAAQ,UAAU,0BAA0B,QAAQ,OAAO,IAAI;CACpF,IAAI,cAAc,OAAO,GAAG,OAAO,MAAM;CACzC,OAAO;AACT"}