fix(sdk): address remaining tooling review findings

This commit is contained in:
imccyu
2026-07-15 23:08:06 +08:00
parent d8f6251e3a
commit 394706fa3c
12 changed files with 236 additions and 52 deletions

View File

@@ -18,8 +18,23 @@ function hasLocalPluginPackages(root: string): boolean {
}
function hasTsdownConfig(root: string): boolean {
return ['tsdown.config.ts', 'tsdown.config.js', 'tsdown.config.mjs', 'tsdown.config.mts']
const hasConfigFile = [
'tsdown.config.ts', 'tsdown.config.mts', 'tsdown.config.cts',
'tsdown.config.js', 'tsdown.config.mjs', 'tsdown.config.cjs',
'tsdown.config.json',
]
.some(name => existsSync(resolve(root, name)))
if (hasConfigFile) return true
let manifestText: string
try {
manifestText = readFileSync(resolve(root, 'package.json'), 'utf8')
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false
throw error
}
const manifest: unknown = JSON.parse(manifestText)
return manifest !== null && !Array.isArray(manifest) && typeof manifest === 'object'
&& Object.hasOwn(manifest, 'tsdown')
}
/**

View File

@@ -17,6 +17,7 @@ import {
type NestedMultiSelectValue,
type ProjectCommitResult,
type PromptPort,
type RunInterface,
type SdkProject,
} from '@deepseek-ai/dsh-helper'
import { DSH_SDK_TEMPLATES } from '../templates/dsh-sdk-templates.ts'
@@ -39,6 +40,14 @@ function sameOptions(left: readonly string[], right: readonly string[]): boolean
return [...left].sort().join('\0') === [...right].sort().join('\0')
}
function targetRunInterface(
current: RunInterface,
desired: ReadonlyMap<string, NestedMultiSelectValue<string, string>>,
): RunInterface {
const selected = desired.get('feature:app')?.choices[0]
return selected === 'acp' || selected === 'stdio' || selected === 'embed' ? selected : current
}
/** Reconcile one tree selection into domain commands, then review and commit once. */
export class ConfigWorkflow {
private readonly port: PromptPort
@@ -100,6 +109,13 @@ export class ConfigWorkflow {
],
}))
const desiredByTarget = new Map(desired.map(item => [item.value, item]))
const targetProfile = {
...project.profile,
runInterface: targetRunInterface(project.profile.runInterface, desiredByTarget),
}
for (const feature of features) {
if (!feature.isApplicable(targetProfile)) desiredByTarget.delete(featureTarget(feature))
}
for (const feature of features) {
const installation = inspections.get(feature.id)

View File

@@ -109,7 +109,7 @@ export async function startSDK(
* @returns target main result or live Cordis context.
*/
export async function runSDK(
target: string | undefined,
target?: string,
options: BootProjectOptions = {},
): Promise<unknown> {
/* v8 ignore next -- the bin always supplies cwd; direct consumers normally accept process.cwd() */