跳转到主要内容
在开始你的首次会话之前,请确保你已经为仓库建立索引完成设置。这些是帮助 Devin 理解并处理你的代码库的基础步骤。
现在你已经完成所有配置,可以开始你的第一个 Devin 会话了!本指南将带你逐步了解新的会话界面,并帮助你理解与 Devin 交互的最佳方式。

了解 Devin 会话页面

当你开始一个新会话时,你会看到两种主要模式:Ask 模式和 Agent 模式。
除非你已经有一个完整且明确的计划,否则我们建议先使用 Ask 模式,与 Devin 一起制定计划,然后再切换到 Agent 模式来执行该计划。

Ask 模式

Ask Devin 是一种轻量级模式,可用于在不修改实际代码的前提下,与 Devin 一起探索你的代码库并规划任务。使用 Ask 模式可以:
  • 了解你的代码是如何工作的
  • 探索架构和依赖项
  • 在实现之前规划任务并界定范围
  • 为 Agent 会话生成富上下文的提示
Ask Mode

触发 Ask 模式

你可以从主页面或 DeepWiki 页面触发 Ask 模式。 要在主页面使用 Ask 模式,切换到 Ask 模式并选择你想要提问的代码仓库。
Ask 模式(主页面)
要在 DeepWiki 页面使用 Ask 模式,在页面底部的聊天输入框中输入你的问题并点击 Ask。Devin 的 Knowledge 将会自动限定在该代码仓库范围内。
Ask 模式(DeepWiki 页面)
在我们的 Ask Devin 指南中了解更多信息。 一旦你已与 Devin 一起理解了问题并制定了计划,就可以切换到 Agent 模式了。

Agent 模式

Agent 模式是 Devin 的完全自主模式,在该模式下它可以编写代码、运行命令、浏览网页,并端到端完成复杂任务。 当你准备:
  • 实现功能或修复 bug
  • 创建 pull request
  • 运行测试并调试问题
  • 执行需要修改代码的多步骤任务
时,请使用 Agent 模式。

触发 Agent 模式

你可以在主页面或 Ask Devin 会话中进入 Agent 模式。 对于范围尚未完全明确的任务,我们建议:
  • 先使用 Ask 模式 来规划任务
  • 构建 Devin Prompt,它会基于你的 Ask 会话生成一个范围清晰的计划
  • 点击 Send to Devin 切换到 Agent 模式并执行任务
该流程如下所示:
Ask Mode to Agent Mode
若要从主页面进入 Agent 模式,将模式切换到 Agent,并选择你要处理的一个或多个代码仓库。
Agent Mode
启动 Agent 会话时,你需要配置几个选项:选择代码仓库,以及选择一个 Agent。

选择代码仓库

选择你希望 Devin 使用的代码仓库。点击仓库选择器,可以查看所有已添加到 Devin 运行环境中的仓库
Repository Selector
选择代码仓库可以确保 Devin:
  • 能访问你的代码库并进行修改
  • 使用正确的分支作为起点
  • 能向正确的仓库创建 pull request

选择 Agent

你可以选择 Devin 在本次会话中使用哪种 agent 配置。不同的 agent 可能具备不同的能力,或针对特定类型的任务进行了专项优化。 目前,我们提供了一个适用于大多数任务的默认 agent,以及一个名为 Dana、专门为数据分析任务优化的数据分析 agent。
Agent Selector
如果你不确定该使用哪个 agent,默认 agent 通常可以很好地完成大多数任务。

使用 @ 提及

使用 @ 提及为 Devin 提供关于文件、代码库或其他资源的特定上下文。当你在聊天输入框中键入 @ 时,你会看到一个可用提及项的下拉列表:
  • @Repos - 引用特定代码仓库
  • @Files - 引用代码库中的特定文件
  • @Macros - 引用某个 Knowledge 条目对应的宏
  • @Playbooks - 引用团队或社区的 playbook(操作手册),这些是详细的提示模板,可用于引导 Devin 的行为。
  • @Secrets - 从 Devin 的会话管理器中引用某个特定机密(例如 API key、凭证等)
At Mentions
@ 提及可以帮助 Devin 准确理解你正在处理的内容,并减少提示中的歧义。

使用斜杠命令

斜杠命令是会展开为预定义提示模板的快捷指令。在聊天输入框中输入 / 即可查看所有可用命令:
  • /plan - 让 Devin 帮你拆解并规划任务范围
  • /review - 设置代码评审工作流
  • /test - 创建测试或分析测试覆盖率
  • /think-hard - 让 Devin 更深入地思考复杂问题
  • /implement - 实现特定功能或改动
Slash Commands
Enterprise 组织还可以根据团队特定的工作流创建自定义斜杠命令。详情请参见我们的斜杠命令指南

为你的首次会话确定范围

先从范围较小的任务开始,并且记得像指导一位人类初级工程师那样,向 Devin 提供同样详细的说明。我们看到用户与 Devin 合作完成的任务非常广泛,从修复小 bug,到定向重构,再到大规模迁移。

首次使用的提示词示例

a new API endpoint
创建一个新的 API 端点 /users/stats,返回一个包含用户数量和平均注册年龄的 JSON 对象。 

使用我们在 PostgreSQL 中现有的 users 表。 

