refactor(feishu): ship a static entry skill and report failures by exit code
The `feishu` skill is now `skills/feishu/SKILL.md`, mounted through the skill filesystem provider as the package's bundled root: the catalog lists it and a load returns the file without running lark-cli, and DSH owns the entry's length, which stays below the tool-result pruning threshold for the 28 guides that lark-cli 1.0.97 embeds. The `lark-cli skills list --json` read, its JSON command helper, the recorded catalog fixture, and the catalog failure cases go away. A failed account command reports its command and exit code through the kit's `exitFailure`. The stderr envelope classification and its `type` and `subtype` fields go away: they only appended two untranslated words to the failure line, while the recovery text is chosen by the operation kind. The `feishu-skills` snapshot is refreshed for the new skill body; the refresh also takes master's current runtime-context wording.
This commit is contained in:
1 parent
44e1378407
commit
4f4e124836
30 files changed
+215
-852
No files matched your search
@@ -33,7 +33,6 @@ const visited = (name, done) => {
|
||||
}
|
||||
const line = (value) => { process.stdout.write(JSON.stringify(value) + '\\n') }
|
||||
switch (process.argv.slice(2).join(' ')) {
|
||||
case 'skills list --json': line({ ok: true, skills: [] }); break
|
||||
case 'auth status --verify --json':
|
||||
if (!state.app) {
|
||||
process.stderr.write(JSON.stringify({ ok: false, error: { type: 'config', subtype: 'not_configured' } }))
|
||||
@@ -119,7 +118,7 @@ describe.skipIf(process.platform === 'win32')('web e2e: Feishu plugin connection
|
||||
await section.getByRole('button', { name: '关联飞书应用', exact: true }).click()
|
||||
await section.getByRole('alert').waitFor({ timeout: 20_000 })
|
||||
expect(await section.getAttribute('data-connector-account')).toBe('disconnected')
|
||||
expect(await section.getByRole('alert').innerText()).toContain('internal · sdk_error')
|
||||
expect(await section.getByRole('alert').innerText()).toContain('config-init · exit 5')
|
||||
expect(await section.getByRole('alert').innerText()).toContain('已有应用')
|
||||
expect(await section.innerText()).not.toContain('fixture-secret')
|
||||
expect(await section.innerText()).not.toContain('fixture-code')
|
||||
|
||||
@@ -1559,7 +1559,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `skills` · `subprocess` · `systemPrompt`
|
||||
- `refs`: [`CliAccountConfig`](../packages/connector/cli-account/src/index.ts)
|
||||
- `source`: [`packages/connector/feishu/src/index.ts:29`](../packages/connector/feishu/src/index.ts)
|
||||
- `source`: [`packages/connector/feishu/src/index.ts:33`](../packages/connector/feishu/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Where lark-cli is and how long a command that does not wait for the user may run. */
|
||||
|
||||
@@ -1561,7 +1561,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `skills` · `subprocess` · `systemPrompt`
|
||||
- `refs`: [`CliAccountConfig`](../packages/connector/cli-account/src/index.ts)
|
||||
- `source`: [`packages/connector/feishu/src/index.ts:29`](../packages/connector/feishu/src/index.ts)
|
||||
- `source`: [`packages/connector/feishu/src/index.ts:33`](../packages/connector/feishu/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Where lark-cli is and how long a command that does not wait for the user may run. */
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
en: 55d9fdc4ef0be522
|
||||
zh: 8063b8baa6c42776
|
||||
/deepseek-ai-dsh-feishu/use-this-package/account-operations:
|
||||
en: 0c5e7c20700696c0
|
||||
zh: a6ac0c5e80ad248d
|
||||
en: 4b5f07c32cac8141
|
||||
zh: 473a23f50efa5947
|
||||
/deepseek-ai-dsh-feishu/use-this-package/configure:
|
||||
en: be7f1c658809cf50
|
||||
zh: 458d6c05a3ffba91
|
||||
/deepseek-ai-dsh-feishu/understand-the-implementation:
|
||||
en: 826060e38654025d
|
||||
zh: 49ebe9f7be76e19b
|
||||
en: 58347ed627e937a5
|
||||
zh: cefa77b932380172
|
||||
/deepseek-ai-dsh-feishu/further-exploration:
|
||||
en: 3332addebdd2dfed
|
||||
zh: 76d826bc7114b075
|
||||
@@ -57,17 +57,11 @@
|
||||
en: 8955ac196848e69f
|
||||
zh: 54aa7db097eafd3c
|
||||
/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/what-the-model-sees:
|
||||
en: 05e71c8816d7c85c
|
||||
zh: 7cfcac5c6d26f88d
|
||||
/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/what-the-model-sees/dsh-guidance:
|
||||
en: 5c7ac466d9d28f26
|
||||
zh: 01dfd0690f58c8bc
|
||||
/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/what-the-model-sees/opening-instructions:
|
||||
en: 0aeb505bbfae6876
|
||||
zh: 7d2747c2e853c430
|
||||
en: 2a9342e3437fff43
|
||||
zh: 30e93bb23973c866
|
||||
/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/token-effect:
|
||||
en: 3a9ea7356aee5a3d
|
||||
zh: 861a77557a3d0067
|
||||
en: f19372aa372976da
|
||||
zh: 647eef6b6980db49
|
||||
/deepseek-ai-dsh-feishu/model-experience/loaded-skill-body/kv-cache-effect:
|
||||
en: 1f6b842a95e14ce4
|
||||
zh: 0d57cdec5e828828
|
||||
@@ -90,8 +84,8 @@
|
||||
en: 67398dd4e4b02db9
|
||||
zh: a873eacd006fa656
|
||||
/deepseek-ai-dsh-feishu/known-limitations-and-deferred-work:
|
||||
en: 950376afffef9d49
|
||||
zh: a2c6f7ae150ff5ca
|
||||
en: 95d813f5fe6e7cb2
|
||||
zh: c65fcf992ac18b69
|
||||
/deepseek-ai-dsh-feishu/known-limitations-and-deferred-work/dev-note:
|
||||
en: be15f75bf32de641
|
||||
zh: 85de42dc5e1d934b
|
||||
@@ -55,7 +55,7 @@ The Plugins page drives these operations through the connector account registry,
|
||||
| `sign-out` | After the user confirms, runs `auth logout --json`, which also signs out the user's own terminal, then checks again |
|
||||
| Cancel | Cancels the operation during app setup or sign-in and waits for its command to exit; other steps are ignored |
|
||||
|
||||
A check runs `auth status --verify --json`. The account reads `connected` only when the CLI reports an available user that its server verified, `signed-out` when the user is missing, not configured, or needs a refresh, `unconfigured` when no app exists, and `unverified` otherwise, for example when verification cannot reach the server. Every state except `unconfigured` carries the configured `appId`. Each link that `config init` prints and each device-authorization link that `auth login` reports is offered only when it is an HTTPS address on `feishu.cn` or `larksuite.com`. A sign-in that leaves requested permissions ungranted (`auth login` exits with code 3 and lists them as missing) still succeeds; a command that later needs a missing permission reports it. Results report succeeded, cancelled, or failed. Failures show the command, observed exit code, and recognized CLI error categories on the page and in the Host log; native messages, paths, and authorization data are omitted. A successful Feishu webpage does not confirm that local credentials were saved. The process running DSH needs access to the CLI configuration and system credential storage; `DSH_HOME` does not relocate either.
|
||||
A check runs `auth status --verify --json`. The account reads `connected` only when the CLI reports an available user that its server verified, `signed-out` when the user is missing, not configured, or needs a refresh, `unconfigured` when no app exists, and `unverified` otherwise, for example when verification cannot reach the server. Every state except `unconfigured` carries the configured `appId`. Each link that `config init` prints and each device-authorization link that `auth login` reports is offered only when it is an HTTPS address on `feishu.cn` or `larksuite.com`. A sign-in that leaves requested permissions ungranted (`auth login` exits with code 3 and lists them as missing) still succeeds; a command that later needs a missing permission reports it. Results report succeeded, cancelled, or failed. Failures show the command and observed exit code on the page and in the Host log; native messages, paths, and authorization data are omitted. A successful Feishu webpage does not confirm that local credentials were saved. The process running DSH needs access to the CLI configuration and system credential storage; `DSH_HOME` does not relocate either.
|
||||
|
||||
### Configure
|
||||
|
||||
@@ -76,9 +76,9 @@ The generated [config catalog](../../../docs/config-catalog.md#deepseek-aidsh-fe
|
||||
<details>
|
||||
<summary>Implementation internals — click to expand</summary>
|
||||
|
||||
[`cordis.patch.yml`](cordis.patch.yml) inserts this package as the `feishu` row after the profile's other layers, and the Plugins page keys the account section by this package name. [`src/index.ts`](src/index.ts) is a function plugin. 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). [`src/presentation.ts`](src/presentation.ts) maps each view to the section the registry serves, in the text of [`src/locales.ts`](src/locales.ts). Disposal cancels the active operation, aborts running commands, and settles after their processes exit.
|
||||
[`cordis.patch.yml`](cordis.patch.yml) inserts this package as the `feishu` row after the profile's other layers, and the Plugins page keys the account section by this package name. [`src/index.ts`](src/index.ts) is a function plugin. It checks that `binDir/lark-cli` (`lark-cli.exe` on Windows) is executable, gives that path to the model in runtime context, and mounts the packaged skill root. [`src/cli.ts`](src/cli.ts) locates `lark-cli` and parses the JSON output of its account 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 reports a failed command by its exit code. [`src/presentation.ts`](src/presentation.ts) maps each view to the section the registry serves, in the text of [`src/locales.ts`](src/locales.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.
|
||||
[`skills/feishu/SKILL.md`](skills/feishu/SKILL.md) is the only skill this package carries: the DSH guidance, an index of the 28 guides that `lark-cli` 1.0.97 embeds, and how to open them. The plugin mounts `skills/` as the bundled root of a [skill filesystem](../../skill/skill-filesystem/README.md) provider named `feishu` without watching it, so the catalog lists the entry and a load returns the file without running the CLI. The guides stay in the binary, and the agent reads them with `lark-cli skills read`.
|
||||
|
||||
</details>
|
||||
|
||||
@@ -122,35 +122,11 @@ The entry is fixed. Loading or unloading the plugin changes the catalog, which i
|
||||
|
||||
#### What the model sees
|
||||
|
||||
A `skill` tool result contains the DSH guidance below, a `## Guides` index with one `` `name`: description `` line for each guide that `lark-cli skills list --json` reports, and the opening instructions below. Its resource description reads `Embedded lark-cli guides; open them with the skills read command given in the loaded skill.`
|
||||
|
||||
##### DSH guidance
|
||||
|
||||
```markdown
|
||||
# Feishu in DSH
|
||||
|
||||
Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.
|
||||
|
||||
When a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.
|
||||
|
||||
Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool's `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.
|
||||
|
||||
Do not install another lark-cli or run `lark-cli update`.
|
||||
```
|
||||
|
||||
##### Opening instructions
|
||||
|
||||
```markdown
|
||||
## Opening a guide
|
||||
|
||||
These guides belong to lark-cli and are not skills: open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool.
|
||||
|
||||
Read a file that a guide references, such as `references/...`, with `lark-cli skills read <name> <relative-path>`. Read a reference to another guide, such as `../lark-foo/...`, with the same command without the leading `../`: `lark-cli skills read lark-foo/...`.
|
||||
```
|
||||
A `skill` tool result for `feishu` contains about 6,700 characters: the DSH guidance, an index that gives each of the 28 guides embedded in `lark-cli` 1.0.97 one line with its routing rules, and how to open a guide. The DSH guidance tells the agent to run `lark-cli` by the absolute path from the current runtime context, to ask the user to connect Feishu on the plugin page before running the CLI's setup and sign-in flow itself, and to set the narrowest `sandbox_permissions` for the commands that save sign-in state. The opening instructions tell the agent that the guides are not skills and that it reads a guide, and the files a guide references, with `lark-cli skills read`. The entry's resource base is its own directory, which holds nothing but the entry.
|
||||
|
||||
#### Token effect
|
||||
|
||||
Each load adds the fixed guidance, the index, and the opening instructions to the retained tool history. For `lark-cli` 1.0.97 the index lists 28 guides, and the tool result has about 8,000 characters. Guides and the files they reference arrive as ordinary Shell output when the agent reads them through `lark-cli`.
|
||||
Each load adds the entry body to the retained tool history. Guides and the files they reference arrive as ordinary Shell output when the agent reads them through `lark-cli`.
|
||||
|
||||
#### KV Cache effect
|
||||
|
||||
@@ -190,6 +166,7 @@ The system prompt does not change; loading or unloading the row, or a changed pa
|
||||
- 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.
|
||||
- The entry's guide index follows `lark-cli` 1.0.97; pinning another `@larksuite/cli` version means checking the index against that version's `lark-cli skills list`.
|
||||
- Under a file sandbox, a token refresh during an ordinary command can be denied and then needs single-command approval.
|
||||
|
||||
<a id="dev-note"></a>
|
||||
|
||||
@@ -55,7 +55,7 @@ pnpm 会拦截 `@larksuite/cli` 的安装脚本,该脚本负责下载并校验
|
||||
| `sign-out` | 用户确认后运行 `auth logout --json`,同时退出用户自己终端里的登录,然后重新检查 |
|
||||
| 取消 | 在应用配置或登录期间取消操作并等待其命令退出;其他步骤会被忽略 |
|
||||
|
||||
检查运行 `auth status --verify --json`。只有 CLI 报告用户可用且已被服务端核实时,账号才是 `connected`;用户缺失、未配置或需要刷新时为 `signed-out`;没有应用时为 `unconfigured`;其他情况为 `unverified`,例如核实时无法连到服务端。除 `unconfigured` 外,每种状态都带有已配置的 `appId`。`config init` 打印的链接和 `auth login` 报告的设备授权链接,只有是 `feishu.cn` 或 `larksuite.com` 上的 HTTPS 地址时才会提供。登录后仍有申请的权限未被授予时(`auth login` 以退出码 3 结束并把它们列为缺失),登录仍算成功;之后需要这些权限的命令会报告缺少哪些。结果分为成功、已取消和失败。失败时,页面和 Host 日志显示命令、观察到的退出码和已识别的 CLI 错误类别;原生消息、路径和授权数据均不保留。飞书网页显示成功不代表本地凭据已保存。运行 DSH 的进程需要能访问 CLI 配置和系统凭据存储;`DSH_HOME` 不会迁移这两者。
|
||||
检查运行 `auth status --verify --json`。只有 CLI 报告用户可用且已被服务端核实时,账号才是 `connected`;用户缺失、未配置或需要刷新时为 `signed-out`;没有应用时为 `unconfigured`;其他情况为 `unverified`,例如核实时无法连到服务端。除 `unconfigured` 外,每种状态都带有已配置的 `appId`。`config init` 打印的链接和 `auth login` 报告的设备授权链接,只有是 `feishu.cn` 或 `larksuite.com` 上的 HTTPS 地址时才会提供。登录后仍有申请的权限未被授予时(`auth login` 以退出码 3 结束并把它们列为缺失),登录仍算成功;之后需要这些权限的命令会报告缺少哪些。结果分为成功、已取消和失败。失败时,页面和 Host 日志显示命令和观察到的退出码;原生消息、路径和授权数据均不保留。飞书网页显示成功不代表本地凭据已保存。运行 DSH 的进程需要能访问 CLI 配置和系统凭据存储;`DSH_HOME` 不会迁移这两者。
|
||||
|
||||
### 配置
|
||||
|
||||
@@ -76,9 +76,9 @@ pnpm 会拦截 `@larksuite/cli` 的安装脚本,该脚本负责下载并校验
|
||||
<details>
|
||||
<summary>实现内部机制——点击展开</summary>
|
||||
|
||||
[`cordis.patch.yml`](cordis.patch.yml) 在 profile 其他层之后把本包作为 `feishu` 行插入,插件页以本包名作为账号区块的 key。[`src/index.ts`](src/index.ts) 是一个函数插件。它检查 `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/presentation.ts`](src/presentation.ts) 用 [`src/locales.ts`](src/locales.ts) 中的文案,把每个视图映射为注册表提供的区块。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。
|
||||
[`cordis.patch.yml`](cordis.patch.yml) 在 profile 其他层之后把本包作为 `feishu` 行插入,插件页以本包名作为账号区块的 key。[`src/index.ts`](src/index.ts) 是一个函数插件。它检查 `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/presentation.ts`](src/presentation.ts) 用 [`src/locales.ts`](src/locales.ts) 中的文案,把每个视图映射为注册表提供的区块。释放时取消进行中的操作,中止正在运行的命令,并在这些进程退出后完成。
|
||||
|
||||
[`src/skills.ts`](src/skills.ts) 列出 `feishu` skill 时不运行 CLI。每次加载运行 `lark-cli skills list --json`,依次放入 DSH 指引、由每个子指南名称与描述组成的索引,以及打开子指南及其引用文件的说明;目录读取失败时本次加载失败,下次加载会重新读取目录。子指南内嵌在二进制中,因此 skill 的资源基址是 opaque 类型。
|
||||
[`skills/feishu/SKILL.md`](skills/feishu/SKILL.md) 是本包携带的唯一 skill:DSH 指引、`lark-cli` 1.0.97 内嵌的 28 个子指南的索引,以及打开它们的方法。插件把 `skills/` 作为名为 `feishu` 的 [skill 文件系统](../../skill/skill-filesystem/README.zh.md)提供方的内置根目录挂载且不监听,因此目录列出入口、加载返回该文件时都不运行 CLI。子指南留在二进制中,agent 用 `lark-cli skills read` 读取。
|
||||
|
||||
</details>
|
||||
|
||||
@@ -122,35 +122,11 @@ Feishu (飞书) and Lark through the bundled lark-cli: documents and wiki, Base,
|
||||
|
||||
#### 模型看到什么
|
||||
|
||||
`skill` 工具结果依次包含下方 DSH 指引、`## Guides` 索引(`lark-cli skills list --json` 报告的每个子指南各占一行 `` `name`: description ``),以及下方的打开说明。其资源描述为 `Embedded lark-cli guides; open them with the skills read command given in the loaded skill.`
|
||||
|
||||
##### DSH 指引
|
||||
|
||||
```markdown
|
||||
# Feishu in DSH
|
||||
|
||||
Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.
|
||||
|
||||
When a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.
|
||||
|
||||
Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool's `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.
|
||||
|
||||
Do not install another lark-cli or run `lark-cli update`.
|
||||
```
|
||||
|
||||
##### 打开说明
|
||||
|
||||
```markdown
|
||||
## Opening a guide
|
||||
|
||||
These guides belong to lark-cli and are not skills: open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool.
|
||||
|
||||
Read a file that a guide references, such as `references/...`, with `lark-cli skills read <name> <relative-path>`. Read a reference to another guide, such as `../lark-foo/...`, with the same command without the leading `../`: `lark-cli skills read lark-foo/...`.
|
||||
```
|
||||
`feishu` 的 `skill` 工具结果约 6,700 个字符:DSH 指引、为 `lark-cli` 1.0.97 内嵌的 28 个子指南各给一行并附路由规则的索引,以及打开子指南的方法。DSH 指引告诉 agent 按当前运行时上下文给出的绝对路径运行 `lark-cli`,在自己运行 CLI 的配置与登录流程之前先请用户到插件页连接飞书,并为保存登录状态的命令设置最窄的 `sandbox_permissions`。打开说明告诉 agent 子指南不是 skill,子指南及其引用的文件都用 `lark-cli skills read` 读取。入口的资源基址是它自己的目录,其中只有入口文件。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
每次加载把固定指引、索引与打开说明加入保留的工具历史。对 `lark-cli` 1.0.97 而言,索引列出 28 个子指南,工具结果约 8,000 个字符。agent 通过 `lark-cli` 读取的子指南及其引用文件作为普通 Shell 输出返回。
|
||||
每次加载把入口正文加入保留的工具历史。agent 通过 `lark-cli` 读取的子指南及其引用文件作为普通 Shell 输出返回。
|
||||
|
||||
#### KV Cache 影响
|
||||
|
||||
@@ -190,6 +166,7 @@ Feishu CLI: run `lark-cli` by its absolute path with the call operator, & '<binD
|
||||
- 命令必须在本 Host 上运行。组合把命令放到别处运行(例如通过 SSH)时,插件仍会加载,但每条运行 `lark-cli` 的命令都会因为那里没有这个路径而失败。
|
||||
- 插件使用 CLI 的默认配置。在 DSH 中登录或退出会影响用户自己的终端,没有 DSH 私有账号或账号选择器。插件不提供解绑操作;关闭插件会保留配置与登录。
|
||||
- 登录从 `lark-cli auth login --json` 的事件中读取设备授权链接和完成结果;CLI 版本改变这些事件时,连接以可重试的结果失败。
|
||||
- 入口的子指南索引对应 `lark-cli` 1.0.97;固定到另一个 `@larksuite/cli` 版本时,需要对照该版本的 `lark-cli skills list` 检查索引。
|
||||
- 在文件沙箱下,普通命令中的 token 刷新可能被拒绝,此时需要单条命令审批。
|
||||
|
||||
<a id="dev-note"></a>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"docs",
|
||||
"lib/index.js",
|
||||
"cordis.patch.yml",
|
||||
"skills",
|
||||
"lib/types/**/*.d.ts",
|
||||
"lib/types/**/*.d.ts.map",
|
||||
"lib/**/*.js.map",
|
||||
@@ -44,6 +45,7 @@
|
||||
"dependencies": {
|
||||
"@deepseek-ai/dsh-brand": "workspace:*",
|
||||
"@deepseek-ai/dsh-cli-account": "workspace:*",
|
||||
"@deepseek-ai/dsh-skill-filesystem": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-values": "workspace:*",
|
||||
"@deepseek-ai/schemastery": "workspace:~",
|
||||
"@larksuite/cli": "1.0.97",
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: feishu
|
||||
description: "Feishu (飞书) and Lark through the bundled lark-cli: documents and wiki, Base, sheets, slides, Drive files, messages and group chats, calendar, video meetings and minutes, tasks, approvals, mail, contacts, OKR, attendance, events, and the CLI's app setup and sign-in. Load it before any Feishu or Lark task; it indexes the guides and how to open them."
|
||||
---
|
||||
|
||||
# Feishu in DSH
|
||||
|
||||
Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.
|
||||
|
||||
When a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.
|
||||
|
||||
Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool's `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.
|
||||
|
||||
Do not install another lark-cli or run `lark-cli update`.
|
||||
|
||||
## Guides
|
||||
|
||||
- `lark-approval`: Feishu Approval: list and handle approval tasks, look up instances, search the definitions you can start, and start native approval instances; to-dos that are not approvals belong to `lark-task`.
|
||||
- `lark-apps`: Miaoda (Spark) app development and hosting: create apps, develop locally or in the cloud, design mockups and prototypes, deploy and publish, and manage logs, metrics, environment variables, collaborators, roles, and automation triggers; use for apps served from `*.aiforce.cloud`.
|
||||
- `lark-attendance`: Feishu Attendance: read your own check-in records.
|
||||
- `lark-base`: Feishu Base (bitable): tables, fields, records, views, statistics, formulas, forms, dashboards, BaseApp pages, workspaces, workflows, roles, and templates; use for `/base/` and `/app/` links.
|
||||
- `lark-calendar`: Feishu Calendar: view, search, create, and update events, manage attendees, query free/busy and suggested times, and book meeting rooms; past video meetings belong to `lark-meeting` and to-dos to `lark-task`.
|
||||
- `lark-contact`: Feishu contacts: resolve a name or email to an `open_id`, look a user up by `open_id`, and search the bots and agents you can see; department trees need the native OpenAPI.
|
||||
- `lark-doc`: Feishu Docs and Wiki documents: read, create, and edit documents, insert or download image attachments, and work with mind notes; route by document URL or token, including `doubao.com` `/docx/` and `/wiki/` links.
|
||||
- `lark-drive`: Feishu Drive: files and folders, upload and download, copy, move, delete, metadata, permissions, comments, subscriptions, titles, versions, security labels, and importing local Word, Markdown, Excel, CSV, PPTX, or `.base` files as Feishu documents.
|
||||
- `lark-event`: Feishu real-time events: subscribe to and consume message, approval, task, meeting, minutes, and whiteboard events as NDJSON, with bounded runs for agents that run as subprocesses.
|
||||
- `lark-im`: Feishu Messenger: send and reply to messages, search chat history, manage group chats and members, transfer images and files, reactions, urgent notices, pinned feeds, interactive cards, and card callbacks.
|
||||
- `lark-mail`: Feishu Mail: draft, send, reply to, forward, read, and search mail, and manage folders, labels, mail contacts, new-mail listeners, and inbox rules; mail intent only.
|
||||
- `lark-markdown`: Feishu Markdown files: view, create, upload, edit, and diff native Markdown files in Feishu, including comparing the remote version with a local draft.
|
||||
- `lark-meeting`: Feishu video meetings: meeting records and artifacts such as minutes and transcripts, Minutes search, upload, download, and editing, bot participation, live meeting content, and in-meeting chat; scheduling, free/busy, and rooms belong to `lark-calendar`.
|
||||
- `lark-minutes`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.
|
||||
- `lark-note`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.
|
||||
- `lark-okr`: Feishu OKR: view and edit cycles, objectives, key results, alignments, metrics, and progress records.
|
||||
- `lark-openapi-explorer`: Feishu native OpenAPI exploration: find and call OpenAPI endpoints the CLI does not wrap when no other guide or registered command fits.
|
||||
- `lark-shared`: lark-cli setup and auth: login, status, and logout, user versus bot identity, business-domain permissions, missing scopes, revoking authorization, and `_notice` JSON.
|
||||
- `lark-sheets`: Feishu Sheets: create and edit spreadsheets, sheet and row or column structure, cell values, formulas, styles, charts, pivot tables, conditional formats, filters, and Excel or CSV import and export; Base belongs to `lark-base`, and searching Drive for a sheet to `lark-drive`.
|
||||
- `lark-skill-maker`: create custom lark-cli skills that wrap Feishu API operations or multi-step flows.
|
||||
- `lark-slides`: Feishu Slides: create presentations, read slide content, and create, delete, read, or partially replace pages; whiteboards inside documents belong to `lark-whiteboard`.
|
||||
- `lark-task`: Feishu Tasks: create and update tasks and their status, subtasks, task lists, assignees, attachments, and task agents.
|
||||
- `lark-vc`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.
|
||||
- `lark-vc-agent`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.
|
||||
- `lark-whiteboard`: Feishu whiteboards inside documents: export a whiteboard as an image or as raw nodes and update its content in several formats.
|
||||
- `lark-wiki`: Feishu Wiki: knowledge spaces, their members, the node hierarchy, and organizing documents and shortcuts; use for `/wiki/` links, while document content belongs to `lark-doc`.
|
||||
- `lark-workflow-meeting-summary`: workflow that collects the meeting minutes of a date range into a structured report.
|
||||
- `lark-workflow-standup-report`: workflow that combines the calendar agenda and open tasks into a summary for a day or a week.
|
||||
|
||||
## Opening a guide
|
||||
|
||||
These guides belong to lark-cli and are not skills: open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool.
|
||||
|
||||
Read a file that a guide references, such as `references/...`, with `lark-cli skills read <name> <relative-path>`. Read a reference to another guide, such as `../lark-foo/...`, with the same command without the leading `../`: `lark-cli skills read lark-foo/...`.
|
||||
@@ -3,10 +3,9 @@
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import { brandString } from '@deepseek-ai/dsh-brand'
|
||||
import z from 'zod'
|
||||
import { CliAccountRuntime, type CliCommandExecutor, type CliOperationControl } from '@deepseek-ai/dsh-cli-account'
|
||||
import { CliAccountRuntime, exitFailure, type CliCommandExecutor, type CliOperationControl } from '@deepseek-ai/dsh-cli-account'
|
||||
import { assertNever } from '@deepseek-ai/dsh-util-values'
|
||||
import { parseJson } from './cli.ts'
|
||||
import { commandFailure } from './diagnostic.ts'
|
||||
import type { FeishuAccountState, FeishuAppId, FeishuOperationFailure, FeishuOperationKind, FeishuPhase } from './types.ts'
|
||||
|
||||
const NotConfigured = z.object({ ok: z.literal(false), error: z.object({ subtype: z.literal('not_configured') }) })
|
||||
@@ -42,7 +41,7 @@ export class FeishuAccount extends CliAccountRuntime<FeishuAccountState, FeishuO
|
||||
check: 'check',
|
||||
cancellable: ['configuring', 'authorizing'],
|
||||
authorizationHosts: ['feishu.cn', 'larksuite.com'],
|
||||
classify: commandFailure,
|
||||
classify: exitFailure,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/** Managed lark-cli location and JSON commands. */
|
||||
/** Managed lark-cli location and the JSON output of its commands. */
|
||||
|
||||
import { accessSync, constants } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { executableFileName, type CliCommandExecutor } from '@deepseek-ai/dsh-cli-account'
|
||||
import { executableFileName } from '@deepseek-ai/dsh-cli-account'
|
||||
|
||||
/** The name lark-cli's guides run it by. */
|
||||
export const PROGRAM = 'lark-cli'
|
||||
@@ -24,37 +24,17 @@ export function resolveCliExecutable(binDir: string | undefined): string {
|
||||
return program
|
||||
}
|
||||
|
||||
function commandLine(args: readonly string[]): string {
|
||||
return [PROGRAM, ...args].join(' ')
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse one command's JSON stdout.
|
||||
* Parse one command's JSON output.
|
||||
* @param args - the command's native arguments, for the error message.
|
||||
* @param stdout - the complete stdout.
|
||||
* @param output - the complete stream the command wrote the JSON to.
|
||||
* @returns unvalidated JSON for the caller to check.
|
||||
* @throws when stdout is not JSON.
|
||||
* @throws when the output is not JSON.
|
||||
*/
|
||||
export function parseJson(args: readonly string[], stdout: string): unknown {
|
||||
export function parseJson(args: readonly string[], output: string): unknown {
|
||||
try {
|
||||
return JSON.parse(stdout)
|
||||
return JSON.parse(output)
|
||||
} catch (error) {
|
||||
throw new Error(`${commandLine(args)} returned invalid JSON`, { cause: error })
|
||||
throw new Error(`${[PROGRAM, ...args].join(' ')} returned invalid JSON`, { cause: error })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run one command and parse its JSON stdout.
|
||||
* @param cli - the plugin's lark-cli executor.
|
||||
* @param args - native arguments without the executable.
|
||||
* @param signal - the caller's lifetime.
|
||||
* @returns unvalidated JSON for the caller to check.
|
||||
* @throws when the command fails, exits nonzero, or prints invalid JSON.
|
||||
*/
|
||||
export async function runJson(cli: CliCommandExecutor, args: readonly string[], signal: AbortSignal): Promise<unknown> {
|
||||
const result = await cli.run(args, signal)
|
||||
if (result.exitCode !== 0) {
|
||||
throw new Error(`${commandLine(args)} exited with ${String(result.exitCode)}${result.stderr.trim() === '' ? '' : `: ${result.stderr.trim()}`}`)
|
||||
}
|
||||
return parseJson(args, result.stdout)
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/** Closed account-command diagnostics projected from the CLI's final stderr JSON envelope. */
|
||||
|
||||
import z from 'zod'
|
||||
import type { CliCommandResult } from '@deepseek-ai/dsh-cli-account'
|
||||
import type { FeishuOperationFailure } from './types.ts'
|
||||
|
||||
const ErrorType = z.enum(['validation', 'authentication', 'authorization', 'config', 'network', 'api', 'policy', 'internal', 'confirmation'])
|
||||
const ErrorSubtype = z.enum(['sdk_error', 'storage', 'file_io', 'not_configured', 'invalid_config', 'invalid_client'])
|
||||
const Envelope = z.object({
|
||||
ok: z.literal(false),
|
||||
error: z.object({
|
||||
type: ErrorType.optional().catch(undefined),
|
||||
subtype: ErrorSubtype.optional().catch(undefined),
|
||||
}),
|
||||
})
|
||||
|
||||
/**
|
||||
* Keep only recognized classifications from the CLI's bounded stderr tail. The final envelope
|
||||
* may follow setup progress and a QR code; truncated or unrecognized output adds no fields.
|
||||
* @param command - the account command whose process finished.
|
||||
* @param result - its observed exit code and captured output.
|
||||
* @returns fixed command identity, exit code, and optional allowlisted classifications.
|
||||
*/
|
||||
export function commandFailure(command: FeishuOperationFailure['command'], result: CliCommandResult): FeishuOperationFailure {
|
||||
const failure: FeishuOperationFailure = { command, exitCode: result.exitCode }
|
||||
const start = result.stderr.lastIndexOf('\n{')
|
||||
let value: unknown
|
||||
try {
|
||||
value = JSON.parse(result.stderr.slice(start < 0 ? 0 : start + 1))
|
||||
} catch (_error) {
|
||||
// Partial or non-JSON stderr cannot supply a safe CLI classification.
|
||||
return failure
|
||||
}
|
||||
const parsed = Envelope.safeParse(value)
|
||||
if (!parsed.success) return failure
|
||||
const { type, subtype } = parsed.data.error
|
||||
return {
|
||||
...failure,
|
||||
...type === undefined ? {} : { type },
|
||||
...subtype === undefined ? {} : { subtype },
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,34 @@
|
||||
/**
|
||||
* Feishu plugin: tells the model the managed lark-cli's absolute path, registers
|
||||
* its embedded skills, and shows the account on the Plugins page through the connector
|
||||
* account registry. The CLI's default account is shared with the user's own terminal.
|
||||
* Feishu plugin: tells the model the managed lark-cli's absolute path, lists the
|
||||
* packaged `feishu` skill that indexes the guides embedded in that CLI, and shows the account on the Plugins page
|
||||
* through the connector account registry. The CLI's default account is shared with the user's own terminal.
|
||||
* @module @deepseek-ai/dsh-feishu
|
||||
*/
|
||||
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import type z from '@deepseek-ai/schemastery'
|
||||
import { CliAccountConfig, CliCommandExecutor, registerCliPathContext } from '@deepseek-ai/dsh-cli-account'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-connector-account'
|
||||
import type {} from '@deepseek-ai/dsh-skill'
|
||||
import * as SkillFilesystem from '@deepseek-ai/dsh-skill-filesystem'
|
||||
import type {} from '@deepseek-ai/dsh-subprocess'
|
||||
import type {} from '@deepseek-ai/dsh-system-prompt'
|
||||
import { FeishuAccount } from './account.ts'
|
||||
import { PROGRAM, resolveCliExecutable } from './cli.ts'
|
||||
import { COPY, FEISHU_PACKAGE, OPERATIONS, presentAccount } from './presentation.ts'
|
||||
import { FeishuSkillProvider } from './skills.ts'
|
||||
|
||||
export type * from './types.ts'
|
||||
|
||||
/** Plugin name. */
|
||||
export const name = 'feishu'
|
||||
|
||||
/** Services the CLI, its skills, and its runtime context need. */
|
||||
/** Services the CLI, its skill, and its runtime context need. */
|
||||
export const inject = ['skills', 'subprocess', 'systemPrompt']
|
||||
|
||||
/** The packaged skill root, which holds only the `feishu` entry; the guides it indexes stay in the CLI. */
|
||||
const SKILLS = fileURLToPath(new URL('../skills', import.meta.url))
|
||||
|
||||
/** Where lark-cli is and how long a command that does not wait for the user may run. */
|
||||
export type Config = CliAccountConfig
|
||||
|
||||
@@ -32,7 +36,7 @@ export type Config = CliAccountConfig
|
||||
export const Config: z<Config> = CliAccountConfig
|
||||
|
||||
/**
|
||||
* Register the CLI and its skills, and show the account on the Plugins page while the connector account registry runs.
|
||||
* Register the CLI and its skill, and show the account on the Plugins page while the connector account registry runs.
|
||||
* @param ctx - Context carrying the skill registry, subprocess runtime, and system prompt.
|
||||
* @param config - CLI location and command deadline.
|
||||
* @throws when `lark-cli` is not executable.
|
||||
@@ -43,7 +47,8 @@ export function apply(ctx: Context, config: Config): void {
|
||||
const cli = new CliCommandExecutor(ctx.subprocess, { program: PROGRAM, executable, commandTimeoutMs: config.commandTimeoutMs })
|
||||
const account = new FeishuAccount(cli, ctx.logger)
|
||||
ctx.effect(() => () => account.dispose(), 'feishu: account')
|
||||
ctx.skills.registerProvider(control => new FeishuSkillProvider(cli, control))
|
||||
// The entry is fixed for the pinned CLI version, so the root is read without a watcher.
|
||||
ctx.plugin(SkillFilesystem, { providerName: 'feishu', includeDefaultRoots: false, watch: false, bundledSkillDir: SKILLS })
|
||||
ctx.inject(['connectorAccounts'], (scope) => {
|
||||
scope.effect(() => scope.connectorAccounts.register({
|
||||
key: FEISHU_PACKAGE, packageName: FEISHU_PACKAGE, source: account, operations: OPERATIONS, copy: COPY, present: presentAccount,
|
||||
|
||||
@@ -76,12 +76,10 @@ function appNotes(appId: FeishuAppId): ConnectorAccountNote[] {
|
||||
}]
|
||||
}
|
||||
|
||||
/** The last failed operation's guidance, with its command, exit code, and the CLI's classified error. */
|
||||
/** The last failed operation's guidance, with its command and exit code. */
|
||||
function failureOf(result: FeishuState['result']): { failure?: ConnectorAccountFailure } {
|
||||
if (result?.outcome !== 'failed') return {}
|
||||
const failure = result.failure
|
||||
const classified = failure === undefined ? [] : [failure.type, failure.subtype].filter(item => item !== undefined)
|
||||
const details = failure === undefined ? [] : [...failureDetails(failure), ...classified]
|
||||
const details = result.failure === undefined ? [] : failureDetails(result.failure)
|
||||
return { failure: { text: text(result.kind === 'link-app' ? 'failed.linkApp' : 'failed'), ...details.length === 0 ? {} : { details } } }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/** One Feishu skill that indexes the embedded lark-cli guides for the DSH Shell and the shared default account. */
|
||||
|
||||
import z from 'zod'
|
||||
import { BUNDLED_SKILL_RANK, isSkillName } from '@deepseek-ai/dsh-skill'
|
||||
import type { SkillCandidate, SkillDefinition, SkillLookupOptions, SkillProvider, SkillProviderControl } from '@deepseek-ai/dsh-skill'
|
||||
import type { CliCommandExecutor } from '@deepseek-ai/dsh-cli-account'
|
||||
import { runJson } from './cli.ts'
|
||||
|
||||
const Catalog = z.object({
|
||||
ok: z.literal(true),
|
||||
skills: z.array(z.object({ name: z.string().refine(isSkillName), description: z.string().min(1) })),
|
||||
})
|
||||
|
||||
const GUIDANCE = [
|
||||
'# Feishu in DSH',
|
||||
'Call this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user\'s own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.',
|
||||
'When a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.',
|
||||
'Commands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool\'s `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.',
|
||||
'Do not install another lark-cli or run `lark-cli update`.',
|
||||
].join('\n\n')
|
||||
|
||||
const OPENING = [
|
||||
'## Opening a guide',
|
||||
'These guides belong to lark-cli and are not skills: open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool.',
|
||||
'Read a file that a guide references, such as `references/...`, with `lark-cli skills read <name> <relative-path>`. Read a reference to another guide, such as `../lark-foo/...`, with the same command without the leading `../`: `lark-cli skills read lark-foo/...`.',
|
||||
].join('\n\n')
|
||||
|
||||
/** Lists the one `feishu` skill without running lark-cli; each load reads the CLI's current guide catalog. */
|
||||
export class FeishuSkillProvider implements SkillProvider {
|
||||
readonly name = 'feishu'
|
||||
|
||||
constructor(
|
||||
private readonly cli: CliCommandExecutor,
|
||||
private readonly control: SkillProviderControl,
|
||||
) {}
|
||||
|
||||
list(): Promise<SkillCandidate[]> {
|
||||
return Promise.resolve([{
|
||||
name: 'feishu',
|
||||
description: 'Feishu (飞书) and Lark through the bundled lark-cli: documents and wiki, Base, sheets, slides, Drive files, messages and group chats, calendar, video meetings and minutes, tasks, approvals, mail, contacts, OKR, attendance, events, and the CLI\'s app setup and sign-in. Load it before any Feishu or Lark task; it indexes the guides and how to open them.',
|
||||
invocation: { modelInvocable: true, userInvocable: true },
|
||||
provider: this.name,
|
||||
source: 'bundled',
|
||||
rank: BUNDLED_SKILL_RANK,
|
||||
locator: 'feishu',
|
||||
resourceBase: { kind: 'opaque', description: 'Embedded lark-cli guides; open them with the skills read command given in the loaded skill.' },
|
||||
}])
|
||||
}
|
||||
|
||||
async get(candidate: SkillCandidate, options: SkillLookupOptions): Promise<SkillDefinition> {
|
||||
const signal = options.signal === undefined ? this.control.signal : AbortSignal.any([options.signal, this.control.signal])
|
||||
const catalog = Catalog.safeParse(await runJson(this.cli, ['skills', 'list', '--json'], signal))
|
||||
if (!catalog.success) throw new Error('lark-cli skills list --json returned an unexpected catalog', { cause: catalog.error })
|
||||
const index = ['## Guides', catalog.data.skills.map(skill => `- \`${skill.name}\`: ${skill.description}`).join('\n')].join('\n\n')
|
||||
const { rank: _rank, locator: _locator, ...summary } = candidate
|
||||
return { ...summary, content: [GUIDANCE, index, OPENING].join('\n\n') }
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,8 @@ export type FeishuOperationKind = 'check' | 'link-app' | 'sign-in' | 'sign-out'
|
||||
/** Feishu steps of an operation, besides the runtime's `checking` and `cancelling`. */
|
||||
export type FeishuPhase = 'configuring' | 'authorizing' | 'verifying' | 'signing-out'
|
||||
|
||||
/** Safe account-command diagnostics; native messages, paths, and credentials are excluded. */
|
||||
export interface FeishuOperationFailure extends CliCommandFailure<'config-init' | 'auth-status' | 'auth-login' | 'auth-logout'> {
|
||||
/** A recognized CLI error category; absent for unrecognized or unreadable error output. */
|
||||
readonly type?: 'validation' | 'authentication' | 'authorization' | 'config' | 'network' | 'api' | 'policy' | 'internal' | 'confirmation'
|
||||
/** A recognized account or storage error subtype; other subtypes are omitted. */
|
||||
readonly subtype?: 'sdk_error' | 'storage' | 'file_io' | 'not_configured' | 'invalid_config' | 'invalid_client'
|
||||
}
|
||||
/** The command and exit code of a failed operation's last command; native messages, paths, and credentials are excluded. */
|
||||
export type FeishuOperationFailure = CliCommandFailure<'config-init' | 'auth-status' | 'auth-login' | 'auth-logout'>
|
||||
|
||||
/** The complete Feishu view the presenter reads after each change. */
|
||||
export type FeishuState = CliAccountView<FeishuAccountState, FeishuOperationKind, FeishuPhase, FeishuOperationFailure>
|
||||
@@ -118,11 +118,11 @@ describe('FeishuAccount', () => {
|
||||
|
||||
const result = await settled(account.start('link-app'))
|
||||
expect(result).toMatchObject({ account: { state: 'unconfigured' }, result: {
|
||||
outcome: 'failed', failure: { command: 'config-init', exitCode: 5, type: 'internal', subtype: 'sdk_error' },
|
||||
outcome: 'failed', failure: { command: 'config-init', exitCode: 5 },
|
||||
} })
|
||||
expect(errors()).toEqual([['feishu: account operation failed: %o', {
|
||||
id: result.result?.id, kind: 'link-app', phase: 'configuring',
|
||||
command: 'config-init', exitCode: 5, type: 'internal', subtype: 'sdk_error',
|
||||
command: 'config-init', exitCode: 5,
|
||||
}]])
|
||||
expect(JSON.stringify({ result, errors: errors() })).not.toContain(sensitive)
|
||||
expect(commands()).toEqual([STATUS, 'config init --new'])
|
||||
@@ -133,7 +133,7 @@ describe('FeishuAccount', () => {
|
||||
script[STATUS] = [{ exitCode: 5, stderr: '{"ok":false,"error":{"type":"internal","subtype":"storage"}}' }]
|
||||
|
||||
expect(await settled(account.start('link-app'))).toMatchObject({ result: {
|
||||
outcome: 'failed', failure: { command: 'auth-status', exitCode: 5, type: 'internal', subtype: 'storage' },
|
||||
outcome: 'failed', failure: { command: 'auth-status', exitCode: 5 },
|
||||
} })
|
||||
})
|
||||
|
||||
|
||||
@@ -1,47 +1,33 @@
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import { CliCommandExecutor } from '@deepseek-ai/dsh-cli-account'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { parseJson, PROGRAM, runJson } from '../src/cli.ts'
|
||||
import { ScriptedSubprocess, type CliReply } from './harness.ts'
|
||||
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 { parseJson, resolveCliExecutable } from '../src/cli.ts'
|
||||
|
||||
const EXECUTABLE = '/fixture/bin/lark-cli'
|
||||
const fs = vi.hoisted(() => ({ accessSync: vi.fn() }))
|
||||
vi.mock('node:fs', async importOriginal => ({ ...await importOriginal<typeof import('node:fs')>(), accessSync: fs.accessSync }))
|
||||
|
||||
describe('lark-cli JSON commands', () => {
|
||||
let ctx: Context
|
||||
let subprocess: ScriptedSubprocess
|
||||
const PACKAGE_BIN = join(dirname(fileURLToPath(import.meta.resolve('@larksuite/cli/package.json'))), 'bin')
|
||||
const FILE = executableFileName('lark-cli')
|
||||
|
||||
beforeEach(async () => {
|
||||
ctx = new Context()
|
||||
await ctx.plugin(ScriptedSubprocess)
|
||||
subprocess = ctx.subprocess as ScriptedSubprocess
|
||||
})
|
||||
beforeEach(() => {
|
||||
fs.accessSync.mockReset()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await ctx.fiber.dispose()
|
||||
})
|
||||
it('defaults to the executable in the installed @larksuite/cli bin directory', () => {
|
||||
expect(resolveCliExecutable(undefined)).toBe(join(PACKAGE_BIN, FILE))
|
||||
expect(fs.accessSync).toHaveBeenCalledWith(join(PACKAGE_BIN, FILE), constants.X_OK)
|
||||
})
|
||||
|
||||
const json = (reply: CliReply) => {
|
||||
subprocess.respond = (process) => { process.reply(reply) }
|
||||
const cli = new CliCommandExecutor(ctx.subprocess, { program: PROGRAM, executable: EXECUTABLE, commandTimeoutMs: 5_000 })
|
||||
return runJson(cli, ['skills', 'list', '--json'], AbortSignal.timeout(5_000))
|
||||
}
|
||||
it('accepts a configured directory and names the missing executable with the install remedy', () => {
|
||||
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, FILE)} is not executable; approve the @larksuite/cli install script or set binDir`)
|
||||
})
|
||||
|
||||
it('runs lark-cli and parses its stdout', async () => {
|
||||
await expect(json({ stdout: '{"ok":\ntrue}\n' })).resolves.toEqual({ ok: true })
|
||||
expect(subprocess.lookups.map(lookup => lookup.command)).toEqual([EXECUTABLE])
|
||||
expect(subprocess.processes[0]?.spec.argv).toEqual([EXECUTABLE, 'skills', 'list', '--json'])
|
||||
})
|
||||
|
||||
it.each([
|
||||
[{ exitCode: 2, stderr: ' {"ok":false} \n' }, 'lark-cli skills list --json exited with 2: {"ok":false}'],
|
||||
[{ exitCode: 1 }, /^lark-cli skills list --json exited with 1$/u],
|
||||
[{ stdout: 'not json' }, 'lark-cli skills list --json returned invalid JSON'],
|
||||
])('names the command that failed %#', async (reply, message) => {
|
||||
await expect(json(reply)).rejects.toThrow(message)
|
||||
})
|
||||
|
||||
it('parses JSON a caller read from another stream', () => {
|
||||
expect(parseJson(['auth', 'status'], '{"ok":false}')).toEqual({ ok: false })
|
||||
expect(() => parseJson(['auth', 'status'], '')).toThrow('lark-cli auth status returned invalid JSON')
|
||||
})
|
||||
it('parses a command\'s JSON output and names the command whose output is not JSON', () => {
|
||||
expect(parseJson(['auth', 'status'], '{"ok":false}')).toEqual({ ok: false })
|
||||
expect(() => parseJson(['auth', 'status'], '')).toThrow('lark-cli auth status returned invalid JSON')
|
||||
})
|
||||
@@ -1,49 +0,0 @@
|
||||
/** Safe projection of native account failures, including setup progress before the JSON envelope. */
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { commandFailure } from '../src/diagnostic.ts'
|
||||
|
||||
const failure = (stderr: string) => commandFailure('config-init', { exitCode: 5, stdout: 'stdout-secret', stderr })
|
||||
|
||||
describe('account command diagnostics', () => {
|
||||
it('keeps only allowlisted classifications after QR output, an authorization URL, and setup progress', () => {
|
||||
const envelope = {
|
||||
ok: false,
|
||||
identity: 'user-secret',
|
||||
error: {
|
||||
type: 'internal', subtype: 'sdk_error',
|
||||
message: 'keychain unavailable: keychain Set failed: open /private/secret-file: operation not permitted',
|
||||
hint: 'https://accounts.feishu.cn/?code=authorization-secret',
|
||||
detail: { app_secret: 'app-secret', access_token: 'token-secret' },
|
||||
},
|
||||
}
|
||||
expect(failure(`QR block\nhttps://open.feishu.cn/?user_code=code-secret\nApp created\n${JSON.stringify(envelope, null, 2)}\n`)).toEqual({
|
||||
command: 'config-init', exitCode: 5, type: 'internal', subtype: 'sdk_error',
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['keychain Set failed: operation not permitted', 'network failed', 'sensitive-token'])('does not infer a cause from the native message %s', (message) => {
|
||||
expect(failure(JSON.stringify({ ok: false, error: { type: 'internal', subtype: 'sdk_error', message } }))).toEqual({
|
||||
command: 'config-init', exitCode: 5, type: 'internal', subtype: 'sdk_error',
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
'', 'permission denied secret', '{"ok":false,"error":',
|
||||
'{"ok":true,"error":{"type":"internal","subtype":"storage"}}',
|
||||
'{"ok":false}',
|
||||
'{"ok":false,"error":{"type":"secret-type","subtype":"secret-subtype"}}',
|
||||
'{"ok":false,"error":{"type":{"secret":"value"},"subtype":42}}',
|
||||
])('omits classifications from unsupported output %#', (stderr) => {
|
||||
expect(failure(stderr)).toEqual({ command: 'config-init', exitCode: 5 })
|
||||
})
|
||||
|
||||
it('keeps a known classification when the other field is unknown', () => {
|
||||
expect(failure('{"ok":false,"error":{"type":"internal","subtype":"unknown-secret"}}')).toEqual({
|
||||
command: 'config-init', exitCode: 5, type: 'internal',
|
||||
})
|
||||
expect(failure('{"ok":false,"error":{"type":"unknown-secret","subtype":"storage"}}')).toEqual({
|
||||
command: 'config-init', exitCode: 5, subtype: 'storage',
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,381 +0,0 @@
|
||||
{
|
||||
"ok": true,
|
||||
"skills": [
|
||||
{
|
||||
"name": "lark-approval",
|
||||
"description": "飞书审批:查询和处理审批待办/已办/实例,搜索可发起审批定义、查看定义详情并发起原生审批实例。当用户要处理审批任务、查看审批实例、搜索或发起审批时使用。审批待办不是飞书任务;非审批类待办走 lark-task。不负责创建审批定义;三方审批定义不走原生提单。",
|
||||
"version": "1.2.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli approval --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-apps",
|
||||
"description": "妙搭(Spark/Miaoda)应用开发与托管:应用创建、本地全栈开发、云端生成迭代、创意设计(UI mockup / 可交互原型 / 线框图 / 落地页 / 仪表盘 / 幻灯片 deck / 视觉探索)、AI相关能力和飞书平台能力或者其他外部能力集成、日志/Trace/监控指标/PV/UV 查询、环境变量管理、应用协作者与协作权限设置、应用角色与成员管理、自动化触发器(定时/记录变更/Webhook/飞书审批)。当用户要开发/新建一个系统·工具·平台·应用,或要本地开发 / 云端开发 / 修改 / 部署 / 发布 / 上线 / 拿可分享链接,或用 HTML 做页面·网站·部署到妙搭,或要设计 / design / mockup / prototype / wireframe / 做 PPT / deck / 视觉探索,或提到妙搭/Spark/Miaoda(应用运行时域名形如 *.aiforce.cloud)、应用数据库、应用文件存储、开放 API Key、可见范围、应用协作者/开发权限、应用角色/角色成员、线上日志、接口请求量、错误量、延迟、访问量、环境变量、给妙搭应用配自动化任务/定时触发/审批通过后自动触发时使用。不负责普通云盘文件上传(lark-drive)、飞书文档编辑(lark-doc)、原生幻灯片创建(lark-slides)。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli apps --help; lark-cli apps +\u003ccmd\u003e --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-attendance",
|
||||
"description": "飞书考勤打卡:查询自己的考勤打卡记录",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli attendance --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-base",
|
||||
"description": "飞书多维表格(Base)操作:建表、字段、记录、视图、统计、公式/lookup、表单、仪表盘、应用模式(BaseApp/AppMode 页面与组件)、Workspace 目录、workflow、角色权限、模板中心(多维表格模板分类/列表/搜索);遇到 Base/多维表格/bitable、BaseApp/AppMode、/base/ 或 /app/ 链接时使用。BaseApp 不走 lark-apps;文件导入/导出转 lark-drive,认证/授权转 lark-shared。",
|
||||
"version": "1.2.23",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli base --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-calendar",
|
||||
"description": "飞书日历:管理日历日程和会议室。查看/搜索日程、创建/更新日程、管理参会人、查询忙闲和推荐时段、预定会议室。当用户需要查看日程安排、创建/修改会议、查询/预定会议室时使用。不负责:查询过去的视频会议记录(走 lark-meeting)、待办任务(走 lark-task)。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli calendar --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-contact",
|
||||
"description": "飞书 / Lark 通讯录:按姓名 / 邮箱解析成 open_id,或按 open_id 反查姓名 / 部门 / 邮箱 / 联系方式 / 个人状态 / 签名,以及按关键词搜索当前用户可见的机器人 / 智能体(agent)。当用户提到一个名字要下一步发消息 / 排日程,或拿到 open_id 想查具体信息时使用。不负责部门树遍历、按部门列员工、组织架构图,这类需求走原生 OpenAPI。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli contact --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-doc",
|
||||
"description": "飞书云文档(Docx / Wiki)内容操作:读取、创建、编辑文档,插入或下载图片附件,以及操作思维笔记。用户提供文档 URL/token(包括 doubao.com 的 /docx/、/wiki/)时使用;按 URL 路径/token 而非域名路由。文档内嵌资源按读取参考中的统一规则分流。独立评论操作走 lark-drive;随正文读取评论使用 docs +fetch。表格或 Base 内部数据操作不在本 skill。",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli docs --help;lark-cli mindnotes --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-shared"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-drive",
|
||||
"description": "飞书云空间(云盘/云存储):管理 Drive 文件和文件夹,包含上传/下载、创建文件夹、复制/移动/删除、查看元数据、查询权限设置、评论/权限/订阅、标题、版本、飞书文档密级标签(secure labels)和本地文件导入。用户需要整理云盘目录、处理云空间资源 URL/token、判断链接类型/真实 token/标题,或导入 Word/Markdown/Excel/CSV/PPTX/.base 为 docx/sheet/bitable/slides 时使用;doubao.com 云空间 URL/token 也按资源路径和 token 路由,不回退 WebFetch。不负责:文档内容编辑(走 lark-doc)、表格/Base 表内数据操作(走 lark-sheets/lark-base)、知识空间节点/成员管理(走 lark-wiki)、原生 Markdown 文件读写/patch/diff(走 lark-markdown)。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli drive --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-event",
|
||||
"description": "Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume \u003cEventKey\u003e` (covers IM messages/reactions/chat changes, Approval status changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli event --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-im",
|
||||
"description": "飞书即时通讯:收发消息和管理群聊。发送和回复消息、搜索聊天记录、管理群聊成员、上传下载图片和文件、管理表情回复、发送应用内/短信/电话加急、发送和处理交互卡片(Interactive Card)、监听卡片按钮回调(card.action.trigger)。当用户需要发消息、查看或搜索聊天记录、下载聊天中的文件、查看群成员、搜索群、创建群聊或话题群、管理标记数据、管理 Feed 置顶(添加/移除/查询置顶会话)、管理标签数据、处理卡片回调时使用。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli im --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-mail",
|
||||
"description": "飞书邮箱:Use when user mentions 起草邮件、写邮件、草稿、发送/回复/转发邮件、查阅邮件、看邮件、搜索邮件、邮件文件夹、邮件标签、邮件联系人、监听新邮件、邮件收信规则等;use for mail/email intent only. Do not use for docs/sheets/calendar/auth setup/pure contact lookup/IM chat tasks.",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli mail --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-markdown",
|
||||
"description": "飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。",
|
||||
"version": "1.2.2",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli markdown --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-meeting",
|
||||
"description": "飞书视频会议:查询会议记录与会议产物(纪要/逐字稿/妙记)、妙记搜索/上传/下载/编辑、机器人参与会议;查询进行中的会议、实时会议内容(发言/聊天/共享文档)问答(会上/会里)、发送会中聊天/表情;基于 meeting_id、meeting_no、event_id、note_id、minute_token、vc-node-id 或妙记 URL 查询相关信息。预约会议、忙闲和会议室管理走 lark-calendar。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli vc --help;lark-cli minutes --help;lark-cli note --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-minutes",
|
||||
"description": "仅当用户或上游配置显式指定 lark-minutes 时使用,相关请求统一交由 lark-meeting 技能处理。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-meeting"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-note",
|
||||
"description": "仅当用户或上游配置显式指定 lark-note 时使用,相关请求统一交由 lark-meeting 技能处理。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-meeting"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-okr",
|
||||
"description": "飞书 OKR:管理目标与关键结果。查看和编辑 OKR 周期、目标、关键结果、对齐关系、量化指标和进展记录。当用户需要查看或创建 OKR、管理目标和关键结果、查看对齐关系时使用。不负责:待办任务管理(lark-task)、日程/会议安排(lark-calendar)、绩效评估",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli okr --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-openapi-explorer",
|
||||
"description": "飞书/Lark 原生 OpenAPI 探索:从官方文档库中挖掘未经 CLI 封装的原生 OpenAPI 接口。当用户的需求无法被现有 lark-* skill 或 lark-cli 已注册命令满足,需要查找并调用原生飞书 OpenAPI 时使用。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-shared",
|
||||
"description": "Use for lark-cli setup/auth tasks: auth login/status/logout, user vs bot identity, business-domain permissions (--domain, including all/docs/drive), missing scopes, revoking authorization, or handling _notice JSON.",
|
||||
"version": "1.1.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-sheets",
|
||||
"description": "飞书电子表格:创建和操作电子表格。支持工作表与行列结构(增删/合并/尺寸/隐藏/冻结/分组)、单元格读写(值/公式/样式/批注/单元格图片)、区域复制移动排序填充、查找替换、批量更新,图表、透视表、条件格式、筛选器与筛选视图、下拉列表、迷你图、浮动图片等对象的创建与维护,以及公式校验、历史版本回滚、本地 Excel/CSV 与飞书表格的导入导出。当用户需要创建或编辑表格、统计汇总与可视化、表格美化、公式计算(含 Excel 公式迁移)、金融/财务建模(DCF、三张表、预算、Sensitivity 等)时使用。多维表格(Base/bitable)请改用 lark-base;若用户是想按名称或关键词搜索云空间(云盘/云存储)里的表格文件,请改用 lark-drive 的 drive +search 先定位资源。当用户给出 doubao.com 的 /sheets/ URL/token 时,也应直接使用本 skill,不要因为域名不是飞书而回退到 WebFetch;路由依据是 URL 路径模式和 token,而不是域名。",
|
||||
"version": "3.5.2",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli sheets --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"siblings": [
|
||||
"lark-shared"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-skill-maker",
|
||||
"description": "创建 lark-cli 的自定义 Skill。当用户需要把飞书 API 操作封装成可复用的 Skill(包装原子 API 或编排多步流程)时使用。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-slides",
|
||||
"description": "飞书幻灯片:创建和编辑幻灯片。创建演示文稿、读取幻灯片内容、管理幻灯片页面(创建、删除、读取、局部替换)。当用户需要创建或编辑幻灯片、读取或修改单个页面时使用。当用户给出 doubao.com 的 /slides/ URL/token 时,也应直接使用本 skill,不要因为域名不是飞书而回退到 WebFetch;路由依据是 URL 路径模式和 token,而不是域名。不负责:云文档内容编辑(走 lark-doc)、云文档里的独立画板对象(走 lark-whiteboard)、上传或下载普通文件(走 lark-drive)。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli slides --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-task",
|
||||
"description": "飞书任务:管理任务、清单和任务智能体。创建待办任务、查看和更新任务状态、拆分子任务、组织任务清单、分配协作成员、上传任务附件、注册或注销任务智能体、更新任务智能体的主页数据、写入智能体任务记录。当用户需要创建待办事项、查看任务列表、跟踪任务进度、管理项目清单或给他人分配任务、为任务上传附件文件、注册注销任务智能体、更新智能体主页数据、写入任务记录时使用。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli task --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-vc",
|
||||
"description": "仅当用户或上游配置显式指定 lark-vc 时使用,相关请求统一交由 lark-meeting 技能处理。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-meeting"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-vc-agent",
|
||||
"description": "仅当用户或上游配置显式指定 lark-vc-agent 时使用,相关请求统一交由 lark-meeting 技能处理。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-meeting"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-whiteboard",
|
||||
"description": "飞书画板:查询和编辑飞书云文档中的画板。支持导出画板为预览图片、导出原始节点结构、使用多种格式更新画板内容。 当用户需要查看画板内容、导出画板图片、编辑画板时使用此 skill。不负责:飞书云文档内容编辑(lark-doc)、文档内嵌电子表格/Base(lark-sheets / lark-base)。\n",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli whiteboard --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-wiki",
|
||||
"description": "飞书知识库:管理知识空间、空间成员和文档节点。创建和查询知识空间、查看和管理空间成员、管理节点层级结构、在知识库中组织文档和快捷方式。当用户需要在知识库中查找或创建文档、浏览知识空间结构、查看或管理空间成员、移动或复制节点时使用。当用户给出 doubao.com 的 /wiki/ URL/token 时,也应直接使用本 skill,不要因为域名不是飞书而回退到 WebFetch;路由依据是 URL 路径模式和 token,而不是域名。不负责:上传文件到知识库节点下(走 lark-drive)、编辑文档/表格/Base 内容(走 lark-doc / lark-sheets / lark-base)。",
|
||||
"version": "1.0.3",
|
||||
"metadata": {
|
||||
"cliHelp": "lark-cli wiki --help",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-workflow-meeting-summary",
|
||||
"description": "会议纪要整理工作流:汇总指定时间范围内的会议纪要并生成结构化报告。当用户需要整理会议纪要、生成会议周报、回顾一段时间内的会议内容时使用。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
],
|
||||
"skills": [
|
||||
"lark-meeting"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lark-workflow-standup-report",
|
||||
"description": "日程待办摘要:编排 calendar +agenda 和 task +get-my-tasks,生成指定日期的日程与未完成任务摘要。适用于了解今天/明天/本周的安排。",
|
||||
"version": "1.0.0",
|
||||
"metadata": {
|
||||
"requires": {
|
||||
"bins": [
|
||||
"lark-cli"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"count": 28
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export interface CliReply {
|
||||
signal?: NodeJS.Signals | null
|
||||
}
|
||||
|
||||
/** A piped process whose managed range exits on termination unless held. */
|
||||
/** A piped process whose managed range exits on termination. */
|
||||
export class ScriptedProcess implements SubprocessHandle {
|
||||
readonly stdin = undefined
|
||||
readonly stdout = new PassThrough()
|
||||
@@ -31,7 +31,6 @@ export class ScriptedProcess implements SubprocessHandle {
|
||||
readonly collected: SubprocessCollectedOutputs = {}
|
||||
readonly done: Promise<SubprocessOutcome>
|
||||
terminated = false
|
||||
holdExit = false
|
||||
private readonly outcome = Promise.withResolvers<SubprocessOutcome>()
|
||||
private readonly exit = Promise.withResolvers<boolean>()
|
||||
|
||||
@@ -57,7 +56,7 @@ export class ScriptedProcess implements SubprocessHandle {
|
||||
this.terminated = true
|
||||
this.close()
|
||||
this.outcome.resolve({ exitCode: null, signal: 'SIGTERM' })
|
||||
if (!this.holdExit) this.exit.resolve(true)
|
||||
this.exit.resolve(true)
|
||||
}
|
||||
|
||||
private close(): void {
|
||||
@@ -65,11 +64,6 @@ export class ScriptedProcess implements SubprocessHandle {
|
||||
if (!this.stderr.writableEnded) this.stderr.end()
|
||||
}
|
||||
|
||||
/** Empty a held managed range. */
|
||||
release(): void {
|
||||
this.exit.resolve(true)
|
||||
}
|
||||
|
||||
waitForExit(): Promise<boolean> {
|
||||
return this.exit.promise
|
||||
}
|
||||
@@ -104,18 +98,6 @@ export class ScriptedSubprocess extends SubprocessRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Answer each command by its arguments after the executable.
|
||||
* @param replies - reply per space-joined argument list.
|
||||
* @returns a `respond` function that fails unknown commands.
|
||||
*/
|
||||
export function byArguments(replies: Record<string, CliReply>): (process: ScriptedProcess) => void {
|
||||
return (process) => {
|
||||
const reply = replies[process.spec.argv.slice(1).join(' ')]
|
||||
process.reply(reply ?? { exitCode: 1, stderr: `unexpected command: ${process.spec.argv.join(' ')}` })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a temporary directory holding an executable `lark-cli` placeholder, `lark-cli.exe` on Windows.
|
||||
* @returns the absolute bin directory.
|
||||
@@ -126,12 +108,3 @@ export async function createBinDir(): Promise<string> {
|
||||
await chmod(join(directory, executableFileName('lark-cli')), 0o755)
|
||||
return directory
|
||||
}
|
||||
|
||||
/** Two-skill catalog in the `skills list --json` format. */
|
||||
export const CATALOG = {
|
||||
ok: true,
|
||||
skills: [
|
||||
{ name: 'lark-doc', description: 'Feishu documents', version: '1.0.0' },
|
||||
{ name: 'lark-shared', description: 'Setup and sign-in', version: '1.1.0' },
|
||||
],
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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<typeof import('node:fs')>(), 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, 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(join('/opt/lark/bin', FILE))
|
||||
fs.accessSync.mockImplementation(() => { throw new Error('EACCES') })
|
||||
expect(() => resolveCliExecutable(PACKAGE_BIN))
|
||||
.toThrow(`feishu: ${join(PACKAGE_BIN, FILE)} is not executable; approve the @larksuite/cli install script or set binDir`)
|
||||
})
|
||||
@@ -1,7 +1,8 @@
|
||||
import { readFile, rm } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { Context } from '@deepseek-ai/cordis'
|
||||
import SkillRegistry, { renderSkillContent } from '@deepseek-ai/dsh-skill'
|
||||
import SkillRegistry 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'
|
||||
@@ -10,17 +11,10 @@ import { cliPathContextText } from '@deepseek-ai/dsh-cli-account/src/context.ts'
|
||||
import * as Feishu from '../src/index.ts'
|
||||
import { COPY, FEISHU_PACKAGE, OPERATIONS, presentAccount } from '../src/presentation.ts'
|
||||
import type { FeishuState } from '../src/types.ts'
|
||||
import { byArguments, CATALOG, createBinDir, ScriptedSubprocess } from './harness.ts'
|
||||
import { createBinDir, ScriptedSubprocess } from './harness.ts'
|
||||
|
||||
const CONFIG = { commandTimeoutMs: 5_000 }
|
||||
const LIST = 'skills list --json'
|
||||
const RELEASE_CATALOG = new URL('./fixtures/lark-cli-1.0.97-skills.json', import.meta.url)
|
||||
|
||||
/**
|
||||
* `packages/bundle/web-app/presets/standard.patch.yml` prunes a tool result only above `thresholdChars: 8192`
|
||||
* code points; a skill result below it reaches the model intact.
|
||||
*/
|
||||
const PRUNER_THRESHOLD_CHARS = 8192
|
||||
const ENTRY = fileURLToPath(new URL('../skills/feishu/SKILL.md', import.meta.url))
|
||||
|
||||
describe('Feishu plugin', () => {
|
||||
let ctx: Context
|
||||
@@ -44,96 +38,36 @@ describe('Feishu plugin', () => {
|
||||
await rm(binDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
const load = async (): Promise<string> => (await ctx.skills.get('feishu'))?.content ?? ''
|
||||
const runtimeContext = async () => renderContextSections(await ctx.systemPrompt.assemble())
|
||||
|
||||
it('lists one feishu skill without running lark-cli', async () => {
|
||||
it('lists the packaged feishu skill and loads its entry without running lark-cli', async () => {
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
|
||||
expect(await ctx.skills.list()).toEqual([{
|
||||
name: 'feishu',
|
||||
description: expect.stringContaining('Load it before any Feishu or Lark task') as string,
|
||||
invocation: { modelInvocable: true, userInvocable: true },
|
||||
provider: 'feishu',
|
||||
source: 'bundled',
|
||||
resourceBase: { kind: 'opaque', description: 'Embedded lark-cli guides; open them with the skills read command given in the loaded skill.' },
|
||||
}])
|
||||
expect(subprocess.processes).toEqual([])
|
||||
})
|
||||
|
||||
it('loads the DSH guidance, an index of every guide, and how to open a guide', async () => {
|
||||
subprocess.respond = byArguments({ [LIST]: { stdout: JSON.stringify(CATALOG) } })
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
|
||||
const content = await load()
|
||||
const sections = content.split('\n\n')
|
||||
const guides = sections.indexOf('## Guides')
|
||||
expect(sections[0]).toBe('# Feishu in DSH')
|
||||
expect(sections[guides + 1]).toBe('- `lark-doc`: Feishu documents\n- `lark-shared`: Setup and sign-in')
|
||||
expect(sections.indexOf('## Opening a guide')).toBeGreaterThan(guides)
|
||||
expect(content).toContain('open one with `lark-cli skills read <name>` 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, executableFileName('lark-cli'))])
|
||||
})
|
||||
|
||||
it('renders the lark-cli 1.0.97 guide index below the tool-result pruning threshold', async () => {
|
||||
const stdout = await readFile(RELEASE_CATALOG, 'utf8')
|
||||
const release = JSON.parse(stdout) as typeof CATALOG
|
||||
subprocess.respond = byArguments({ [LIST]: { stdout } })
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
const catalog = await ctx.skills.list()
|
||||
expect(catalog.map(skill => `${skill.provider}/${skill.source}/${skill.name}`)).toEqual(['feishu/bundled/feishu'])
|
||||
expect(catalog[0]?.description).toContain('Load it before any Feishu or Lark task')
|
||||
|
||||
const loaded = await ctx.skills.get('feishu')
|
||||
if (loaded === undefined) throw new Error('the feishu skill did not load')
|
||||
for (const { name } of release.skills) expect(loaded.content).toContain(`- \`${name}\`: `)
|
||||
// The skill tool returns this rendering; its UTF-16 length is at least the code-point count the pruner measures.
|
||||
expect(renderSkillContent(loaded).length).toBeLessThan(PRUNER_THRESHOLD_CHARS)
|
||||
const file = await readFile(ENTRY, 'utf8')
|
||||
expect(loaded?.content.trim()).toBe(file.slice(file.indexOf('\n---\n', 4) + '\n---\n'.length).trim())
|
||||
expect(loaded?.content).toContain('# Feishu in DSH')
|
||||
expect(loaded?.content).toContain('open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool')
|
||||
expect(loaded?.resourceBase?.kind).toBe('directory')
|
||||
expect(loaded?.resourceBase?.kind === 'directory' ? loaded.resourceBase.path : '').toMatch(/[\\/]skills[\\/]feishu$/u)
|
||||
expect(subprocess.lookups).toEqual([])
|
||||
expect(subprocess.processes).toEqual([])
|
||||
expect(warnings).toEqual([])
|
||||
})
|
||||
|
||||
it('fails a load whose catalog read fails and reads the catalog again on the next load', async () => {
|
||||
let reads = 0
|
||||
subprocess.respond = (process) => {
|
||||
reads += 1
|
||||
process.reply(reads === 1 ? { exitCode: 1, stderr: 'broken install' } : { stdout: JSON.stringify(CATALOG) })
|
||||
}
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
|
||||
await expect(load()).rejects.toThrow('lark-cli skills list --json exited with 1: broken install')
|
||||
expect(await load()).toContain('- `lark-doc`: Feishu documents')
|
||||
})
|
||||
|
||||
it('names the catalog command when its JSON does not match the catalog format', async () => {
|
||||
subprocess.respond = byArguments({ [LIST]: { stdout: JSON.stringify({ ok: true, skills: [{ name: 'Not A Skill', description: 'x' }] }) } })
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
|
||||
await expect(load()).rejects.toThrow('lark-cli skills list --json returned an unexpected catalog')
|
||||
})
|
||||
|
||||
it('terminates the catalog read when the lookup is cancelled', async () => {
|
||||
const lookup = new AbortController()
|
||||
subprocess.respond = () => { lookup.abort(new Error('lookup cancelled')) }
|
||||
await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
|
||||
await expect(ctx.skills.get('feishu', { signal: lookup.signal })).rejects.toThrow('lookup cancelled')
|
||||
await vi.waitFor(() => { expect(subprocess.processes[0]?.terminated).toBe(true) })
|
||||
})
|
||||
|
||||
it('withdraws the runtime context and the skill on disposal after owned processes exit, without a warning', async () => {
|
||||
subprocess.respond = (process) => { process.holdExit = true }
|
||||
it('withdraws the runtime context and the skill on disposal', async () => {
|
||||
const fiber = await ctx.plugin(Feishu, { ...CONFIG, binDir })
|
||||
expect(await runtimeContext()).toEqual([{
|
||||
name: 'feishu:cli',
|
||||
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) })
|
||||
expect((await ctx.skills.list()).map(skill => skill.name)).toEqual(['feishu'])
|
||||
|
||||
let disposed = false
|
||||
const disposal = fiber.dispose().then(() => { disposed = true })
|
||||
await vi.waitFor(() => { expect(subprocess.processes[0]?.terminated).toBe(true) })
|
||||
expect(disposed).toBe(false)
|
||||
subprocess.processes[0]?.release()
|
||||
await disposal
|
||||
await loading
|
||||
await fiber.dispose()
|
||||
|
||||
expect(await runtimeContext()).toEqual([])
|
||||
expect(await ctx.skills.list()).toEqual([])
|
||||
|
||||
@@ -73,13 +73,13 @@ it('retries an unconfirmed sign-in by checking again', () => {
|
||||
expect(shown.buttons).toMatchObject([{ label: say('action.retry'), command: CHECK }])
|
||||
})
|
||||
|
||||
it('reports app-link recovery with the command, exit code, and the CLI\'s classified error', () => {
|
||||
it('reports app-link recovery with the command and exit code', () => {
|
||||
let shown = presentAccount({
|
||||
...UNCONFIGURED,
|
||||
result: { id: OP, kind: 'link-app', outcome: 'failed', failure: { command: 'config-init', exitCode: 1, type: 'internal', subtype: 'sdk_error' } },
|
||||
result: { id: OP, kind: 'link-app', outcome: 'failed', failure: { command: 'config-init', exitCode: 1 } },
|
||||
})
|
||||
expect(labels(shown)).toEqual([zh['action.linkApp']])
|
||||
expect(shown.failure).toMatchObject({ text: say('failed.linkApp'), details: ['config-init', 'exit 1', 'internal', 'sdk_error'] })
|
||||
expect(shown.failure).toMatchObject({ text: say('failed.linkApp'), details: ['config-init', 'exit 1'] })
|
||||
|
||||
shown = presentAccount({ ...SIGNED_OUT, result: { id: OP, kind: 'link-app', outcome: 'failed', failure: { command: 'auth-status', exitCode: null } } })
|
||||
expect(labels(shown)).toEqual([zh['action.signIn']])
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/** The packaged entry skill: its index names exactly the guides lark-cli 1.0.97 embeds, and it stays below the pruner threshold. */
|
||||
import { readdirSync, readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { renderSkillContent } from '@deepseek-ai/dsh-skill'
|
||||
import { expect, it } from 'vitest'
|
||||
|
||||
const skills = fileURLToPath(new URL('../skills/', import.meta.url))
|
||||
const entry = join(skills, 'feishu')
|
||||
|
||||
/** The guides `lark-cli skills list` reports in the pinned `@larksuite/cli` 1.0.97. */
|
||||
const GUIDES = [
|
||||
'lark-approval', 'lark-apps', 'lark-attendance', 'lark-base', 'lark-calendar', 'lark-contact', 'lark-doc', 'lark-drive',
|
||||
'lark-event', 'lark-im', 'lark-mail', 'lark-markdown', 'lark-meeting', 'lark-minutes', 'lark-note', 'lark-okr',
|
||||
'lark-openapi-explorer', 'lark-shared', 'lark-sheets', 'lark-skill-maker', 'lark-slides', 'lark-task', 'lark-vc',
|
||||
'lark-vc-agent', 'lark-whiteboard', 'lark-wiki', 'lark-workflow-meeting-summary', 'lark-workflow-standup-report',
|
||||
]
|
||||
|
||||
/**
|
||||
* `packages/bundle/web-app/presets/standard.patch.yml` prunes a tool result only above `thresholdChars: 8192`
|
||||
* code points; a skill result below it reaches the model intact.
|
||||
*/
|
||||
const PRUNER_THRESHOLD_CHARS = 8192
|
||||
|
||||
/** The body the `skill` tool returns: the file without its YAML frontmatter. */
|
||||
function body(): string {
|
||||
const text = readFileSync(join(entry, 'SKILL.md'), 'utf8')
|
||||
const end = text.indexOf('\n---\n', 4)
|
||||
return text.slice(end + '\n---\n'.length)
|
||||
}
|
||||
|
||||
it('ships only the feishu entry; its guides stay in lark-cli', () => {
|
||||
expect(readdirSync(skills, { recursive: true }).toSorted()).toEqual(['feishu', join('feishu', 'SKILL.md')])
|
||||
})
|
||||
|
||||
it('renders the entry below the pruner threshold', () => {
|
||||
const rendered = renderSkillContent({ name: 'feishu', provider: 'feishu', resourceBase: { kind: 'directory', path: entry }, content: body() })
|
||||
expect(Array.from(rendered).length).toBeLessThan(PRUNER_THRESHOLD_CHARS)
|
||||
})
|
||||
|
||||
it('indexes every guide of the pinned lark-cli exactly once', () => {
|
||||
const indexed = [...body().matchAll(/^- `([a-z-]+)`:/gmu)].map(match => match[1] ?? '')
|
||||
expect(indexed.toSorted()).toEqual(GUIDES)
|
||||
})
|
||||
@@ -20,6 +20,9 @@
|
||||
{
|
||||
"path": "../../util/values"
|
||||
},
|
||||
{
|
||||
"path": "../../skill/skill-filesystem"
|
||||
},
|
||||
{
|
||||
"path": "../../skill/skill"
|
||||
},
|
||||
|
||||
Generated
+3
@@ -7612,6 +7612,9 @@ importers:
|
||||
'@deepseek-ai/dsh-cli-account':
|
||||
specifier: workspace:*
|
||||
version: link:../cli-account
|
||||
'@deepseek-ai/dsh-skill-filesystem':
|
||||
specifier: workspace:*
|
||||
version: link:../../skill/skill-filesystem
|
||||
'@deepseek-ai/dsh-util-values':
|
||||
specifier: workspace:*
|
||||
version: link:../../util/values
|
||||
|
||||
@@ -214,6 +214,8 @@ const packageFileExtras: Readonly<Record<string, readonly string[]>> = {
|
||||
'@deepseek-ai/dsh-client-ui-theme': ['lib/styles'],
|
||||
// The physical-key protocol is a public entry usable without the browser service.
|
||||
'@deepseek-ai/dsh-client-shortcuts': ['lib/protocol.js'],
|
||||
// The Feishu entry skill travels with the package; the guides it indexes stay in lark-cli.
|
||||
'@deepseek-ai/dsh-feishu': ['skills'],
|
||||
// The CPython side ships as source .py files, published as-is rather than built.
|
||||
'@deepseek-ai/dsh-experimental-ptc-runtime-python': ['py/**/*.py'],
|
||||
'@deepseek-ai/dsh-experimental-speech-to-text-sensevoice': ['runtime/assets.json'],
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
{"type":"step/start","data":{"turn":1,"step":1}}
|
||||
{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt"},"id":"{{message:2}}"}},"surfaceOp":"append"}
|
||||
{"type":"user/message","data":{"content":[{"type":"text","text":"Load the feishu skill, open its lark-doc guide through lark-cli, then reply DONE."}],"source":{"kind":"user"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
|
||||
{"type":"user/message","data":{"content":[{"type":"text","text":"Current runtime context. This snapshot supersedes earlier runtime-context snapshots.\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are the root agent. Your agent id is \"{{session:1}}\".\n\nTo message other agents, use send_message({ agent_id: \"<agent-id>\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their ids.\n\nFeishu CLI: run `lark-cli` by its absolute path \"{{cwd}}/feishu-bin/lark-cli\"; the bare name may resolve to another installation or to none."}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are the root agent. Your agent id is \"{{session:1}}\".\n\nTo message other agents, use send_message({ agent_id: \"<agent-id>\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their ids."},{"name":"feishu:cli","text":"Feishu CLI: run `lark-cli` by its absolute path \"{{cwd}}/feishu-bin/lark-cli\"; the bare name may resolve to another installation or to none."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
|
||||
{"type":"user/message","data":{"content":[{"type":"text","text":"<system-reminder>\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"<agent-name>\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nFeishu CLI: run `lark-cli` by its absolute path \"{{cwd}}/feishu-bin/lark-cli\"; the bare name may resolve to another installation or to none.\n</system-reminder>"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"<agent-name>\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"feishu:cli","text":"Feishu CLI: run `lark-cli` by its absolute path \"{{cwd}}/feishu-bin/lark-cli\"; the bare name may resolve to another installation or to none."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
|
||||
{"type":"user/message","data":{"content":[{"type":"text","text":"<system-reminder>\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n<available_skills>\n- `feishu`: Feishu (飞书) and Lark through the bundled lark-cli: documents and wiki, Base, sheets, slides, Drive files, messages and group chats, calendar, video meetings and minutes, tasks, approvals, mail, contacts, OKR, attendance, events, and the CLI's app setup and sign-in. Load it before any Feishu or Lark task; it indexes the guides and how to open them.\n</available_skills>\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its <skill_content> block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n</system-reminder>"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"feishu","description":"Feishu (飞书) and Lark through the bundled lark-cli: documents and wiki, Base, sheets, slides, Drive files, messages and group chats, calendar, video meetings and minutes, tasks, approvals, mail, contacts, OKR, attendance, events, and the CLI's app setup and sign-in. Load it before any Feishu or Lark task; it indexes the guides and how to open them."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
|
||||
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}
|
||||
{"type":"request/context","data":{"provider":"deepseek-official","model":"deepseek-v4-flash"}}
|
||||
{"type":"session/title","data":{"title":"Load the feishu skill, open","messageSeqs":[8],"source":{"kind":"fallback"}}}
|
||||
{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"reasoning","text":"Load the requested Feishu skill."},{"type":"tool-call","id":"call_feishu_skill","name":"skill","arguments":"{\"name\":\"feishu\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:5}}"},"usage":{"inputTokens":100,"outputTokens":20,"cacheReadTokens":0,"reasoningTokens":5},"stream":[{"type":"chunk","time":1791975987526,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}},{"type":"reasoning-chunks","time0":1791975987526,"index":0,"dt":[],"texts":["Load the requested Feishu skill."]},{"type":"chunk","time":1791975987526,"chunk":{"type":"block-start","index":1,"blockType":"tool-call"}},{"type":"tool-call-chunks","time0":1791975987526,"index":1,"dt":[],"id":"call_feishu_skill","name":"skill","args":["{\"name\":\"feishu\"}"]},{"type":"chunk","time":1791975987526,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":"Load the requested Feishu skill."}}},{"type":"chunk","time":1791975987526,"chunk":{"type":"block-end","index":1,"block":{"type":"tool-call","id":"call_feishu_skill","name":"skill","arguments":"{\"name\":\"feishu\"}"}}},{"type":"chunk","time":1791975987526,"chunk":{"type":"usage","usage":{"inputTokens":100,"outputTokens":20,"cacheReadTokens":0,"reasoningTokens":5}}},{"type":"chunk","time":1791975987526,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"}
|
||||
{"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_feishu_skill","name":"skill","arguments":"{\"name\":\"feishu\"}"}}
|
||||
{"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_feishu_skill"},"toolCallId":"call_feishu_skill","content":[{"type":"text","text":"<skill_content name=\"feishu\">\n<skill_resources>\nResources for this skill: Embedded lark-cli guides; open them with the skills read command given in the loaded skill.\nLoad referenced resources only as needed.\n</skill_resources>\n\n<skill_instructions>\n# Feishu in DSH\n\nCall this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.\n\nWhen a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.\n\nCommands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool's `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.\n\nDo not install another lark-cli or run `lark-cli update`.\n\n## Guides\n\n- `lark-doc`: Read and edit Feishu documents.\n\n## Opening a guide\n\nThese guides belong to lark-cli and are not skills: open one with `lark-cli skills read <name>` in the Host Shell, not with the skill tool.\n\nRead a file that a guide references, such as `references/...`, with `lark-cli skills read <name> <relative-path>`. Read a reference to another guide, such as `../lark-foo/...`, with the same command without the leading `../`: `lark-cli skills read lark-foo/...`.\n</skill_instructions>\n</skill_content>"}],"isError":false,"id":"{{message:6}}"}},"sourceEventSeqs":[15],"surfaceOp":"append"}
|
||||
{"type":"tool/result","data":{"turn":1,"step":1,"message":{"role":"tool","source":{"kind":"tool","callId":"call_feishu_skill"},"toolCallId":"call_feishu_skill","content":[{"type":"text","text":"<skill_content name=\"feishu\">\n<skill_resources>\nBase directory for this skill: /Users/gengruilin/github-private/deepseek-harness/.claude/worktrees/m1108-feishu-plugin/packages/connector/feishu/skills/feishu\nResolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed.\n</skill_resources>\n\n<skill_instructions>\n# Feishu in DSH\n\nCall this integration the Feishu plugin (飞书插件 in Chinese) in user-facing replies. Run `lark-cli` in the Host Shell by the absolute path that the current runtime context gives for it, not by name; DSH installs the version this plugin pins. It uses the default lark-cli configuration and sign-in shared with the user's own terminal, so do not remove, switch, or sign out of apps or profiles unless the user asks.\n\nWhen a command reports a missing app configuration or sign-in, first ask the user to connect Feishu on the Feishu plugin page in Plugins. Open the lark-shared guide and run its setup and auth flow yourself only when the user asks to finish it in this conversation. Never ask for or print app secrets or tokens.\n\nCommands that save sign-in state, such as `auth login --device-code` and `config init`, write outside the workspace and use up their one-time authorization even when the save is denied: on the first attempt, set the Shell tool's `sandbox_permissions` to the narrowest mode that can write outside the workspace, with a `justification`. Run other commands in the existing sandbox and set `sandbox_permissions` only when a credential, lock, log, or cache write is denied.\n\nDo not install another lark-cli or run `lark-cli update`.\n\n## Guides\n\n- `lark-approval`: Feishu Approval: list and handle approval tasks, look up instances, search the definitions you can start, and start native approval instances; to-dos that are not approvals belong to `lark-task`.\n- `lark-apps`: Miaoda (Spark) app development and hosting: create apps, develop locally or in the cloud, design mockups and prototypes, deploy and publish, and manage logs, metrics, environment variables, collaborators, roles, and automation triggers; use for apps served from `*.aiforce.cloud`.\n- `lark-attendance`: Feishu Attendance: read your own check-in records.\n- `lark-base`: Feishu Base (bitable): tables, fields, records, views, statistics, formulas, forms, dashboards, BaseApp pages, workspaces, workflows, roles, and templates; use for `/base/` and `/app/` links.\n- `lark-calendar`: Feishu Calendar: view, search, create, and update events, manage attendees, query free/busy and suggested times, and book meeting rooms; past video meetings belong to `lark-meeting` and to-dos to `lark-task`.\n- `lark-contact`: Feishu contacts: resolve a name or email to an `open_id`, look a user up by `open_id`, and search the bots and agents you can see; department trees need the native OpenAPI.\n- `lark-doc`: Feishu Docs and Wiki documents: read, create, and edit documents, insert or download image attachments, and work with mind notes; route by document URL or token, including `doubao.com` `/docx/` and `/wiki/` links.\n- `lark-drive`: Feishu Drive: files and folders, upload and download, copy, move, delete, metadata, permissions, comments, subscriptions, titles, versions, security labels, and importing local Word, Markdown, Excel, CSV, PPTX, or `.base` files as Feishu documents.\n- `lark-event`: Feishu real-time events: subscribe to and consume message, approval, task, meeting, minutes, and whiteboard events as NDJSON, with bounded runs for agents that run as subprocesses.\n- `lark-im`: Feishu Messenger: send and reply to messages, search chat history, manage group chats and members, transfer images and files, reactions, urgent notices, pinned feeds, interactive cards, and card callbacks.\n- `lark-mail`: Feishu Mail: draft, send, reply to, forward, read, and search mail, and manage folders, labels, mail contacts, new-mail listeners, and inbox rules; mail intent only.\n- `lark-markdown`: Feishu Markdown files: view, create, upload, edit, and diff native Markdown files in Feishu, including comparing the remote version with a local draft.\n- `lark-meeting`: Feishu video meetings: meeting records and artifacts such as minutes and transcripts, Minutes search, upload, download, and editing, bot participation, live meeting content, and in-meeting chat; scheduling, free/busy, and rooms belong to `lark-calendar`.\n- `lark-minutes`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.\n- `lark-note`: alias that defers to `lark-meeting`; open it only when the user or a configuration names it.\n- `lark-okr`: Feishu OKR: view and edit cycles, objectives, key results, alignments, metrics, and progress records.\n- `lark-openapi-exLine truncated
|
||||
{"type":"step/end","data":{"turn":1,"step":1}}
|
||||
{"type":"step/start","data":{"turn":1,"step":2}}
|
||||
{"type":"assistant/message","data":{"turn":1,"step":2,"message":{"role":"assistant","content":[{"type":"reasoning","text":"Open the lark-doc guide through lark-cli."},{"type":"tool-call","id":"call_feishu_guide","name":"bash","arguments":"{\"command\":\"\\\"{{cwd}}/feishu-bin/lark-cli\\\" skills read lark-doc\",\"description\":\"Open the lark-doc guide\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:7}}"},"usage":{"inputTokens":200,"outputTokens":20,"cacheReadTokens":0,"reasoningTokens":5},"stream":[{"type":"chunk","time":1793073515578,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}},{"type":"chunk","time":1793073515578,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":"Open the lark-doc guide through lark-cli."}}},{"type":"chunk","time":1793073515578,"chunk":{"type":"block-start","index":1,"blockType":"tool-call"}},{"type":"chunk","time":1793073515578,"chunk":{"type":"block-end","index":1,"block":{"type":"tool-call","id":"call_feishu_guide","name":"bash","arguments":"{\"command\":\"\\\"{{cwd}}/feishu-bin/lark-cli\\\" skills read lark-doc\",\"description\":\"Open the lark-doc guide\"}"}}},{"type":"chunk","time":1793073515578,"chunk":{"type":"usage","usage":{"inputTokens":200,"outputTokens":20,"cacheReadTokens":0,"reasoningTokens":5}}},{"type":"chunk","time":1793073515578,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"}
|
||||
|
||||
@@ -7,7 +7,7 @@ Verify your work by running the code or tests. Keep answers brief and factual.
|
||||
|
||||
Check the [exit code: N] marker on every bash result; investigate failures before moving on.
|
||||
|
||||
Use the read tool — not shell commands like cat — to inspect text files. Use offset and limit to continue reading large files.
|
||||
Use the read tool — not shell commands like cat, sed, head, or tail — to inspect text files. Use offset and limit to read a line range or continue a large file.
|
||||
|
||||
Read an existing file before overwriting it with write and prefer edit for targeted changes.
|
||||
|
||||
@@ -31,4 +31,4 @@ Use the workflow tool ONLY when the user explicitly asks for a workflow or for l
|
||||
|
||||
Start independent delegations with `subagent` or `subagent_fork` together in one assistant message and continue useful work while they run. When only waiting for their results remains, end your turn instead of sleeping or polling; the next result starts a new turn. Collect the subagent results required to complete the task before giving the user a final answer.
|
||||
|
||||
Agents may use different working directories; changes to shared files affect other agents. Split parallel write work into disjoint file or directory scopes. Bash, formatters, code generators, and scripts can overwrite concurrent edits without conflict detection; coordinate their changes explicitly. The agent integrating the work must review the final diff and run relevant tests.
|
||||
Bash, formatters, code generators, and scripts can overwrite concurrent edits without conflict detection; coordinate their changes explicitly. The agent integrating the work must review the final diff and run relevant tests.
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// Offline lark-cli stand-in serving its guide catalog and one guide with the CLI's stderr reading tip.
|
||||
// Offline lark-cli stand-in serving one guide with the CLI's stderr reading tip.
|
||||
const replies = {
|
||||
'skills list --json': { ok: true, skills: [{ name: 'lark-doc', description: 'Read and edit Feishu documents.', version: '1.0.0' }] },
|
||||
'skills read lark-doc': '---\nname: lark-doc\ndescription: Read and edit Feishu documents.\n---\n\n# docs\n\nRead references/lark-doc-fetch.md before fetching a document.',
|
||||
}
|
||||
const tips = {
|
||||
|
||||
Reference in new issue
Block a user