Repository navigation
Expand file tree
/
Copy pathgithub-summarizer.ts
More file actions
70 lines (59 loc) · 1.62 KB
/
Copy pathgithub-summarizer.ts
File metadata and controls
70 lines (59 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
import { z } from "zod";
import * as readline from "readline";
config();
const client = new Hyperbrowser({
apiKey: process.env.HYPERBROWSER_API_KEY,
});
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const promptUser = async (question: string): Promise<string> => {
return new Promise((resolve) => {
rl.question(question, (answer) => {
resolve(answer);
});
});
};
const main = async () => {
const username = await promptUser("Enter a GitHub username: ");
if (!username) {
console.error("Username cannot be empty");
rl.close();
return;
}
const githubUrl = `https://github.com/${username}`;
console.log(`Analyzing GitHub profile: ${githubUrl}`);
const schema = z.object({
username: z.string(),
primaryLanguages: z.array(z.string()),
frameworks: z.array(z.string()),
tools: z.array(z.string()),
repositories: z.array(
z.object({
name: z.string(),
summary: z.string().optional(),
}),
),
});
try {
const result = await client.extract.startAndWait({
urls: [githubUrl],
prompt:
"Summarize their tech stack, their main languages, frameworks, tools, contributions, and top repositories.",
schema: schema,
sessionOptions: {
useProxy: true,
solveCaptchas: true,
},
});
console.log("Tech Stack Analysis:", JSON.stringify(result, null, 2));
} catch (error) {
console.error("Error analyzing GitHub profile:", error);
} finally {
rl.close();
}
};
main();