refactor(cli-account): declare the shared config schema in the entry module
The config catalog reads a plugin's imported schema only from the entry file it resolves to, so CLI app plugins can now use CliAccountConfig as their Config.
This commit is contained in:
1 parent
1e40d38359
commit
75d96450b0
6 files changed
+22
-24
No files matched your search
@@ -30,8 +30,8 @@
|
||||
en: 9a2ca1dc8d3824ce
|
||||
zh: 93039bfade3d44fa
|
||||
/deepseek-ai-dsh-cli-account/understand-the-implementation:
|
||||
en: 455303ac1b4a8d8b
|
||||
zh: 61c36ecf972fa60e
|
||||
en: dd37cab6897a1ce0
|
||||
zh: c1b694ad3a356709
|
||||
/deepseek-ai-dsh-cli-account/further-exploration:
|
||||
en: 51a9a21640f56d70
|
||||
zh: c18b3aba1e0fe4e6
|
||||
|
||||
@@ -86,7 +86,7 @@ The runtime owns the operation lifecycle and the plugin owns the meaning of each
|
||||
| [`src/executor.ts`](src/executor.ts) | Bounded command execution and process ownership |
|
||||
| [`src/runtime.ts`](src/runtime.ts) | One-at-a-time operations, cancellation, link filtering, failure classification, and the follow stream |
|
||||
| [`src/types.ts`](src/types.ts) | The generic Remote view types |
|
||||
| [`src/config.ts`](src/config.ts) | The shared config fields |
|
||||
| [`src/index.ts`](src/index.ts) | The entry module and the shared config fields |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ const account = new Account({
|
||||
| [`src/executor.ts`](src/executor.ts) | 有上限的命令执行与进程归属 |
|
||||
| [`src/runtime.ts`](src/runtime.ts) | 一次一个操作、取消、链接过滤、失败分类与订阅流 |
|
||||
| [`src/types.ts`](src/types.ts) | 泛型 Remote 视图类型 |
|
||||
| [`src/config.ts`](src/config.ts) | 共用配置字段 |
|
||||
| [`src/index.ts`](src/index.ts) | 入口模块与共用配置字段 |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/** Config fields that CLI plugins share. */
|
||||
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
|
||||
|
||||
/** Where a plugin's CLI is and how long commands that do not wait for the user may run. */
|
||||
export interface CliAccountConfig {
|
||||
/** Absolute directory holding the CLI executable; the plugin defines the default. */
|
||||
binDir?: string
|
||||
/** Deadline in milliseconds for a command that does not wait for the user, including executable lookup. */
|
||||
commandTimeoutMs: number
|
||||
}
|
||||
|
||||
/** Schema for {@link CliAccountConfig}; a plugin with no other fields uses it as its `Config`. */
|
||||
export const CliAccountConfig: z<Partial<CliAccountConfig>, CliAccountConfig> = z.object({
|
||||
binDir: z.string().min(1),
|
||||
commandTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS).default(30_000),
|
||||
})
|
||||
@@ -4,7 +4,23 @@
|
||||
* @module @deepseek-ai/dsh-cli-account
|
||||
*/
|
||||
|
||||
export { CliAccountConfig } from './config.ts'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
|
||||
|
||||
export { CliCommandExecutor, type CliCommandExecutorOptions, type CliCommandResult, type CliRunOptions } from './executor.ts'
|
||||
export { CliAccountRuntime, exitFailure, type CliAccountRuntimeOptions, type CliOperationControl } from './runtime.ts'
|
||||
export type * from './types.ts'
|
||||
|
||||
/** Where a plugin's CLI is and how long commands that do not wait for the user may run. */
|
||||
export interface CliAccountConfig {
|
||||
/** Absolute directory holding the CLI executable; the plugin defines the default. */
|
||||
binDir?: string
|
||||
/** Deadline in milliseconds for a command that does not wait for the user, including executable lookup. */
|
||||
commandTimeoutMs: number
|
||||
}
|
||||
|
||||
/** Schema for {@link CliAccountConfig}; a plugin with no other fields uses it as its `Config`. */
|
||||
export const CliAccountConfig: z<Partial<CliAccountConfig>, CliAccountConfig> = z.object({
|
||||
binDir: z.string().min(1),
|
||||
commandTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS).default(30_000),
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { CliAccountConfig } from '../src/config.ts'
|
||||
import { CliAccountConfig } from '../src/index.ts'
|
||||
|
||||
it('defaults the command deadline and leaves the bin directory to the plugin', () => {
|
||||
expect(CliAccountConfig({})).toEqual({ commandTimeoutMs: 30_000 })
|
||||
|
||||
Reference in new issue
Block a user