comfy-pr 1.2.1 → 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.
Files changed (2) hide show
  1. package/bot/cli.ts +123 -0
  2. package/package.json +1 -1
package/bot/cli.ts CHANGED
@@ -38,6 +38,11 @@ import yaml from "yaml";
38
38
 
39
39
  // Notion ability
40
40
  import { searchNotion } from "@/lib/notion/search";
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";
41
46
 
42
47
  // Video ability
43
48
  import { readVideo } from "@/lib/video/read-video";
@@ -288,6 +293,72 @@ async function main() {
288
293
  });
289
294
  },
290
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
+ )
291
362
  .command("slack", "Slack integration commands", (yargs) => {
292
363
  return yargs
293
364
  .command(
@@ -894,6 +965,56 @@ async function main() {
894
965
  }
895
966
  },
896
967
  )
968
+ .command(
969
+ "notion people",
970
+ "List GitHub→Slack mappings from Notion People database",
971
+ (y) =>
972
+ y
973
+ .option("github", {
974
+ alias: "g",
975
+ type: "string",
976
+ describe: "Look up a specific GitHub username",
977
+ })
978
+ .option("missing", {
979
+ alias: "m",
980
+ type: "boolean",
981
+ describe: "Show active members missing a GitHub username",
982
+ default: false,
983
+ }),
984
+ async (args) => {
985
+ await loadEnvLocal();
986
+ const mappings = await fetchPeopleMappings();
987
+
988
+ if (args.github) {
989
+ const slackId = await findSlackIdByGithubUsername(args.github);
990
+ if (slackId) {
991
+ const entry = mappings.find(
992
+ (m) => m.githubUsername.toLowerCase() === args.github!.toLowerCase(),
993
+ );
994
+ console.log(yaml.stringify({ github: args.github, slackId, person: entry?.person }));
995
+ } else {
996
+ console.log(`No mapping found for GitHub username: ${args.github}`);
997
+ process.exit(1);
998
+ }
999
+ } else if (args.missing) {
1000
+ const missing = mappings.filter((m) => !m.inactive && !m.githubUsername);
1001
+ console.log(`Active members without GitHub username: ${missing.length}\n`);
1002
+ console.log(yaml.stringify(missing));
1003
+ } else {
1004
+ const active = mappings.filter((m) => !m.inactive && m.slackId);
1005
+ console.log(`Active people mappings: ${active.length}\n`);
1006
+ console.log(
1007
+ yaml.stringify(
1008
+ active.map((m) => ({
1009
+ person: m.person || "(unnamed)",
1010
+ github: m.githubUsername || "(not set)",
1011
+ slackId: m.slackId,
1012
+ })),
1013
+ ),
1014
+ );
1015
+ }
1016
+ },
1017
+ )
897
1018
  .command(
898
1019
  "registry search",
899
1020
  "Search ComfyUI custom nodes registry",
@@ -1179,6 +1300,8 @@ async function main() {
1179
1300
  .epilog(
1180
1301
  [
1181
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",
1182
1305
  " prbot code pr -r Comfy-Org/ComfyUI -b main -p 'Fix auth bug'",
1183
1306
  " prbot code search -q 'binarization' --repo Comfy-Org/ComfyUI",
1184
1307
  " prbot github-issue search -q 'authentication bug' -l 5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-pr",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry]( https://registry.comfy.org/ ).",
5
5
  "keywords": [],
6
6
  "license": "ISC",