lean-update

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

lean-update

lean-update

The script (
lean-agents
,
scripts/lean.mjs
) is the only thing that changes files: deterministic, tested, undone by
--uninstall
. You are the middleware: detect, ask, run it, read it back. Change nothing before the user says yes.
Run the script with
npx -y lean-agents@<version> <flags>
(the latest release version, below). Without npm access or Node.js 22.20+, use the fallback bootstrap. It checks git and Node.js the way the README does (
install.sh
offers
brew install
only with Homebrew, asks first, else stops with a link;
install.ps1
uses
winget
), then downloads that release and checks its SHA256:
curl -fsSL https://github.com/estebanmr99/lean-agents/releases/download/<tag>/install.sh | bash -s -- <flags>
. In a clone,
node scripts/lean.mjs ...
works too. Use the latest release tag:
gh release view --repo estebanmr99/lean-agents --json tagName -q .tagName
.
  1. Read the release. Fetch
    core/pins.json
    at that tag from
    https://raw.githubusercontent.com/estebanmr99/lean-agents/<tag>/
    . Then read every release between the installed lean-agents version (
    version
    in
    state.json
    ; for a hand install, ask or say it is unknown and read from the oldest release you can match) and the latest:
    gh release view <tag> --repo estebanmr99/lean-agents --json body -q .body
    , and the matching
    CHANGELOG.md
    sections. A pin's
    note
    adds to the impact.
    • Start your answer with the breaking changes and upgrade steps from those notes, before any table.
    • The notes mention OpenCode 2: say that upgrading OpenCode is the user's own step (lean-agents never upgrades it), and that before it they should back up the OpenCode data folder (
      opencode.db
      ) and config; see "Staying on OpenCode 1.x" in
      docs/compatibility.md
      . This skill never runs the OpenCode upgrade.
    • A release with no clear "Upgrade" or "Breaking" notes: say so in plain words, and put "none in the release notes" in the table.
  2. Detect.
    • ~/.config/lean-agents/state.json
      exists (or
      --doctor --json
      works): run
      --doctor --json
      . Its
      behind
      list is what is older than the pins.
    • No
      state.json
      (installed by hand): run the read-only commands in "Detect what is installed" in
      docs/manual-install.md
      to learn which agents and tools are there. Say that this install has no state yet and that the script will take it over without overwriting user files.
  3. Dry run as JSON, with the script.
    • With state:
      --update --dry-run --yes --json
      .
    • Without state:
      --dry-run --yes --json --agents <detected> --tools <detected>
      . The JSON lists files, commands (exact
      npx
      /
      brew
      lines, all pinned) and, on update,
      behind
      .
  4. Show one table in plain words:
    tool | installed | pinned | impact | upgrade notes | what it would run
    . Installed comes from
    behind
    or the detection; impact from step 1 ("not in the changelog" when it is not); upgrade notes from the releases in step 1 ("none in the release notes" when there are none); what it would run from the JSON
    commands
    . Then ask: "Update these N tools?" Stop on no.
  5. Back up only what changes, then run. One backup folder in the OS temp directory holding the files the JSON says will change (paths start with
    ~
    : expand them to full paths first) and that the engine does not already restore. This snippet is proven in bash only; its embedded quotes are untested on PowerShell 5.1, so on Windows PowerShell save the same JavaScript to a
    .js
    file in the temp folder and run
    node <file> <path1> <path2>
    instead. It prints the folder and copies each path in as
    <n>-<name>
    :
    node -e "const fs=require('fs'),os=require('os'),p=require('path');const d=fs.mkdtempSync(p.join(os.tmpdir(),'lean-agents-backup-'));process.argv.slice(1).forEach((f,i)=>{if(fs.existsSync(f))fs.cpSync(f,p.join(d,i+'-'+p.basename(f)),{recursive:true})});console.log(d)" <path1> <path2>
    . Then run the same flags without
    --dry-run
    :
    --update --yes
    , or
    --yes --agents ... --tools ...
    . Stop at the first failure and report it.
  6. Read it back. Run
    --doctor --json
    . When
    ok
    is true and
    behind
    is empty, delete the backup folder (same PowerShell 5.1 caveat: use a
    .js
    file there) with
    node -e "require('fs').rmSync(process.argv[1],{recursive:true,force:true})" <folder>
    and tell the user it is gone and that
    --uninstall
    still undoes everything. When it is not, keep the backup, say where it is, and offer to restore.
    • Hand-off: if this lean-agents release offers the finish-step summary page (#181), tell the user it exists and offer to open it after they agree; the page lists what was updated, kept and skipped and the logins still needed. If this release has no such page, skip this and go to step 8.
  7. Share findings (optional). Only if you found a problem or an improvement (a failed command, a tool the detection cannot see, a missing changelog note):
    • Never offer under
      --privacy strict
      ,
      --network off
      or
      --outbound off
      . Read the saved preset from
      state.json
      ; with no state, ask once whether outbound calls are allowed.
    • Ask: "Draft a redacted issue for lean-agents?" Stop on no.
    • lean-agents --feedback-draft --feedback-kind update --failed-command "<tool>" --network on
      with the details on stdin (bash:
      < details.txt
      ; PowerShell:
      Get-Content details.txt | npx -y lean-agents@<version> ...
      ).
      {"offer": false}
      means stop.
    • Duplicates:
      gh issue list --repo estebanmr99/lean-agents --search "<title words>"
      . If one matches, show it and stop.
    • Show the full draft. Only after a yes:
      gh issue create --repo estebanmr99/lean-agents --title "<title>" --body-file <draft>
      .
  8. Report: old -> new per tool, what you verified (
    --doctor --json
    ), what is left for the user.
脚本(
lean-agents
、
scripts/lean.mjs
)是唯一会修改文件的部分:行为确定、经过测试,并可通过
--uninstall
撤销。你负责充当中间层:执行检测、询问用户、运行脚本并回读结果。在用户同意前不要做任何更改。
使用
npx -y lean-agents@<version> <flags>
运行脚本(使用下文给出的最新 release 版本)。如果无法访问 npm 或 Node.js 版本低于 22.20+,则使用 fallback bootstrap。它会按照 README 中的方式检查 git 和 Node.js(
install.sh
仅在已安装 Homebrew 时提供
brew install
,并会先询问;否则停止并给出链接;
install.ps1
使用
winget
),随后下载该 release 并校验其 SHA256:
curl -fsSL https://github.com/estebanmr99/lean-agents/releases/download/<tag>/install.sh | bash -s -- <flags>
。在 clone 中,也可以运行
node scripts/lean.mjs ...
。使用最新 release tag:
gh release view --repo estebanmr99/lean-agents --json tagName -q .tagName
。
  1. 读取 release。 从
    https://raw.githubusercontent.com/estebanmr99/lean-agents/<tag>/
    获取该 tag 对应的
    core/pins.json
    。然后读取已安装的 lean-agents 版本(
    state.json
    中的
    version
    ;对于手动安装,先询问,若无法确定则说明版本未知,并从能够匹配的最早 release 开始读取)与最新版本之间的每个 release:
    gh release view <tag> --repo estebanmr99/lean-agents --json body -q .body
    ,以及
    CHANGELOG.md
    中对应的章节。某个 pin 的
    note
    会补充说明其影响。
    • 回答时,先给出这些说明中的 breaking changes 和升级步骤,然后再展示表格。
    • 说明中提到 OpenCode 2 时,要说明升级 OpenCode 需要用户自行完成(lean-agents 绝不升级它),并且应在此之前备份 OpenCode 数据文件夹(
      opencode.db
      )和配置;参见
      docs/compatibility.md
      中的 “Staying on OpenCode 1.x”。此 skill 绝不运行 OpenCode 升级。
    • 如果某个 release 没有明确的 “Upgrade” 或 “Breaking” 说明,用通俗易懂的话指出这一点,并在表格中填写 “release notes 中无相关说明”。
  2. 检测。
    • 如果
      ~/.config/lean-agents/state.json
      存在(或
      --doctor --json
      可运行):运行
      --doctor --json
      。其
      behind
      列表包含版本低于 pins 的项目。
    • 如果没有
      state.json
      (手动安装):运行
      docs/manual-install.md
      中 “Detect what is installed” 部分的只读命令,了解已安装的 agents 和 tools。告知用户此安装尚无 state,脚本将接管该安装,但不会覆盖用户文件。
  3. 使用脚本以 JSON 形式执行 dry run。
    • 有 state 时:
      --update --dry-run --yes --json
      。
    • 没有 state 时:
      --dry-run --yes --json --agents <detected> --tools <detected>
      。 JSON 会列出 files、commands(准确的
      npx
      /
      brew
      命令行,且均为已 pin 的版本),并在 update 时列出
      behind
      。
  4. 用通俗易懂的语言展示一张表格:
    工具 | 已安装版本 | 固定版本 | 影响 | 升级说明 | 将运行的命令
    。“已安装版本”取自
    behind
    或检测结果;“影响”取自步骤 1(若没有则填写 “not in the changelog”);“升级说明”取自步骤 1 中的 releases(没有相关说明时填写 “release notes 中无相关说明”);“将运行的命令”取自 JSON 的
    commands
    。然后询问:“更新这 N 个工具吗?”用户拒绝时停止。
  5. 仅备份将要更改的内容,然后运行。 在操作系统临时目录中创建一个备份文件夹,其中保存 JSON 指明将更改、且 engine 本身不会恢复的文件(路径以
    ~
    开头:先将其展开为完整路径)。此代码段仅在 bash 中经过验证;其内嵌引号未在 PowerShell 5.1 上测试,因此在 Windows PowerShell 上,应将同一段 JavaScript 保存到临时文件夹中的
    .js
    文件,再运行
    node <file> <path1> <path2>
    。它会输出文件夹路径,并将每个路径复制进去,命名为
    <n>-<name>
    :
    node -e "const fs=require('fs'),os=require('os'),p=require('path');const d=fs.mkdtempSync(p.join(os.tmpdir(),'lean-agents-backup-'));process.argv.slice(1).forEach((f,i)=>{if(fs.existsSync(f))fs.cpSync(f,p.join(d,i+'-'+p.basename(f)),{recursive:true})});console.log(d)" <path1> <path2>
    。然后使用相同 flags、但不带
    --dry-run
    运行:
    --update --yes
    ,或
    --yes --agents ... --tools ...
    。首次失败时立即停止并报告。
  6. 回读结果。 运行
    --doctor --json
    。当
    ok
    为 true 且
    behind
    为空时,使用
    node -e "require('fs').rmSync(process.argv[1],{recursive:true,force:true})" <folder>
    删除备份文件夹(同样注意 PowerShell 5.1 的限制:应在该环境中使用
    .js
    文件),并告知用户备份已删除,且
    --uninstall
    仍可撤销所有更改。否则,保留备份,说明其所在位置,并主动询问是否恢复。
    • 交接: 如果此 lean-agents release 提供了完成步骤的汇总页面(#181),告知用户该页面的存在,并在用户同意后询问是否打开。页面会列出已更新、保留和跳过的内容,以及仍需完成的登录。如果此 release 没有该页面,则跳过此步骤并进入步骤 8。
  7. 分享发现(可选)。 仅当发现问题时或存在改进机会时才执行(例如命令失败、检测程序无法看到的工具、缺少 changelog 说明):
    • 在
      --privacy strict
      、
      --network off
      或
      --outbound off
      模式下,绝不提供此选项。从
      state.json
      读取已保存的 preset;如果没有 state,则询问一次是否允许 outbound calls。
    • 询问:“为 lean-agents 起草一份已脱敏的 issue 吗?”用户拒绝时停止。
    • 运行
      lean-agents --feedback-draft --feedback-kind update --failed-command "<tool>" --network on
      ,并通过 stdin 提供详细信息(bash:
      < details.txt
      ;PowerShell:
      Get-Content details.txt | npx -y lean-agents@<version> ...
      )。
      {"offer": false}
      表示停止。
    • 重复项:运行
      gh issue list --repo estebanmr99/lean-agents --search "<title words>"
      。如果找到匹配项,展示该 issue 并停止。
    • 展示完整草稿。仅在用户同意后运行:
      gh issue create --repo estebanmr99/lean-agents --title "<title>" --body-file <draft>
      。
  8. 报告: 按工具列出旧版本 -> 新版本、已验证的内容(
    --doctor --json
    ),以及仍需用户处理的事项。

Fallback: the script cannot run

Fallback:脚本无法运行

Only when Node is missing or the machine blocks the script. Use the table of commands and the install lines in
docs/manual-install.md
(sections 4, 6, 7) by hand, with the same table, the same ask, the same backup and the same read-back. Say that this is the fallback: nothing here is recorded in
state.json
, so
--uninstall
will not know about it.
仅当缺少 Node.js 或机器阻止脚本运行时使用此 fallback。根据
docs/manual-install.md
第 4、6、7 节中的命令表和安装命令行手动执行,同时使用相同的表格、询问、备份和回读流程。明确说明这是 fallback:此处执行的操作不会记录到
state.json
,因此
--uninstall
不会知道这些更改。