AACWorkflow Docs

依赖更新智能体

连续扫描过时的 npm 包、安全漏洞和破坏性变更。自动提议带有升级路径和风险摘要的 PR。

保持依赖项最新对于安全性和稳定性至关重要,但手动跟踪很繁琐。安全公告、新的主要版本和传递依赖项更新堆积很快。

一个依赖更新智能体监控你的包注册表,检测漏洞和过时的包,评估升级安全性,并打开带有清晰风险评估的 PR。

智能体的功能

按照每周的计划,依赖智能体会:

  1. 扫描依赖 — 运行 npm audityarn auditpnpm audit 找到漏洞和过时包
  2. 按风险过滤 — 将 patch/minor 更新与可能导致问题的主要版本分开
  3. 评估破坏性变更 — 检查 changelog 和 GitHub 发布以了解破坏性变更
  4. 测试升级 — 对更新的依赖运行你的测试套件
  5. 提议 PR — 创建分组的 PR(一个用于例行更新,一个用于安全,每个主要 bump 一个)并附带风险摘要
  6. 跟踪风险分数 — 在 PR 描述中包括 CVE 严重性、采纳率和发布稳定性

设置

前提条件

  • 具有活跃智能体的 AACWorkflow 工作区
  • 你的仓库中配置了 npm、yarn 或 pnpm
  • 运行测试的 CI/CD 管道(GitHub Actions、Buildkite 等)

步骤 1:创建依赖更新智能体

  1. 转到 Settings → Agents 并单击 New Agent
  2. 选择你的运行时和提供商
  3. 将其命名为 dependency-botupgrade-manager
  4. 添加这个系统提示
Role: Dependency update manager
Task: Weekly or on-demand:
1. Run npm/yarn/pnpm audit to find vulnerabilities and outdated packages
2. Separate findings:
   - Critical/high CVEs → immediate branch
   - Patch & minor updates → routine maintenance branch
   - Major version updates → per-package branches (evaluate breaking changes)
3. For each major update:
   - Check GitHub releases for breaking changes
   - Run full test suite with updated version
   - Report pass/fail and any deprecation warnings
4. Create GitHub branches and PRs grouped by risk tier
5. Add detailed PR description with:
   - Vulnerability CVE-IDs and severity (CVSS score if available)
   - Changelog highlights
   - Test results summary
   - "⚠️ This is a major version bump" flag for breaking updates

Example PR title format:
- "deps: security updates (npm audit)" → patch updates, no breaks
- "deps: urgent | CVE-2025-1234 (critical)" → security hot-fix
- "deps: major | react@19 + breaking changes" → major version bump

5. Auto-request code review from team (post in Slack/Teams)
6. Link PRs to AACWorkflow issues for tracking

步骤 2:计划智能体

转到 Settings → Automations 并创建计划任务:

  • Trigger: 每周(例如,星期四上午 10 点)
  • Task: 分配给 dependency-bot 智能体
  • Template: dependency-update

或使用 cron 任务:

# 每个星期四上午 10 点
0 10 * * 4 curl -X POST https://aacworkflow.com/api/tasks \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"agent_id": "dependency-bot", "title": "Weekly dependency scan"}'

步骤 3:配置审计规则

添加 .aacworkflow/dependency-config.yml

dependency_audit:
  package_managers:
    - npm
    - pnpm
  auto_merge:
    enabled: true
    conditions:
      - type: patch
        only_if: all_tests_pass
      - type: minor
        only_if: all_tests_pass_and_no_deprecation_warnings
      - type: major
        only_if: manual_approval
  
  skip_packages:
    - react       # pin in package.json, don't auto-update
    - react-dom
    - expo        # mobile pinned
  
  priority:
    critical_cve: "auto-merge if tests pass"
    high_cve: "create PR, notify team"
    medium_cve: "batch with weekly update"
    patches: "batch with weekly update"

  notification:
    slack_channel: "#dependencies"
    mention_on_critical: "@security-team"

示例 PR 输出

例行更新(patch + minor)

Title: deps: routine updates (3 packages)

Body:

## Changes

- chalk 5.3.0 → 5.4.1 (patch)
- lodash-es 4.17.21 → 4.18.0 (minor)
- ts-node 10.9.1 → 10.9.2 (patch)

All changes are backwards compatible. Tests: ✅ PASS (1200 tests in 42s)

---
**Risk:** Low | No deprecation warnings | Routine maintenance
Merging this is safe.

安全更新(高 CVE)

Title: deps: urgent | CVE-2025-1234 (high) in express

Body:

## Vulnerability

**express 4.18.0 → 4.19.5** (patch)

⚠️ **CVE-2025-1234** — Request header parsing DoS
- CVSS Score: 7.5 (High)
- Affected: express < 4.19.5
- Fix: Backport in patch release

https://nvd.nist.gov/vuln/detail/CVE-2025-1234

## Action

This is a security patch with no breaking changes.

Tests: ✅ PASS (1200 tests in 40s)
No deprecation warnings.

---
**Risk:** Low (security patch only)
✅ Safe to merge immediately. Recommend merging today.

主要版本更新(破坏性变更)

Title: deps: major | typescript@5.6 (from 5.5)

Body:

## Breaking Changes

**typescript 5.5.4 → 5.6.0** (major)

### Highlights
- Stricter null checking (new flag)
- Removed deprecated `ts.transpileOnly` option
- New `verbatimModuleSyntax` requirement for type imports

### Migration Required

Files needing updates:
- `tsconfig.json`: set `verbatimModuleSyntax: true`
- 3 files with bare `import type` → add `type` keyword

## Test Results

Typecheck: ⚠️ 12 errors (migration required) Unit tests: ⛔ FAIL (due to typecheck failures) E2E: ⛔ SKIP (blocked by typecheck)


This PR is in **DRAFT** mode. Required steps to merge:
1. Fix tsconfig.json
2. Update import statements
3. Re-run tests (target: all green)
4. Get code review from @backend-lead

---
**Risk:** Medium | Requires migration | Recommend 1–2 day sprint

提示和最佳实践

按风险分开。 将例行补丁分组,批量安全更新,并将主要版本视为单独的项目。不要用单个 50 文件的 PR 让你的团队不堪重负。

  • 在提议前测试 — 针对更新的依赖运行完整的测试套件;只有在测试通过或失败明显是预先存在的情况下才打开 PR
  • 传递依赖 — 使用 npm audit fix --audit-level=moderate 自动应用安全的传递依赖更新
  • 锁定文件策略 — 提交锁定文件;在合并前运行测试以捕获细微的破坏性变更
  • 安全第一 — 如果存在关键 CVE,请当天打开 PR;不要与例行更新打包
  • 弃用警告 — 在 PR 中捕获 npm list 弃用输出;规划删除时间表
  • 团队通知 — 立即在 Slack/Teams 中发布高严重性 PR;不要等待每周摘要

相关指南