feat(baoyu-fetch): add URL reader CLI with Chrome CDP and site adapters

This commit is contained in:
Jim Liu 宝玉
2026-03-27 14:11:00 -05:00
parent 2c14872e88
commit d0764c2739
65 changed files with 10235 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
export interface Logger {
info(message: string): void;
warn(message: string): void;
error(message: string): void;
debug(message: string): void;
}
export function createLogger(debugEnabled = false): Logger {
const print = (level: string, message: string): void => {
console.error(`[${level}] ${message}`);
};
return {
info(message: string) {
print("info", message);
},
warn(message: string) {
print("warn", message);
},
error(message: string) {
print("error", message);
},
debug(message: string) {
if (debugEnabled) {
print("debug", message);
}
},
};
}
+12
View File
@@ -0,0 +1,12 @@
export function normalizeUrl(input: string): URL {
try {
return new URL(input);
} catch {
throw new Error(`Invalid URL: ${input}`);
}
}
export function sanitizeFilename(input: string): string {
return input.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "document";
}