diff --git a/docs/module-graph.md b/docs/module-graph.md index 60d331bd69..94deb95fd7 100644 --- a/docs/module-graph.md +++ b/docs/module-graph.md @@ -234,6 +234,7 @@ flowchart TD pkg_cli_account["cli-account"] pkg_tencent_meeting["tencent-meeting"] pkg_tencent_meeting_cli["tencent-meeting-cli"] + pkg_upstream_skills["upstream-skills"] end subgraph group_context["packages/context"] pkg_agent_instructions["agent-instructions"] @@ -538,6 +539,7 @@ flowchart TD pkg_tencent_meeting_cli --> pkg_subprocess pkg_tencent_meeting_cli --> pkg_system_prompt pkg_tencent_meeting_cli --> pkg_typert_protocol + 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 @@ -1691,6 +1693,7 @@ flowchart TD | [`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) | | [`tencent-meeting-cli`](../packages/connector/tencent-meeting-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) | +| [`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 38ba8ef967..a6b5639716 100644 --- a/docs/module-graph.zh.md +++ b/docs/module-graph.zh.md @@ -236,6 +236,7 @@ flowchart TD pkg_cli_account["cli-account"] pkg_tencent_meeting["tencent-meeting"] pkg_tencent_meeting_cli["tencent-meeting-cli"] + pkg_upstream_skills["upstream-skills"] end subgraph group_context["packages/context"] pkg_agent_instructions["agent-instructions"] @@ -540,6 +541,7 @@ flowchart TD pkg_tencent_meeting_cli --> pkg_subprocess pkg_tencent_meeting_cli --> pkg_system_prompt pkg_tencent_meeting_cli --> pkg_typert_protocol + 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 @@ -1693,6 +1695,7 @@ flowchart TD | [`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) | | [`tencent-meeting-cli`](../packages/connector/tencent-meeting-cli) | `connector` | [`skill`](../packages/skill/skill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`typert-protocol`](../packages/typert/protocol) | +| [`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/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}`) 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 () => {