refactor(cli): introduce declarative CLI command registry and shared runtime helpers

This commit is contained in:
gitea committed 2026-09-30 00:31:30 +08:00
1 parent 27c86e052a
commit fbdfbaa8d3
3 files changed
+241 -162

No files matched your search

+17
View File
@@ -90,6 +90,23 @@ export async function createScriptEngineClientForCorp(corp: CorpConfig, platform
export const createPiperClientForCorp = createScriptEngineClientForCorp;
export function requireSelectedCorp(
runtime: CliRuntime,
message = "未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose-use auth login 登录。"
): CorpConfig {
if (!runtime.selectedCorp) {
throw new Error(message);
}
return runtime.selectedCorp;
}
export async function getSessionClientForRuntime(runtime: CliRuntime) {
const corp = requireSelectedCorp(runtime);
const corpId = corp.credentials?.corpId || corp.corpId || corp.id;
const client = await createSessionClient(corp);
return { corp, corpId, client };
}
export function prompt(question: string): Promise<string> {
const rl = readline.createInterface({
input: process.stdin,