Refine skill and CLI for business-user centric experience
This commit is contained in:
1 parent
7bbddd7aba
commit
b5e6cc0282
8 files changed
+484
-581
No files matched your search
@@ -841,4 +841,22 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
|
||||
expect(authResult.exitCode).toBe(2);
|
||||
expect(authResult.stderr).toContain("合思子域专享能力");
|
||||
});
|
||||
|
||||
test("maskCellphone masks standard 11-digit mobile and non-standard phones safely", async () => {
|
||||
const { maskCellphone } = await import("./corps.js");
|
||||
expect(maskCellphone("13812345678")).toBe("138****5678");
|
||||
expect(maskCellphone("19988887777")).toBe("199****7777");
|
||||
expect(maskCellphone(undefined)).toBe("未绑定手机");
|
||||
expect(maskCellphone("")).toBe("未绑定手机");
|
||||
expect(maskCellphone("010123456")).toBe("010****3456");
|
||||
});
|
||||
|
||||
test("RULE_SUMMARY_FIELDS excludes raw internal UUID and prioritizes business fields", async () => {
|
||||
const { RULE_SUMMARY_FIELDS } = await import("../printer.js");
|
||||
expect(RULE_SUMMARY_FIELDS).not.toContain("id");
|
||||
expect(RULE_SUMMARY_FIELDS).toContain("code");
|
||||
expect(RULE_SUMMARY_FIELDS).toContain("status");
|
||||
expect(RULE_SUMMARY_FIELDS).toContain("strictness");
|
||||
expect(RULE_SUMMARY_FIELDS).toContain("scope");
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import type { OutputOptions } from "./types.js";
|
||||
|
||||
const RULE_LIST_FULL_COUNT_LIMIT = 100;
|
||||
const RULE_LIST_FULL_BYTES_LIMIT = 120_000;
|
||||
export const RULE_SUMMARY_FIELDS = ["id", "code", "status", "strictness", "scope", "createdAt", "updatedAt"];
|
||||
export const RULE_SUMMARY_FIELDS = ["code", "status", "strictness", "scope", "updatedAt"];
|
||||
const DEFAULT_OUTPUT_BYTES_LIMIT = 200_000;
|
||||
|
||||
export function formatConsoleOutput(values: unknown[]): string {
|
||||
|
||||
Reference in new issue
Block a user