@tacone/prosey 0.2.6 → 0.4.0
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/README.md +59 -39
- package/bin/prosey +17196 -15426
- package/package.json +2 -1
- package/src/config-resolve.test.ts +104 -0
- package/src/config-resolve.ts +17 -0
- package/src/config.test.ts +3 -1
- package/src/config.ts +26 -17
- package/src/default-config.toml +39 -11
- package/src/extract-chapters.test.ts +229 -0
- package/src/extract-chapters.ts +66 -0
- package/src/html.test.ts +25 -0
- package/src/html.ts +141 -0
- package/src/index.test.ts +12 -0
- package/src/index.ts +277 -11
- package/src/summarize.test.ts +74 -3
- package/src/summarize.ts +18 -4
package/src/summarize.ts
CHANGED
|
@@ -7,7 +7,13 @@ export interface SummarizeOptions {
|
|
|
7
7
|
cwd?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export type ExecuteCommand = (command: string, input: string, cwd?: string) => Promise<string>;
|
|
11
|
+
|
|
12
|
+
export const defaultExecuteCommand: ExecuteCommand = (
|
|
13
|
+
command: string,
|
|
14
|
+
input: string,
|
|
15
|
+
cwd?: string,
|
|
16
|
+
) => {
|
|
11
17
|
return new Promise((resolve, reject) => {
|
|
12
18
|
const proc = spawn(command, [], { shell: true, stdio: "pipe", cwd });
|
|
13
19
|
|
|
@@ -32,12 +38,20 @@ function executeCommand(command: string, input: string, cwd?: string): Promise<s
|
|
|
32
38
|
proc.stdin!.write(input);
|
|
33
39
|
proc.stdin!.end();
|
|
34
40
|
});
|
|
35
|
-
}
|
|
41
|
+
};
|
|
36
42
|
|
|
37
|
-
export async function summarize(
|
|
43
|
+
export async function summarize(
|
|
44
|
+
options: SummarizeOptions,
|
|
45
|
+
execCommand: ExecuteCommand = defaultExecuteCommand,
|
|
46
|
+
): Promise<string> {
|
|
38
47
|
const { prompt, command, transcript, cwd } = options;
|
|
48
|
+
|
|
49
|
+
if (!prompt) {
|
|
50
|
+
throw new Error("No prompt configured. A prompt is required in the config.");
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
const fullPrompt = `${prompt}\n\n${transcript}`;
|
|
40
|
-
const output = await
|
|
54
|
+
const output = await execCommand(command, fullPrompt, cwd);
|
|
41
55
|
|
|
42
56
|
const cleaned = output.startsWith(fullPrompt)
|
|
43
57
|
? output.slice(fullPrompt.length).replace(/\n+$/, "")
|