@hasna/conversations 0.1.15 → 0.1.16
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/bin/index.js +68 -13
- package/bin/mcp.js +1 -1
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3231,7 +3231,7 @@ var init_poll = __esm(() => {
|
|
|
3231
3231
|
var require_package = __commonJS((exports, module) => {
|
|
3232
3232
|
module.exports = {
|
|
3233
3233
|
name: "@hasna/conversations",
|
|
3234
|
-
version: "0.1.
|
|
3234
|
+
version: "0.1.16",
|
|
3235
3235
|
description: "Real-time CLI messaging for AI agents",
|
|
3236
3236
|
type: "module",
|
|
3237
3237
|
bin: {
|
|
@@ -35261,22 +35261,76 @@ program2.command("watch").description("Watch for new messages with desktop notif
|
|
|
35261
35261
|
const agent = resolveIdentity(opts.from);
|
|
35262
35262
|
heartbeat(agent);
|
|
35263
35263
|
const interval = Number.isFinite(opts.interval) && opts.interval > 0 ? opts.interval : 1000;
|
|
35264
|
-
|
|
35265
|
-
console.log(
|
|
35266
|
-
`));
|
|
35264
|
+
const cols = Math.min(process.stdout.columns || 80, 100);
|
|
35265
|
+
console.log("");
|
|
35266
|
+
console.log(chalk2.bold(` Conversations`) + chalk2.dim(` \u2014 watching as ${chalk2.cyan(agent)}`));
|
|
35267
|
+
console.log(chalk2.dim(` ${opts.space ? `Space: #${opts.space}` : "All DMs"} \xB7 Poll: ${interval}ms \xB7 Ctrl+C to stop`));
|
|
35268
|
+
console.log(chalk2.dim(" " + "\u2500".repeat(cols - 4)));
|
|
35269
|
+
console.log("");
|
|
35267
35270
|
const { startPolling: startPolling2 } = (init_poll(), __toCommonJS(exports_poll));
|
|
35268
|
-
const
|
|
35269
|
-
const
|
|
35270
|
-
|
|
35271
|
+
const renderContent = (content) => {
|
|
35272
|
+
const lines = content.split(`
|
|
35273
|
+
`);
|
|
35274
|
+
const rendered = [];
|
|
35275
|
+
for (const line of lines) {
|
|
35276
|
+
let l = line;
|
|
35277
|
+
const h = l.match(/^(#{1,3})\s+(.+)/);
|
|
35278
|
+
if (h) {
|
|
35279
|
+
rendered.push(chalk2.bold(h[2]));
|
|
35280
|
+
continue;
|
|
35281
|
+
}
|
|
35282
|
+
if (/^\s*[-*+]\s/.test(l)) {
|
|
35283
|
+
rendered.push(" " + chalk2.dim("\u2022") + " " + renderInline(l.replace(/^\s*[-*+]\s/, "")));
|
|
35284
|
+
continue;
|
|
35285
|
+
}
|
|
35286
|
+
const ol = l.match(/^\s*(\d+)[.)]\s(.*)/);
|
|
35287
|
+
if (ol) {
|
|
35288
|
+
rendered.push(" " + chalk2.dim(ol[1] + ".") + " " + renderInline(ol[2]));
|
|
35289
|
+
continue;
|
|
35290
|
+
}
|
|
35291
|
+
if (l.startsWith(">")) {
|
|
35292
|
+
rendered.push(chalk2.dim(" \u2502 ") + chalk2.italic(renderInline(l.replace(/^>\s?/, ""))));
|
|
35293
|
+
continue;
|
|
35294
|
+
}
|
|
35295
|
+
if (l.trimStart().startsWith("```"))
|
|
35296
|
+
continue;
|
|
35297
|
+
if (l.trim() === "") {
|
|
35298
|
+
rendered.push("");
|
|
35299
|
+
continue;
|
|
35300
|
+
}
|
|
35301
|
+
rendered.push(renderInline(l));
|
|
35302
|
+
}
|
|
35303
|
+
return rendered.join(`
|
|
35304
|
+
`);
|
|
35305
|
+
};
|
|
35306
|
+
const renderInline = (text) => {
|
|
35307
|
+
return text.replace(/`([^`]+)`/g, (_, code) => chalk2.bgGray.white(` ${code} `)).replace(/\*\*\*(.+?)\*\*\*/g, (_, t) => chalk2.bold.italic(t)).replace(/\*\*(.+?)\*\*/g, (_, t) => chalk2.bold(t)).replace(/\*(.+?)\*/g, (_, t) => chalk2.italic(t)).replace(/~~(.+?)~~/g, (_, t) => chalk2.strikethrough(t));
|
|
35308
|
+
};
|
|
35309
|
+
const desktopNotify = (title, body) => {
|
|
35271
35310
|
if (process.platform === "darwin") {
|
|
35272
35311
|
try {
|
|
35273
35312
|
const { execSync } = __require("child_process");
|
|
35274
|
-
const
|
|
35275
|
-
const
|
|
35276
|
-
execSync(`osascript -e 'display notification "${
|
|
35313
|
+
const t = title.replace(/"/g, "\\\"");
|
|
35314
|
+
const b = body.replace(/"/g, "\\\"").replace(/\n/g, " ").slice(0, 200);
|
|
35315
|
+
execSync(`osascript -e 'display notification "${b}" with title "${t}"'`, { timeout: 3000 });
|
|
35277
35316
|
} catch {}
|
|
35278
35317
|
}
|
|
35279
35318
|
};
|
|
35319
|
+
const renderMessage = (msg) => {
|
|
35320
|
+
const time3 = chalk2.dim(msg.created_at.slice(11, 19));
|
|
35321
|
+
const where = msg.space ? chalk2.magenta(`#${msg.space}`) : chalk2.yellow("DM");
|
|
35322
|
+
const priority = msg.priority !== "normal" ? msg.priority === "urgent" ? chalk2.red.bold(` [${msg.priority}]`) : msg.priority === "high" ? chalk2.yellow(` [${msg.priority}]`) : chalk2.dim(` [${msg.priority}]`) : "";
|
|
35323
|
+
const blocking = msg.blocking ? chalk2.red.bold(" \u26A0 BLOCKER") : "";
|
|
35324
|
+
const sender = chalk2.cyan.bold(msg.from_agent);
|
|
35325
|
+
console.log(` ${sender} ${where} ${time3}${priority}${blocking}`);
|
|
35326
|
+
const content = renderContent(msg.content);
|
|
35327
|
+
const indented = content.split(`
|
|
35328
|
+
`).map((l) => " " + l).join(`
|
|
35329
|
+
`);
|
|
35330
|
+
console.log(indented);
|
|
35331
|
+
console.log(chalk2.dim(" " + "\xB7".repeat(Math.min(cols - 8, 60))));
|
|
35332
|
+
console.log("");
|
|
35333
|
+
};
|
|
35280
35334
|
startPolling2({
|
|
35281
35335
|
to_agent: opts.space ? undefined : agent,
|
|
35282
35336
|
space: opts.space,
|
|
@@ -35285,15 +35339,16 @@ program2.command("watch").description("Watch for new messages with desktop notif
|
|
|
35285
35339
|
for (const msg of messages) {
|
|
35286
35340
|
if (msg.from_agent === agent)
|
|
35287
35341
|
continue;
|
|
35342
|
+
renderMessage(msg);
|
|
35288
35343
|
const where = msg.space ? `#${msg.space}` : "DM";
|
|
35289
|
-
const preview = msg.content.
|
|
35290
|
-
|
|
35344
|
+
const preview = msg.content.replace(/[*#`~_>\-]/g, "").slice(0, 150);
|
|
35345
|
+
desktopNotify(`${msg.from_agent} (${where})`, preview);
|
|
35291
35346
|
}
|
|
35292
35347
|
}
|
|
35293
35348
|
});
|
|
35294
35349
|
process.on("SIGINT", () => {
|
|
35295
35350
|
console.log(chalk2.dim(`
|
|
35296
|
-
Stopped watching.`));
|
|
35351
|
+
Stopped watching.`));
|
|
35297
35352
|
closeDb();
|
|
35298
35353
|
process.exit(0);
|
|
35299
35354
|
});
|
package/bin/mcp.js
CHANGED
|
@@ -29554,7 +29554,7 @@ function renameAgent(oldName, newName) {
|
|
|
29554
29554
|
// package.json
|
|
29555
29555
|
var package_default = {
|
|
29556
29556
|
name: "@hasna/conversations",
|
|
29557
|
-
version: "0.1.
|
|
29557
|
+
version: "0.1.16",
|
|
29558
29558
|
description: "Real-time CLI messaging for AI agents",
|
|
29559
29559
|
type: "module",
|
|
29560
29560
|
bin: {
|