issue #203:十万级目录下纯 JS 递归遍历是秒级,10 万条访问预算一顶结果 还被静默截断。现在启动后惰性探测一次本机 fd / rg(每个候选 `--version` 500ms 内验证通过才算数,进程内缓存),探到就用引擎输出,探不到或运行失败 整段回退原来的遍历(导出为 `searchFilesPlain`);坏二进制在进程内禁用, 超时只降级本次(树大 ≠ 二进制坏)。 为什么按 dev 现状重写而不是机械解冲突(PR #303 的落点全部复核过): - **#801 的必填 `dirs` 是语义级冲突,必须扩引擎契约**。dev 的 `FsSearchResult` 多了 `dirs`(`TreePanel` 用它把命中行当目录导航,否则 `fs.read` 报 “is a directory”),而 PR 的引擎侧只产出 `{paths, truncated}`,`searchFilesPlain` 的空查询也还在返回两字段形状; 照搬会让 #801 修的 bug 在引擎路径上静默回退。收口:fd 用第二次 `--type d` 调用取目录子集(fd 自己不做标注),rg 由文件路径倒推匹配的 目录段(`deriveRgMatches`),dispatch 再把 `dirs` 收敛成 `matches` 的 子集。残留差异只有**空目录在 rg 下不可见**(没有文件路径能带上它)。 - **rg 的路径级 glob 补成三个**:PR 的 `**/*<q>*/**` 缺一个直接子文件 (`util/helper.ts` 是最常见形态),只加 `**` 会让这类目录命中在 rg-only 机器上凭空消失;`**/*<q>/*` + `**/*<q>/**` 两条并用(对真实 rg 15 实测:单用任一条都丢结果)。 - **`bundledRgCandidates` 的路径推导按真机布局改写**:npm/pnpm 把 `@vscode/ripgrep-<platform>-<arch>` 提升到 `@deepseek-ai` 的**同级**, 不存在 `<root>/@deepseek-ai/dsh/node_modules/@vscode/...`;候选根改成 「从 CLI 入口(argv[1])向上逐级 `node_modules`」+ 各包管理器全局前缀, 桌面壳那种「自带依赖树 + 外部 node」的布局才探得到捆绑 rg(实测命中)。 - **丢掉 abort 形参**:`src/index.ts` 的生产路径不传 signal(PR 里也只有 测试在用),单为测试保留一条贯穿三层的通道不划算;引擎子进程由 15s 内部超时兜底。 - **文档锚点按 dev 重锚**:README 的 v0.12.3 条目已随发布历史迁到 CHANGELOG(新增 Unreleased 条目),AGENTS §2 的引擎门禁入口挂到现有 ci-windows 段落,指南 §14 参考实现行补 `src/search-engines.ts`。 - 未新增任何依赖:`@vscode/ripgrep` 只作为**路径**探测,不做模块导入。 Windows 侧由既有 ci-windows lane 承载:`choco install fd ripgrep` 把真 二进制放进 PATH,套件后 `pnpm check:engines`(`scripts/win-engine-check.mjs --assert`,import `src/search-engines.ts` 取插件自己的 argv)断言 `--path-separator /` 的输出不含 `\`/CR、非 ASCII 文件名命中;引擎缺失则 跳过(fd 在 ubuntu lane 与多数开发机上都没有)。 测试:`tests/search-engines.spec.ts`(探测缓存 / 运行失败禁用 / 超时不禁 用 / argv 对称性与噪声目录排除 / `deriveRgMatches` / 捆绑 rg 候选推导 / 真引擎在场时的端到端——缺席即返回),`tests/fs-search.spec.ts` 拆成 「直接钉遍历」+「注入假引擎的 dispatch 组」(引擎优先、`dirs` 透传与 子集收敛、预算透传、运行失败回退并禁用)。真机核对:本仓库上 rg 路径与 JS 遍历对 `locales` / `util` / `client` / `src` / `e2e` 五个查询的 matches 与 dirs **逐项一致**。 Refs #303
235 lines
10 KiB
YAML
235 lines
10 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
# `dev` is the alpha integration branch (AGENTS.md §0): everything lands
|
|
# there first, so its post-merge state needs the same green signal `main`
|
|
# gets. `pull_request` below has no branch filter, so PRs targeting `dev`
|
|
# are already covered.
|
|
branches: [main, dev]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
# Cancel a superseded PR run (it is on a stale commit); never cancel a
|
|
# push run — it is already producing the post-merge signal. The mount job
|
|
# boots a real DSH + Chromium, so the savings matter there most.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
# Tests run git log against this repository and need the full history.
|
|
fetch-depth: 0
|
|
# pnpm version is pinned via packageManager in package.json; the action
|
|
# reads it from there (specifying both makes action-setup fail on
|
|
# purpose with ERR_PNPM_BAD_PM_VERSION).
|
|
- uses: pnpm/action-setup@v6
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
# The plugin's git revert/cherry-pick spawn git without setting an
|
|
# identity (deliberate, see tests/smoke.spec.ts) and rely on ambient
|
|
# config; the runner has none by default.
|
|
- name: Configure git identity for tests
|
|
run: |
|
|
git config --global user.name "dsh-better-sidebar-ci"
|
|
git config --global user.email "ci@dsh.invalid"
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
- name: Lint
|
|
run: pnpm lint
|
|
- name: Test
|
|
run: pnpm test
|
|
- name: Build
|
|
run: pnpm build
|
|
# The consumer-facing declaration surface guard: a browser-only plugin
|
|
# (no @types/node, skipLibCheck: false) must type-check against the
|
|
# shipped lib/types. Runs AFTER build (it reads the built output).
|
|
- name: Check consumer type surface
|
|
run: pnpm check:consumer-types
|
|
|
|
# Windows parity lane for the pure-logic suite. The codebase carries real
|
|
# win32 branches (shell parsing, WSL path projection, the PowerShell
|
|
# installer) that mock-injection tests alone cannot validate — this lane
|
|
# runs the same typecheck / test / build / consumer-type-surface steps on
|
|
# a real Windows runtime. The plugin-mount lane (real DSH + Playwright
|
|
# Chromium) stays ubuntu-only and is deliberately NOT mirrored here.
|
|
#
|
|
# It also carries the search-engine gate: real fd/ripgrep binaries land on
|
|
# PATH (choco) before the suite runs, and the output-shape assertions run
|
|
# against them afterwards. Windows is where the engine output format bites
|
|
# hardest (backslash separators, CR line endings, console code pages);
|
|
# docs/ci-windows.md holds the red lines.
|
|
ci-windows:
|
|
runs-on: windows-latest
|
|
timeout-minutes: 30
|
|
defaults:
|
|
run:
|
|
# The runner ships Git Bash: multi-line steps and
|
|
# scripts/check-consumer-types.sh work verbatim.
|
|
shell: bash
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
# Tests run git log against this repository and need the full history.
|
|
fetch-depth: 0
|
|
# pnpm version is pinned via packageManager in package.json; the action
|
|
# reads it from there (specifying both makes action-setup fail on
|
|
# purpose with ERR_PNPM_BAD_PM_VERSION).
|
|
- uses: pnpm/action-setup@v6
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
# Same rationale as the ci job: smoke tests spawn git without an
|
|
# identity and rely on ambient config, which the runner lacks.
|
|
- name: Configure git identity for tests
|
|
run: |
|
|
git config --global user.name "dsh-better-sidebar-ci"
|
|
git config --global user.email "ci@dsh.invalid"
|
|
# Real engine binaries for the output-shape assertions below. The probe
|
|
# inside src/search-engines.ts reads PATH, so the whole suite runs with
|
|
# engines present here; the specs never depend on that (they inject
|
|
# their own probes, and the one real-engine case skips when absent).
|
|
- name: Install fd / ripgrep (choco)
|
|
run: choco install fd ripgrep -y --no-progress
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
- name: Lint
|
|
run: pnpm lint
|
|
# `test:windows` runs the whole suite in ONE fork (`--maxWorkers=1`),
|
|
# not `pnpm test`'s unbounded pool. Two distinct Windows-only failures
|
|
# motivated it, both recorded in docs/plans/2026-09-10-dsh-0.1.5-rc.2-adaptation.md:
|
|
#
|
|
# 1. Six red runs were real 5000 ms vitest timeouts in specs that
|
|
# really start a process (tests/agent-pty:71/:106,
|
|
# tests/install-powershell:105 — a cold powershell.exe start
|
|
# measured 12.1 s, tests/git.spec.ts:85 at 9.6 s). The suite now
|
|
# declares its own budgets (global testTimeout 15 s, 30 s in the
|
|
# two heaviest describes), and serial execution stops the
|
|
# process-spawning specs starving each other on a 2-core runner.
|
|
# 2. Four runs died at teardown with `[vitest-pool]: Worker forks
|
|
# emitted error / Worker exited unexpectedly` while reporting
|
|
# N-1 of N files passed and zero FAIL lines — a worker recycling
|
|
# race, not a test failure. It survived --maxWorkers=2, so the
|
|
# lane now recycles nothing at all.
|
|
#
|
|
# No retries: they would hide a real regression instead of removing the
|
|
# race. The cost is wall-clock (the Windows step runs several minutes
|
|
# against a 30-minute job budget), not signal.
|
|
- name: Test
|
|
run: pnpm test:windows
|
|
- name: Build
|
|
run: pnpm build
|
|
- name: Check consumer type surface
|
|
run: pnpm check:consumer-types
|
|
# Output-shape assertions on the REAL engine binaries installed above:
|
|
# the plugin's own argv must produce '/'-separated, CR-free paths and
|
|
# hit a non-ASCII file name. An engine that is absent skips (so the
|
|
# script stays runnable on a dev machine); an assertion failure exits
|
|
# non-zero.
|
|
- name: Engine output-shape assertions (real fd/rg)
|
|
run: pnpm check:engines
|
|
|
|
# Pack the plugin as an npm tarball, mount it into a REAL DSH instance
|
|
# through the official `dsh plugin --profile web add` channel, and render
|
|
# the DSH web UI headlessly (Playwright Chromium) to prove the plugin
|
|
# mounts without crashing the shell. Drives `pnpm test:mount`, which boots
|
|
# a keyless `dsh web` against a scratch profile and sweeps every built-in
|
|
# sidebar tab. No API key needed — the whole lane is deterministic.
|
|
plugin-mount:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
# CI runs must never report to the production telemetry endpoint baked
|
|
# into the DSH composition (same guard DSH's own CI uses).
|
|
env:
|
|
DSH_TELEMETRY_DISABLED: '1'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
# pnpm version is pinned via packageManager in package.json; the action
|
|
# reads it from there (specifying both makes action-setup fail on
|
|
# purpose with ERR_PNPM_BAD_PM_VERSION).
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# Pin the DSH CLI the lane mounts into; the profile's bundle stack
|
|
# (dsh-base / dsh-web-app) resolves from this installation. Keep in
|
|
# step with the plugin's @deepseek-ai/* peer range when bumping.
|
|
# Write an EXACT version, never a dist-tag: when 0.1.7-rc.1 shipped, the
|
|
# npm `alpha` tag still meant 0.1.7-alpha.2, rc.1 went out on `next`, and
|
|
# `latest` was still the 0.1.5 line — `@alpha` would mount a host this
|
|
# plugin no longer supports. The 0.2.0 line repeats the pattern: its
|
|
# first candidate is `next` while `latest` is still 0.1.7-rc.2.
|
|
# The lanes speak the slash-only RPC dialect
|
|
# (tests/e2e/host-protocol.ts).
|
|
#
|
|
# The larger heap is the fix for one of the two ways this step used to
|
|
# die (runs 34490912649 and 34363627184 on the alpha line): the pinned
|
|
# version's TRANSITIVES are declared as floating `^` ranges, so while
|
|
# upstream publishes a prerelease in stages (0.1.5-rc.2 went out
|
|
# 14:43-14:57 on 2026-09-10) npm resolved a mixed peer graph —
|
|
# 3062 ERESOLVE lines, then "Ineffective mark-compacts near heap limit"
|
|
# (exit 134). The other failure mode was a hard ETARGET on a sibling
|
|
# package that appeared minutes later; pinning a version that is fully
|
|
# published (not mid-flight) is the fix for that one.
|
|
#
|
|
# Peer resolution stays ON: `--legacy-peer-deps` was tried in the first
|
|
# cut of this fix and made the install broken rather than robust — it
|
|
# skips exactly the peers a global install has to supply, and
|
|
# @deepseek-ai/dsh-app-boot requires `@deepseek-ai/cordis-plugin-group`
|
|
# (a peer, not a dependency) at boot, so the CLI died with
|
|
# ERR_MODULE_NOT_FOUND before the smoke could even start. Verified
|
|
# locally that the plain install resolves it.
|
|
- name: Install dsh CLI (pinned)
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=4096
|
|
run: npm install -g @deepseek-ai/dsh@0.2.0-rc.1
|
|
|
|
# lib/ is gitignored; the tarball is produced from this build.
|
|
- name: Build and pack the npm tarball
|
|
run: pnpm build && pnpm pack
|
|
|
|
- name: Install Playwright Chromium
|
|
run: pnpm exec playwright install --with-deps chromium
|
|
|
|
- name: Mount + headless-render smoke
|
|
run: pnpm test:mount
|
|
|
|
# Aggregate double-mount regression: a fixture aggregate bundle mounts
|
|
# dsh-better-sidebar under its own entry id BEFORE the plugin's bundle
|
|
# row; the plugin must back off (no duplicate /sidebar/api, boot OK).
|
|
# Uses the pinned DSH CLI installed above.
|
|
- name: Aggregate double-mount regression
|
|
env:
|
|
DSH_CMD: dsh
|
|
run: pnpm test:mount:aggregate
|
|
|
|
- name: Upload Playwright report on failure
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: |
|
|
playwright-report/
|
|
test-results/
|
|
if-no-files-found: ignore
|