Refine skill and CLI for business-user centric experience

This commit is contained in:
gitea committed 2026-09-20 11:41:36 +08:00
1 parent 7bbddd7aba
commit b5e6cc0282
8 files changed
+484 -581

No files matched your search

+36 -9
View File
@@ -1038,6 +1038,25 @@ export async function handleCorpsCommand(action: string | undefined, maybeName:
throw new Error(`Unknown corps command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
}
// ---------------------------------------------------------------------------
// Helpers & Sanitizers
// ---------------------------------------------------------------------------
export function maskCellphone(phone: string | undefined | null): string {
if (!phone) return "未绑定手机";
const cleaned = phone.trim();
if (cleaned.length === 11) {
return `${cleaned.slice(0, 3)}****${cleaned.slice(7)}`;
}
if (cleaned.length >= 7) {
return `${cleaned.slice(0, 3)}****${cleaned.slice(-4)}`;
}
if (cleaned.length > 4) {
return `${cleaned.slice(0, 2)}****${cleaned.slice(-2)}`;
}
return cleaned;
}
// ---------------------------------------------------------------------------
// Hosecloud integration sync helpers
// ---------------------------------------------------------------------------
@@ -1326,12 +1345,16 @@ async function addHoseCorp(input: Record<string, unknown>) {
);
}
} else if (!force) {
const candidates = staffDetails
.map((s) => `${s.name} (${s.cellphone || "no-phone"}, id: ${s.id}, active: ${s.active})`)
.join("\n - ");
const candidateLines = staffDetails
.map((s, idx) => ` [${idx + 1}] ${s.name} (${maskCellphone(s.cellphone)})`)
.join("\n");
throw new Error(
`Missing required parameter: staffId. Found ${staffDetails.length} candidate administrators:\n - ${candidates}\n` +
`Please specify 'staffId', 'staffName', or 'staffPhone' to explicitly select an account (or pass force:true to bypass).`
`Missing required parameter: staffId. 当前企业共配置了 ${staffDetails.length} 位管理员账号(手机号已脱敏):\n\n` +
`${candidateLines}\n\n` +
`👉 请指定要作为审计身份绑定的管理员:\n` +
` • 按姓名选择:追加 --staffName <姓名>(支持关键字,如: --staffName 谢子豪)\n` +
` • 按手机选择:追加 --staffPhone <手机号>(支持手机后4位,如: --staffPhone 5678)\n` +
` • 或传 force:true / --force 自动使用默认首位管理员。`
);
}
}
@@ -1348,7 +1371,7 @@ async function addHoseCorp(input: Record<string, unknown>) {
}
const id = optionalString(input, "id") ?? corpId;
const name = corpName ?? corpId;
let name = nameInput ?? corpName ?? corpId;
const sealUrl = optionalString(input, "sealUrl") ?? `https://${corpId.toLowerCase()}.sealai.cc`;
const config: CorpConfig = {
@@ -1376,7 +1399,11 @@ async function addHoseCorp(input: Record<string, unknown>) {
if (verify) {
clearCorpTokenCache(id);
await resolveLiveSealEnterpriseConfig(config);
const live = await resolveLiveSealEnterpriseConfig(config);
if ((!nameInput || nameInput === corpId) && live.tenantName && live.tenantName !== corpId) {
name = live.tenantName;
config.name = live.tenantName;
}
}
const enterprisesDir = resolveWritableEnterprisesDir();
@@ -1529,7 +1556,7 @@ async function addLinkAsHoseCorp(
appKey: selectedKey.appKey,
appSecurity: selectedKey.appSecurity,
corpId: result.corpId,
name: name ?? result.corpName ?? result.corpId,
name: name ?? result.corpName,
staffId: result.staffId,
overwrite,
force
@@ -1566,7 +1593,7 @@ export async function extractKeysFromLinkAction(
appKey: selectedKey.appKey,
appSecurity: selectedKey.appSecurity,
corpId: result.corpId,
name: options.name ?? result.corpName ?? result.corpId,
name: options.name ?? result.corpName,
staffId: result.staffId,
overwrite: options.overwrite,
force: options.force