可以参考 statsController.js 中的 /orders/stats 端点,了解我们如何构造响应。 

确保新端点纳入 StatsController.test.js 测试套件的覆盖范围。
frontend features
在 UserProfileComponent 中添加一个下拉菜单,用于显示用户角色列表(admin、editor、viewer)。 

使用 DropdownBase 的样式。 

当选择某个角色时,调用现有的 API 来设置用户角色。 

通过检查所选角色是否更新了数据库中的用户角色来进行验证。请参考你的 Knowledge,了解如何正确进行测试。
为 AuthService 的 login 和 logout 方法添加 Jest 测试。 

确保这两个函数的测试覆盖率至少为 80%。 

使用 UserService.test.js 作为示例。

实现完成后,运行 `npm test -- --coverage`,并确认覆盖率报告中这两个函数的覆盖率均超过 80%。 

同时确认在凭据有效和无效两种情况下测试都能通过,并且 logout 能正确清除会话数据。
将 logger.js 从 JavaScript 迁移到 TypeScript。 

我们已经有用于校验的 tsconfig.json 和 LoggerTest.test.js 测试套件。 

确保编译无错误,并且不要修改现有配置!

迁移完成后,请通过以下方式验证: 
1) 运行 `tsc`,确认没有类型错误
2) 运行 `npm test LoggerTest.test.js`,确保所有测试通过
3) 检查代码库中所有现有的 logger 方法调用,确认它们仍然可以正常工作且没有类型错误。
unit tests
我们正在从 pg 迁移到 sequelize(参见 https://sequelize.org/api/v6/identifiers)。 

请将 UserModel 中的查询更新为使用 Sequelize 方法。 

可以参考本代码库中的 OrderModel,了解我们的具体实现方式。

实现完成后,请按以下步骤进行验证:
1) 运行 `npm run test:integration UserModel.test.js`,确认所有集成测试通过
2) 在包含 1000 个用户的测试数据集上检查执行时间,确认查询性能没有下降
3) 运行 `npm run test:e2e user-flows.test.js`,验证所有 CRUD 操作仍然能够保证数据完整性
Quick PR
    ## Overview
    The task is to make a quick pull request to a repository.
    Since this is a 'quick' PR, you will not need to run any code or test anything; simply make a PR and the user will handle the testing. Your only responsibility is reading and writing code.

    ## What's Needed From User
    - 用于创建 PR 的代码仓库

    ## Procedure
    ### Prepare your workspace
    1. Navigate to the relevant repository on your machine (clarify with the user if you can't figure it out).
        - Check out the main branch and note down the name of the main branch.
        - Checkout to a new branch since you'll be making a pull request. The name of the branch has to be of the format `devin/<your-branch-name>/X` where X is a random number. For example `devin/fix-popup/3234`. Run `git remote -v && git pull && git checkout -b devin/{branch-name}/$RANDOM` and replace `{branch-name}` with the name of the branch you want to create.
    2. Study the request, codebase, and plan out the changes
        - Review the most relevant files and code sections, identifying relevant snippets.
        - Inform the user of your plan
    ### Work on the PR itself
    3. Make the code changes
        - Don't change anything that wasn't specifically requested by the user
    4. Make the PR
        - Commit and push the changes and tell the user.
        - See advice section for the exact command to make the PR
        - Make a pull request & review the pr to make sure it looks OK.
        - Ensure all GitHub actions pass successfully & make necessary changes until they do
        - Send the PR link to the user and summarize what you changed.
    5. Address any feedback from the review; send the PR link again every time you make any changes
        - If you need to make updates, just push more commits to the same branch; don't create a new one


    ## Task Specification
    - PR link is included in your messages to the user
    - PR was reviewed after creation
    - PR does not include any stray changes
    - PR does not change anything that wasn't specifically requested by the user
    - PR description should include a summary of the changes, formatted as a checklist
    - PR description should mention that the code was written without testing, and include - [ ] Test the changes as an item
    - PR description should include the following footer: "This PR was written by [Devin](https://devin.ai/) :angel:"
    - PR description should include any metadata that the user has provided (e.g. linear ticket tags in the appropriate syntax)
    - PR description should not be malformatted (use --body-file instead of --body if the newlines are garbled!)

    ## Forbidden Actions
    - Do NOT try to access github.com through the browser, you will not be authenticated.
    - NEVER force push on branches! Prefer merging over rebasing so that you don't lose any work.
    - Do NOT push directly to the main branch.

    ## Advice and Pointers
    - Double check the name of the main branch (which could be `main` or `master`) using `git branch`.
    - For repos with CI/CD on github actions, you can check build logs using the gh cli. if you're asked to fix a build/fix lint, you should start by looking at recent build logs
    - Check `git status` before committing or adding files.
    - Use `git diff` to see what changes you have made before committing.
    - If you're updating an existing repo, use `gh cli` to make pull requests.
    - Send the PR link to the user every time you update & ask them to re-review so that it's convenient for them
    - You should already be authorized to access any repositories the user tells you about. If not, ask the user for access.
如果你想进一步了解 Devin 能做什么以及如何实现这些能力,请查看下方入门 教程

后续步骤

当你已经熟悉基础会话后,可以进一步查看以下资源,以更高效地使用 Devin: