@pmate/cli 0.28.4 → 0.28.5
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 +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +99 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ pmate im1 health
|
|
|
52
52
|
pmate im1 threads --limit 20
|
|
53
53
|
pmate im1 threads --search "titlte" --limit 5
|
|
54
54
|
pmate im1 messages --thread "<conversationId-or-thread-name>" --limit 50
|
|
55
|
+
pmate im1 pending-mentions --hours 24 --context 10
|
|
55
56
|
pmate im1 reply --thread "<conversationId-or-thread-name>" --text "hello"
|
|
56
57
|
```
|
|
57
58
|
|
package/dist/index.d.ts
CHANGED
|
@@ -628,6 +628,16 @@ type CollectCommandArgs = {
|
|
|
628
628
|
thread: string;
|
|
629
629
|
limit?: number;
|
|
630
630
|
json?: boolean;
|
|
631
|
+
} | {
|
|
632
|
+
type: Command.Collect;
|
|
633
|
+
action: "pending-mentions";
|
|
634
|
+
me: string;
|
|
635
|
+
from?: string;
|
|
636
|
+
to?: string;
|
|
637
|
+
hours: number;
|
|
638
|
+
context: number;
|
|
639
|
+
limit?: number;
|
|
640
|
+
json?: boolean;
|
|
631
641
|
} | {
|
|
632
642
|
type: Command.Collect;
|
|
633
643
|
action: "reply";
|
package/dist/index.js
CHANGED
|
@@ -16869,6 +16869,16 @@ var Im1BotClient = class {
|
|
|
16869
16869
|
);
|
|
16870
16870
|
return json.messages ?? [];
|
|
16871
16871
|
}
|
|
16872
|
+
async listPendingMentions(input) {
|
|
16873
|
+
const params = new URLSearchParams({
|
|
16874
|
+
me: input.me,
|
|
16875
|
+
from: input.from,
|
|
16876
|
+
to: input.to,
|
|
16877
|
+
context: String(input.context)
|
|
16878
|
+
});
|
|
16879
|
+
if (input.limit) params.set("limit", String(input.limit));
|
|
16880
|
+
return this.request(`/mentions/pending?${params.toString()}`);
|
|
16881
|
+
}
|
|
16872
16882
|
async sendMessage(input) {
|
|
16873
16883
|
return this.request("/messages/send", {
|
|
16874
16884
|
method: "POST",
|
|
@@ -17105,6 +17115,10 @@ var CollectCommandHandler = class {
|
|
|
17105
17115
|
await this.handleBotMessages(args);
|
|
17106
17116
|
return;
|
|
17107
17117
|
}
|
|
17118
|
+
if (args.action === "pending-mentions") {
|
|
17119
|
+
await this.handleBotPendingMentions(args);
|
|
17120
|
+
return;
|
|
17121
|
+
}
|
|
17108
17122
|
if (args.action === "reply") {
|
|
17109
17123
|
await this.handleBotReply(args);
|
|
17110
17124
|
return;
|
|
@@ -17148,6 +17162,32 @@ var CollectCommandHandler = class {
|
|
|
17148
17162
|
ui.plain(formatBotMessage(message));
|
|
17149
17163
|
}
|
|
17150
17164
|
}
|
|
17165
|
+
async handleBotPendingMentions(args) {
|
|
17166
|
+
const to = args.to ? new Date(args.to) : /* @__PURE__ */ new Date();
|
|
17167
|
+
const from = args.from ? new Date(args.from) : new Date(to.getTime() - args.hours * 60 * 60 * 1e3);
|
|
17168
|
+
if (from >= to) throw new Error("Expected --from to be earlier than --to");
|
|
17169
|
+
const result = await new Im1BotClient().listPendingMentions({
|
|
17170
|
+
me: args.me,
|
|
17171
|
+
from: from.toISOString(),
|
|
17172
|
+
to: to.toISOString(),
|
|
17173
|
+
context: args.context,
|
|
17174
|
+
limit: args.limit
|
|
17175
|
+
});
|
|
17176
|
+
if (args.json !== false) {
|
|
17177
|
+
ui.plain(JSON.stringify(result, null, 2));
|
|
17178
|
+
return;
|
|
17179
|
+
}
|
|
17180
|
+
if (result.mentions.length === 0) {
|
|
17181
|
+
ui.plain("No pending mentions found.");
|
|
17182
|
+
return;
|
|
17183
|
+
}
|
|
17184
|
+
for (const mention of result.mentions) {
|
|
17185
|
+
ui.plain(`${mention.sentAt} ${mention.thread?.name ?? mention.conversationId} ${mention.sender ?? "unknown"}: ${mention.body}`);
|
|
17186
|
+
for (const message of mention.context) {
|
|
17187
|
+
ui.plain(` ${message.sentAt} ${message.sender ?? "unknown"}: ${message.body}`);
|
|
17188
|
+
}
|
|
17189
|
+
}
|
|
17190
|
+
}
|
|
17151
17191
|
async handleBotReply(args) {
|
|
17152
17192
|
const client = new Im1BotClient();
|
|
17153
17193
|
const attachment = args.file ? await readOutgoingAttachment(args.file) : void 0;
|
|
@@ -27610,6 +27650,9 @@ function parseIm1Args(tokens) {
|
|
|
27610
27650
|
if (action === "messages") {
|
|
27611
27651
|
return parseIm1MessagesArgs(rest);
|
|
27612
27652
|
}
|
|
27653
|
+
if (action === "pending-mentions") {
|
|
27654
|
+
return parseIm1PendingMentionsArgs(rest);
|
|
27655
|
+
}
|
|
27613
27656
|
if (action === "reply") {
|
|
27614
27657
|
return parseIm1ReplyArgs(rest);
|
|
27615
27658
|
}
|
|
@@ -27618,6 +27661,51 @@ function parseIm1Args(tokens) {
|
|
|
27618
27661
|
}
|
|
27619
27662
|
throw new Error(`Unknown im1 action: ${action}`);
|
|
27620
27663
|
}
|
|
27664
|
+
function parseIm1PendingMentionsArgs(tokens) {
|
|
27665
|
+
const rest = [...tokens];
|
|
27666
|
+
let me = "Chef Ryan";
|
|
27667
|
+
let from;
|
|
27668
|
+
let to;
|
|
27669
|
+
let hours = 24;
|
|
27670
|
+
let context = 10;
|
|
27671
|
+
let limit;
|
|
27672
|
+
let json = true;
|
|
27673
|
+
while (rest.length > 0) {
|
|
27674
|
+
const token = rest.shift();
|
|
27675
|
+
switch (token) {
|
|
27676
|
+
case "--me":
|
|
27677
|
+
me = requireValue12(rest, token);
|
|
27678
|
+
break;
|
|
27679
|
+
case "--from":
|
|
27680
|
+
from = parseIsoDate(requireValue12(rest, token), token);
|
|
27681
|
+
break;
|
|
27682
|
+
case "--to":
|
|
27683
|
+
to = parseIsoDate(requireValue12(rest, token), token);
|
|
27684
|
+
break;
|
|
27685
|
+
case "--hours":
|
|
27686
|
+
hours = parsePositiveInt2(requireValue12(rest, token), token);
|
|
27687
|
+
break;
|
|
27688
|
+
case "--context":
|
|
27689
|
+
context = parseBoundedPositiveInt(requireValue12(rest, token), token, 50);
|
|
27690
|
+
break;
|
|
27691
|
+
case "--limit":
|
|
27692
|
+
limit = parseBoundedPositiveInt(requireValue12(rest, token), token, 500);
|
|
27693
|
+
break;
|
|
27694
|
+
case "--json":
|
|
27695
|
+
json = true;
|
|
27696
|
+
break;
|
|
27697
|
+
case "--text":
|
|
27698
|
+
json = false;
|
|
27699
|
+
break;
|
|
27700
|
+
default:
|
|
27701
|
+
throw new Error(`Unknown im1 pending-mentions option: ${token}`);
|
|
27702
|
+
}
|
|
27703
|
+
}
|
|
27704
|
+
if (from && !to || !from && to) {
|
|
27705
|
+
throw new Error("Use --from and --to together");
|
|
27706
|
+
}
|
|
27707
|
+
return { type: "collect" /* Collect */, action: "pending-mentions", me, from, to, hours, context, limit, json };
|
|
27708
|
+
}
|
|
27621
27709
|
function parseIm1HealthArgs(tokens) {
|
|
27622
27710
|
const rest = [...tokens];
|
|
27623
27711
|
let json = false;
|
|
@@ -27782,6 +27870,16 @@ function parsePositiveInt2(value, optionName) {
|
|
|
27782
27870
|
}
|
|
27783
27871
|
return parsed;
|
|
27784
27872
|
}
|
|
27873
|
+
function parseBoundedPositiveInt(value, optionName, max) {
|
|
27874
|
+
const parsed = parsePositiveInt2(value, optionName);
|
|
27875
|
+
if (parsed > max) throw new Error(`Invalid value for ${optionName}: ${value} (max ${max})`);
|
|
27876
|
+
return parsed;
|
|
27877
|
+
}
|
|
27878
|
+
function parseIsoDate(value, optionName) {
|
|
27879
|
+
const date = new Date(value);
|
|
27880
|
+
if (!Number.isFinite(date.getTime())) throw new Error(`Invalid value for ${optionName}: ${value}`);
|
|
27881
|
+
return date.toISOString();
|
|
27882
|
+
}
|
|
27785
27883
|
|
|
27786
27884
|
// src/chatRoomCommandParser.ts
|
|
27787
27885
|
function parseChatRoomArgs(tokens) {
|
|
@@ -28007,6 +28105,7 @@ var HELP_TEXT = [
|
|
|
28007
28105
|
` ${import_chalk4.default.gray(" health [--json]")}`,
|
|
28008
28106
|
` ${import_chalk4.default.gray(" threads [--q <keyword>] [--search <title>] [--limit <n>] [--json|--text]")}`,
|
|
28009
28107
|
` ${import_chalk4.default.gray(" messages --thread <name|conversation-id> [--limit <n>] [--json|--text]")}`,
|
|
28108
|
+
` ${import_chalk4.default.gray(" pending-mentions [--me <name>] [--hours <n>|--from <iso> --to <iso>] [--context <1-50>] [--limit <1-500>] [--json|--text]")}`,
|
|
28010
28109
|
` ${import_chalk4.default.gray(" reply --thread <name|conversation-id> [--text <text>] [--file|--image <path>] [--dryrun]")}`,
|
|
28011
28110
|
` ${import_chalk4.default.gray(" react --thread <name|conversation-id> --emoji <emoji> [--message <id|timestamp>] [--remove] [--dryrun]")}`,
|
|
28012
28111
|
` ${import_chalk4.default.cyan("collect")} Legacy alias for CC/yelling collection`,
|