Skip to content

Ci/update - #2

Merged
th-dd merged 13 commits into
gh-pagesfrom
ci/update
Aug 4, 2026
Merged

Ci/update#2
th-dd merged 13 commits into
gh-pagesfrom
ci/update

Conversation

@th-dd

@th-dd th-dd commented Aug 4, 2026

Copy link
Copy Markdown
Owner

由 Sourcery 提供的摘要

为 VS Code 扩展添加自动化构建工作流,并相应更新扩展文档。

新功能:

  • 提供 GitHub Actions 工作流,用于在 push、PR、定时任务和手动运行时构建并发布 VS Code 扩展的 VSIX 构件。

增强内容:

  • 修改 VS Code 扩展的 README,提供更清晰的安装方法,包括从 GitHub Actions 下载构件,以及更新后的故障排查部分。
  • 将 VS Code 扩展的包版本从 1.0.0 升级到 1.0.1。
  • 配置 Dependabot 管理 VS Code 扩展的 npm 依赖,并对 GitHub Actions 更新进行分组。

CI:

  • 引入专门的 CI 工作流,用于构建 VS Code 扩展并上传 VSIX 构件,包括 PR 评论和运行摘要。
  • 调整 Dependabot 配置,以分组 GitHub Actions 更新,并为扩展目录添加每周 npm 更新。
Original summary in English

Summary by Sourcery

自动化构建与分发 VS Code GitHub 中文化 插件,并刷新相关文档、配置和测试。

新功能:

  • 新增 GitHub Actions 工作流,用于构建 VS Code 插件、上传 VSIX 构建产物、在 PR 中发布评论,以及生成运行摘要。

错误修复:

  • 改进运行时测试辅助工具,以正确定位后续运行时函数,避免在解析文件中最后一个函数时发生失败。
  • 将回归测试的预期结果与运行时使用的最新繁体中文翻译对齐。

增强改进:

  • 更新 VS Code 插件的 README,提供更清晰的安装说明,包括从 GitHub Actions 下载 VSIX,以及新增疑难排解(troubleshooting)章节。
  • 提升 VS Code 插件与用户脚本版本号,并将用户脚本指向对应的新本地化(localization)资源包。
  • 移除已被插件取代的、过时的 VS Code 专用用户脚本文件。

CI:

  • 调整 Dependabot,将 GitHub Actions 更新进行分组,并为 VS Code 插件目录新增每周一次的 npm 依赖检查。
  • 引入专门用于构建 VS Code 插件并管理其构建产物的定时和事件驱动 CI 工作流。

文档:

  • 重构并扩展 VS Code 插件文档,以涵盖通过 GitHub Actions 构建产物进行安装、从源代码构建,以及常见问题说明。

测试:

Original summary in English

Summary by Sourcery

Automate building and distribution of the VS Code GitHub 中文化 extension and refresh related documentation, configuration, and tests.

New Features:

  • Add a GitHub Actions workflow to build the VS Code extension, upload the VSIX artifact, post PR comments, and generate run summaries.

Bug Fixes:

  • Improve the runtime test helper to correctly locate subsequent runtime functions, preventing failures when parsing the last function in a file.
  • Align regression test expectations with updated Traditional Chinese translations used at runtime.

Enhancements:

  • Update the VS Code extension README with clearer installation instructions, including downloading VSIX from GitHub Actions and a new troubleshooting section.
  • Bump the VS Code extension and userscript versions and point the userscript to the corresponding new localization bundle.
  • Remove the obsolete VS Code-specific userscript file now superseded by the extension.

CI:

  • Adjust Dependabot to group GitHub Actions updates and add weekly npm dependency checks for the VS Code extension directory.
  • Introduce a scheduled and event-driven CI workflow dedicated to building the VS Code extension and managing its artifacts.

Documentation:

  • Restructure and expand the VS Code extension documentation to cover installation via GitHub Actions artifacts, building from source, and common issues.

Tests:

th-dd added 7 commits August 2, 2026 20:58
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

