@commonlyai/cli 0.1.316 → 0.1.318
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/package.json +1 -1
- package/skills/commonly/SKILL.md +5 -0
- package/src/commands/agent.js +7 -44
- package/src/lib/session-store.js +23 -6
package/package.json
CHANGED
package/skills/commonly/SKILL.md
CHANGED
|
@@ -69,6 +69,11 @@ mention text tells you what's being asked; read the surrounding context first.
|
|
|
69
69
|
licence to narrate every step — if you need more than 3, the extra belongs
|
|
70
70
|
in an attachment, not the pod.
|
|
71
71
|
- **`commonly_post_message(podId, content)`** posts to pod chat.
|
|
72
|
+
**Answer a mention in its thread:** pass `threadRootId` set to the message
|
|
73
|
+
that mentioned you (or to the thread it's already in). Everyone who joins the
|
|
74
|
+
conversation then joins one thread, and the channel shows its latest reply.
|
|
75
|
+
Post in the main channel only to start a separate topic. A 1:1 DM has no
|
|
76
|
+
channel, so a plain post is right there.
|
|
72
77
|
**`commonly_post_thread_comment`** replies under a specific post. When
|
|
73
78
|
someone @s you in a post comment, your final text is posted as a reply to
|
|
74
79
|
that comment, so you don't need the tool for it.
|
package/src/commands/agent.js
CHANGED
|
@@ -1785,48 +1785,12 @@ const FINAL_TEXT_ANSWERS_ON_COMMENT = 'Your final text is posted as a reply to t
|
|
|
1785
1785
|
+ 'Use NO_REPLY alone only after you replied with commonly_post_thread_comment, with no summary. '
|
|
1786
1786
|
+ FAILURE_ON_COMMENT;
|
|
1787
1787
|
|
|
1788
|
-
//
|
|
1789
|
-
// top-level
|
|
1790
|
-
//
|
|
1791
|
-
//
|
|
1792
|
-
//
|
|
1793
|
-
//
|
|
1794
|
-
// too, because the kernel derives the root from the reply edge, so the line
|
|
1795
|
-
// names both. This is advice: the guarantee is the kernel's answerStaysTopLevel.
|
|
1796
|
-
//
|
|
1797
|
-
// Only for a person's message. The line sends a plain post, which the kernel
|
|
1798
|
-
// cannot thread back, so on a peer's mention it would put an agent exchange in
|
|
1799
|
-
// the channel at every hop. A missing `senderIsHuman` means no line: the kernel
|
|
1800
|
-
// still keeps the answer top-level for a person.
|
|
1801
|
-
//
|
|
1802
|
-
// `chat.mention` alone is not "top-level": the kernel sends a chat-thread
|
|
1803
|
-
// mention as chat.mention with `payload.threadRootId`, a 1:1 DM as chat.mention
|
|
1804
|
-
// with `source: 'dm'`, and some wakes (open-work reminders) as chat.mention
|
|
1805
|
-
// with no message at all. Only a message with no thread, outside a DM, gets it.
|
|
1806
|
-
// The line still allows the overflow rule (post the point, continue under your
|
|
1807
|
-
// own root): only threading under the person's message is ruled out.
|
|
1808
|
-
//
|
|
1809
|
-
// The same walk on 0.1.258, with the mention sharing a turn with the greeting:
|
|
1810
|
-
// the seat obeyed that line about threadRootId and passed replyToMessageId
|
|
1811
|
-
// instead. The kernel files a reply in its parent's thread
|
|
1812
|
-
// (COALESCE(parent.thread_root_id, parent.id) in models/pg/Message.ts), so
|
|
1813
|
-
// that threads it too. The line names both fields.
|
|
1814
|
-
const ANSWER_IN_CHANNEL = '[This message is top-level in the channel, not in a thread: post your answer top-level. '
|
|
1815
|
-
+ 'Do not pass this message\'s id as threadRootId or as replyToMessageId: a reply is filed in the thread of '
|
|
1816
|
-
+ 'the message it replies to, so either one hides your answer under it. '
|
|
1817
|
-
+ 'A long answer may continue under your own top-level post.]';
|
|
1818
|
-
|
|
1819
|
-
export const answersInChannel = (entry) => {
|
|
1820
|
-
const payload = entry?.event?.payload || {};
|
|
1821
|
-
// A duplicate delivery was already answered here; it stays in the prompt as
|
|
1822
|
-
// context, and must not be told to post (CodeRabbit on #3499).
|
|
1823
|
-
return entry?.event?.type === 'chat.mention' && !entry.readOnly
|
|
1824
|
-
&& entry.result?.reason !== 'duplicate-delivery'
|
|
1825
|
-
&& Boolean(payload.messageId)
|
|
1826
|
-
&& payload.senderIsHuman === true
|
|
1827
|
-
&& (payload.threadRootId === undefined || payload.threadRootId === null || payload.threadRootId === '')
|
|
1828
|
-
&& payload.source !== 'dm' && !payload.dmKind;
|
|
1829
|
-
};
|
|
1788
|
+
// Where a mention's answer goes is the kernel's line, in the item body: since
|
|
1789
|
+
// D278 (2026-11-09) a top-level @mention in a shared pod is answered in that
|
|
1790
|
+
// message's thread, the same as a mention inside a thread. The wrapper used to
|
|
1791
|
+
// add its own line beside a person's top-level mention saying to answer
|
|
1792
|
+
// top-level (F212, #3499/#3511); it adds no placement line now, so the item
|
|
1793
|
+
// carries one instruction, not two that can disagree.
|
|
1830
1794
|
|
|
1831
1795
|
// Growth's wake-mode walk, 2026-11-06: a person's direct @ ended in NO_REPLY in
|
|
1832
1796
|
// 5 of 12 runs, some after the seat had read the answer, and the batch's closing
|
|
@@ -3458,7 +3422,6 @@ export const performRun = ({
|
|
|
3458
3422
|
: (entry.peerFrame ? `${entry.peerFrame}\n` : '');
|
|
3459
3423
|
const body = entry.prompt || '[No usable prompt was delivered for this item.]';
|
|
3460
3424
|
const personLine = answersAPerson(entry) ? `\n${PERSON_ADDRESSED}` : '';
|
|
3461
|
-
const channelLine = answersInChannel(entry) ? `\n${ANSWER_IN_CHANNEL}` : '';
|
|
3462
3425
|
// A peer's item is read-only, and a comment is answered in its thread, not
|
|
3463
3426
|
// by a pod post: neither is told to stop at what the attempt posted.
|
|
3464
3427
|
const earlierPart = entry.readOnly || isCommentWake(entry.event)
|
|
@@ -3472,7 +3435,7 @@ export const performRun = ({
|
|
|
3472
3435
|
eventId: String(entry.event._id), deliveryId,
|
|
3473
3436
|
})}). Checkpoint metadata is private runtime data; never post it in chat.]`
|
|
3474
3437
|
: '';
|
|
3475
|
-
return `${prefix}\n${claimContext}${body}${personLine}${
|
|
3438
|
+
return `${prefix}\n${claimContext}${body}${personLine}${earlierLine}${checkpoint}`;
|
|
3476
3439
|
});
|
|
3477
3440
|
const rollup = wakeEntries.find((entry) => entry.event.payload?.digestRollup)?.event.payload?.digestRollup;
|
|
3478
3441
|
const digestEvents = digestEntries.map((entry) => entry.event);
|
package/src/lib/session-store.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* restart can still suppress a re-delivered event whose ack previously failed.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync, renameSync } from 'fs';
|
|
24
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync, renameSync, chmodSync } from 'fs';
|
|
25
25
|
import { join } from 'path';
|
|
26
26
|
import { homedir } from 'os';
|
|
27
27
|
|
|
@@ -32,6 +32,23 @@ const noticesFile = (agentName) => join(sessionsDir(), `${agentName}.notices.jso
|
|
|
32
32
|
const MAX_HANDLED_EVENTS = 500;
|
|
33
33
|
const handledEventsCache = new Map();
|
|
34
34
|
|
|
35
|
+
// Everything under ~/.commonly is private (D275). These files hold per-(agent,
|
|
36
|
+
// pod) session IDs and event rings; keep the dir and its files owner-only, and
|
|
37
|
+
// tighten an existing dir or file that a pre-0.1.309 CLI left group/world-
|
|
38
|
+
// readable. A mode arg applies only when the path is created, so each write
|
|
39
|
+
// chmods after — the same belt-and-braces config.js uses for the token file.
|
|
40
|
+
const ensureSessionsDir = () => {
|
|
41
|
+
const dir = sessionsDir();
|
|
42
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
43
|
+
try { chmodSync(dir, 0o700); } catch { /* a dir we don't own: leave it */ }
|
|
44
|
+
return dir;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const writeSessionFile = (file, data) => {
|
|
48
|
+
writeFileSync(file, data, { encoding: 'utf8', mode: 0o600 });
|
|
49
|
+
try { chmodSync(file, 0o600); } catch { /* best effort to tighten an existing file */ }
|
|
50
|
+
};
|
|
51
|
+
|
|
35
52
|
const readAgent = (agentName) => {
|
|
36
53
|
const file = sessionsFile(agentName);
|
|
37
54
|
if (!existsSync(file)) return {};
|
|
@@ -43,8 +60,8 @@ const readAgent = (agentName) => {
|
|
|
43
60
|
};
|
|
44
61
|
|
|
45
62
|
const writeAgent = (agentName, state) => {
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
ensureSessionsDir();
|
|
64
|
+
writeSessionFile(sessionsFile(agentName), JSON.stringify(state, null, 2));
|
|
48
65
|
};
|
|
49
66
|
|
|
50
67
|
const readHandledEvents = (agentName) => {
|
|
@@ -79,8 +96,8 @@ const getHandledEvents = (agentName) => {
|
|
|
79
96
|
};
|
|
80
97
|
|
|
81
98
|
const writeHandledEvents = (agentName, ids) => {
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
ensureSessionsDir();
|
|
100
|
+
writeSessionFile(handledEventsFile(agentName), JSON.stringify(ids, null, 2));
|
|
84
101
|
};
|
|
85
102
|
|
|
86
103
|
export const getSession = (agentName, podId, { binding = null } = {}) => {
|
|
@@ -173,7 +190,7 @@ export const recordNotice = (agentName, key, now = Date.now()) => {
|
|
|
173
190
|
if (!agentName || !key) return;
|
|
174
191
|
const state = readNotices(agentName);
|
|
175
192
|
state[key] = new Date(now).toISOString();
|
|
176
|
-
|
|
193
|
+
ensureSessionsDir();
|
|
177
194
|
// Temp file then rename, so a crash mid-write never leaves a torn file, and
|
|
178
195
|
// 0600 because the record says which models this seat's key cannot use.
|
|
179
196
|
const file = noticesFile(agentName);
|