From 317716ab27cc31fe7bdec7ff26557d11108e1bf2 Mon Sep 17 00:00:00 2001 From: gengruilin Date: Fri, 30 Oct 2026 17:52:29 +0800 Subject: [PATCH] feat(feishu): run lark-cli.exe on Windows x64 --- packages/connector/feishu-cli/README.i18n.yaml | 15 +++++++++------ packages/connector/feishu-cli/README.md | 12 +++++++++--- packages/connector/feishu-cli/README.zh.md | 12 +++++++++--- packages/connector/feishu-cli/src/cli.ts | 6 +++--- packages/connector/feishu-cli/tests/harness.ts | 7 ++++--- .../feishu-cli/tests/installation.spec.ts | 10 ++++++---- .../connector/feishu-cli/tests/plugin.spec.ts | 6 ++++-- packages/connector/feishu/README.i18n.yaml | 8 ++++---- packages/connector/feishu/README.md | 4 ++-- packages/connector/feishu/README.zh.md | 4 ++-- 10 files changed, 52 insertions(+), 32 deletions(-) diff --git a/packages/connector/feishu-cli/README.i18n.yaml b/packages/connector/feishu-cli/README.i18n.yaml index c607d51e43..84487a9de4 100644 --- a/packages/connector/feishu-cli/README.i18n.yaml +++ b/packages/connector/feishu-cli/README.i18n.yaml @@ -27,11 +27,11 @@ en: 21b806690bb289f6 zh: 08465992827a0e3c /deepseek-ai-dsh-feishu-cli/use-this-package/configure: - en: 6e777c8d3e50258e - zh: 6622a5fa0f2b0775 + en: d4458b73049501cd + zh: f929f9aada46111b /deepseek-ai-dsh-feishu-cli/understand-the-implementation: - en: 796e562005463d41 - zh: 1be570f8158483e0 + en: 51921c1d270a397e + zh: d55ebd66db3159d8 /deepseek-ai-dsh-feishu-cli/further-exploration: en: fcf26946d254f126 zh: 31f194af698606d9 @@ -80,6 +80,9 @@ /deepseek-ai-dsh-feishu-cli/model-experience/cli-path/what-the-model-sees/runtime-context-entry: en: c91314832f78f460 zh: aac156ea0b5b816a +/deepseek-ai-dsh-feishu-cli/model-experience/cli-path/what-the-model-sees/runtime-context-entry-on-windows: + en: 54f899bbaf7ed198 + zh: 31256473a192427b /deepseek-ai-dsh-feishu-cli/model-experience/cli-path/token-effect: en: 2952585b710ffd05 zh: 6e93e58b6256d534 @@ -87,8 +90,8 @@ en: 67398dd4e4b02db9 zh: a873eacd006fa656 /deepseek-ai-dsh-feishu-cli/known-limitations-and-deferred-work: - en: 3806fa58c1987177 - zh: 6f41143f206e5b9e + en: 950376afffef9d49 + zh: a2c6f7ae150ff5ca /deepseek-ai-dsh-feishu-cli/known-limitations-and-deferred-work/dev-note: en: ae8a15329b9dc2d8 zh: bec9872542b38b58 diff --git a/packages/connector/feishu-cli/README.md b/packages/connector/feishu-cli/README.md index 1d75bcac3a..c4fd78e371 100644 --- a/packages/connector/feishu-cli/README.md +++ b/packages/connector/feishu-cli/README.md @@ -55,7 +55,7 @@ A check runs `auth status --verify --json`. The account reads `connected` only w | Field | Default | Meaning | |---|---|---| -| `binDir` | the installed `@larksuite/cli` package's `bin` | Absolute directory containing an executable `lark-cli` | +| `binDir` | the installed `@larksuite/cli` package's `bin` | Absolute directory containing an executable `lark-cli`, `lark-cli.exe` on Windows | | `commandTimeoutMs` | `30000` | Deadline for one skill command, account check, or sign-out, including executable lookup | App setup and sign-in wait up to 10 minutes for the user in the browser, and each command keeps at most 1 MiB of stdout; the [CLI account library](../cli-account/README.md) fixes both limits. @@ -70,7 +70,7 @@ The generated [config catalog](../../../docs/config-catalog.md#deepseek-aidsh-fe
Implementation internals — click to expand -[`src/index.ts`](src/index.ts) is a Remote service registered as `ctx.feishu`. It checks that `binDir/lark-cli` is executable, gives that path to the model in runtime context, and registers the skill provider. [`src/cli.ts`](src/cli.ts) locates `lark-cli` and parses the JSON output of its commands. The [CLI account library](../cli-account/README.md) registers that runtime context, runs each command by the same path, and runs one account operation at a time. [`src/account.ts`](src/account.ts) extends that runtime with the Feishu commands, reads setup and sign-in links from their output lines, and classifies failures through [`src/diagnostic.ts`](src/diagnostic.ts). Disposal cancels the active operation, aborts running commands, and settles after their processes exit. +[`src/index.ts`](src/index.ts) is a Remote service registered as `ctx.feishu`. It checks that `binDir/lark-cli` (`lark-cli.exe` on Windows) is executable, gives that path to the model in runtime context, and registers the skill provider. [`src/cli.ts`](src/cli.ts) locates `lark-cli` and parses the JSON output of its commands. The [CLI account library](../cli-account/README.md) registers that runtime context, runs each command by the same path, and runs one account operation at a time. [`src/account.ts`](src/account.ts) extends that runtime with the Feishu commands, reads setup and sign-in links from their output lines, and classifies failures through [`src/diagnostic.ts`](src/diagnostic.ts). Disposal cancels the active operation, aborts running commands, and settles after their processes exit. [`src/skills.ts`](src/skills.ts) lists the `feishu` skill without running the CLI. Each load runs `lark-cli skills list --json` and places the DSH guidance, an index of each guide's name and description, and the instructions for opening a guide and the files it references; a failed catalog read fails that load, and the next load reads the catalog again. Guides are embedded in the binary, so the skill's resource base is opaque. @@ -163,6 +163,12 @@ While the row is loaded, the [CLI account library](../cli-account/README.md#mode Feishu CLI: run `lark-cli` by its absolute path "/lark-cli"; the bare name may resolve to another installation or to none. ``` +##### Runtime-context entry on Windows + +```markdown +Feishu CLI: run `lark-cli` by its absolute path with the call operator, & '\lark-cli.exe'; the bare name may resolve to another installation or to none. +``` + #### Token effect One line of about 110 characters plus the path in each runtime-context snapshot. @@ -175,7 +181,7 @@ The system prompt does not change; loading or unloading the row, or a changed pa -- Only macOS is supported. Other platforms are unverified, and the Windows executable name `lark-cli.exe` is not located. +- Only macOS and Windows x64 are supported; other platforms are unverified. - Commands must run on this Host. When a composition runs them elsewhere, such as over SSH, the plugin still loads, and each command that runs `lark-cli` fails because the path does not exist there. - The plugin uses the CLI's default configuration. Signing in or out from DSH affects the user's own terminal, and there is no DSH-private account or account picker. The plugin offers no unbind operation; turning it off keeps the configuration and sign-in. - Sign-in reads the device-authorization link and the completion from `lark-cli auth login --json` events; a CLI version that changes those events fails the connection with a retryable result. diff --git a/packages/connector/feishu-cli/README.zh.md b/packages/connector/feishu-cli/README.zh.md index 458f16df56..a02e118cec 100644 --- a/packages/connector/feishu-cli/README.zh.md +++ b/packages/connector/feishu-cli/README.zh.md @@ -55,7 +55,7 @@ kind: "package-reference" | 字段 | 默认值 | 含义 | |---|---|---| -| `binDir` | 已安装 `@larksuite/cli` 包的 `bin` | 包含可执行 `lark-cli` 的绝对目录 | +| `binDir` | 已安装 `@larksuite/cli` 包的 `bin` | 包含可执行 `lark-cli`(Windows 上为 `lark-cli.exe`)的绝对目录 | | `commandTimeoutMs` | `30000` | 单条 skill 命令、账号检查或退出登录的期限,包含可执行文件查找 | 应用配置和登录最多等待用户在浏览器中操作 10 分钟,每条命令最多保留 1 MiB 的 stdout;这两个上限由 [CLI 账号库](../cli-account/README.zh.md)固定。 @@ -70,7 +70,7 @@ kind: "package-reference"
实现内部机制——点击展开 -[`src/index.ts`](src/index.ts) 是注册为 `ctx.feishu` 的 Remote 服务。它检查 `binDir/lark-cli` 是否可执行,在运行时上下文中把这个路径告诉模型,并注册 skill 提供方。[`src/cli.ts`](src/cli.ts) 定位 `lark-cli` 并解析其命令的 JSON 输出。[CLI 账号库](../cli-account/README.zh.md)注册这条运行时上下文,按同一路径运行每条命令,并一次执行一个账号操作。[`src/account.ts`](src/account.ts) 在该运行时上实现飞书的命令,从命令输出行中读取配置与登录链接,并通过 [`src/diagnostic.ts`](src/diagnostic.ts) 对失败分类。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。 +[`src/index.ts`](src/index.ts) 是注册为 `ctx.feishu` 的 Remote 服务。它检查 `binDir/lark-cli`(Windows 上为 `lark-cli.exe`)是否可执行,在运行时上下文中把这个路径告诉模型,并注册 skill 提供方。[`src/cli.ts`](src/cli.ts) 定位 `lark-cli` 并解析其命令的 JSON 输出。[CLI 账号库](../cli-account/README.zh.md)注册这条运行时上下文,按同一路径运行每条命令,并一次执行一个账号操作。[`src/account.ts`](src/account.ts) 在该运行时上实现飞书的命令,从命令输出行中读取配置与登录链接,并通过 [`src/diagnostic.ts`](src/diagnostic.ts) 对失败分类。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。 [`src/skills.ts`](src/skills.ts) 列出 `feishu` skill 时不运行 CLI。每次加载运行 `lark-cli skills list --json`,依次放入 DSH 指引、由每个子指南名称与描述组成的索引,以及打开子指南及其引用文件的说明;目录读取失败时本次加载失败,下次加载会重新读取目录。子指南内嵌在二进制中,因此 skill 的资源基址是 opaque 类型。 @@ -163,6 +163,12 @@ Read a file that a guide references, such as `references/...`, with `lark-cli sk Feishu CLI: run `lark-cli` by its absolute path "/lark-cli"; the bare name may resolve to another installation or to none. ``` +##### Windows 上的运行时上下文条目 + +```markdown +Feishu CLI: run `lark-cli` by its absolute path with the call operator, & '\lark-cli.exe'; the bare name may resolve to another installation or to none. +``` + #### Token 影响 每份运行时上下文快照中一行,约 110 个字符加上路径。 @@ -175,7 +181,7 @@ Feishu CLI: run `lark-cli` by its absolute path "/lark-cli"; the bare na -- 仅支持 macOS。其他平台未经验证,且不会定位 Windows 可执行文件名 `lark-cli.exe`。 +- 仅支持 macOS 和 Windows x64;其他平台未经验证。 - 命令必须在本 Host 上运行。组合把命令放到别处运行(例如通过 SSH)时,插件仍会加载,但每条运行 `lark-cli` 的命令都会因为那里没有这个路径而失败。 - 插件使用 CLI 的默认配置。在 DSH 中登录或退出会影响用户自己的终端,没有 DSH 私有账号或账号选择器。插件不提供解绑操作;关闭插件会保留配置与登录。 - 登录从 `lark-cli auth login --json` 的事件中读取设备授权链接和完成结果;CLI 版本改变这些事件时,连接以可重试的结果失败。 diff --git a/packages/connector/feishu-cli/src/cli.ts b/packages/connector/feishu-cli/src/cli.ts index 49582d908c..274fe308bf 100644 --- a/packages/connector/feishu-cli/src/cli.ts +++ b/packages/connector/feishu-cli/src/cli.ts @@ -3,7 +3,7 @@ import { accessSync, constants } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' -import type { CliCommandExecutor } from '@deepseek-ai/dsh-cli-account' +import { executableFileName, type CliCommandExecutor } from '@deepseek-ai/dsh-cli-account' /** The name lark-cli's guides run it by. */ export const PROGRAM = 'lark-cli' @@ -11,11 +11,11 @@ export const PROGRAM = 'lark-cli' /** * Locate the managed executable. * @param binDir - absolute override; defaults to the installed `@larksuite/cli` package. - * @returns the absolute path of the executable `lark-cli`. + * @returns the absolute path of the executable `lark-cli`, `lark-cli.exe` on Windows. * @throws when the executable is missing. */ export function resolveCliExecutable(binDir: string | undefined): string { - const program = join(binDir ?? join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin'), PROGRAM) + const program = join(binDir ?? join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin'), executableFileName(PROGRAM)) try { accessSync(program, constants.X_OK) } catch (error) { diff --git a/packages/connector/feishu-cli/tests/harness.ts b/packages/connector/feishu-cli/tests/harness.ts index 95e58e0713..6c40ea9c9f 100644 --- a/packages/connector/feishu-cli/tests/harness.ts +++ b/packages/connector/feishu-cli/tests/harness.ts @@ -4,6 +4,7 @@ import { chmod, mkdtemp, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { PassThrough } from 'node:stream' +import { executableFileName } from '@deepseek-ai/dsh-cli-account' import { SubprocessRuntime } from '@deepseek-ai/dsh-subprocess' import type { SubprocessCollectedOutputs, @@ -116,13 +117,13 @@ export function byArguments(replies: Record): (process: Script } /** - * Create a temporary directory holding an executable `lark-cli` placeholder. + * Create a temporary directory holding an executable `lark-cli` placeholder, `lark-cli.exe` on Windows. * @returns the absolute bin directory. */ export async function createBinDir(): Promise { const directory = await mkdtemp(join(tmpdir(), 'dsh-feishu-bin-')) - await writeFile(join(directory, 'lark-cli'), '') - await chmod(join(directory, 'lark-cli'), 0o755) + await writeFile(join(directory, executableFileName('lark-cli')), '') + await chmod(join(directory, executableFileName('lark-cli')), 0o755) return directory } diff --git a/packages/connector/feishu-cli/tests/installation.spec.ts b/packages/connector/feishu-cli/tests/installation.spec.ts index 6c0800edb2..9b8c849fa9 100644 --- a/packages/connector/feishu-cli/tests/installation.spec.ts +++ b/packages/connector/feishu-cli/tests/installation.spec.ts @@ -2,25 +2,27 @@ import { constants } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { beforeEach, expect, it, vi } from 'vitest' +import { executableFileName } from '@deepseek-ai/dsh-cli-account' import { resolveCliExecutable } from '../src/cli.ts' const fs = vi.hoisted(() => ({ accessSync: vi.fn() })) vi.mock('node:fs', async importOriginal => ({ ...await importOriginal(), accessSync: fs.accessSync })) const PACKAGE_BIN = join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin') +const FILE = executableFileName('lark-cli') beforeEach(() => { fs.accessSync.mockReset() }) it('defaults to the executable in the installed @larksuite/cli bin directory', () => { - expect(resolveCliExecutable(undefined)).toBe(join(PACKAGE_BIN, 'lark-cli')) - expect(fs.accessSync).toHaveBeenCalledWith(join(PACKAGE_BIN, 'lark-cli'), constants.X_OK) + expect(resolveCliExecutable(undefined)).toBe(join(PACKAGE_BIN, FILE)) + expect(fs.accessSync).toHaveBeenCalledWith(join(PACKAGE_BIN, FILE), constants.X_OK) }) it('accepts a configured directory and names the missing executable with the install remedy', () => { - expect(resolveCliExecutable('/opt/lark/bin')).toBe('/opt/lark/bin/lark-cli') + expect(resolveCliExecutable('/opt/lark/bin')).toBe(join('/opt/lark/bin', FILE)) fs.accessSync.mockImplementation(() => { throw new Error('EACCES') }) expect(() => resolveCliExecutable(PACKAGE_BIN)) - .toThrow(`feishu: ${join(PACKAGE_BIN, 'lark-cli')} is not executable; approve the @larksuite/cli install script or set binDir`) + .toThrow(`feishu: ${join(PACKAGE_BIN, FILE)} is not executable; approve the @larksuite/cli install script or set binDir`) }) diff --git a/packages/connector/feishu-cli/tests/plugin.spec.ts b/packages/connector/feishu-cli/tests/plugin.spec.ts index 65f8f33c76..360ffe4e71 100644 --- a/packages/connector/feishu-cli/tests/plugin.spec.ts +++ b/packages/connector/feishu-cli/tests/plugin.spec.ts @@ -4,6 +4,8 @@ import { Context } from '@deepseek-ai/cordis' import SkillRegistry, { renderSkillContent } from '@deepseek-ai/dsh-skill' import SystemPrompt, { renderContextSections } from '@deepseek-ai/dsh-system-prompt' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { executableFileName } from '@deepseek-ai/dsh-cli-account' +import { cliPathContextText } from '@deepseek-ai/dsh-cli-account/src/context.ts' import Feishu from '../src/index.ts' import { byArguments, CATALOG, createBinDir, ScriptedSubprocess } from './harness.ts' @@ -68,7 +70,7 @@ describe('Feishu plugin', () => { expect(sections.indexOf('## Opening a guide')).toBeGreaterThan(guides) expect(content).toContain('open one with `lark-cli skills read ` in the Host Shell, not with the skill tool') expect(content).toContain('without the leading `../`: `lark-cli skills read lark-foo/...`') - expect(subprocess.lookups.map(lookup => lookup.command)).toEqual([join(binDir, 'lark-cli')]) + expect(subprocess.lookups.map(lookup => lookup.command)).toEqual([join(binDir, executableFileName('lark-cli'))]) }) it('renders the lark-cli 1.0.97 guide index below the tool-result pruning threshold', async () => { @@ -117,7 +119,7 @@ describe('Feishu plugin', () => { const fiber = await ctx.plugin(Feishu, { ...CONFIG, binDir }) expect(await runtimeContext()).toEqual([{ name: 'feishu:cli', - text: `Feishu CLI: run \`lark-cli\` by its absolute path "${join(binDir, 'lark-cli')}"; the bare name may resolve to another installation or to none.`, + text: cliPathContextText({ name: 'feishu:cli', product: 'Feishu', program: 'lark-cli', executable: join(binDir, executableFileName('lark-cli')) }, process.platform), }]) const loading = expect(load()).rejects.toThrow() await vi.waitFor(() => { expect(subprocess.processes).toHaveLength(1) }) diff --git a/packages/connector/feishu/README.i18n.yaml b/packages/connector/feishu/README.i18n.yaml index ff4c4eae2f..aba9cb363a 100644 --- a/packages/connector/feishu/README.i18n.yaml +++ b/packages/connector/feishu/README.i18n.yaml @@ -9,8 +9,8 @@ en: 5b26d6ad2128b454 zh: 6d3ccfcdb716ef8d /deepseek-ai-dsh-feishu/summary: - en: 109bf10780c7284a - zh: 1a52910fb00cdf40 + en: 8e70fde7a5179e0c + zh: ed7a3eb6124f8ebb /deepseek-ai-dsh-feishu/table-of-contents: en: d152484eb41ac6b4 zh: 09388d293f9be9cb @@ -36,8 +36,8 @@ en: e28f40513f584320 zh: d6a722b900770554 /deepseek-ai-dsh-feishu/known-limitations-and-deferred-work: - en: 508d1a6842f5af30 - zh: d184d7808604f699 + en: b1feae479657ced7 + zh: d7cf575bb2745489 /deepseek-ai-dsh-feishu/known-limitations-and-deferred-work/dev-note: en: e67f633dc6fe7773 zh: e88aeb617ffb74ea diff --git a/packages/connector/feishu/README.md b/packages/connector/feishu/README.md index 6799737121..3877996e6c 100644 --- a/packages/connector/feishu/README.md +++ b/packages/connector/feishu/README.md @@ -9,7 +9,7 @@ English | [中文](README.zh.md) ## Summary -The Feishu plugin lets conversations use Feishu through the official `lark-cli`. Installing this bundle adds two rows: the CLI with its embedded skills, and the Feishu account section on the Plugins page, where the user links an app and signs in without starting a conversation. The CLI keeps the account in its default configuration, which the user's own terminal shares. Only macOS is supported. +The Feishu plugin lets conversations use Feishu through the official `lark-cli`. Installing this bundle adds two rows: the CLI with its embedded skills, and the Feishu account section on the Plugins page, where the user links an app and signs in without starting a conversation. The CLI keeps the account in its default configuration, which the user's own terminal shares. Only macOS and Windows x64 are supported. ## Table of Contents @@ -82,7 +82,7 @@ None beyond the `feishu` row's skill catalog; the bundle itself sends no provide -- Only macOS is supported; the row packages list their own limitations. +- Only macOS and Windows x64 are supported; the row packages list their own limitations. ### Dev Note diff --git a/packages/connector/feishu/README.zh.md b/packages/connector/feishu/README.zh.md index 1fb3f32707..8ccef79a6a 100644 --- a/packages/connector/feishu/README.zh.md +++ b/packages/connector/feishu/README.zh.md @@ -9,7 +9,7 @@ kind: "package-bundle" ## 概述 -飞书插件让对话通过官方 `lark-cli` 使用飞书。安装这个 bundle 会加入两行:带内嵌技能的 CLI,以及插件页上的飞书账号区块;用户在插件页关联应用并登录,不需要先开始对话。CLI 把账号保存在默认配置中,与用户自己的终端共用。仅支持 macOS。 +飞书插件让对话通过官方 `lark-cli` 使用飞书。安装这个 bundle 会加入两行:带内嵌技能的 CLI,以及插件页上的飞书账号区块;用户在插件页关联应用并登录,不需要先开始对话。CLI 把账号保存在默认配置中,与用户自己的终端共用。仅支持 macOS 和 Windows x64。 ## 目录 @@ -82,7 +82,7 @@ pnpm 会拦截 `@larksuite/cli` 的安装脚本,该脚本负责下载并校验 -- 仅支持 macOS;两个行包各自列出其限制。 +- 仅支持 macOS 和 Windows x64;两个行包各自列出其限制。 ### 开发备注