feat(cli): add corps search command and intuitive aliases

- Implement hose-use corps search <keyword> with case-insensitive fuzzy matching across id, name, corpId, staffId, staffName, and accountId
- Format terminal table output with matched cell brackets, hit labels, active corp markers, and friendly no-match fallback
- Support --json structured output conforming to CliResult specification
- Add intuitive aliases for frequently guessed commands: auth list -> auth accounts, corps find -> corps search, config show -> config paths
- Enhance CorpSummary and CorpContext with corpId, staffName, and getAllCorps
- Add comprehensive unit tests in corps.test.ts, auth.test.ts, and config.test.ts
This commit is contained in:
gitea committed 2026-09-09 14:42:58 +08:00
1 parent 8efce4342a
commit 1cd8901f7a
10 files changed
+630 -11

No files matched your search

+9 -1
View File
@@ -4,6 +4,8 @@ import { saveGlobalConfig } from "./loader.js";
export interface CorpSummary {
id: string;
name: string;
corpId?: string;
staffName?: string;
source?: string;
accountId?: string;
staffId: string;
@@ -143,13 +145,19 @@ export class CorpContext {
return true;
}
getAllCorps(): CorpConfig[] {
return Array.from(this.corps.values());
}
listCorps(): CorpSummary[] {
return Array.from(this.corps.values()).map((corp) => ({
id: corp.id,
name: corp.name,
corpId: corp.corpId || corp.credentials.corpId,
staffId: corp.credentials.staffId,
staffName: corp.staffName || corp.session?.staffName || undefined,
source: corp.source || "manual",
accountId: corp.accountId,
staffId: corp.credentials.staffId,
baseUrl: corp.baseUrl,
current: corp.id === this.current?.id,
expiresAt: corp.auth?.expiresAt || (corp.session?.expTime ?? undefined),