explainthisrepo 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +17 -1
- package/dist/prompt.d.ts +1 -0
- package/dist/prompt.js +30 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { fetchRepo, fetchReadme } from "./github.js";
|
|
8
|
-
import { buildPrompt } from "./prompt.js";
|
|
8
|
+
import { buildPrompt, buildSimplePrompt } from "./prompt.js";
|
|
9
9
|
import { generateExplanation } from "./generate.js";
|
|
10
10
|
import { writeOutput } from "./writer.js";
|
|
11
11
|
import { readRepoSignalFiles } from "./repo_reader.js";
|
|
@@ -14,6 +14,7 @@ function usage() {
|
|
|
14
14
|
console.log(" explainthisrepo owner/repo");
|
|
15
15
|
console.log(" explainthisrepo owner/repo --detailed");
|
|
16
16
|
console.log(" explainthisrepo owner/repo --quick");
|
|
17
|
+
console.log(" explainthisrepo owner/repo --simple");
|
|
17
18
|
console.log(" explainthisrepo --doctor");
|
|
18
19
|
console.log(" explainthisrepo --version");
|
|
19
20
|
}
|
|
@@ -88,11 +89,14 @@ async function main() {
|
|
|
88
89
|
}
|
|
89
90
|
let detailed = false;
|
|
90
91
|
let quick = false;
|
|
92
|
+
let simple = false;
|
|
91
93
|
if (args.length === 2) {
|
|
92
94
|
if (args[1] === "--detailed")
|
|
93
95
|
detailed = true;
|
|
94
96
|
else if (args[1] === "--quick")
|
|
95
97
|
quick = true;
|
|
98
|
+
else if (args[1] === "--simple")
|
|
99
|
+
simple = true;
|
|
96
100
|
else {
|
|
97
101
|
usage();
|
|
98
102
|
process.exit(1);
|
|
@@ -102,6 +106,10 @@ async function main() {
|
|
|
102
106
|
usage();
|
|
103
107
|
process.exit(1);
|
|
104
108
|
}
|
|
109
|
+
if ((quick && simple) || (detailed && simple) || (detailed && quick)) {
|
|
110
|
+
usage();
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
105
113
|
const target = args[0];
|
|
106
114
|
if (!target.includes("/") || target.split("/").length !== 2) {
|
|
107
115
|
console.log("Invalid format. Use owner/repo");
|
|
@@ -125,6 +133,14 @@ async function main() {
|
|
|
125
133
|
console.log(output.trim());
|
|
126
134
|
return;
|
|
127
135
|
}
|
|
136
|
+
if (simple) {
|
|
137
|
+
console.log("Summarizing...");
|
|
138
|
+
const simplePrompt = buildSimplePrompt(output);
|
|
139
|
+
const simpleOutput = await generateExplanation(simplePrompt);
|
|
140
|
+
console.log("Simple summary 🎉");
|
|
141
|
+
console.log(simpleOutput.trim());
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
128
144
|
console.log("Writing EXPLAIN.md...");
|
|
129
145
|
writeOutput(output);
|
|
130
146
|
const wordCount = output.split(/\s+/).filter(Boolean).length;
|
package/dist/prompt.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare function buildPrompt(repoName: string, description: string | null, readme: string | null, detailed?: boolean, quick?: boolean, treeText?: string | null, filesText?: string | null): string;
|
|
2
|
+
export declare function buildSimplePrompt(longExplanation: string): string;
|
package/dist/prompt.js
CHANGED
|
@@ -36,7 +36,7 @@ README content:
|
|
|
36
36
|
${readme || "No README provided"}
|
|
37
37
|
|
|
38
38
|
Repository structure:
|
|
39
|
-
${treeText || "No tree
|
|
39
|
+
${treeText || "No tree provided"}
|
|
40
40
|
|
|
41
41
|
Key files (snippets):
|
|
42
42
|
${filesText || "No code files provided"}
|
|
@@ -71,3 +71,32 @@ Output format:
|
|
|
71
71
|
`;
|
|
72
72
|
return prompt.trim();
|
|
73
73
|
}
|
|
74
|
+
export function buildSimplePrompt(longExplanation) {
|
|
75
|
+
return `
|
|
76
|
+
You are a senior software engineer.
|
|
77
|
+
|
|
78
|
+
Rewrite the long repository explanation below into a SIMPLE version in the exact style specified.
|
|
79
|
+
|
|
80
|
+
Input explanation:
|
|
81
|
+
${longExplanation}
|
|
82
|
+
|
|
83
|
+
Output style rules:
|
|
84
|
+
- Plain English.
|
|
85
|
+
- No markdown.
|
|
86
|
+
- Do NOT use headings like "Overview", "What this project does", etc.
|
|
87
|
+
- Start with exactly this line:
|
|
88
|
+
Key points from the repo:
|
|
89
|
+
- Then output 4 to 7 bullets only.
|
|
90
|
+
- Each bullet MUST start with: ⬤
|
|
91
|
+
- Each bullet title should be 1–3 words only (example: "Purpose", "Stack", "Entrypoints", "How it works", "Usage", "Structure").
|
|
92
|
+
- Each bullet body should be 1–2 lines max.
|
|
93
|
+
- If the input contains architecture/pipeline steps, capture them naturally.
|
|
94
|
+
- If the input does NOT contain architecture/pipeline steps, do NOT invent them.
|
|
95
|
+
- Optional: end with one extra line starting with:
|
|
96
|
+
Also interesting:
|
|
97
|
+
- Do NOT add features not present in the input.
|
|
98
|
+
- No quotes.
|
|
99
|
+
|
|
100
|
+
Make it feel like a human developer explaining to another developer in simple terms.
|
|
101
|
+
`.trim();
|
|
102
|
+
}
|