Files
deepseek-harness/packages/sdk/create-sdk/src/args.ts
Yichen Jiang fee12f1af0 refactor(llm-deepseek)!: rename the provider route to deepseek-official
The native adapter's route was named deepseek, colliding with pi-ai's
catalog provider of the same name, so the two DeepSeek paths could never
be mounted side by side. The web settings page needs both configurable at
once. Compositions, fixtures, goldens, scaffolding defaults, and docs all
move together (pre-release, no shim); TUI/session-query-spill/
missing-credential goldens re-recorded through their keyless refresh
modes because provider-name length shifts box padding and spill
truncation points.
2026-07-29 16:36:07 +08:00

97 lines
3.5 KiB
TypeScript

/**
* Commander adapter for the create-sdk command surface.
*
* @module @deepseek-ai/create-sdk/args
*/
import { Command, Option } from 'commander'
import type { PackageManagerName, RunInterface } from '@deepseek-ai/dsh-helper'
/** Parsed create command flags before interactive resolution. */
export interface CreateArgs {
directory?: string
description?: string
provider?: 'deepseek-official' | 'custom'
baseURL?: string
apiKey?: string
model?: string
runInterface?: RunInterface
packageManager?: PackageManagerName
install?: boolean
linkWorkspace?: boolean
config?: string
configJson?: string
json?: boolean
help: boolean
}
interface CommanderCreateOptions {
description?: string
provider?: 'deepseek-official' | 'custom'
baseUrl?: string
apiKey?: string
model?: string
interface?: RunInterface
pm?: PackageManagerName
install?: boolean
linkWorkspace?: boolean
config?: string
configJson?: string
json?: boolean
help?: boolean
}
function createProgram(): Command {
return new Command()
.name('create-sdk')
.description('Create a DeepSeek Harness SDK project')
.helpOption(false)
.showHelpAfterError(false)
.exitOverride()
.configureOutput({
/* v8 ignore next -- the command wrapper renders the package-owned usage template */
writeOut: () => {},
/* v8 ignore next -- Commander output is deliberately suppressed; errors are returned to the bin wrapper */
writeErr: () => {},
})
.argument('[directory]')
.option('-h, --help')
.option('--description <text>')
.addOption(new Option('--provider <name>').choices(['deepseek-official', 'custom']))
.option('--base-url <url>')
.option('--api-key <key>')
.option('--model <name>')
.addOption(new Option('--interface <name>').choices(['acp', 'tui', 'embed']))
.addOption(new Option('--pm <name>').choices(['npm', 'pnpm', 'yarn']))
.addOption(new Option('--install').default(undefined))
.addOption(new Option('--no-install').default(undefined))
.option('--link-workspace')
.option('--config <path>')
.option('--config-json <json>')
.addOption(new Option('--json').default(undefined))
}
/** Parse create-sdk positionals/options through Commander into a domain-neutral value. */
export function parseCreateArgs(argv: readonly string[]): CreateArgs {
const program = createProgram()
program.parse([...argv], { from: 'user' })
const options = program.opts<CommanderCreateOptions>()
const directory = program.processedArgs[0] as string | undefined
return {
...directory === undefined ? {} : { directory },
...options.description === undefined ? {} : { description: options.description },
...options.provider === undefined ? {} : { provider: options.provider },
...options.baseUrl === undefined ? {} : { baseURL: options.baseUrl },
...options.apiKey === undefined ? {} : { apiKey: options.apiKey },
...options.model === undefined ? {} : { model: options.model },
...options.interface === undefined ? {} : { runInterface: options.interface },
...options.pm === undefined ? {} : { packageManager: options.pm },
...options.install === undefined ? {} : { install: options.install },
...options.linkWorkspace ? { linkWorkspace: true } : {},
...options.config === undefined ? {} : { config: options.config },
...options.configJson === undefined ? {} : { configJson: options.configJson },
...options.json === undefined ? {} : { json: options.json },
help: options.help ?? false,
}
}