slashvibe-mcp 0.9.10 → 0.9.12
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/arrival.js +25 -1
- package/hooks/arrival-hook.cjs +46 -3
- package/package.json +1 -1
- package/tools/line.js +7 -1
package/arrival.js
CHANGED
|
@@ -252,6 +252,30 @@ function record(threads, me, { since = 0, roster = [], bindingFor = null, env =
|
|
|
252
252
|
return out;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* What this side's agent just said for its person over an open line, queued so
|
|
257
|
+
* the person is SHOWN it by the hook after the answering tool call. The promise
|
|
258
|
+
* is that they are always told afterwards; measured, the agent forgot to say it
|
|
259
|
+
* in six runs of eight, so it no longer depends on the agent. The row is not an
|
|
260
|
+
* arrival: `kind: 'told'` keeps it from ever being answered.
|
|
261
|
+
*/
|
|
262
|
+
function told({ me, to, said, id }, env = process.env) {
|
|
263
|
+
const safe = safeId(`told-${id}`);
|
|
264
|
+
const mine = String(me || '').toLowerCase();
|
|
265
|
+
if (!safe || !mine) return false;
|
|
266
|
+
const who = inertField(to, 40);
|
|
267
|
+
try {
|
|
268
|
+
const dir = spoolDir(env);
|
|
269
|
+
ensureDir(dir);
|
|
270
|
+
writeAtomic(path.join(dir, `${safe}.json`), {
|
|
271
|
+
id: safe, kind: 'told', to: mine, from: mine, at: Date.now(),
|
|
272
|
+
context: `/vibe — the person you are working with has just been shown, word for word, what you answered @${who} over the open line. Do not repeat it. Carry on with their task.`,
|
|
273
|
+
line: `/vibe · your agent answered @${who} over your open line: "${inertField(said, 200)}"`,
|
|
274
|
+
});
|
|
275
|
+
return true;
|
|
276
|
+
} catch { return false; }
|
|
277
|
+
}
|
|
278
|
+
|
|
255
279
|
/**
|
|
256
280
|
* Housekeeping, run by the server process: drop spool rows that are stale or
|
|
257
281
|
* addressed to an account that is no longer the one signed in here, and old
|
|
@@ -319,7 +343,7 @@ async function wroteLastPeople(threads, me, { kindOf = null, limit = 3, ...opts
|
|
|
319
343
|
|
|
320
344
|
module.exports = {
|
|
321
345
|
wroteLastPeople,
|
|
322
|
-
spoolDir, safeId, claim, isClaimed, isSpooled,
|
|
346
|
+
spoolDir, safeId, claim, isClaimed, isSpooled, told,
|
|
323
347
|
render, pickArrivals, record, prune, wroteLast,
|
|
324
348
|
SPOOL_TTL_MS, ARRIVAL_SLACK_MS,
|
|
325
349
|
};
|
package/hooks/arrival-hook.cjs
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* reads the identity it was installed for.
|
|
16
16
|
*
|
|
17
17
|
* Presentation only: writes no receipt and no read state.
|
|
18
|
+
*
|
|
19
|
+
* One more thing it does on a prompt: when the person says they are stuck, it
|
|
20
|
+
* reminds the agent, once per session, that vibe_bump exists (see stuckNudge).
|
|
18
21
|
*/
|
|
19
22
|
'use strict';
|
|
20
23
|
|
|
@@ -53,16 +56,56 @@ function main() {
|
|
|
53
56
|
|
|
54
57
|
const dir = process.env.VIBE_ARRIVALS_DIR || path.join(__dirname, '..', 'arrivals');
|
|
55
58
|
const rows = take(dir, Date.now());
|
|
56
|
-
|
|
59
|
+
const nudge = event === 'UserPromptSubmit' ? stuckNudge(input, dir) : '';
|
|
60
|
+
if (rows.length === 0 && !nudge) return quiet();
|
|
57
61
|
|
|
62
|
+
const context = rows.map((r) => r.context);
|
|
63
|
+
if (nudge) context.push(nudge);
|
|
64
|
+
const shown = rows.map((r) => r.line).filter(Boolean).join('\n');
|
|
58
65
|
process.stdout.write(JSON.stringify({
|
|
59
66
|
suppressOutput: true,
|
|
60
|
-
systemMessage:
|
|
67
|
+
...(shown ? { systemMessage: shown } : {}),
|
|
61
68
|
hookSpecificOutput: {
|
|
62
69
|
hookEventName: event,
|
|
63
|
-
additionalContext:
|
|
70
|
+
additionalContext: context.join('\n\n'),
|
|
64
71
|
},
|
|
65
72
|
}));
|
|
66
73
|
}
|
|
67
74
|
|
|
75
|
+
// ── the bump, made dependable ───────────────────────────────────────────────
|
|
76
|
+
// vibe_bump exists for the moment a person is stuck, but whether the agent
|
|
77
|
+
// thinks of it was left to the agent, and measured it mostly did not: one
|
|
78
|
+
// session in four, and not at all on production. The person saying so in plain
|
|
79
|
+
// words is something this hook can see. When they do, the agent is reminded,
|
|
80
|
+
// once per session, that the tool exists. Nothing is shown to the person, no
|
|
81
|
+
// name is given here (the tool names only people they know), nothing leaves the
|
|
82
|
+
// machine, and quiet turns it off with everything else.
|
|
83
|
+
// First-person, plain wording only: "the stuck-detection code" must not count.
|
|
84
|
+
const STUCK = new RegExp([
|
|
85
|
+
"\\b(i'?m|i am|i'?ve been|i have been|we'?re|we are|we'?ve been|still|totally|completely|really|so|got|getting|been) stuck\\b",
|
|
86
|
+
"\\bstuck (on|with|for|all|here|again)\\b",
|
|
87
|
+
"\\b(keep )?going (a?round )?in circles\\b",
|
|
88
|
+
"\\b(i'?m|i am|we'?re|we are) blocked on\\b",
|
|
89
|
+
"\\bcan(no|')?t figure (this|it|that) out\\b",
|
|
90
|
+
"\\bbanging my head\\b",
|
|
91
|
+
"\\bat my wits'? end\\b",
|
|
92
|
+
].join('|'), 'i');
|
|
93
|
+
|
|
94
|
+
function stuckNudge(input, dir) {
|
|
95
|
+
try {
|
|
96
|
+
const said = typeof input.prompt === 'string' ? input.prompt : '';
|
|
97
|
+
if (!said || said.length > 4000 || !STUCK.test(said)) return '';
|
|
98
|
+
try { if (JSON.parse(fs.readFileSync(path.join(dir, '..', 'reach.json'), 'utf8')).quiet === true) return ''; } catch {}
|
|
99
|
+
const session = String(input.session_id || '').replace(/[^A-Za-z0-9_-]/g, '').slice(0, 80);
|
|
100
|
+
if (!session) return '';
|
|
101
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
102
|
+
// Once per session: the first prompt that says it claims the marker.
|
|
103
|
+
try { fs.closeSync(fs.openSync(path.join(dir, `stuck-${session}.shown`), 'wx', 0o600)); } catch { return ''; }
|
|
104
|
+
return [
|
|
105
|
+
'/vibe: the person has just said, in their own words, that they are stuck.',
|
|
106
|
+
'Help with the problem first. Then call vibe_bump once, with one line on what they are stuck on: it says whether someone they already know is in a session right now working on the same thing. If it names nobody who fits, say nothing about it.',
|
|
107
|
+
].join('\n');
|
|
108
|
+
} catch { return ''; }
|
|
109
|
+
}
|
|
110
|
+
|
|
68
111
|
try { main(); } catch { quiet(); }
|
package/package.json
CHANGED
package/tools/line.js
CHANGED
|
@@ -129,7 +129,11 @@ const answerDefinition = {
|
|
|
129
129
|
function arrived(id) {
|
|
130
130
|
const safe = arrival.safeId(String(id || '').replace(/^#/, ''));
|
|
131
131
|
if (!safe) return null;
|
|
132
|
-
try {
|
|
132
|
+
try {
|
|
133
|
+
const row = JSON.parse(fs.readFileSync(path.join(arrival.spoolDir(), `${safe}.json`), 'utf8'));
|
|
134
|
+
// Only something that ARRIVED. The note of what this side said is not one.
|
|
135
|
+
return row && row.kind !== 'told' ? row : null;
|
|
136
|
+
} catch { return null; }
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
async function answerHandler(args = {}) {
|
|
@@ -152,6 +156,8 @@ async function answerHandler(args = {}) {
|
|
|
152
156
|
const sent = await deliver({ to, message: message + line.ANSWERED(me), replyTo: id, origin: 'agent_line' });
|
|
153
157
|
if (!sent.data || !sent.data.sent) return sent;
|
|
154
158
|
line.record({ kind: 'answered', with: to, id: sent.data.message_id, answers: id, asked: line.stripMark(row.text || ''), said: message });
|
|
159
|
+
// The person is shown the answer by the hook, not by the agent's memory.
|
|
160
|
+
arrival.told({ me, to, said: message, id: sent.data.message_id });
|
|
155
161
|
return {
|
|
156
162
|
display: `Answered @${to} over the open line. Now tell the person here, in one line: @${to} asked "${inertField(line.stripMark(row.text || ''), 120)}" and you told them "${inertField(message, 160)}". Then carry on with their task.`,
|
|
157
163
|
data: { sent: true, message_id: sent.data.message_id, to },
|