@pmate/cli 0.25.6 → 0.25.7

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 CHANGED
@@ -48,6 +48,10 @@ pmate notion create --private --title "Private Notes" --file ./notes.md
48
48
  pmate notion update <page-id-or-url> --file ./notes.md --append
49
49
  pmate vercel projects
50
50
  pmate vercel deploys --project web --last-week
51
+ pmate im1 health
52
+ pmate im1 threads --limit 20
53
+ pmate im1 messages --thread "<conversationId-or-thread-name>" --limit 50
54
+ pmate im1 reply --source cc --thread "<conversationId-or-thread-name>" --text "hello"
51
55
  ```
52
56
 
53
57
  Notes:
@@ -159,6 +163,33 @@ Notes:
159
163
  - Platform commands such as `pmate sts`, `pmate agent`, and `pmate app` still
160
164
  default to the `@pmate/cli` session.
161
165
 
166
+ ## IM1 / CC messages
167
+
168
+ `pmate im1` reads CC messages through the local `cc-bot` service at
169
+ `http://localhost:39223` by default. Override the base URL with
170
+ `PMATE_IM1_BASE_URL` only when debugging another local service instance.
171
+
172
+ Useful commands:
173
+
174
+ ```bash
175
+ pmate im1 health
176
+ pmate im1 threads --limit 20
177
+ pmate im1 threads --q Bug --limit 10
178
+ pmate im1 messages --thread "<conversationId-or-thread-name>" --limit 50
179
+ pmate im1 reply --source cc --thread "<conversationId-or-thread-name>" --text "hello"
180
+ ```
181
+
182
+ `threads` and `messages` output JSON by default. Thread rows include both
183
+ `conversationId` and `threadKey`; prefer `conversationId` when scripting or
184
+ passing a thread back into `messages`/`reply`. Add `--text` for compact
185
+ human-readable output.
186
+
187
+ CC sync is owned by the background service in `~/dev/pcs/cc-bot`, which runs
188
+ under PM2, keeps TimescaleDB running, listens for new CC messages, and performs
189
+ bounded 3-day backfill. `pmate im1 collect sync --source cc` is intentionally
190
+ disabled. Legacy yelling/custom endpoint collection still uses
191
+ `pmate im1 collect sync --source yelling` or `--endpoint`.
192
+
162
193
  ## Notion config
163
194
 
164
195
  Add a Notion integration token to `~/.pmate/config.yaml`:
