@vibest/cli 0.0.1-beta.19 → 0.0.1-beta.20
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/vibest.cjs +23 -13
- package/harnesses/agy/.agents/plugins/vibest/hook.sh +48 -0
- package/harnesses/agy/.agents/plugins/vibest/hooks.json +38 -0
- package/harnesses/agy/.agents/plugins/vibest/plugin.json +5 -0
- package/harnesses/agy/.agents/plugins/vibest/skills/delegate/SKILL.md +66 -0
- package/harnesses/agy/.agents/plugins/vibest/skills/pipeline/SKILL.md +57 -0
- package/harnesses/agy/index.js +1405 -0
- package/harnesses/claude/.claude-plugin/plugin.json +2 -2
- package/harnesses/claude/README.md +17 -17
- package/harnesses/claude/hooks/hooks.json +1 -1
- package/harnesses/claude/hooks/register.mjs +154 -101
- package/harnesses/claude/skills/delegate/SKILL.md +18 -18
- package/harnesses/claude/skills/pipeline/SKILL.md +14 -14
- package/harnesses/cursor/.cursor-plugin/plugin.json +2 -2
- package/harnesses/cursor/hooks/hooks.json +3 -0
- package/harnesses/cursor/hooks/vibest.sh +3 -3
- package/harnesses/cursor/index.js +1340 -0
- package/harnesses/cursor/skills/delegate/SKILL.md +18 -18
- package/harnesses/cursor/skills/pipeline/SKILL.md +14 -14
- package/harnesses/pi/extension.mjs +643 -1112
- package/harnesses/pi/presentation.mjs +1023 -0
- package/harnesses/pi/skills/delegate/SKILL.md +18 -18
- package/harnesses/pi/skills/pipeline/SKILL.md +14 -14
- package/herdr-plugin/README.md +2 -2
- package/herdr-plugin/bin/vibest.sh +1 -1
- package/herdr-plugin/herdr-plugin.toml +5 -5
- package/package.json +17 -16
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibest",
|
|
3
|
-
"description": "VIBEST for Claude Code:
|
|
3
|
+
"description": "VIBEST for Claude Code: execution-end reports, prompt reports and the tool guard for VIBEST sessions, and the entry session inbox that delivers VIBEST messages as prompts, all over HTTP to vibestd",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "vibest-dev"
|
|
6
6
|
},
|
|
7
7
|
"repository": "https://github.com/vibest-dev/vibest",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "0.0.1-beta.
|
|
9
|
+
"version": "0.0.1-beta.20"
|
|
10
10
|
}
|
|
@@ -3,38 +3,37 @@
|
|
|
3
3
|
One ordinary Claude Code plugin, one hooks module. Every call to vibest is an HTTP request from `$.http.fetch` to
|
|
4
4
|
vibestd's unix socket `<VIBEST_HOME>/vibest-http.sock`; the plugin runs no `vibest` process.
|
|
5
5
|
|
|
6
|
-
- `turn.complete` posts each main-loop
|
|
6
|
+
- `turn.complete` posts each main-loop execution end to `/hooks/claude/execution-end` with its `reason`, the answer and the
|
|
7
7
|
current Claude session id. vibest maps the reason: `answer` is the result as it is; `aborted` is an interrupted
|
|
8
8
|
(failed) result when the person pressed Esc, and nothing when `vibest interrupt` (or remove, archive) stopped the
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
execution; `refusal` and `error` are failed results. A subagent's loop (`agentId` set) reports nothing. For the
|
|
10
|
+
entry session vibestd records only the conversation id.
|
|
11
11
|
- `prompt.submit` posts a worker's prompt with its `origin.kind` to `/hooks/claude/prompt`; vibest keeps only what
|
|
12
12
|
the person submitted (`composer`, or `bridge` for Remote Control).
|
|
13
13
|
- `tool.call` posts each tool call, a subagent's included, to `/hooks/claude/guard` and returns `{ deny }` when vibest
|
|
14
14
|
refuses it. It tries for 2 s, then again after 100, 300 and 900 ms; when nothing answers, the call is refused.
|
|
15
|
-
- The **
|
|
15
|
+
- The **inbox**: from `session.start`, a session asks `/inbox/take` every second while it is idle (after `session.start`
|
|
16
|
+
and `turn.complete`, never while an execution runs). A batch comes with its execution id as
|
|
16
17
|
one short line (`<Type> Agent "<title>" completed (<id>) · +N more`) and its full text. The line is submitted with
|
|
17
18
|
`$.prompt.submit` from the AbovePrompt `ui.render` hook, one batch per draw, and this module's own `prompt.submit`
|
|
18
|
-
hook attaches the full text as context.
|
|
19
|
+
hook attaches the full text as context. This module's own `prompt.submit` hook reports the batch's execution as accepted
|
|
20
|
+
(`PromptSubmit` with `origin: "vibest"` and the execution id) before the prompt goes on; a
|
|
19
21
|
`drop` puts the batch back at the front of the queue. The submit has to come from inside a hook's call stack: a
|
|
20
22
|
submit from a clock callback would skip this module's own `prompt.submit` hook as re-entry. The render hook awaits
|
|
21
23
|
the submit before it returns: Claude Code reads the call against the hooks still running when it arrives, and under
|
|
22
24
|
load a hook that returned at once had often settled first, so its own `prompt.submit` hook was skipped the same way
|
|
23
|
-
and the line went out without its full text.
|
|
24
|
-
row ids it has taken, so a batch handed out again after its lease ran out or vibestd restarted is not shown twice:
|
|
25
|
-
in a batch that mixes taken rows with new ones, the taken ones are acked and the new ones given back, so they come
|
|
26
|
-
alone. Full texts wait for `prompt.submit` for at most the last 100 lines. A one-line notice is its own full text and
|
|
25
|
+
and the line went out without its full text. Full texts wait for `prompt.submit` for at most the last 100 lines. A one-line notice is its own full text and
|
|
27
26
|
is not attached again. Using the AbovePrompt render hook as a place to submit from is undocumented; E2E covers it.
|
|
28
27
|
|
|
29
|
-
Reports (
|
|
30
|
-
A failed report never blocks or continues a stopped
|
|
28
|
+
Reports (execution end, prompt) retry in the background after 1, 2, 4, 8, 15 and 30 s while vibestd does not take them.
|
|
29
|
+
A failed report never blocks or continues a stopped execution. Five failed polls in a row put "vibestd unreachable" on the
|
|
31
30
|
status line. `Session.Ready` goes with Claude Code's own pid, read as the `$PPID` of a command the module runs, since
|
|
32
31
|
a restart signals that process. A failed hook is skipped unless its handler answers, so outside vibest every listener
|
|
33
32
|
answers with a pass. The tool arguments sent to the guard are the `tool.call` input without its reserved keys
|
|
34
33
|
(`tool`, `tool_use_id`, `consent`, `agentId`).
|
|
35
34
|
|
|
36
35
|
Every request carries the session headers from `@vibest/protocol` `sessionHeaders`: protocol, `VIBEST_SESSION_ID`,
|
|
37
|
-
`VIBEST_PROJECT_ID`, the current Claude session id, `
|
|
36
|
+
`VIBEST_PROJECT_ID`, the current Claude session id, `VIBEST_HARNESS`, the cwd, `VIBEST_RUNTIME` and the
|
|
38
37
|
plugin version. Paths carry no version; the only one is `PROTOCOL` in the `vibest-protocol` header. vibestd refuses a
|
|
39
38
|
request with an unknown session (404), a missing or wrong project id (403) or another protocol (409). A 409 body holds
|
|
40
39
|
vibestd's protocol and version, a message and the command to run (`action`); the plugin puts them on the status line
|
|
@@ -61,22 +60,23 @@ The plugin directory holds exactly:
|
|
|
61
60
|
`$.plugin` has no version, so the build inlines it. Bun writes each module's path relative to the working directory
|
|
62
61
|
into the bundle, so the build pins the working directory and the bytes do not vary.
|
|
63
62
|
|
|
64
|
-
The generated files are ignored by Git.
|
|
63
|
+
The generated files are ignored by Git.
|
|
65
64
|
|
|
66
65
|
## Use
|
|
67
66
|
|
|
68
67
|
The launch side (arguments, models, resume, subscription reading) is the `claude` harness definition, added by the
|
|
69
68
|
builtin plugin `harness-claude` in `packages/plugin-harnesses`; this package is only what runs inside Claude.
|
|
70
69
|
|
|
71
|
-
Nothing to install. vibest starts each Claude session (and a Claude
|
|
70
|
+
Nothing to install. vibest starts each Claude session (and a Claude entry session) with
|
|
72
71
|
`claude --plugin-dir <@vibest/cli>/harnesses/claude`, which loads the plugin for that session only. vibest writes
|
|
73
|
-
nothing into `~/.claude`. Plain `claude` sessions never load it, and in a Claude process without
|
|
72
|
+
nothing into `~/.claude`. Plain `claude` sessions never load it, and in a Claude process without
|
|
74
73
|
`VIBEST_SESSION_ID` every listener returns `next` and sends nothing.
|
|
75
74
|
|
|
76
75
|
**Mods are not sandboxed.** The module is code that Claude Code runs in its own process with your permissions. What it
|
|
77
76
|
does is narrow: POST to the fixed vibestd socket and submit the inbox line as a prompt. Its `tool.call` listener only
|
|
78
77
|
refuses; it registers no `tool.check` approval and changes no permission or policy setting. A module that does not
|
|
79
|
-
load guards nothing:
|
|
78
|
+
load guards nothing: vibest's `--settings` only grants the project folder, so the guard rules hold only while this
|
|
79
|
+
module runs.
|
|
80
80
|
|
|
81
81
|
**`/clear`.** Claude Code 2.1.316 changes `$.session.id()` on `/clear`, fires `session.end` for the old id and no new
|
|
82
82
|
`session.start`; the poll timer keeps running. The plugin therefore has no `session.end` handler and sends the
|
|
@@ -105,4 +105,4 @@ calls stay in `register` or the top-level `nativeHost`: `$.http.fetch`, `$.sessi
|
|
|
105
105
|
|
|
106
106
|
Hooks modules are early access and may change between releases. `claude plugin validate` and `claude plugin test` have
|
|
107
107
|
not been run on this revision. The E2E check I4 loads it with `--plugin-dir` into a real Claude: the guard refuses and the
|
|
108
|
-
|
|
108
|
+
execution end reports.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "VIBEST:
|
|
2
|
+
"description": "VIBEST: execution-end reports and the tool guard for VIBEST sessions; the entry session inbox module",
|
|
3
3
|
"modules": ["./register.mjs"]
|
|
4
4
|
}
|
|
@@ -1,41 +1,97 @@
|
|
|
1
|
+
// ../../schema/src/version.ts
|
|
2
|
+
var PROTOCOL = 11;
|
|
3
|
+
|
|
4
|
+
// ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/Function.js
|
|
5
|
+
var dual = function(arity, body) {
|
|
6
|
+
if (typeof arity === "function") {
|
|
7
|
+
return function() {
|
|
8
|
+
return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
switch (arity) {
|
|
12
|
+
case 0:
|
|
13
|
+
case 1:
|
|
14
|
+
throw new RangeError(`Invalid arity ${arity}`);
|
|
15
|
+
case 2:
|
|
16
|
+
return function(a, b) {
|
|
17
|
+
if (arguments.length >= 2) {
|
|
18
|
+
return body(a, b);
|
|
19
|
+
}
|
|
20
|
+
return function(self) {
|
|
21
|
+
return body(self, a);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
case 3:
|
|
25
|
+
return function(a, b, c) {
|
|
26
|
+
if (arguments.length >= 3) {
|
|
27
|
+
return body(a, b, c);
|
|
28
|
+
}
|
|
29
|
+
return function(self) {
|
|
30
|
+
return body(self, a, b);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
return function() {
|
|
35
|
+
if (arguments.length >= arity) {
|
|
36
|
+
return body.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
const args = arguments;
|
|
39
|
+
return function(self) {
|
|
40
|
+
return body(self, ...args);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// ../../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/Predicate.js
|
|
47
|
+
function isString(input) {
|
|
48
|
+
return typeof input === "string";
|
|
49
|
+
}
|
|
50
|
+
function isNumber(input) {
|
|
51
|
+
return typeof input === "number";
|
|
52
|
+
}
|
|
53
|
+
function isFunction(input) {
|
|
54
|
+
return typeof input === "function";
|
|
55
|
+
}
|
|
56
|
+
function isObjectOrArray(input) {
|
|
57
|
+
return typeof input === "object" && input !== null;
|
|
58
|
+
}
|
|
59
|
+
function isObjectKeyword(input) {
|
|
60
|
+
return typeof input === "object" && input !== null || isFunction(input);
|
|
61
|
+
}
|
|
62
|
+
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObjectKeyword(self) && (property in self));
|
|
63
|
+
|
|
1
64
|
// ../../protocol/src/protocol.ts
|
|
2
|
-
var PROTOCOL = 8;
|
|
3
65
|
var PROTOCOL_HEADER = "vibest-protocol";
|
|
4
66
|
var CALLER_HEADER = "vibest-caller";
|
|
5
67
|
var SESSION_HEADER = "vibest-session-id";
|
|
6
68
|
var REPOSITORY_HEADER = "vibest-repository";
|
|
7
69
|
var PROJECT_HEADER = "vibest-project-id";
|
|
8
70
|
var HARNESS_SESSION_HEADER = "vibest-harness-session-id";
|
|
9
|
-
var AGENT_HEADER = "vibest-agent";
|
|
10
71
|
var HARNESS_HEADER = "vibest-harness";
|
|
11
72
|
var CWD_HEADER = "vibest-cwd";
|
|
12
73
|
var RUNTIME_HEADER = "vibest-runtime";
|
|
13
74
|
var PLUGIN_VERSION_HEADER = "vibest-plugin-version";
|
|
14
|
-
var
|
|
15
|
-
var
|
|
75
|
+
var PROCESS_HEADER = "vibest-process";
|
|
76
|
+
var TAKE_ROUTE = "/inbox/take";
|
|
16
77
|
var hookRoute = (harness, hook) => `/hooks/${harness}/${hook}`;
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
put(PLUGIN_VERSION_HEADER, who.pluginVersion);
|
|
35
|
-
if (who.repositoryRoot !== undefined)
|
|
36
|
-
headers[REPOSITORY_HEADER] = who.repositoryRoot;
|
|
37
|
-
return headers;
|
|
38
|
-
};
|
|
78
|
+
var isTaken = (body) => isObjectOrArray(body) && hasProperty(body, "execution") && isNumber(body.execution) && hasProperty(body, "ids") && Array.isArray(body.ids) && hasProperty(body, "line") && isString(body.line) && hasProperty(body, "text") && isString(body.text);
|
|
79
|
+
var presentHeaders = (headers) => Object.fromEntries(headers.flatMap(([name, value]) => value ? [[name, value]] : []));
|
|
80
|
+
var sessionHeaders = (who) => ({
|
|
81
|
+
[PROTOCOL_HEADER]: String(PROTOCOL),
|
|
82
|
+
[CALLER_HEADER]: "session",
|
|
83
|
+
[SESSION_HEADER]: who.sessionId,
|
|
84
|
+
...presentHeaders([
|
|
85
|
+
[PROJECT_HEADER, who.projectId],
|
|
86
|
+
[HARNESS_SESSION_HEADER, who.harnessSessionId],
|
|
87
|
+
[HARNESS_HEADER, who.harness],
|
|
88
|
+
[CWD_HEADER, who.cwd === undefined ? undefined : encodeURIComponent(who.cwd)],
|
|
89
|
+
[RUNTIME_HEADER, who.runtime],
|
|
90
|
+
[PLUGIN_VERSION_HEADER, who.pluginVersion],
|
|
91
|
+
[PROCESS_HEADER, who.process]
|
|
92
|
+
]),
|
|
93
|
+
...who.repositoryRoot !== undefined && { [REPOSITORY_HEADER]: who.repositoryRoot }
|
|
94
|
+
});
|
|
39
95
|
|
|
40
96
|
// src/plugin.ts
|
|
41
97
|
var POLL_MS = 1000;
|
|
@@ -50,8 +106,6 @@ function nativeHost($) {
|
|
|
50
106
|
return {
|
|
51
107
|
env: (name) => {
|
|
52
108
|
switch (name) {
|
|
53
|
-
case "VIBEST_AGENT":
|
|
54
|
-
return $.env.get("VIBEST_AGENT");
|
|
55
109
|
case "VIBEST_SESSION_ID":
|
|
56
110
|
return $.env.get("VIBEST_SESSION_ID");
|
|
57
111
|
case "VIBEST_PROJECT_ID":
|
|
@@ -62,6 +116,8 @@ function nativeHost($) {
|
|
|
62
116
|
return $.env.get("VIBEST_RUNTIME");
|
|
63
117
|
case "VIBEST_HOME":
|
|
64
118
|
return $.env.get("VIBEST_HOME");
|
|
119
|
+
case "VIBEST_PROCESS":
|
|
120
|
+
return $.env.get("VIBEST_PROCESS");
|
|
65
121
|
case "HOME":
|
|
66
122
|
return $.env.get("HOME");
|
|
67
123
|
}
|
|
@@ -82,22 +138,15 @@ function nativeHost($) {
|
|
|
82
138
|
};
|
|
83
139
|
}
|
|
84
140
|
var TOOL_CALL_RESERVED_KEYS = new Set(["tool", "tool_use_id", "consent", "agentId"]);
|
|
85
|
-
var toolInput = (event) =>
|
|
86
|
-
const input = {};
|
|
87
|
-
for (const [key, value] of Object.entries(event)) {
|
|
88
|
-
if (!TOOL_CALL_RESERVED_KEYS.has(key))
|
|
89
|
-
input[key] = value;
|
|
90
|
-
}
|
|
91
|
-
return input;
|
|
92
|
-
};
|
|
141
|
+
var toolInput = (event) => Object.fromEntries(Object.entries(event).filter(([key]) => !TOOL_CALL_RESERVED_KEYS.has(key)));
|
|
93
142
|
var timeout = (promise, ms, after) => new Promise((resolve, reject) => {
|
|
94
143
|
const timer = after(ms, () => reject(new Error(`no answer in ${ms} ms`)));
|
|
95
144
|
promise.then((value) => {
|
|
96
145
|
timer.cancel();
|
|
97
146
|
resolve(value);
|
|
98
|
-
}, (
|
|
147
|
+
}, (cause) => {
|
|
99
148
|
timer.cancel();
|
|
100
|
-
reject(
|
|
149
|
+
reject(cause);
|
|
101
150
|
});
|
|
102
151
|
});
|
|
103
152
|
var parse = (text) => {
|
|
@@ -107,25 +156,28 @@ var parse = (text) => {
|
|
|
107
156
|
return;
|
|
108
157
|
}
|
|
109
158
|
};
|
|
110
|
-
var
|
|
111
|
-
|
|
159
|
+
var isFields = (value) => value instanceof Object && !Array.isArray(value);
|
|
160
|
+
var member = (body, name) => isFields(body) ? body[name] : undefined;
|
|
161
|
+
var errorOf = (body) => {
|
|
162
|
+
const error = member(body, "error");
|
|
163
|
+
return isString(error) ? error : undefined;
|
|
164
|
+
};
|
|
165
|
+
function register(on) {
|
|
112
166
|
const queue = [];
|
|
113
|
-
const seen = new Set;
|
|
114
167
|
const full = new Map;
|
|
115
|
-
let
|
|
116
|
-
let release = [];
|
|
168
|
+
let idle = false;
|
|
117
169
|
let polling = false;
|
|
118
170
|
let draining = false;
|
|
119
171
|
let failures = 0;
|
|
120
172
|
let mismatched = false;
|
|
121
173
|
let timer;
|
|
174
|
+
let processId;
|
|
122
175
|
const identity = async (host) => {
|
|
123
|
-
const agent = await host.env("VIBEST_AGENT");
|
|
124
176
|
const sessionId = await host.env("VIBEST_SESSION_ID");
|
|
125
|
-
if (!
|
|
177
|
+
if (!sessionId)
|
|
126
178
|
return;
|
|
127
179
|
const home = await host.env("VIBEST_HOME") || `${await host.env("HOME") ?? ""}/.vibest`;
|
|
128
|
-
return {
|
|
180
|
+
return { sessionId, socket: `${home}/vibest-http.sock` };
|
|
129
181
|
};
|
|
130
182
|
const post = async (host, path, body, ms) => {
|
|
131
183
|
const who = await identity(host);
|
|
@@ -137,13 +189,13 @@ function register(on, _options) {
|
|
|
137
189
|
harnessSessionId: await host.conversation().catch(() => {
|
|
138
190
|
return;
|
|
139
191
|
}),
|
|
140
|
-
agent: who.agent,
|
|
141
192
|
harness: await host.env("VIBEST_HARNESS") || "claude",
|
|
142
193
|
cwd: await host.cwd().catch(() => {
|
|
143
194
|
return;
|
|
144
195
|
}),
|
|
145
196
|
runtime: await host.env("VIBEST_RUNTIME"),
|
|
146
|
-
pluginVersion: "0.0.1-beta.
|
|
197
|
+
pluginVersion: "0.0.1-beta.20",
|
|
198
|
+
process: processId ?? await host.env("VIBEST_PROCESS")
|
|
147
199
|
});
|
|
148
200
|
const r = await timeout(host.fetch(who.socket, path, { ...headers, "content-type": "application/json" }, JSON.stringify(body)), ms, host.after);
|
|
149
201
|
const reply = { status: r.status, body: parse(r.text) };
|
|
@@ -156,12 +208,14 @@ function register(on, _options) {
|
|
|
156
208
|
}
|
|
157
209
|
return reply;
|
|
158
210
|
};
|
|
159
|
-
const report = async (host, path, body) => {
|
|
211
|
+
const report = async (host, path, body, answered) => {
|
|
160
212
|
const attempt = async (n) => {
|
|
161
213
|
let retry = true;
|
|
162
214
|
try {
|
|
163
215
|
const r = await post(host, path, body, REPORT_TRY_MS);
|
|
164
216
|
retry = r.status >= 500;
|
|
217
|
+
if (r.status === 200)
|
|
218
|
+
answered?.(r.body);
|
|
165
219
|
} catch {}
|
|
166
220
|
const pause = REPORT_BACKOFF_MS[n];
|
|
167
221
|
if (retry && pause !== undefined)
|
|
@@ -170,42 +224,23 @@ function register(on, _options) {
|
|
|
170
224
|
await attempt(0);
|
|
171
225
|
};
|
|
172
226
|
const tick = async (host) => {
|
|
173
|
-
if (polling)
|
|
227
|
+
if (polling || !idle || draining || queue.length > 0)
|
|
174
228
|
return;
|
|
175
229
|
polling = true;
|
|
176
230
|
try {
|
|
177
|
-
|
|
178
|
-
const r = await post(host, ACK_ROUTE, { ids: unacked, release }, REPORT_TRY_MS);
|
|
179
|
-
if (r.status === 200) {
|
|
180
|
-
unacked = [];
|
|
181
|
-
release = [];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const r = await post(host, POLL_ROUTE, {}, REPORT_TRY_MS);
|
|
231
|
+
const r = await post(host, TAKE_ROUTE, {}, REPORT_TRY_MS);
|
|
185
232
|
if (r.status === 409)
|
|
186
233
|
return;
|
|
187
|
-
if (r.status !== 200
|
|
188
|
-
throw new Error(errorOf(r.body) ?? `
|
|
234
|
+
if (r.status !== 200 && r.status !== 204)
|
|
235
|
+
throw new Error(errorOf(r.body) ?? `take answered ${r.status}`);
|
|
189
236
|
if (failures >= POLL_FAILURES_SHOWN)
|
|
190
237
|
host.status(undefined);
|
|
191
238
|
failures = 0;
|
|
192
|
-
|
|
193
|
-
if (batch.ids.length === 0)
|
|
194
|
-
return;
|
|
195
|
-
const queued = (id) => queue.some((b) => b.ids.includes(id));
|
|
196
|
-
for (const id of batch.ids)
|
|
197
|
-
if (seen.has(id) && !queued(id) && !unacked.includes(id))
|
|
198
|
-
unacked.push(id);
|
|
199
|
-
const fresh = batch.ids.filter((id) => !seen.has(id));
|
|
200
|
-
if (fresh.length === 0)
|
|
239
|
+
if (r.status === 204)
|
|
201
240
|
return;
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
for (const id of batch.ids)
|
|
207
|
-
seen.add(id);
|
|
208
|
-
queue.push(batch);
|
|
241
|
+
if (!isTaken(r.body))
|
|
242
|
+
throw new Error("take answered an unknown shape");
|
|
243
|
+
queue.push(r.body);
|
|
209
244
|
host.redraw();
|
|
210
245
|
} catch {
|
|
211
246
|
failures += 1;
|
|
@@ -215,18 +250,18 @@ function register(on, _options) {
|
|
|
215
250
|
polling = false;
|
|
216
251
|
}
|
|
217
252
|
};
|
|
218
|
-
const keep = (line,
|
|
253
|
+
const keep = (line, taken) => {
|
|
219
254
|
const list = full.get(line);
|
|
220
255
|
if (list)
|
|
221
|
-
list.push(
|
|
256
|
+
list.push(taken);
|
|
222
257
|
else
|
|
223
|
-
full.set(line, [
|
|
258
|
+
full.set(line, [taken]);
|
|
224
259
|
while (full.size > FULL_MAX)
|
|
225
260
|
full.delete(full.keys().next().value);
|
|
226
261
|
};
|
|
227
|
-
const forget = (line,
|
|
262
|
+
const forget = (line, execution) => {
|
|
228
263
|
const list = full.get(line);
|
|
229
|
-
const at = list?.
|
|
264
|
+
const at = list?.findLastIndex((taken) => taken.execution === execution) ?? -1;
|
|
230
265
|
if (list && at >= 0)
|
|
231
266
|
list.splice(at, 1);
|
|
232
267
|
if (list?.length === 0)
|
|
@@ -240,9 +275,14 @@ function register(on, _options) {
|
|
|
240
275
|
const pid = await host.claudeCodePid().catch(() => {
|
|
241
276
|
return;
|
|
242
277
|
});
|
|
243
|
-
report(host, "/session/ready", pid === undefined ? {} : { pid })
|
|
278
|
+
report(host, "/session/ready", pid === undefined ? {} : { pid }, (body) => {
|
|
279
|
+
const current = member(body, "process");
|
|
280
|
+
if (isNumber(current))
|
|
281
|
+
processId = String(current);
|
|
282
|
+
});
|
|
244
283
|
}
|
|
245
|
-
|
|
284
|
+
idle = true;
|
|
285
|
+
if (timer === undefined && await identity(host)) {
|
|
246
286
|
timer = host.every(POLL_MS, () => void tick(host));
|
|
247
287
|
tick(host);
|
|
248
288
|
}
|
|
@@ -254,19 +294,23 @@ function register(on, _options) {
|
|
|
254
294
|
const host = nativeHost($);
|
|
255
295
|
draining = true;
|
|
256
296
|
queue.shift();
|
|
257
|
-
keep(batch.line, batch
|
|
297
|
+
keep(batch.line, batch);
|
|
258
298
|
await host.submit(batch.line).then((r) => {
|
|
259
299
|
draining = false;
|
|
260
300
|
if (r.drop !== undefined) {
|
|
261
|
-
forget(batch.line, batch.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
301
|
+
forget(batch.line, batch.execution);
|
|
302
|
+
report(host, hookRoute("claude", "prompt"), {
|
|
303
|
+
hook_event_name: "PromptSubmit",
|
|
304
|
+
origin: "vibest",
|
|
305
|
+
execution: batch.execution,
|
|
306
|
+
refused: true
|
|
307
|
+
});
|
|
308
|
+
}
|
|
265
309
|
if (queue.length > 0)
|
|
266
310
|
host.redraw();
|
|
267
311
|
}, () => {
|
|
268
312
|
draining = false;
|
|
269
|
-
forget(batch.line, batch.
|
|
313
|
+
forget(batch.line, batch.execution);
|
|
270
314
|
queue.unshift(batch);
|
|
271
315
|
host.redraw();
|
|
272
316
|
});
|
|
@@ -279,32 +323,41 @@ function register(on, _options) {
|
|
|
279
323
|
const who = await identity(host).catch(() => {
|
|
280
324
|
return;
|
|
281
325
|
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
326
|
+
idle = true;
|
|
327
|
+
if (who)
|
|
328
|
+
report(host, hookRoute("claude", "execution-end"), {
|
|
329
|
+
hook_event_name: "ExecutionComplete",
|
|
285
330
|
session_id: await host.conversation().catch(() => ""),
|
|
286
331
|
reason: event.reason,
|
|
287
332
|
last_assistant_message: event.answer,
|
|
288
|
-
...event.reason === "refusal"
|
|
333
|
+
...event.reason === "refusal" && { refusal: event.refusal }
|
|
289
334
|
});
|
|
290
335
|
}
|
|
291
336
|
return next(event);
|
|
292
337
|
});
|
|
293
338
|
on("prompt.submit", async ($, event, next) => {
|
|
294
339
|
const host = nativeHost($);
|
|
340
|
+
idle = false;
|
|
295
341
|
if (event.origin.kind === "plugin" && event.origin.name === host.plugin()) {
|
|
296
342
|
const list = full.get(event.text);
|
|
297
|
-
const
|
|
343
|
+
const taken = list?.shift();
|
|
298
344
|
if (list?.length === 0)
|
|
299
345
|
full.delete(event.text);
|
|
300
|
-
if (
|
|
346
|
+
if (taken === undefined)
|
|
347
|
+
return next(event);
|
|
348
|
+
await report(host, hookRoute("claude", "prompt"), {
|
|
349
|
+
hook_event_name: "PromptSubmit",
|
|
350
|
+
origin: "vibest",
|
|
351
|
+
execution: taken.execution
|
|
352
|
+
});
|
|
353
|
+
if (event.text.trimEnd().endsWith(taken.text.trim()))
|
|
301
354
|
return next(event);
|
|
302
|
-
return next({ ...event, context: [...event.context ?? [], text] });
|
|
355
|
+
return next({ ...event, context: [...event.context ?? [], taken.text] });
|
|
303
356
|
}
|
|
304
357
|
const who = await identity(host).catch(() => {
|
|
305
358
|
return;
|
|
306
359
|
});
|
|
307
|
-
if (who
|
|
360
|
+
if (who)
|
|
308
361
|
await report(host, hookRoute("claude", "prompt"), {
|
|
309
362
|
hook_event_name: "PromptSubmit",
|
|
310
363
|
text: event.text,
|
|
@@ -314,15 +367,15 @@ function register(on, _options) {
|
|
|
314
367
|
});
|
|
315
368
|
on("tool.call", async ($, event, next) => {
|
|
316
369
|
const host = nativeHost($);
|
|
317
|
-
if (!await host.env("
|
|
370
|
+
if (!await host.env("VIBEST_SESSION_ID"))
|
|
318
371
|
return next(event);
|
|
319
372
|
const body = { tool_name: event.tool, tool_input: toolInput(event), cwd: await host.cwd() };
|
|
320
373
|
for (let n = 0;; n++) {
|
|
321
374
|
try {
|
|
322
375
|
const r = await post(host, hookRoute("claude", "guard"), body, GUARD_TRY_MS);
|
|
323
376
|
if (r.status === 200) {
|
|
324
|
-
const deny = r.body
|
|
325
|
-
return
|
|
377
|
+
const deny = member(r.body, "deny");
|
|
378
|
+
return isString(deny) ? { deny } : next(event);
|
|
326
379
|
}
|
|
327
380
|
if (r.status < 500)
|
|
328
381
|
return { deny: `vibest refused the tool call: ${errorOf(r.body) ?? `status ${r.status}`}` };
|
|
@@ -334,7 +387,7 @@ function register(on, _options) {
|
|
|
334
387
|
}
|
|
335
388
|
}).catch(async ($, event, next) => {
|
|
336
389
|
try {
|
|
337
|
-
if (!await nativeHost($).env("
|
|
390
|
+
if (!await nativeHost($).env("VIBEST_SESSION_ID"))
|
|
338
391
|
return;
|
|
339
392
|
} catch {
|
|
340
393
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: delegate
|
|
3
|
-
description: Hand work to subagents with `vibest run` and keep talking with the user while they work.
|
|
3
|
+
description: Hand work to subagents with `vibest run` and keep talking with the user while they work. Use for any request to change, fix, build, investigate, research, test or verify code ("fix this bug", "add X", "look into why Y", "do these three things", "have an agent check it"), and whenever a task splits into independent parts that can run at the same time.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Delegate
|
|
7
7
|
|
|
8
|
-
You direct subagents. You stay with the user.
|
|
8
|
+
You direct subagents. You stay with the user. An agent messages you when it finishes, asks or is blocked; vibest notifies you only of what the agent cannot say; an idle agent sends nothing. Do not poll, sleep, or loop on `vibest result`.
|
|
9
9
|
|
|
10
10
|
## Dispatch
|
|
11
11
|
|
|
@@ -18,49 +18,49 @@ vibest run [<harness>] --title '<Title>' -- '<self-contained task>'
|
|
|
18
18
|
Its id is <id>.
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
vibest run [<harness>] --title '<Title>' --archive-on-
|
|
21
|
+
vibest run [<harness>] --title '<Title>' --archive-on-idle -- '<task>'
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
`--archive-on-
|
|
24
|
+
`--archive-on-idle` is only for work whose message you will not answer. It archives the first time the session is idle after a completed execution with nothing it sent or was sent still waiting. The branch is kept. Do not `vibest send` it after that. Any execution that ends normally archives it, a question included, so do not use it for a session that may need an answer. A failed execution has not archived it: send the correction to the id it printed; the flag still archives the completed execution that follows. A reviewer that gets later executions is the pipeline skill and must stay open, without this flag.
|
|
25
25
|
|
|
26
26
|
- Leave `<harness>` out to use your own harness, provider and model; name one (`pi`, `claude`, `cursor`, or any harness a plugin adds; `vibest harness list`) to switch.
|
|
27
27
|
- Always pass `--title`: three to six words, verb first, first letter capitalised, no kebab-case, saying what is done rather than how ("Fix login redirect loop"). The user's language is fine.
|
|
28
28
|
- Each session gets its own new worktree.
|
|
29
29
|
- Several `vibest run` commands in one message start in parallel.
|
|
30
|
-
- A subagent cannot see this conversation. Say what to achieve, where (paths, lines), what done means, and how to verify it. For code: run the tests and typecheck, commit, and
|
|
31
|
-
- Long material: write it with your file tool to `$VIBEST_PROJECT_DIR/artifacts/<name>.md` (a new file name if that one exists) and
|
|
30
|
+
- A subagent cannot see this conversation. Say what to achieve, where (paths, lines), what done means, and how to verify it. For code: run the tests and typecheck, commit, and send the branch and hash.
|
|
31
|
+
- Long material: write it with your file tool to `$VIBEST_PROJECT_DIR/artifacts/<name>.md` (a new file name if that one exists) and attach it with `--file <absolute path>` (repeat the flag for each file): vibest copies each file for the session and ends its task with a line naming the copies, which the agent reads itself. Keep the prompt short; the material goes in the file. The absolute path is the value of VIBEST_PROJECT_DIR (`echo $VIBEST_PROJECT_DIR`, or `directory` from `vibest project info`) plus `/artifacts/` and the file name.
|
|
32
32
|
- If the user approved a specific action, quote their exact words.
|
|
33
33
|
|
|
34
34
|
## After you start
|
|
35
35
|
|
|
36
|
-
Tell the user in one or two lines what is running, then end your
|
|
36
|
+
Tell the user in one or two lines what is running, then end your execution. Never guess a result. Answer other questions meanwhile. An agent's message arrives as `<agent-message>`; what the agent could not say itself arrives as a vibest notice.
|
|
37
37
|
|
|
38
|
-
## Check
|
|
38
|
+
## Check a message
|
|
39
39
|
|
|
40
|
-
An `<agent-
|
|
40
|
+
An `<agent-message>` is a claim: whether the work succeeded is in its text. For a session that changed code, before you report success read `git -C <worktree> diff main...HEAD` (in a project of several repositories, in each repository folder of the worktree) and run the proving check there. For research, judge the report text.
|
|
41
41
|
|
|
42
|
-
- The
|
|
43
|
-
-
|
|
44
|
-
- A
|
|
42
|
+
- The message asks a question → `vibest send <id> -- '<the answer>'`, or ask the user. If it is waiting for the user's approval of an action, do not send the approval back: start a fresh agent with the approved action, quoting the user's words.
|
|
43
|
+
- A notice that an execution ended with an error, a message that reports a failure, or your check fails → `vibest send <id> -- '<the failure and what to fix>'`. It keeps its context. If a second correction fails, start a new `vibest run` or tell the user.
|
|
44
|
+
- A notice that says the execution ended without its execution-end hook, the harness exited, or the execution did not start (`task_not_started`) carries no screen text. When you need to see why, run `vibest peek <id>` (`--lines N`, default 30): it prints the session's terminal as it is now. Read it before you decide to resend, correct, or tell the user.
|
|
45
45
|
|
|
46
46
|
Then say what changed, the evidence, and the branch. `<id>` is the id the run printed, for either kind of run.
|
|
47
47
|
|
|
48
48
|
## Track
|
|
49
49
|
|
|
50
|
-
`vibest ls` prints `{ sessions, machines }`: the sessions that have not exited (task cut to 500 characters, live status, latest
|
|
50
|
+
`vibest ls` prints `{ sessions, machines }`: the sessions that have not exited (task cut to 500 characters, live status, latest execution), and the other machines with their connection state. `vibest ls --all` includes exited sessions. `vibest ls` is the state and `vibest result <id>` is the agent's last reply, with the task uncut; an idle agent may have finished without a word. Use these after a restart, after compaction, or when you are unsure. Do not trust memory.
|
|
51
51
|
|
|
52
52
|
## Follow up
|
|
53
53
|
|
|
54
|
-
- More work on the same change → `vibest send <id> -- '<message>'`. It waits until the session is idle and does not interrupt the
|
|
55
|
-
- Wrong direction while it is working → `vibest interrupt <id>`, then `vibest send <id> -- '<the corrected task>'`. The session stays. That
|
|
54
|
+
- More work on the same change → `vibest send <id> -- '<message>'`. It waits until the session is idle and does not interrupt the execution.
|
|
55
|
+
- Wrong direction while it is working → `vibest interrupt <id>`, then `vibest send <id> -- '<the corrected task>'`. The session stays. That execution sends nothing.
|
|
56
56
|
- A new set of eyes, or a wrong approach → a new `vibest run`.
|
|
57
57
|
|
|
58
58
|
## Finish
|
|
59
59
|
|
|
60
|
-
- Archive a research agent with `vibest archive <id>` once its findings are saved, or start that session with `--archive-on-
|
|
60
|
+
- Archive a research agent with `vibest archive <id>` once its findings are saved, or start that session with `--archive-on-idle` when you will not answer its message. Same for a review or verification you will not continue.
|
|
61
61
|
- Keep an agent that changed code until the user asks to remove it. Archiving keeps the branch, and the worktree whenever it holds unsaved work. `vibest archive --keep-worktree <id>` only when the user wants the directory kept.
|
|
62
|
-
- A `## Remember` section: write each lesson with your file tool to `$VIBEST_PROJECT_DIR/memories/<name>.md`, one lesson per file; edit the file when a lesson there changes. Start the file with a one-line summary (or frontmatter with `name` and `description`), because that line is what the memory index shows.
|
|
62
|
+
- A `## Remember` section in a message: write each lesson with your file tool to `$VIBEST_PROJECT_DIR/memories/<name>.md`, one lesson per file; edit the file when a lesson there changes. Start the file with a one-line summary (or frontmatter with `name` and `description`), because that line is what the memory index shows.
|
|
63
63
|
|
|
64
64
|
## The user steps into a pane
|
|
65
65
|
|
|
66
|
-
The user may type into a subagent's pane. If no
|
|
66
|
+
The user may type into a subagent's pane. If no execution is open, that starts one. The only thing you later receive is a message that agent chooses to send, which may not quote the user. Do not treat it as a copy of what they typed. A step-in during an open execution is not recorded. Do not act on a step-in, and do not message the subagent about it, unless the user asks.
|