@mnemom/mnemom 0.17.24 → 0.17.25

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.
@@ -6,7 +6,8 @@
6
6
  * mnemom agent slack login # store the bot + app-level tokens (0600)
7
7
  * mnemom agent slack logout # remove them
8
8
  * mnemom agent slack status # tokens, bot identity, router, live sessions
9
- * mnemom agent slack post [--channel C] [--thread TS] [--icon-emoji E] <text…|->
9
+ * mnemom agent slack post [--channel C] [--thread TS] [--icon-emoji E] [--] <text…|->
10
+ * # --help prints usage; unknown flags are refused
10
11
  * mnemom agent slack delete [--channel C] <ts> # delete a message THIS session posted
11
12
  * mnemom agent slack inbox [--peek] # unread messages addressed to THIS session
12
13
  * mnemom agent slack listen # this session's channel server (spawned by --slack)
@@ -21,7 +22,15 @@ interface PostArgs {
21
22
  channel?: string;
22
23
  thread?: string;
23
24
  iconEmoji?: string;
25
+ /** `--help` / `-h` was given: print POST_USAGE and post nothing. */
26
+ help?: true;
24
27
  text: string;
25
28
  }
29
+ export declare const POST_USAGE = "Usage: mnemom agent slack post [options] [--] <text\u2026|->\n\nPost a message to Slack as this session.\n\nOptions:\n -c, --channel <C> channel name or id (default: slack_channel from `mnemom agent config`)\n -t, --thread <TS> reply in the thread whose parent message has this ts\n --icon-emoji <E> emoji to show as the poster's icon\n -h, --help show this help and exit; nothing is posted\n\nText:\n The remaining words, joined by spaces. `-` (or no words with a piped stdin) reads stdin.\n Any other word starting with \"-\" before `--` is refused as an unknown flag. A message\n that starts with \"-\" must come after `--`, e.g. mnemom agent slack post -c C1 -- \"-1 on this\"";
30
+ /**
31
+ * Parse `post` arguments. Before a `--` separator, `--help`/`-h` asks for usage and any
32
+ * other dash-word that is not a known flag is refused, so a typo or a guessed flag can
33
+ * never be posted as message text. Everything after `--` is text, verbatim.
34
+ */
26
35
  export declare function parsePostArgs(argv: string[]): PostArgs;
27
36
  export {};
@@ -6,7 +6,8 @@
6
6
  * mnemom agent slack login # store the bot + app-level tokens (0600)
7
7
  * mnemom agent slack logout # remove them
8
8
  * mnemom agent slack status # tokens, bot identity, router, live sessions
9
- * mnemom agent slack post [--channel C] [--thread TS] [--icon-emoji E] <text…|->
9
+ * mnemom agent slack post [--channel C] [--thread TS] [--icon-emoji E] [--] <text…|->
10
+ * # --help prints usage; unknown flags are refused
10
11
  * mnemom agent slack delete [--channel C] <ts> # delete a message THIS session posted
11
12
  * mnemom agent slack inbox [--peek] # unread messages addressed to THIS session
12
13
  * mnemom agent slack listen # this session's channel server (spawned by --slack)
@@ -121,15 +122,39 @@ async function status() {
121
122
  const allow = loadLauncherConfig().slackAllow ?? [];
122
123
  out(`allowed senders: ${allow.length ? allow.join(", ") : "none — no message will reach a session"}`);
123
124
  }
125
+ export const POST_USAGE = `Usage: mnemom agent slack post [options] [--] <text…|->
126
+
127
+ Post a message to Slack as this session.
128
+
129
+ Options:
130
+ -c, --channel <C> channel name or id (default: slack_channel from \`mnemom agent config\`)
131
+ -t, --thread <TS> reply in the thread whose parent message has this ts
132
+ --icon-emoji <E> emoji to show as the poster's icon
133
+ -h, --help show this help and exit; nothing is posted
134
+
135
+ Text:
136
+ The remaining words, joined by spaces. \`-\` (or no words with a piped stdin) reads stdin.
137
+ Any other word starting with "-" before \`--\` is refused as an unknown flag. A message
138
+ that starts with "-" must come after \`--\`, e.g. mnemom agent slack post -c C1 -- "-1 on this"`;
139
+ const POST_SHORT_FLAGS = new Set(["-c", "-t", "-h"]);
140
+ /**
141
+ * Parse `post` arguments. Before a `--` separator, `--help`/`-h` asks for usage and any
142
+ * other dash-word that is not a known flag is refused, so a typo or a guessed flag can
143
+ * never be posted as message text. Everything after `--` is text, verbatim.
144
+ */
124
145
  export function parsePostArgs(argv) {
125
146
  const res = { text: "" };
126
147
  const words = [];
148
+ let unknown;
127
149
  for (let i = 0; i < argv.length; i++) {
128
150
  const a = argv[i];
129
151
  const val = () => {
130
152
  const v = argv[++i];
131
- if (v === undefined)
153
+ // A flag is never a value: `--channel --help` must not eat the --help. (A short
154
+ // dash-word that is not a flag stays a value: `--icon-emoji -1` is Slack's thumbsdown.)
155
+ if (v === undefined || v.startsWith("--") || POST_SHORT_FLAGS.has(v)) {
132
156
  throw new Error(`mnemom agent slack post: ${a} needs a value.`);
157
+ }
133
158
  return v;
134
159
  };
135
160
  if (a === "--channel" || a === "-c")
@@ -138,18 +163,32 @@ export function parsePostArgs(argv) {
138
163
  res.thread = val();
139
164
  else if (a === "--icon-emoji")
140
165
  res.iconEmoji = val();
166
+ else if (a === "--help" || a === "-h")
167
+ res.help = true;
141
168
  else if (a === "--") {
142
169
  words.push(...argv.slice(i + 1));
143
170
  break;
144
171
  }
172
+ else if (a.startsWith("-") && a !== "-")
173
+ unknown ??= a;
145
174
  else
146
175
  words.push(a);
147
176
  }
177
+ // Help wins over an unknown flag: someone asking for usage should get it.
178
+ if (res.help)
179
+ return { help: true, text: "" };
180
+ if (unknown !== undefined) {
181
+ throw new Error(`mnemom agent slack post: unknown flag ${unknown}; put message text after --. See \`mnemom agent slack post --help\`.`);
182
+ }
148
183
  res.text = words.join(" ");
149
184
  return res;
150
185
  }
151
186
  async function post(argv) {
152
187
  const args = parsePostArgs(argv);
188
+ if (args.help) {
189
+ process.stdout.write(POST_USAGE + "\n");
190
+ return;
191
+ }
153
192
  let text = args.text;
154
193
  if (text === "-" || (!text && !process.stdin.isTTY))
155
194
  text = readFileSync(0, "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnemom/mnemom",
3
- "version": "0.17.24",
3
+ "version": "0.17.25",
4
4
  "description": "Transparent AI agent tracing",
5
5
  "type": "module",
6
6
  "bin": {