fix(packages): polish cli and mcp package contracts

This commit is contained in:
t8y2
2026-05-30 17:20:38 +08:00
parent 2a696be49a
commit c467372fc8
9 changed files with 154 additions and 45 deletions
+13
View File
@@ -0,0 +1,13 @@
export function mdTable(headers: string[], rows: string[][]): string {
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] || "").length), 3));
const header = `| ${headers.map((h, i) => h.padEnd(widths[i])).join(" | ")} |`;
const sep = `| ${widths.map((w) => "-".repeat(w)).join(" | ")} |`;
const body = rows.map((r) => `| ${r.map((c, i) => (c || "").padEnd(widths[i])).join(" | ")} |`).join("\n");
return body ? `${header}\n${sep}\n${body}` : `${header}\n${sep}`;
}
export function formatCell(value: unknown): string {
if (value === null || value === undefined) return "NULL";
if (typeof value === "object") return JSON.stringify(value);
return String(value);
}
+1
View File
@@ -3,6 +3,7 @@ export * from "./bridge.js";
export * from "./connections.js";
export * from "./database.js";
export * from "./diagnostics.js";
export * from "./format.js";
export * from "./paths.js";
export * from "./schema-context.js";
export * from "./sql-safety.js";