{"meta":{"title":"在不中断工作流程的情况下提交问题","intro":"当你在处理任务时注意到某个问题，可以使用 Copilot CLI 创建一个包含代码上下文、关联 PR 和标签的 GitHub issue，然后继续手头的工作。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/tutorials","title":"教程"},{"href":"/zh/copilot/tutorials/copilot-cookbook","title":"GitHub Copilot 指南"},{"href":"/zh/copilot/tutorials/copilot-cookbook/document-code","title":"文档编码"},{"href":"/zh/copilot/tutorials/copilot-cookbook/document-code/filing-issues-without-breaking-your-flow","title":"不中断流的文件问题"}],"documentType":"article"},"body":"# 在不中断工作流程的情况下提交问题\n\n当你在处理任务时注意到某个问题，可以使用 Copilot CLI 创建一个包含代码上下文、关联 PR 和标签的 GitHub issue，然后继续手头的工作。\n\nCopilot CLI可以从终端打开GitHub问题。 无需切换到浏览器并手动填写问题单，你只需描述你的需求，Copilot 就会从你的代码库和 GitHub 收集相关上下文，然后创建问题单，让你可以继续手头的工作。\n\n## 示例场景 1：由 CI 失败提交问题单\n\n你的 CI 运行失败了，或者你在生产日志中发现了错误。 与其手动顺着堆栈跟踪追溯到某次提交，不如让 Copilot CLI 为你调查并提报该问题。\n\n### 示例提示\n\n```text copy\nThe CI workflow on main has been failing since yesterday. Look at the failing \nrun, figure out what's breaking and which commit likely introduced it, then \ncreate an issue with the stack trace, a link to the failing run, and the \nsuspected PR that caused it. Label it \"bug\" and \"regression\".\n```\n\n### 示例响应\n\n> \\[!NOTE] 以下响应是示例。 Copilot Chat 的回答是不确定的，因此你可能会得到与这里所显示的不同的回答。\n\nCopilot CLI 使用其 GitHub MCP 工具来：\n\n1. **获取失败的工作流运行记录**，并从日志中提取堆栈跟踪。\n2. **标识负责任的代码** ，例如 `src/services/payment.ts:94`。\n3. **搜索最近修改该文件的提交**，并查找引入该更改的 PR。\n4. **创建问题**，并附上已整理好的全部上下文信息：\n\n   ```text\n   Created issue #421: Regression: PaymentService throws TypeError after #398\n\n   What's failing:\n   The `build` job on main has failed since commit `a3f7c21`. Stack trace:\n\n   TypeError: Cannot read properties of undefined (reading 'amount') at processRefund (src/services/payment.ts:94:22)\n\n   Introduced by: PR #398 (merged 2 days ago) refactored the payment types but missed updating `processRefund` to handle the new nullable `transaction` field.\n\n   Failing run: Actions run #2847\n\n   Suggested fix: Add a null check for `transaction` before accessing `transaction.amount` on line 94.\n\n   Labels: `bug`, `regression`\n   ```\n\n## 示例场景 2：将 TODO 转换为可跟踪的工作项\n\n随着时间的推移，TODO 和 FIXME 注释累积在代码库中，没有可见性。 可以要求 Copilot CLI 扫描这些注释、评估优先级并创建问题，以便跟踪工作。\n\n### 示例提示\n\n```text copy\nScan this repo for TODO and FIXME comments. Group them by area, pick the 5 \nmost important ones based on the surrounding code context, and create an issue \nfor each. Include the code snippet, file location, and suggest a label.\n```\n\n### 示例响应\n\n> \\[!NOTE] 以下响应是示例。 Copilot Chat 的回答是不确定的，因此你可能会得到与这里所显示的不同的回答。\n\nCopilot CLI 搜索代码库，读取每个注释的上下文，并根据严重性确定优先级：\n\n```text\nFound 23 TODO/FIXME comments across the repo. Here are the 5 I'd prioritize:\n\nCreated issue #422: FIXME: SQL injection risk in search query builder\n- src/db/search.ts:34 — user input concatenated directly into query string\n- Label: security, priority:high\n\nCreated issue #423: TODO: Rate limiter bypassed for internal routes\n- src/middleware/rate_limit.ts:12 — comment says \"temporary bypass, remove before launch\"\n- Label: security, technical-debt\n\nCreated issue #424: FIXME: Memory leak in WebSocket handler\n- src/ws/handler.ts:87 — listeners are added on each connection but never cleaned up\n- Label: bug, performance\n\nCreated issue #425: TODO: Retry logic missing for payment webhook\n- src/webhooks/payment.ts:56 — failures silently dropped, no retry queue\n- Label: reliability, priority:medium\n\nCreated issue #426: TODO: Migrate to new auth token format\n- src/auth/token.ts:3 — comment references a closing down API version\n- Label: technical-debt\n```\n\n## 延伸阅读\n\n* [GitHub Copilot CLI](/zh/copilot/how-tos/copilot-cli)"}