From 90586796552e66e51b124bc69b4b10febcacffcb Mon Sep 17 00:00:00 2001 From: gengruilin Date: Wed, 28 Oct 2026 18:30:45 +0800 Subject: [PATCH 1/3] test(upstream-skills): keep the time-limit and publish tests independent of timing and directory order --- .../connector/upstream-skills/tests/skills.spec.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/connector/upstream-skills/tests/skills.spec.ts b/packages/connector/upstream-skills/tests/skills.spec.ts index e4cc0abf33..712c21da54 100644 --- a/packages/connector/upstream-skills/tests/skills.spec.ts +++ b/packages/connector/upstream-skills/tests/skills.spec.ts @@ -168,7 +168,7 @@ describe('registerUpstreamSkills', () => { expect(states).toEqual(['installed']) expect(await ctx.skills.list()).toEqual(listed(published())) for (const [path, content] of Object.entries(KEPT)) expect(await readFile(join(published(), path), 'utf8')).toBe(content) - expect(await readdir(join(published(), 'skills', 'alpha'))).toEqual(['SKILL.md', 'references']) + expect((await readdir(join(published(), 'skills', 'alpha'))).toSorted()).toEqual(['SKILL.md', 'references']) expect(await readdir(cache())).toEqual([`skills-${set.sha256.slice(0, 16)}`]) expect(host.requests).toEqual([archivePath(set)]) }) @@ -184,9 +184,13 @@ describe('registerUpstreamSkills', () => { it('moves on from a skills URL that does not deliver the whole archive within the time limit', async () => { host.routes[archivePath(set, '/slow')] = (response) => { response.writeHead(200).write(repository().subarray(0, 64)) } host.routes[archivePath(set, '/mirror')] = serve(repository()) - const skills = register({ skillsUrls: [`${host.base}/slow`, `${host.base}/mirror`], skillsTimeoutMs: 100 }) + // The limit applies to each URL, so it also bounds the mirror on a loaded machine. + const skills = register({ skillsUrls: [`${host.base}/slow`, `${host.base}/mirror`], skillsTimeoutMs: 1_000 }) expect(await settled(skills)).toBe('installed') - expect(logged()).toMatchObject([{ message: `vendor: downloading the upstream skills from ${host.base} failed`, error: { cause: { name: 'TimeoutError' } } }]) + expect(warnings()).toEqual([`vendor: downloading the upstream skills from ${host.base} failed`]) + // Depending on which stream observes the abort first, the time limit arrives as the TimeoutError or as its cause. + const timedOut = (error: unknown) => error instanceof Error && [error.name, error.cause instanceof Error ? error.cause.name : ''].includes('TimeoutError') + expect(logged()[0]?.error).toSatisfy(timedOut) }) it('refuses every source whose files differ from the pin, publishes nothing, and logs the failure', async () => { From 81057d987dc2342b62a95ba39f303b561955317e Mon Sep 17 00:00:00 2001 From: gengruilin Date: Wed, 28 Oct 2026 18:30:46 +0800 Subject: [PATCH 2/3] docs(upstream-skills): state that node-tar reads backslashes as slashes on Windows --- packages/connector/upstream-skills/README.i18n.yaml | 4 ++-- packages/connector/upstream-skills/README.md | 2 +- packages/connector/upstream-skills/README.zh.md | 2 +- packages/connector/upstream-skills/src/archive.ts | 3 ++- packages/connector/upstream-skills/tests/archive.spec.ts | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/connector/upstream-skills/README.i18n.yaml b/packages/connector/upstream-skills/README.i18n.yaml index 0a03d85d66..a91b3a3887 100644 --- a/packages/connector/upstream-skills/README.i18n.yaml +++ b/packages/connector/upstream-skills/README.i18n.yaml @@ -24,8 +24,8 @@ en: c3e1b60c8e4e023a zh: e51792ead0b00e7f /deepseek-ai-dsh-upstream-skills/use-this-package/kept-files-and-verification: - en: cd4d442693abdb36 - zh: b0845b8d37496151 + en: 7614b61ddd183abf + zh: 1037e5fb77d3621f /deepseek-ai-dsh-upstream-skills/use-this-package/pinning-a-commit: en: 78a5744ffb34a667 zh: d9fb0a2ac7730b2c diff --git a/packages/connector/upstream-skills/README.md b/packages/connector/upstream-skills/README.md index 808f37d49c..fb2d97f0a6 100644 --- a/packages/connector/upstream-skills/README.md +++ b/packages/connector/upstream-skills/README.md @@ -64,7 +64,7 @@ const skills = registerUpstreamSkills(ctx, { ### Kept files and verification -The library downloads `///tar.gz/` from each `skillsUrls` prefix in order. A prefix that answers with an error status or no body, does not deliver the whole archive within `skillsTimeoutMs`, sends a malformed archive, or sends files that differ from the pin is logged with its origin, and the next prefix is tried; disposing the plugin stops at once. The library keeps every regular file under `directory` except the paths in `exclude`, plus `license`, at their repository paths. It refuses an archive with an empty, `.`, or `..` path segment or a backslash in any entry, entries outside its one top-level directory, a kept path that is a link or appears twice, kept files above `bytes`, or no license file. The digest hashes each kept file's path, byte length, and content in path order, because GitHub keeps the files of a commit archive stable but not its compressed bytes. Verified files are written to a sibling staging directory, which is then renamed to `skills.directory`; a directory that another process, such as Desktop beside Web, published first is kept. +The library downloads `///tar.gz/` from each `skillsUrls` prefix in order. A prefix that answers with an error status or no body, does not deliver the whole archive within `skillsTimeoutMs`, sends a malformed archive, or sends files that differ from the pin is logged with its origin, and the next prefix is tried; disposing the plugin stops at once. The library keeps every regular file under `directory` except the paths in `exclude`, plus `license`, at their repository paths. It refuses an archive with an empty, `.`, or `..` path segment or a backslash in any entry, entries outside its one top-level directory, a kept path that is a link or appears twice, kept files above `bytes`, or no license file. On Windows, node-tar turns backslashes into slashes before the library reads a path, so the segments they separate are checked instead. The digest hashes each kept file's path, byte length, and content in path order, because GitHub keeps the files of a commit archive stable but not its compressed bytes. Verified files are written to a sibling staging directory, which is then renamed to `skills.directory`; a directory that another process, such as Desktop beside Web, published first is kept. ### Pinning a commit diff --git a/packages/connector/upstream-skills/README.zh.md b/packages/connector/upstream-skills/README.zh.md index 4be958877c..a9ecd77403 100644 --- a/packages/connector/upstream-skills/README.zh.md +++ b/packages/connector/upstream-skills/README.zh.md @@ -64,7 +64,7 @@ const skills = registerUpstreamSkills(ctx, { ### 保留的文件与校验 -库按顺序从每个 `skillsUrls` 前缀下载 `<前缀>///tar.gz/`。某个前缀返回错误状态或空响应体、没有在 `skillsTimeoutMs` 内送达完整归档、发来损坏的归档,或发来的文件与固定信息不符时,记录它的来源并尝试下一个;卸载插件则立即停止。库保留 `directory` 下除 `exclude` 列出的路径之外的所有普通文件,以及 `license`,并保持它们的仓库路径。以下归档会被拒绝:任一条目的路径含空段、`.`、`..` 或反斜杠;条目不在唯一的顶层目录下;保留的路径是链接或出现两次;保留的文件超过 `bytes`;没有许可证文件。摘要按路径顺序对每个保留文件的路径、字节长度和内容做哈希,因为 GitHub 保证提交归档里的文件不变,但不保证压缩后的字节不变。校验通过的文件先写入同级的暂存目录,再改名为 `skills.directory`;另一个进程(例如与 Web 同时运行的桌面端)先发布的目录会被保留。 +库按顺序从每个 `skillsUrls` 前缀下载 `<前缀>///tar.gz/`。某个前缀返回错误状态或空响应体、没有在 `skillsTimeoutMs` 内送达完整归档、发来损坏的归档,或发来的文件与固定信息不符时,记录它的来源并尝试下一个;卸载插件则立即停止。库保留 `directory` 下除 `exclude` 列出的路径之外的所有普通文件,以及 `license`,并保持它们的仓库路径。以下归档会被拒绝:任一条目的路径含空段、`.`、`..` 或反斜杠;条目不在唯一的顶层目录下;保留的路径是链接或出现两次;保留的文件超过 `bytes`;没有许可证文件。Windows 上 node-tar 在库读取路径之前已把反斜杠转成 `/`,因此改为检查它分开的各段。摘要按路径顺序对每个保留文件的路径、字节长度和内容做哈希,因为 GitHub 保证提交归档里的文件不变,但不保证压缩后的字节不变。校验通过的文件先写入同级的暂存目录,再改名为 `skills.directory`;另一个进程(例如与 Web 同时运行的桌面端)先发布的目录会被保留。 ### 固定提交 diff --git a/packages/connector/upstream-skills/src/archive.ts b/packages/connector/upstream-skills/src/archive.ts index f02aa94481..57842480cb 100644 --- a/packages/connector/upstream-skills/src/archive.ts +++ b/packages/connector/upstream-skills/src/archive.ts @@ -23,7 +23,8 @@ function isKept(selection: UpstreamSkillSelection, path: string): boolean { * @param selection - which files to keep. * @param maxBytes - the most bytes the kept files may hold; reading stops at the entry that exceeds it. * @returns the kept files keyed by their path relative to the repository root. - * @throws when an entry path is empty, `.`, `..`, or holds a backslash, entries sit under more than one top-level + * @throws when an entry path is empty, `.`, `..`, or holds a backslash (on Windows node-tar has already turned backslashes + * into slashes, so the segments they separate are checked instead), entries sit under more than one top-level * directory, a kept path is not a regular file or appears twice, the kept files exceed `maxBytes`, the license file is * missing, or the archive is malformed. */ diff --git a/packages/connector/upstream-skills/tests/archive.spec.ts b/packages/connector/upstream-skills/tests/archive.spec.ts index 6c09ab4038..687c7b0219 100644 --- a/packages/connector/upstream-skills/tests/archive.spec.ts +++ b/packages/connector/upstream-skills/tests/archive.spec.ts @@ -25,7 +25,8 @@ describe('readArchive', () => { ['a current-directory segment', `${ROOT}/skills/./alpha/SKILL.md`], ['an empty segment', `${ROOT}//skills/alpha/SKILL.md`], ['an absolute path', '/etc/passwd'], - ['a backslash', `${ROOT}/skills/alpha\\SKILL.md`], + // On Windows node-tar turns backslashes into slashes before the library reads the path. + ...process.platform === 'win32' ? [] : [['a backslash', `${ROOT}/skills/alpha\\SKILL.md`]], ])('refuses %s anywhere in the archive and reads no entry after it', async (_case, path) => { const after = { path: `${ROOT}/skills/alpha/../../after`, content: 'x' } await expect(read(withLicense([{ path, content: 'x' }, after]))).rejects.toThrow(`the archive holds the unsafe path ${path}`) From 429eb5844ba35b640689f24f33aca8d65942e7c3 Mon Sep 17 00:00:00 2001 From: gengruilin Date: Wed, 28 Oct 2026 18:30:47 +0800 Subject: [PATCH 3/3] docs(upstream-skills): add the package to the module graph --- docs/module-graph.md | 3 +++ docs/module-graph.zh.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/module-graph.md b/docs/module-graph.md index 3eae45ae49..eedf1ce2df 100644 --- a/docs/module-graph.md +++ b/docs/module-graph.md @@ -231,6 +231,7 @@ flowchart TD end subgraph group_connector["packages/connector"] pkg_cli_account["cli-account"] + pkg_upstream_skills["upstream-skills"] end subgraph group_context["packages/context"] pkg_agent_instructions["agent-instructions"] @@ -531,6 +532,7 @@ flowchart TD pkg_hmr --> pkg_cmdline pkg_cli_account --> pkg_subprocess pkg_cli_account --> pkg_system_prompt + pkg_upstream_skills --> pkg_skill pkg_deliverable_file_references --> pkg_system_prompt pkg_experimental_computer_use_cua_driver_mcp --> pkg_computer_use pkg_experimental_forge_github --> pkg_experimental_forge @@ -1681,6 +1683,7 @@ flowchart TD | [`attachment-local`](../packages/attachment/attachment-local) | `attachment` | [`attachment`](../packages/attachment/attachment), [`home-paths`](../packages/util/home-paths) | | [`hmr`](../packages/boot/hmr) | `boot` | [`app-boot`](../packages/boot/app-boot), [`cmdline`](../packages/boot/cmdline) | | [`cli-account`](../packages/connector/cli-account) | `connector` | [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | +| [`upstream-skills`](../packages/connector/upstream-skills) | `connector` | [`skill`](../packages/skill/skill) | | [`deliverable-file-references`](../packages/deliverables/deliverable-file-references) | `deliverables` | [`system-prompt`](../packages/core/system-prompt) | | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp) | `experimental` | [`computer-use`](../packages/computer-use/computer-use) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`subprocess`](../packages/subprocess/subprocess) | diff --git a/docs/module-graph.zh.md b/docs/module-graph.zh.md index fcb6e7efd6..3881b23ca1 100644 --- a/docs/module-graph.zh.md +++ b/docs/module-graph.zh.md @@ -233,6 +233,7 @@ flowchart TD end subgraph group_connector["packages/connector"] pkg_cli_account["cli-account"] + pkg_upstream_skills["upstream-skills"] end subgraph group_context["packages/context"] pkg_agent_instructions["agent-instructions"] @@ -533,6 +534,7 @@ flowchart TD pkg_hmr --> pkg_cmdline pkg_cli_account --> pkg_subprocess pkg_cli_account --> pkg_system_prompt + pkg_upstream_skills --> pkg_skill pkg_deliverable_file_references --> pkg_system_prompt pkg_experimental_computer_use_cua_driver_mcp --> pkg_computer_use pkg_experimental_forge_github --> pkg_experimental_forge @@ -1683,6 +1685,7 @@ flowchart TD | [`attachment-local`](../packages/attachment/attachment-local) | `attachment` | [`attachment`](../packages/attachment/attachment), [`home-paths`](../packages/util/home-paths) | | [`hmr`](../packages/boot/hmr) | `boot` | [`app-boot`](../packages/boot/app-boot), [`cmdline`](../packages/boot/cmdline) | | [`cli-account`](../packages/connector/cli-account) | `connector` | [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt) | +| [`upstream-skills`](../packages/connector/upstream-skills) | `connector` | [`skill`](../packages/skill/skill) | | [`deliverable-file-references`](../packages/deliverables/deliverable-file-references) | `deliverables` | [`system-prompt`](../packages/core/system-prompt) | | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp) | `experimental` | [`computer-use`](../packages/computer-use/computer-use) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`subprocess`](../packages/subprocess/subprocess) |