comfy-pr 1.2.2 → 1.3.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/bot/cli.ts +72 -0
- package/package.json +1 -1
package/bot/cli.ts
CHANGED
|
@@ -39,6 +39,10 @@ import yaml from "yaml";
|
|
|
39
39
|
// Notion ability
|
|
40
40
|
import { searchNotion } from "@/lib/notion/search";
|
|
41
41
|
import { fetchPeopleMappings, findSlackIdByGithubUsername } from "@/lib/notion/people";
|
|
42
|
+
import { readNotionPage } from "@/lib/notion/read-page";
|
|
43
|
+
|
|
44
|
+
// URL parsing
|
|
45
|
+
import { parseUrl } from "@/lib/url/parseUrl";
|
|
42
46
|
|
|
43
47
|
// Video ability
|
|
44
48
|
import { readVideo } from "@/lib/video/read-video";
|
|
@@ -289,6 +293,72 @@ async function main() {
|
|
|
289
293
|
});
|
|
290
294
|
},
|
|
291
295
|
)
|
|
296
|
+
.command(
|
|
297
|
+
"read <url>",
|
|
298
|
+
"Read any supported URL (Slack message/channel/file, Notion page) and output content as YAML",
|
|
299
|
+
(y) =>
|
|
300
|
+
y.positional("url", {
|
|
301
|
+
type: "string",
|
|
302
|
+
describe: "URL to read (Slack or Notion)",
|
|
303
|
+
demandOption: true,
|
|
304
|
+
}),
|
|
305
|
+
async (args) => {
|
|
306
|
+
await loadEnvLocal();
|
|
307
|
+
|
|
308
|
+
const url = args.url as string;
|
|
309
|
+
const parsed = parseUrl(url);
|
|
310
|
+
|
|
311
|
+
switch (parsed.type) {
|
|
312
|
+
case "slack-message": {
|
|
313
|
+
const messages = await readNearbyMessages(parsed.channel!, parsed.ts!, 20, 20);
|
|
314
|
+
console.log(yaml.stringify(messages));
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
case "slack-channel": {
|
|
319
|
+
const messages = await readRecentMessages(parsed.channel!, 10);
|
|
320
|
+
console.log(yaml.stringify(messages));
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
case "slack-file": {
|
|
325
|
+
if (!parsed.fileId) {
|
|
326
|
+
console.error("Could not extract file ID from URL");
|
|
327
|
+
process.exit(1);
|
|
328
|
+
}
|
|
329
|
+
const fileInfo = await getSlackFileInfo(parsed.fileId);
|
|
330
|
+
const fileName = fileInfo.name || `file-${parsed.fileId}`;
|
|
331
|
+
const outputPath = `./${fileName}`;
|
|
332
|
+
await downloadSlackFile(parsed.fileId, outputPath);
|
|
333
|
+
console.log(
|
|
334
|
+
yaml.stringify({
|
|
335
|
+
type: "file_downloaded",
|
|
336
|
+
file_id: parsed.fileId,
|
|
337
|
+
file_name: fileName,
|
|
338
|
+
file_size: fileInfo.size,
|
|
339
|
+
downloaded_to: outputPath,
|
|
340
|
+
}),
|
|
341
|
+
);
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
case "notion-page": {
|
|
346
|
+
const page = await readNotionPage(parsed.notionPageId!);
|
|
347
|
+
console.log(yaml.stringify(page));
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
default:
|
|
352
|
+
console.error(`Unsupported URL: ${url}`);
|
|
353
|
+
console.error("Supported formats:");
|
|
354
|
+
console.error(" Slack message: https://workspace.slack.com/archives/C123/p1234567890");
|
|
355
|
+
console.error(" Slack channel: https://workspace.slack.com/archives/C123");
|
|
356
|
+
console.error(" Slack file: https://files.slack.com/files-pri/T123-F456/file.pdf");
|
|
357
|
+
console.error(" Notion page: https://www.notion.so/workspace/Page-Title-<id>");
|
|
358
|
+
process.exit(1);
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
)
|
|
292
362
|
.command("slack", "Slack integration commands", (yargs) => {
|
|
293
363
|
return yargs
|
|
294
364
|
.command(
|
|
@@ -1230,6 +1300,8 @@ async function main() {
|
|
|
1230
1300
|
.epilog(
|
|
1231
1301
|
[
|
|
1232
1302
|
"Examples:",
|
|
1303
|
+
" prbot read 'https://workspace.slack.com/archives/C123/p1234567890' # Slack message",
|
|
1304
|
+
" prbot read 'https://www.notion.so/my-workspace/Page-Title-abc123' # Notion page",
|
|
1233
1305
|
" prbot code pr -r Comfy-Org/ComfyUI -b main -p 'Fix auth bug'",
|
|
1234
1306
|
" prbot code search -q 'binarization' --repo Comfy-Org/ComfyUI",
|
|
1235
1307
|
" prbot github-issue search -q 'authentication bug' -l 5",
|