审查者指南(Reviewer's Guide)

此变更添加了一个自动化的 GitHub Actions 工作流,用于构建并发布 VS Code 扩展的 VSIX 构件;更新了安装文档和故障排查指南;提升了扩展版本;微调了测试与翻译预期;并为 GitHub Actions 更新分组以及扩展的 npm 依赖的每周更新配置了 Dependabot。

新增 VS Code 扩展构建 GitHub Actions 工作流的时序图

sequenceDiagram
  actor Developer
  participant GitHub
  participant Build_Extension_Workflow as Build_Extension_Workflow
  participant Actions_Artifact_Storage as Actions_Artifact_Storage
  participant Pull_Request as Pull_Request

  Developer->>GitHub: push / pull_request / schedule / workflow_dispatch
  GitHub->>Build_Extension_Workflow: trigger build-vscode-extension.yml

  Build_Extension_Workflow->>Build_Extension_Workflow: actions/checkout@v4
  Build_Extension_Workflow->>Build_Extension_Workflow: actions/setup-node@v4
  Build_Extension_Workflow->>Build_Extension_Workflow: npm ci
  Build_Extension_Workflow->>Build_Extension_Workflow: npx @vscode/vsce package

  Build_Extension_Workflow->>Actions_Artifact_Storage: actions/upload-artifact@v7 (github-chinese-extension.vsix)

  alt [github.event_name == pull_request]
    Build_Extension_Workflow->>Pull_Request: actions/github-script@v7 createComment / updateComment
  end

  Build_Extension_Workflow->>GitHub: write GITHUB_STEP_SUMMARY
Loading

文件级变更

Change Details Files
引入一个 GitHub Actions 工作流,用于构建并上传带版本号的 VS Code 扩展 VSIX 构件,并在 PR 中添加评论和运行摘要。
  • 添加一个可由定时任务 / push / PR / 手动触发的工作流,使用 Node 24 和 npm ci 构建 VS Code 扩展。
  • 使用 vsce 将扩展打包为具有确定性输出的 VSIX 文件,并通过作业输出暴露其名称和路径。
  • 将 VSIX 作为构件上传,使用固定名称、保留期为 5 天,并包含过期时间戳。
  • 在 PR 中发布或更新包含构件详情和运行链接的评论,并生成一个 Markdown 格式的运行摘要。
.github/workflows/build-vscode-extension.yml
改进 VS Code 扩展文档,以描述基于构件的安装方式、更清晰的构建步骤以及故障排查说明。
  • 用两种安装路径替换原先单一的“源码构建”章节:从 GitHub Actions 下载 VSIX 和从源码构建。
  • 详细说明环境要求,并提供逐步的 PowerShell 命令,用于克隆仓库、安装依赖并打包扩展。
  • 添加 FAQ/故障排查章节,解释 GitHub Pages 可能未本地化的常见原因以及需要进行的检查。
  • 澄清前文对“源码构建”章节的引用,并调整关于使用必要参数启动 VS Code 的措辞。
vscode-extension/README.md
调整回归测试以匹配更新后的繁体中文翻译,并修复运行时函数解析逻辑。
  • 更新预期的导航标签翻译(例如 Pull requests、安全与质量、洞察、设置、软件包、发布、代理、搜索提示等)到新的用词。
  • 修改 loadRuntimeFunction,通过对切片后的子字符串执行正则匹配来定位下一个运行时函数,从而处理目标函数可能位于文件末尾的情况。
  • 确保断言仍然验证该函数存在,并且在期望的情况下,其后跟随另一个运行时函数。
test/issue-702-regression.test.cjs
配置 Dependabot,以管理 VS Code 扩展的 npm 依赖,并对 GitHub Actions 更新进行分组。
  • 添加一个单独的 npm 更新配置项,作用域限定在 /vscode-extension 目录,并设为每周计划。
  • 为 GitHub Actions 更新定义一个分组,这样每次运行只会生成一个合并了所有 GitHub Actions 更新的 Dependabot PR,而不是多个小 PR。
.github/dependabot.yml
提升脚本与扩展版本,以反映新版本发布,并保持 VS Code 扩展构件版本一致。
  • 将 VS Code 扩展的包版本从 1.0.0 提升到 1.0.1
  • 更新用户脚本的版本字符串以及其所需的 locals.js URL 查询参数,使其使用新的、带日期标签的版本。
  • 移除已不再需要的 main(vscode).user.js 文件,该文件预计已被 VS Code 扩展路径取代。
vscode-extension/package.json
main.user.js
main(vscode).user.js

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论即可继续讨论。
  • 从审查评论生成 GitHub Issue: 通过回复某条审查评论,请求 Sourcery 根据该评论创建一个 Issue。你也可以回复该审查评论 @sourcery-ai issue 来创建对应 Issue。
  • 生成拉取请求标题: 在拉取请求标题中任意位置写上 @sourcery-ai 即可在任何时候生成标题。你也可以在拉取请求中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可在任何时候(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve 以标记解决所有 Sourcery 评论。当你已经处理完所有评论且不再希望看到它们时,这非常有用。
  • 驳回所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。特别适用于你想以一次全新的审查开始——别忘了随后评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的 仪表盘 以:

  • 启用或禁用审查功能,比如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 修改审查语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Adds an automated GitHub Actions workflow to build and publish a VSIX artifact for the VS Code extension, updates installation docs and troubleshooting guidance, bumps the extension version, tweaks tests and translation expectations, and configures Dependabot for grouped GitHub Actions and weekly npm updates for the extension.

Sequence diagram for the new VS Code extension build GitHub Actions workflow

sequenceDiagram
  actor Developer
  participant GitHub
  participant Build_Extension_Workflow as Build_Extension_Workflow
  participant Actions_Artifact_Storage as Actions_Artifact_Storage
  participant Pull_Request as Pull_Request

  Developer->>GitHub: push / pull_request / schedule / workflow_dispatch
  GitHub->>Build_Extension_Workflow: trigger build-vscode-extension.yml

  Build_Extension_Workflow->>Build_Extension_Workflow: actions/checkout@v4
  Build_Extension_Workflow->>Build_Extension_Workflow: actions/setup-node@v4
  Build_Extension_Workflow->>Build_Extension_Workflow: npm ci
  Build_Extension_Workflow->>Build_Extension_Workflow: npx @vscode/vsce package

  Build_Extension_Workflow->>Actions_Artifact_Storage: actions/upload-artifact@v7 (github-chinese-extension.vsix)

  alt [github.event_name == pull_request]
    Build_Extension_Workflow->>Pull_Request: actions/github-script@v7 createComment / updateComment
  end

  Build_Extension_Workflow->>GitHub: write GITHUB_STEP_SUMMARY
Loading

File-Level Changes

Change Details Files
Introduce a GitHub Actions workflow to build and upload versioned VSIX artifacts for the VS Code extension, with PR comments and run summaries.
  • Add a scheduled/push/PR/manual-triggered workflow that builds the VS Code extension using Node 24 and npm ci.
  • Package the extension into a deterministic VSIX file using vsce and expose its name and path via job outputs.
  • Upload the VSIX as an artifact with a fixed name and 5-day retention, including an expiry timestamp.
  • Post or update a PR comment with artifact details and a link to the run, and generate a markdown run summary.
.github/workflows/build-vscode-extension.yml
Improve VS Code extension documentation to describe artifact-based installation, clearer build steps, and troubleshooting.
  • Replace the single source-build section with two installation paths: downloading VSIX from GitHub Actions and building from source.
  • Detail environment requirements and step-by-step PowerShell commands for cloning, installing dependencies, and packaging the extension.
  • Add a FAQ/troubleshooting section explaining common reasons why GitHub pages might not be localized and checks to perform.
  • Clarify references to the source-build section in earlier text and adjust wording for launching VS Code with required flags.
vscode-extension/README.md
Adjust regression tests to match updated Traditional Chinese translations and fix runtime function parsing logic.
  • Update expected navigation label translations (e.g., for pull requests, security and quality, insights, settings, packages, releases, agents, search hints) to new wording.
  • Modify loadRuntimeFunction to locate the next runtime function using a regex over a sliced substring, handling files where the target function might be last.
  • Ensure assertions still validate that the function exists and is followed by another runtime function when expected.
test/issue-702-regression.test.cjs
Configure Dependabot to manage npm dependencies for the VS Code extension and group GitHub Actions updates.
  • Add a separate npm update entry scoped to the /vscode-extension directory with a weekly schedule.
  • Define a group for GitHub Actions updates so they are combined into a single Dependabot PR per run instead of many small ones.
.github/dependabot.yml
Bump script and extension versions to reflect the new release and keep VS Code extension artifacts in sync.
  • Increment the VS Code extension package version from 1.0.0 to 1.0.1.
  • Update the userscript version string and its required locals.js URL query parameter to a new date-tagged version.
  • Remove the now-obsolete main(vscode).user.js file, presumably replaced by the VS Code extension path.
vscode-extension/package.json
main.user.js
main(vscode).user.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 5 个问题,并留下了一些总体反馈:

  • README 中的工作流链接指向 actions/workflows/build-vscode-extension,但实际的 Actions URL 通常会包含 .yml 后缀(例如 build-vscode-extension.yml),建议更新该链接以避免 404。
  • Actions 工作流使用了 node-version: '24',这已经超出了当前的 LTS 版本;建议固定到最新的 LTS(例如 22),或者在文档中说明为什么需要 24,以避免当 GitHub Runner 镜像更新时出现意外的 CI 中断。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- The workflow link in the README points to `actions/workflows/build-vscode-extension` but the actual Actions URL typically includes the `.yml` suffix (e.g. `build-vscode-extension.yml`), so consider updating the link to avoid 404s.
- The Actions workflow uses `node-version: '24'`, which is ahead of the current LTS; consider pinning to the latest LTS (e.g. 22) or documenting why 24 is required to avoid unexpected CI breakage when GitHub’s runner image changes.

## Individual Comments

### Comment 1
<location path=".github/workflows/build-vscode-extension.yml" line_range="33-36" />
<code_context>
+      - name: 检出代码
+        uses: actions/checkout@v4
+
+      - name: 设置 Node.js 环境
+        uses: actions/setup-node@v4
+        with:
+          node-version: '24'
+          cache: 'npm'
+          cache-dependency-path: 'vscode-extension/package-lock.json'
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider pinning Node to an LTS version or a more explicit version range for build stability

`node-version: '24'` will always use the latest 24.x, which isn’t an LTS line and can introduce breaking changes into CI over time. For more stable builds, consider pinning to the current LTS (e.g. `22`) or to an exact minor/patch. If you intentionally require 24.x, please document that and optionally run a small version matrix (e.g. `20`/`22`/`24`) to detect incompatibilities early.

Suggested implementation:

```
      - name: 设置 Node.js 环境(使用 LTS 版本以提高构建稳定性)
        uses: actions/setup-node@v4
        with:
          # 使用当前 Node.js LTS 版本,避免非 LTS 版本在次要更新中引入破坏性变更
          node-version: '22.x'
          cache: 'npm'
          cache-dependency-path: 'vscode-extension/package-lock.json'

```

If you want to go further with the suggestion and run a small version matrix (e.g. `20`/`22`/`24`), you would:
1. Introduce a `strategy.matrix.node-version` section at the job level with the desired versions.
2. Replace this `node-version: '22.x'` with `node-version: ${{ matrix.node-version }}`.
3. Optionally extend the job to run compatibility checks or tests across all matrix entries.
</issue_to_address>

### Comment 2
<location path=".github/workflows/build-vscode-extension.yml" line_range="40-43" />
<code_context>
+          cache: 'npm'
+          cache-dependency-path: 'vscode-extension/package-lock.json'
+
+      - name: 进入插件目录并安装依赖
+        run: |
+          cd vscode-extension
+          npm install
+
+      - name: 打包 VSIX
</code_context>
<issue_to_address>
**suggestion (performance):** Using `npm ci` instead of `npm install` would make builds more reproducible and faster

Given you’re already caching based on `package-lock.json`, switching this step to `npm ci` will better enforce the lockfile (failing on drift) and usually install faster, leading to more deterministic and efficient CI runs.

```suggestion
      - name: 进入插件目录并安装依赖
        run: |
          cd vscode-extension
          npm ci
```
</issue_to_address>

### Comment 3
<location path=".github/workflows/build-vscode-extension.yml" line_range="45-52" />
<code_context>
+          cd vscode-extension
+          npm install
+
+      - name: 打包 VSIX
+        id: package
+        run: |
+          cd vscode-extension
+          npx @vscode/vsce package
+          VSIX_FILE=$(ls *.vsix | head -n 1)
+          echo "artifact_name=$VSIX_FILE" >> $GITHUB_OUTPUT
+          echo "vsix_path=vscode-extension/$VSIX_FILE" >> $GITHUB_OUTPUT
</code_context>
<issue_to_address>
**suggestion:** The VSIX file detection relies on `ls` and assumes a single match, which could be fragile

This logic depends on shell globbing and on there being exactly one `.vsix` file, so if multiple packages are present you may upload the wrong artifact. Consider making the filename deterministic by cleaning the directory first, using `vsce package -o <expected-name>.vsix`, or constraining the glob to a more specific pattern (e.g. including version).

```suggestion
      - name: 打包 VSIX
        id: package
        run: |
          cd vscode-extension
          # 清理旧的 VSIX 文件,避免上传历史构件
          rm -f ./*.vsix
          # 使用 package.json 中的 name 和 version 生成确定性的文件名
          PKG_NAME=$(node -p "require('./package.json').name")
          PKG_VERSION=$(node -p "require('./package.json').version")
          VSIX_FILE="${PKG_NAME}-${PKG_VERSION}.vsix"
          # 以指定的文件名打包 VSIX,避免依赖 ls 和通配符
          npx @vscode/vsce package -o "$VSIX_FILE"
          echo "artifact_name=$VSIX_FILE" >> $GITHUB_OUTPUT
          echo "vsix_path=vscode-extension/$VSIX_FILE" >> $GITHUB_OUTPUT
```
</issue_to_address>

### Comment 4
<location path=".github/workflows/build-vscode-extension.yml" line_range="60-66" />
<code_context>
+          EXPIRY_DATE=$(date -u -d "+5 days" '+%Y-%m-%d %H:%M UTC')
+          echo "expires_at=$EXPIRY_DATE" >> $GITHUB_OUTPUT
+
+      - name: 上传构件
+        uses: actions/upload-artifact@v7
+        with:
+          name: github-chinese-extension
+          path: vscode-extension/*.vsix
+          retention-days: 5
+          archive: false
</code_context>
<issue_to_address>
**suggestion:** Align artifact upload path with the computed VSIX path/output for clarity and consistency

Using `path: vscode-extension/*.vsix` while also computing `vsix_path`/`artifact_name` can upload multiple VSIX files if more than one exists, and may not match the artifact referenced in the PR comment. Please switch the upload path to `${{ steps.package.outputs.vsix_path }}` so the uploaded artifact is guaranteed to be the same one referenced elsewhere.

```suggestion
      - name: 上传构件
        uses: actions/upload-artifact@v7
        with:
          name: github-chinese-extension
          path: ${{ steps.package.outputs.vsix_path }}
          retention-days: 5
          archive: false
```
</issue_to_address>

### Comment 5
<location path="vscode-extension/README.md" line_range="75" />
<code_context>
+```shell
+git clone https://github.com/maboloshi/github-chinese.git # 克隆仓库
+
+# 若你的网络环境无法访问 Github 克隆仓库,请自行寻找加速器等解决
+
+cd github-chinese/vscode-extension # 进入插件目录
</code_context>
<issue_to_address>
**issue (typo):** Correct “Github” to the proper capitalization “GitHub”.

Use the official capitalization “GitHub” here for consistency with the rest of the document.

```suggestion
# 若你的网络环境无法访问 GitHub 克隆仓库,请自行寻找加速器等解决
```
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的 Review 还不错,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English

Hey - I've found 5 issues, and left some high level feedback:

  • The workflow link in the README points to actions/workflows/build-vscode-extension but the actual Actions URL typically includes the .yml suffix (e.g. build-vscode-extension.yml), so consider updating the link to avoid 404s.
  • The Actions workflow uses node-version: '24', which is ahead of the current LTS; consider pinning to the latest LTS (e.g. 22) or documenting why 24 is required to avoid unexpected CI breakage when GitHub’s runner image changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The workflow link in the README points to `actions/workflows/build-vscode-extension` but the actual Actions URL typically includes the `.yml` suffix (e.g. `build-vscode-extension.yml`), so consider updating the link to avoid 404s.
- The Actions workflow uses `node-version: '24'`, which is ahead of the current LTS; consider pinning to the latest LTS (e.g. 22) or documenting why 24 is required to avoid unexpected CI breakage when GitHub’s runner image changes.

## Individual Comments

### Comment 1
<location path=".github/workflows/build-vscode-extension.yml" line_range="33-36" />
<code_context>
+      - name: 检出代码
+        uses: actions/checkout@v4
+
+      - name: 设置 Node.js 环境
+        uses: actions/setup-node@v4
+        with:
+          node-version: '24'
+          cache: 'npm'
+          cache-dependency-path: 'vscode-extension/package-lock.json'
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider pinning Node to an LTS version or a more explicit version range for build stability

`node-version: '24'` will always use the latest 24.x, which isn’t an LTS line and can introduce breaking changes into CI over time. For more stable builds, consider pinning to the current LTS (e.g. `22`) or to an exact minor/patch. If you intentionally require 24.x, please document that and optionally run a small version matrix (e.g. `20`/`22`/`24`) to detect incompatibilities early.

Suggested implementation:

```
      - name: 设置 Node.js 环境(使用 LTS 版本以提高构建稳定性)
        uses: actions/setup-node@v4
        with:
          # 使用当前 Node.js LTS 版本,避免非 LTS 版本在次要更新中引入破坏性变更
          node-version: '22.x'
          cache: 'npm'
          cache-dependency-path: 'vscode-extension/package-lock.json'

```

If you want to go further with the suggestion and run a small version matrix (e.g. `20`/`22`/`24`), you would:
1. Introduce a `strategy.matrix.node-version` section at the job level with the desired versions.
2. Replace this `node-version: '22.x'` with `node-version: ${{ matrix.node-version }}`.
3. Optionally extend the job to run compatibility checks or tests across all matrix entries.
</issue_to_address>

### Comment 2
<location path=".github/workflows/build-vscode-extension.yml" line_range="40-43" />
<code_context>
+          cache: 'npm'
+          cache-dependency-path: 'vscode-extension/package-lock.json'
+
+      - name: 进入插件目录并安装依赖
+        run: |
+          cd vscode-extension
+          npm install
+
+      - name: 打包 VSIX
</code_context>
<issue_to_address>
**suggestion (performance):** Using `npm ci` instead of `npm install` would make builds more reproducible and faster

Given you’re already caching based on `package-lock.json`, switching this step to `npm ci` will better enforce the lockfile (failing on drift) and usually install faster, leading to more deterministic and efficient CI runs.

```suggestion
      - name: 进入插件目录并安装依赖
        run: |
          cd vscode-extension
          npm ci
```
</issue_to_address>

### Comment 3
<location path=".github/workflows/build-vscode-extension.yml" line_range="45-52" />
<code_context>
+          cd vscode-extension
+          npm install
+
+      - name: 打包 VSIX
+        id: package
+        run: |
+          cd vscode-extension
+          npx @vscode/vsce package
+          VSIX_FILE=$(ls *.vsix | head -n 1)
+          echo "artifact_name=$VSIX_FILE" >> $GITHUB_OUTPUT
+          echo "vsix_path=vscode-extension/$VSIX_FILE" >> $GITHUB_OUTPUT
</code_context>
<issue_to_address>
**suggestion:** The VSIX file detection relies on `ls` and assumes a single match, which could be fragile

This logic depends on shell globbing and on there being exactly one `.vsix` file, so if multiple packages are present you may upload the wrong artifact. Consider making the filename deterministic by cleaning the directory first, using `vsce package -o <expected-name>.vsix`, or constraining the glob to a more specific pattern (e.g. including version).

```suggestion
      - name: 打包 VSIX
        id: package
        run: |
          cd vscode-extension
          # 清理旧的 VSIX 文件,避免上传历史构件
          rm -f ./*.vsix
          # 使用 package.json 中的 name 和 version 生成确定性的文件名
          PKG_NAME=$(node -p "require('./package.json').name")
          PKG_VERSION=$(node -p "require('./package.json').version")
          VSIX_FILE="${PKG_NAME}-${PKG_VERSION}.vsix"
          # 以指定的文件名打包 VSIX,避免依赖 ls 和通配符
          npx @vscode/vsce package -o "$VSIX_FILE"
          echo "artifact_name=$VSIX_FILE" >> $GITHUB_OUTPUT
          echo "vsix_path=vscode-extension/$VSIX_FILE" >> $GITHUB_OUTPUT
```
</issue_to_address>

### Comment 4
<location path=".github/workflows/build-vscode-extension.yml" line_range="60-66" />
<code_context>
+          EXPIRY_DATE=$(date -u -d "+5 days" '+%Y-%m-%d %H:%M UTC')
+          echo "expires_at=$EXPIRY_DATE" >> $GITHUB_OUTPUT
+
+      - name: 上传构件
+        uses: actions/upload-artifact@v7
+        with:
+          name: github-chinese-extension
+          path: vscode-extension/*.vsix
+          retention-days: 5
+          archive: false
</code_context>
<issue_to_address>
**suggestion:** Align artifact upload path with the computed VSIX path/output for clarity and consistency

Using `path: vscode-extension/*.vsix` while also computing `vsix_path`/`artifact_name` can upload multiple VSIX files if more than one exists, and may not match the artifact referenced in the PR comment. Please switch the upload path to `${{ steps.package.outputs.vsix_path }}` so the uploaded artifact is guaranteed to be the same one referenced elsewhere.

```suggestion
      - name: 上传构件
        uses: actions/upload-artifact@v7
        with:
          name: github-chinese-extension
          path: ${{ steps.package.outputs.vsix_path }}
          retention-days: 5
          archive: false
```
</issue_to_address>

### Comment 5
<location path="vscode-extension/README.md" line_range="75" />
<code_context>
+```shell
+git clone https://github.com/maboloshi/github-chinese.git # 克隆仓库
+
+# 若你的网络环境无法访问 Github 克隆仓库,请自行寻找加速器等解决
+
+cd github-chinese/vscode-extension # 进入插件目录
</code_context>
<issue_to_address>
**issue (typo):** Correct “Github” to the proper capitalization “GitHub”.

Use the official capitalization “GitHub” here for consistency with the rest of the document.

```suggestion
# 若你的网络环境无法访问 GitHub 克隆仓库,请自行寻找加速器等解决
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/build-vscode-extension.yml
Comment thread .github/workflows/build-vscode-extension.yml Outdated
Comment thread .github/workflows/build-vscode-extension.yml
Comment thread .github/workflows/build-vscode-extension.yml
Comment thread vscode-extension/README.md Outdated
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

📦 GitHub 中文化扩展构建完成

项目 详情
构建状态 ✅ 成功
产物名称 github-chinese-1.0.1.vsix
预计过期时间 2026-08-09 09:27 UTC
下载链接 点击下载构件

Warning

Actions 工作流工件仅保存5天,到期将永久删除


工作流运行详情https://github.com/th-dd/github-chinese/actions/runs/30896395465

th-dd and others added 5 commits August 4, 2026 13:59
* main.user.js Update to 1.9.4.4-2026-07-29

Signed-off-by: action-assistant[bot] <152410706+action-assistant[bot]@users.noreply.github.com>

* refactor: 移除根目录 main(vscode).user.js, 统一由扩展维护 (maboloshi#767)

* test: fix issue 702 regression expectations (maboloshi#725)

---------

Signed-off-by: action-assistant[bot] <152410706+action-assistant[bot]@users.noreply.github.com>
Co-authored-by: action-assistant[bot] <152410706+action-assistant[bot]@users.noreply.github.com>
Co-authored-by: PtJade Ceramic <185668489+PtJade-Ceramic@users.noreply.github.com>
Co-authored-by: saime428 <51110572+saime428@users.noreply.github.com>
将 npm install 改为 npm ci

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
替换打包方式部分过程

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
更换上传文件的匹配方式

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
修改错误的拼写

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: 叹号大帝 <162813557+th-dd@users.noreply.github.com>
@th-dd

th-dd commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

@sourcery-ai review

@th-dd

th-dd commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

@sourcery-ai resolve
@sourcery-ai guide
@sourcery-ai summary
@sourcery-ai title

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 3 个问题,并留下了一些总体反馈:

  • 在构建工作流中,建议在 actions/setup-node 里使用 LTS 版本(例如 node-version: 'lts/*' 或 20),而不是写死为 24,以避免该版本过时或不再受支持时导致 CI 失败。
  • README 中指向 Actions 工作流的链接(/actions/workflows/build-vscode-extension)可能缺少 .yml 后缀;将其更新为完整的工作流 URL,可以确保用户被直接带到正确的工作流运行列表。
  • README 指导用户下载 github-chinese-extension.vsix,但工作流上传的是名为 github-chinese-extension 的构件,其中包含带版本号的 VSIX 文件;将构件名称或 README 中的描述与实际文件名对齐,可以减少用户在下载扩展时的困惑。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the build workflow, consider using an LTS version for `actions/setup-node` (e.g. `node-version: 'lts/*'` or 20) instead of hard-coding `24` to avoid CI breakage when that version becomes outdated or unsupported.
- The README link to the Actions workflow (`/actions/workflows/build-vscode-extension`) may be missing the `.yml` suffix; updating it to the exact workflow URL ensures users are taken directly to the correct workflow run list.
- The README instructs users to download `github-chinese-extension.vsix`, but the workflow uploads an artifact named `github-chinese-extension` containing a versioned VSIX file; aligning the artifact name or README wording with the actual file name will reduce confusion for users downloading the extension.

## Individual Comments

### Comment 1
<location path=".github/workflows/build-vscode-extension.yml" line_range="4-6" />
<code_context>
+name: Build Extension
+
+on:
+  # 定时触发:每5天自动运行一次
+  schedule:
+    - cron: '0 0 */5 * *'
+  
+  # 代码推送触发:当 vscode-extension 目录有变更时自动构建
</code_context>
<issue_to_address>
**nitpick:** Cron expression `*/5` in the day-of-month field doesn’t give a strict “every 5 days” cadence

The comment states “每5天自动运行一次”, but `0 0 */5 * *` actually means “on days 1, 6, 11, 16, 21, 26, 31 at 00:00”, which introduces gaps at month boundaries (e.g. 31st → 6th). If this cadence is acceptable, update the comment to match the real behavior; if a true rolling 5‑day interval is required, adjust the schedule (e.g. multiple cron entries or a different mechanism).
</issue_to_address>

### Comment 2
<location path="test/issue-702-regression.test.cjs" line_range="259" />
<code_context>
     const source = fs.readFileSync(filePath, 'utf8');
     const start = source.indexOf(`    function ${functionName}(`);
-    const end = source.indexOf('\n\n    function ', start + 1);
+    const nextFunction = source.slice(start + 1).search(/\r?\n\r?\n    function /);
+    const end = nextFunction === -1 ? -1 : start + 1 + nextFunction;
     assert.notEqual(start, -1, `${functionName} should exist in ${fileName}`);
</code_context>
<issue_to_address>
**suggestion (testing):** Add a regression test to cover CRLF line endings in `loadRuntimeFunction`.

The regex now intentionally supports both LF and CRLF when locating the next runtime function, but that behavior is only covered indirectly. Please add a focused regression test that passes a synthetic source string with `\r\n\r\n    function` separators into `loadRuntimeFunction` (or a small helper) and asserts that `end` is found (i.e., not `-1`). This will explicitly lock in support for mixed newline styles and prevent future regressions.
</issue_to_address>

### Comment 3
<location path="vscode-extension/README.md" line_range="66" />
<code_context>
+
+- [Git](https://git-scm.cn/install) (可选,用于克隆仓库,若不打算安装 Git ,请自行将仓库下载至本地)
+
+- [NodeJS](https://nodejs.org)
+
+#### 构建步骤
</code_context>
<issue_to_address>
**nitpick (typo):** 考虑使用官方写法 “Node.js” 以保持术语一致性

这里写成了 “NodeJS”,建议改为更常见且与官网一致的 “Node.js”,以便与官方文档和社区用法对齐。

```suggestion
- [Node.js](https://nodejs.org)
```
</issue_to_address>

Sourcery 是对开源项目免费的——如果你觉得我们的代码审查有帮助,请考虑分享它们 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've found 3 issues, and left some high level feedback:

  • In the build workflow, consider using an LTS version for actions/setup-node (e.g. node-version: 'lts/*' or 20) instead of hard-coding 24 to avoid CI breakage when that version becomes outdated or unsupported.
  • The README link to the Actions workflow (/actions/workflows/build-vscode-extension) may be missing the .yml suffix; updating it to the exact workflow URL ensures users are taken directly to the correct workflow run list.
  • The README instructs users to download github-chinese-extension.vsix, but the workflow uploads an artifact named github-chinese-extension containing a versioned VSIX file; aligning the artifact name or README wording with the actual file name will reduce confusion for users downloading the extension.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the build workflow, consider using an LTS version for `actions/setup-node` (e.g. `node-version: 'lts/*'` or 20) instead of hard-coding `24` to avoid CI breakage when that version becomes outdated or unsupported.
- The README link to the Actions workflow (`/actions/workflows/build-vscode-extension`) may be missing the `.yml` suffix; updating it to the exact workflow URL ensures users are taken directly to the correct workflow run list.
- The README instructs users to download `github-chinese-extension.vsix`, but the workflow uploads an artifact named `github-chinese-extension` containing a versioned VSIX file; aligning the artifact name or README wording with the actual file name will reduce confusion for users downloading the extension.

## Individual Comments

### Comment 1
<location path=".github/workflows/build-vscode-extension.yml" line_range="4-6" />
<code_context>
+name: Build Extension
+
+on:
+  # 定时触发:每5天自动运行一次
+  schedule:
+    - cron: '0 0 */5 * *'
+  
+  # 代码推送触发:当 vscode-extension 目录有变更时自动构建
</code_context>
<issue_to_address>
**nitpick:** Cron expression `*/5` in the day-of-month field doesn’t give a strict “every 5 days” cadence

The comment states “每5天自动运行一次”, but `0 0 */5 * *` actually means “on days 1, 6, 11, 16, 21, 26, 31 at 00:00”, which introduces gaps at month boundaries (e.g. 31st → 6th). If this cadence is acceptable, update the comment to match the real behavior; if a true rolling 5‑day interval is required, adjust the schedule (e.g. multiple cron entries or a different mechanism).
</issue_to_address>

### Comment 2
<location path="test/issue-702-regression.test.cjs" line_range="259" />
<code_context>
     const source = fs.readFileSync(filePath, 'utf8');
     const start = source.indexOf(`    function ${functionName}(`);
-    const end = source.indexOf('\n\n    function ', start + 1);
+    const nextFunction = source.slice(start + 1).search(/\r?\n\r?\n    function /);
+    const end = nextFunction === -1 ? -1 : start + 1 + nextFunction;
     assert.notEqual(start, -1, `${functionName} should exist in ${fileName}`);
</code_context>
<issue_to_address>
**suggestion (testing):** Add a regression test to cover CRLF line endings in `loadRuntimeFunction`.

The regex now intentionally supports both LF and CRLF when locating the next runtime function, but that behavior is only covered indirectly. Please add a focused regression test that passes a synthetic source string with `\r\n\r\n    function` separators into `loadRuntimeFunction` (or a small helper) and asserts that `end` is found (i.e., not `-1`). This will explicitly lock in support for mixed newline styles and prevent future regressions.
</issue_to_address>

### Comment 3
<location path="vscode-extension/README.md" line_range="66" />
<code_context>
+
+- [Git](https://git-scm.cn/install) (可选,用于克隆仓库,若不打算安装 Git ,请自行将仓库下载至本地)
+
+- [NodeJS](https://nodejs.org)
+
+#### 构建步骤
</code_context>
<issue_to_address>
**nitpick (typo):** 考虑使用官方写法 “Node.js” 以保持术语一致性

这里写成了 “NodeJS”,建议改为更常见且与官网一致的 “Node.js”,以便与官方文档和社区用法对齐。

```suggestion
- [Node.js](https://nodejs.org)
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/build-vscode-extension.yml
Comment thread test/issue-702-regression.test.cjs
Comment thread vscode-extension/README.md
@th-dd
th-dd merged commit 2516a98 into gh-pages Aug 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant