chirpie 1.0.37 → 1.0.39

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/dist/index.js +123 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command9 } from "commander";
4
+ import { Command as Command10 } from "commander";
5
5
  import { createRequire } from "module";
6
6
 
7
7
  // src/commands/auth.ts
@@ -748,9 +748,125 @@ for (const { cmd, label } of comingSoonCli) {
748
748
  });
749
749
  }
750
750
 
751
- // src/commands/analytics.ts
751
+ // src/commands/comments.ts
752
752
  import { Command as Command7 } from "commander";
753
- var analyticsCommand = new Command7("analytics").description("Get analytics for a post").argument("<post_id>", "Post ID").option("--json", "Output raw JSON").action(async (postId, opts) => {
753
+ var PREVIEW_CHARS = 60;
754
+ function commentAuthorLabel(comment) {
755
+ const displayName = comment.author.display_name?.trim();
756
+ if (displayName) return displayName;
757
+ const handle = comment.author.handle?.trim();
758
+ if (handle) return handle;
759
+ return "Unknown commenter";
760
+ }
761
+ function commentRowText(comment) {
762
+ if (comment.deleted) return "[deleted]";
763
+ const flat = comment.text.replace(/\s+/gu, " ").trim();
764
+ const chars = [...flat];
765
+ if (chars.length <= PREVIEW_CHARS) return flat;
766
+ return chars.slice(0, PREVIEW_CHARS).join("").trimEnd() + "\u2026";
767
+ }
768
+ var commentsCommand = new Command7("comments").description("List, reply to, hide, or delete the comments on a post").option("--json", "Output raw JSON");
769
+ commentsCommand.command("list").description("List the comments on a post you published").argument("<post_id>", "Post ID").option("--limit <n>", "Comments to show (default 25, max 100)").option("--cursor <cursor>", "The next_cursor from the previous page").option("--since <datetime>", "Only comments posted after this ISO 8601 time").option("--no-sync", "Show the stored comments without refreshing them").option("--hidden", "Include comments you have hidden").option("--json", "Output raw JSON").action(async (postId, opts, cmd) => {
770
+ const client = getClient();
771
+ try {
772
+ const result = await client.listComments(postId, {
773
+ limit: opts.limit ? parseInt(opts.limit, 10) : void 0,
774
+ cursor: opts.cursor,
775
+ since: opts.since,
776
+ // Commander turns `--no-sync` into `sync: false` and leaves it `true`
777
+ // otherwise, which is not the same as asking for a refresh now: the
778
+ // default is the server's own `auto`.
779
+ sync: opts.sync === false ? false : void 0,
780
+ include_hidden: opts.hidden ? true : void 0
781
+ });
782
+ if (wantsJson(opts, cmd)) {
783
+ json(result);
784
+ return;
785
+ }
786
+ if (result.sync.status !== "ok" && result.sync.reason) {
787
+ info(result.sync.reason);
788
+ }
789
+ table(
790
+ result.comments.map((comment) => ({
791
+ id: comment.id.slice(0, 8),
792
+ author: commentAuthorLabel(comment),
793
+ time: comment.created_at.slice(0, 16).replace("T", " "),
794
+ text: commentRowText(comment),
795
+ replied: comment.replied ? "\u2713" : ""
796
+ }))
797
+ );
798
+ if (result.next_cursor) {
799
+ info(`More comments: --cursor ${result.next_cursor}`);
800
+ }
801
+ } catch (err) {
802
+ apiError(err, "Failed to list comments");
803
+ process.exit(1);
804
+ }
805
+ });
806
+ commentsCommand.command("reply").description("Reply to a comment (counts as one post against your quota)").argument("<post_id>", "Post ID").argument("<comment_id>", "Comment ID from `chirpie comments list`").requiredOption("--text <text>", "The reply text").option("--json", "Output raw JSON").action(async (postId, commentId, opts, cmd) => {
807
+ const client = getClient();
808
+ try {
809
+ const reply = await client.replyToComment(postId, commentId, opts.text);
810
+ if (wantsJson(opts, cmd)) {
811
+ json(reply);
812
+ } else {
813
+ success(`Replied to ${commentId}`);
814
+ }
815
+ } catch (err) {
816
+ apiError(err, "Failed to reply to comment");
817
+ process.exit(1);
818
+ }
819
+ });
820
+ commentsCommand.command("hide").description("Hide a comment, or show it again with --unhide").argument("<post_id>", "Post ID").argument("<comment_id>", "Comment ID from `chirpie comments list`").option("--unhide", "Show a comment you hid earlier").option("--json", "Output raw JSON").action(async (postId, commentId, opts, cmd) => {
821
+ const client = getClient();
822
+ try {
823
+ const updated = opts.unhide ? await client.unhideComment(postId, commentId) : await client.hideComment(postId, commentId);
824
+ if (wantsJson(opts, cmd)) {
825
+ json(updated);
826
+ } else {
827
+ success(`Comment ${commentId} ${opts.unhide ? "shown" : "hidden"}`);
828
+ }
829
+ } catch (err) {
830
+ apiError(err, "Failed to hide comment");
831
+ process.exit(1);
832
+ }
833
+ });
834
+ commentsCommand.command("delete").description("Delete a comment from the platform").argument("<post_id>", "Post ID").argument("<comment_id>", "Comment ID from `chirpie comments list`").option("-y, --yes", "Skip the confirmation prompt").option("--json", "Output raw JSON").action(async (postId, commentId, opts, cmd) => {
835
+ if (!opts.yes && !await confirm(`Delete comment ${commentId}?`)) {
836
+ error("Cancelled");
837
+ process.exit(1);
838
+ }
839
+ const client = getClient();
840
+ try {
841
+ const result = await client.deleteComment(postId, commentId);
842
+ if (wantsJson(opts, cmd)) {
843
+ json(result);
844
+ } else {
845
+ success(`Comment ${commentId} deleted`);
846
+ }
847
+ } catch (err) {
848
+ apiError(err, "Failed to delete comment");
849
+ process.exit(1);
850
+ }
851
+ });
852
+ async function confirm(question) {
853
+ if (!process.stdin.isTTY) return false;
854
+ const readline = await import("readline");
855
+ const rl = readline.createInterface({
856
+ input: process.stdin,
857
+ output: process.stderr
858
+ });
859
+ return new Promise((resolve) => {
860
+ rl.question(`${question} [y/N] `, (answer) => {
861
+ rl.close();
862
+ resolve(answer.trim().toLowerCase() === "y");
863
+ });
864
+ });
865
+ }
866
+
867
+ // src/commands/analytics.ts
868
+ import { Command as Command8 } from "commander";
869
+ var analyticsCommand = new Command8("analytics").description("Get analytics for a post").argument("<post_id>", "Post ID").option("--json", "Output raw JSON").action(async (postId, opts) => {
754
870
  const client = getClient();
755
871
  try {
756
872
  const analytics = await client.getPostAnalytics(postId);
@@ -774,8 +890,8 @@ var analyticsCommand = new Command7("analytics").description("Get analytics for
774
890
  });
775
891
 
776
892
  // src/commands/keys.ts
777
- import { Command as Command8 } from "commander";
778
- var keysCommand = new Command8("keys").description("Manage API keys").option("--json", "Output raw JSON").action(async (opts, cmd) => {
893
+ import { Command as Command9 } from "commander";
894
+ var keysCommand = new Command9("keys").description("Manage API keys").option("--json", "Output raw JSON").action(async (opts, cmd) => {
779
895
  const client = getClient();
780
896
  try {
781
897
  const keys = await client.listKeys();
@@ -834,7 +950,7 @@ keysCommand.command("revoke <id>").description("Revoke an API key").option("--js
834
950
  // src/index.ts
835
951
  var require2 = createRequire(import.meta.url);
836
952
  var { version } = require2("../package.json");
837
- var program = new Command9().name("chirpie").description("Chirpie: the social media layer for AI agents").version(version);
953
+ var program = new Command10().name("chirpie").description("Chirpie: the social media layer for AI agents").version(version);
838
954
  program.addCommand(loginCommand);
839
955
  program.addCommand(logoutCommand);
840
956
  program.addCommand(authCommand);
@@ -843,6 +959,7 @@ program.addCommand(postCommand);
843
959
  program.addCommand(threadCommand);
844
960
  program.addCommand(postsCommand);
845
961
  program.addCommand(accountsCommand);
962
+ program.addCommand(commentsCommand);
846
963
  program.addCommand(analyticsCommand);
847
964
  program.addCommand(keysCommand);
848
965
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chirpie",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "Chirpie CLI: post to social media from the command line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
- "@chirpie/sdk": "^1.0.34",
47
+ "@chirpie/sdk": "^1.0.36",
48
48
  "commander": "^13"
49
49
  },
50
50
  "devDependencies": {