> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 每周依赖项更新 PR

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="每周依赖更新 PR" description="安排每周一次 Devin 会话，查找过时的依赖包、运行测试并创建升级 PR。" prompt="检查是否有过时的 npm 依赖包。将所有补丁版和次要版本的更新合并在一个 PR 中——运行测试套件，并附上一张列出所有变更的表格。对于任何主版本升级，为其单独创建 PR，并附上从变更日志中摘录的破坏性变更说明。" category="自动化" features="计划" type="schedule" />

<div className="uc-detail-wrapper">
  <Tip>不想手动配置？将本页链接粘贴到 Devin 会话中，让它为你完成所有设置。</Tip>

  <Steps>
    <Step title="创建每周计划">
      打开 [app.devin.ai](https://app.devin.ai/?utm_source=docs\&utm_medium=use-case-gallery) 并前往 **Settings > Schedules**。点击 **Create schedule** 并按如下配置：

      * **Frequency：** Weekly——例如，每周一 UTC 时间早上 7:00 (`0 7 * * 1`)
      * **Prompt：** 粘贴下面的依赖更新提示词

      <PromptBlock type="schedule">
        ```txt Weekly dependency update prompt theme={null}
        检查 acme/frontend 仓库中是否存在过时的 npm 包。对于每个包：
        1. 将所有补丁版本和次要版本一起在单个 PR 中更新。
           运行完整测试套件，并附上一张变更摘要表。
        2. 对于每个主版本升级，单独创建一个 PR，并包含：
           - 来自该软件包变更日志的重大变更摘要
           - 为保持兼容性所需的任何代码修改
           - 更新后的 lockfile
        3. 运行 `npm audit` 并标记任何存在已知漏洞的软件包。
        ```
      </PromptBlock>

      如果你使用了关于团队如何处理依赖升级的 [Playbook](/zh/product-guides/creating-playbooks) (例如，更新后总是运行 `npm run build`，或跳过 `devDependencies`) ，请将其附加到该计划上，这样每次运行都会遵循同样的流程。
    </Step>

    <Step title="添加 Knowledge 以引导更新">
      并不是每个包都应该自动更新。前往 **Settings > Knowledge**，添加条目，告诉 Devin 哪些需要跳过或谨慎处理：

      * `Do not update react past v18 — we're mid-migration to v19 on a separate branch.`
      * `Always pin @types/node to match our Node.js version (20.x).`
      * `Skip eslint-plugin-import — it conflicts with our custom lint config.`
      * `Our test command is npm run test:ci, not npm test.`

      这些 [Knowledge](/zh/product-guides/knowledge) 条目会在每次按计划运行时持续生效，因此 Devin 会始终遵守你的约束，而无需你在提示词中反复重复。
    </Step>

    <Step title="审查 Devin 的交付结果">
      每周一，Devin 会检查你的仓库中是否有过时的包，并代表你创建 PR。典型的一周可能会产生：

      **PR #1 —— 安全更新 (补丁 + 次要版本) ：**

      ```
      ## Dependency Updates — Week of Feb 10

      | Package         | From    | To      | Type  |
      |-----------------|---------|---------|-------|
      | axios           | 1.6.2   | 1.6.8   | patch |
      | react-query     | 5.17.0  | 5.22.1  | minor |
      | tailwindcss     | 3.4.1   | 3.4.6   | patch |
      | typescript      | 5.3.3   | 5.3.5   | patch |

      All 847 tests passing. No vulnerabilities found by npm audit.
      ```

      **PR #2 —— 主版本升级 (单独 PR，附说明) ：**

      ```
      ## Major Update: zod 3.x → 4.0.0

      Breaking changes (from CHANGELOG):
      - `z.object().strict()` is now the default behavior
      - `z.enum` requires at least one value
      - Removed deprecated `.check()` method

      Code changes in this PR:
      - Updated 3 schema files to remove explicit `.strict()` calls
      - Added fallback value to empty enum in src/schemas/status.ts
      ```

      Devin 会对每个 PR 独立运行你的测试套件，因此你可以立即合并安全更新批次，并花时间审查主版本升级。
    </Step>

    <Step title="迭代并扩展">
      当你的每周计划开始稳定运行后，你可以逐步优化它。回复任意一次计划会话，为 Devin 提供后续指令：

      <PromptBlock>
        ```txt Handle a major update theme={null}
        继续推进 zod 从 v3 到 v4 的迁移。查看迁移指南：
        https://zod.dev/v4 并据此更新所有 schema 文件。
        ```
      </PromptBlock>

      <PromptBlock>
        ```txt Expand to backend deps theme={null}
        同时检查 acme/backend 仓库中使用 pip 管理的过时 Python 包。
        更新所有兼容版本并创建单独的 PR。在提交前运行 pytest。
        ```
      </PromptBlock>

      **让流程更顺畅的技巧：**

      * **前后端分开** —— 如果你的仓库同时包含前端和后端，请创建两个计划，这样每个 PR 都能保持聚焦、便于审查。
      * **在合并前让 CI 完整运行** —— 即便看起来安全的次要版本更新，也可能引入隐蔽 bug。Devin 会运行你的测试，但你完整的 CI 流水线能够再提供一层信心保障。
      * **查看 [Schedules](/zh/product-guides/scheduled-sessions) 页面** 来监控运行历史、在代码冻结期间暂停某个计划，或调整 cron 表达式。
    </Step>
  </Steps>
</div>