package/dist/index.d.ts CHANGED
@@ -550,18 +550,21 @@ type CollectCommandArgs = {
550
550
  } | {
551
551
  type: Command.Collect;
552
552
  action: "health";
553
+ json?: boolean;
553
554
  } | {
554
555
  type: Command.Collect;
555
556
  action: "threads";
556
557
  source?: "cc";
557
558
  query?: string;
558
559
  limit?: number;
560
+ json?: boolean;
559
561
  } | {
560
562
  type: Command.Collect;
561
563
  action: "messages";
562
564
  source?: "cc";
563
565
  thread: string;
564
566
  limit?: number;
567
+ json?: boolean;
565
568
  } | {
566
569
  type: Command.Collect;
567
570
  action: "reply";
package/dist/index.js CHANGED
@@ -15772,6 +15772,10 @@ var CollectCommandHandler = class {
15772
15772
  async handleBotThreads(args) {
15773
15773
  const client = new Im1BotClient();
15774
15774
  const threads = await client.listThreads({ q: args.query, limit: args.limit });
15775
+ if (args.json !== false) {
15776
+ ui.plain(JSON.stringify({ ok: true, threads }, null, 2));
15777
+ return;
15778
+ }
15775
15779
  for (const thread of threads) {
15776
15780
  ui.plain(formatBotThread(thread));
15777
15781
  }
@@ -15779,6 +15783,10 @@ var CollectCommandHandler = class {
15779
15783
  async handleBotMessages(args) {
15780
15784
  const client = new Im1BotClient();
15781
15785
  const messages2 = await client.listMessages({ thread: args.thread, limit: args.limit });
15786
+ if (args.json !== false) {
15787
+ ui.plain(JSON.stringify({ ok: true, messages: messages2 }, null, 2));
15788
+ return;
15789
+ }
15782
15790
  for (const message of messages2.reverse()) {
15783
15791
  ui.plain(formatBotMessage(message));
15784
15792
  }
@@ -15790,11 +15798,7 @@ var CollectCommandHandler = class {
15790
15798
  text: args.text,
15791
15799
  dryRun: args.dryRun
15792
15800
  });
15793
- if (args.dryRun) {
15794
- ui.plain(JSON.stringify(result, null, 2));
15795
- return;
15796
- }
15797
- ui.success("im1 reply sent", { source: "cc", thread: args.thread });
15801
+ ui.plain(JSON.stringify(result, null, 2));
15798
15802
  }
15799
15803
  async handleSync(args) {
15800
15804
  let browser = null;
@@ -16176,13 +16180,18 @@ function isExternalImageRef(imagePath) {
16176
16180
  function formatBotThread(thread) {
16177
16181
  const unread = thread.unread && thread.unread > 0 ? ` unread=${thread.unread}` : "";
16178
16182
  const time = thread.lastMessageAt ? ` ${thread.lastMessageAt}` : "";
16179
- const preview = thread.preview ? ` - ${thread.preview}` : "";
16183
+ const preview = thread.preview ? ` - ${truncateCliPreview(thread.preview, 120)}` : "";
16180
16184
  return `${thread.name} (${thread.conversationId})${unread}${time}${preview}`;
16181
16185
  }
16182
16186
  function formatBotMessage(message) {
16183
16187
  const sender = message.sender ? `${message.sender}: ` : "";
16184
16188
  return `[${message.sentAt}] ${sender}${message.body}`;
16185
16189
  }
16190
+ function truncateCliPreview(value, maxLength) {
16191
+ const normalized = value.replace(/\s+/g, " ").replace(/\u200B/g, "").trim();
16192
+ if (normalized.length <= maxLength) return normalized;
16193
+ return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
16194
+ }
16186
16195
  function filterThreadsForSync(threads, target) {
16187
16196
  if (!target) {
16188
16197
  return threads;
@@ -25680,7 +25689,7 @@ function parseIm1Args(tokens) {
25680
25689
  return parseIm1CollectArgs(rest);
25681
25690
  }
25682
25691
  if (action === "health") {
25683
- return { type: "collect" /* Collect */, action: "health" };
25692
+ return parseIm1HealthArgs(rest);
25684
25693
  }
25685
25694
  if (action === "threads") {
25686
25695
  return parseIm1ThreadsArgs(rest);
@@ -25693,11 +25702,27 @@ function parseIm1Args(tokens) {
25693
25702
  }
25694
25703
  throw new Error(`Unknown im1 action: ${action}`);
25695
25704
  }
25705
+ function parseIm1HealthArgs(tokens) {
25706
+ const rest = [...tokens];
25707
+ let json = false;
25708
+ while (rest.length > 0) {
25709
+ const token = rest.shift();
25710
+ switch (token) {
25711
+ case "--json":
25712
+ json = true;
25713
+ break;
25714
+ default:
25715
+ throw new Error(`Unknown im1 health option: ${token}`);
25716
+ }
25717
+ }
25718
+ return { type: "collect" /* Collect */, action: "health", json };
25719
+ }
25696
25720
  function parseIm1ThreadsArgs(tokens) {
25697
25721
  const rest = [...tokens];
25698
25722
  let query;
25699
25723
  let limit;
25700
25724
  let source = "cc";
25725
+ let json = true;
25701
25726
  while (rest.length > 0) {
25702
25727
  const token = rest.shift();
25703
25728
  switch (token) {
@@ -25714,17 +25739,24 @@ function parseIm1ThreadsArgs(tokens) {
25714
25739
  case "--limit":
25715
25740
  limit = parsePositiveInt2(requireValue11(rest, token), token);
25716
25741
  break;
25742
+ case "--json":
25743
+ json = true;
25744
+ break;
25745
+ case "--text":
25746
+ json = false;
25747
+ break;
25717
25748
  default:
25718
25749
  throw new Error(`Unknown im1 threads option: ${token}`);
25719
25750
  }
25720
25751
  }
25721
- return { type: "collect" /* Collect */, action: "threads", source, query, limit };
25752
+ return { type: "collect" /* Collect */, action: "threads", source, query, limit, json };
25722
25753
  }
25723
25754
  function parseIm1MessagesArgs(tokens) {
25724
25755
  const rest = [...tokens];
25725
25756
  let thread;
25726
25757
  let limit;
25727
25758
  let source = "cc";
25759
+ let json = true;
25728
25760
  while (rest.length > 0) {
25729
25761
  const token = rest.shift();
25730
25762
  switch (token) {
@@ -25741,6 +25773,12 @@ function parseIm1MessagesArgs(tokens) {
25741
25773
  case "--limit":
25742
25774
  limit = parsePositiveInt2(requireValue11(rest, token), token);
25743
25775
  break;
25776
+ case "--json":
25777
+ json = true;
25778
+ break;
25779
+ case "--text":
25780
+ json = false;
25781
+ break;
25744
25782
  default:
25745
25783
  throw new Error(`Unknown im1 messages option: ${token}`);
25746
25784
  }
@@ -25748,7 +25786,7 @@ function parseIm1MessagesArgs(tokens) {
25748
25786
  if (!thread) {
25749
25787
  throw new Error("Usage: im1 messages --thread <name|conversation-id> [--limit <n>]");
25750
25788
  }
25751
- return { type: "collect" /* Collect */, action: "messages", source, thread, limit };
25789
+ return { type: "collect" /* Collect */, action: "messages", source, thread, limit, json };
25752
25790
  }
25753
25791
  function parseIm1CollectArgs(tokens) {
25754
25792
  const rest = [...tokens];
@@ -26081,9 +26119,9 @@ var HELP_TEXT = [
26081
26119
  ` ${import_chalk4.default.gray(" [--count <n>]")}`,
26082
26120
  ` ${import_chalk4.default.gray(" --easy [--words <n>] [--digits <n>] [--separator <s>] [--count <n>]")}`,
26083
26121
  ` ${import_chalk4.default.cyan("im1")} Read and reply to local CC messages through cc-bot`,
26084
- ` ${import_chalk4.default.gray(" health")}`,
26085
- ` ${import_chalk4.default.gray(" threads [--q <keyword>] [--limit <n>]")}`,
26086
- ` ${import_chalk4.default.gray(" messages --thread <name|conversation-id> [--limit <n>]")}`,
26122
+ ` ${import_chalk4.default.gray(" health [--json]")}`,
26123
+ ` ${import_chalk4.default.gray(" threads [--q <keyword>] [--limit <n>] [--json|--text]")}`,
26124
+ ` ${import_chalk4.default.gray(" messages --thread <name|conversation-id> [--limit <n>] [--json|--text]")}`,
26087
26125
  ` ${import_chalk4.default.gray(" collect sync [--thread <name|conversation-id>] (--source <cc|yelling> | --endpoint <url>)")}`,
26088
26126
  ` ${import_chalk4.default.gray(" reply --thread <name> --text <text> (--source <cc|yelling> | --endpoint <url>)")}`,
26089
26127
  ` ${import_chalk4.default.cyan("collect")} Legacy alias for CC/yelling collection`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.25.6",
3
+ "version": "0.25.7",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {