@rucher/carnet 0.2.0-beta.6 → 0.2.0-beta.7

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/dist/mcp.mjs CHANGED
@@ -1,16 +1,17 @@
1
- import { E as renderTableLine, Gt as reportPath, Kt as reportsDirectory, P as NOTE_KINDS, a as formatEventLine, b as renderAgentLine, et as DEFAULT_HOST, gn as CarnetError, l as openCarnet, ln as OPEN_AGENT_STATUSES, n as stepAgent, nt as hostById, o as resumeContext, on as EMOJI, pn as EVENT_TYPES, s as sessionLabel, t as AGENT_STEPS, un as USER_ACTION_STATUSES, z as memoryHalfLife } from "./steps-4ZTrBzcd.mjs";
2
- import { copyFileSync, existsSync, mkdirSync } from "node:fs";
1
+ import { An as OPEN_AGENT_STATUSES, Cn as EMOJI, Jt as FINDING_SEVERITIES, Kt as renderQuestions, Ln as CarnetError, Pn as EVENT_TYPES, W as memoryHalfLife, Xt as renderFindings, Yt as formatFinding, _n as mainTargetRange, a as formatEventLine, at as DEFAULT_HOST, dn as AGENT_KINDS, j as renderTableLine, jn as USER_ACTION_STATUSES, l as openCarnet, n as stepAgent, nn as reportsDirectory, o as resumeContext, pn as FINAL_ACTIONS, qt as FINDING_DECISIONS, s as sessionLabel, st as hostById, t as AGENT_STEPS, tn as reportPath, vn as statusAfterAnswers, w as renderAgentLine, z as NOTE_KINDS } from "./steps-Bd8FlgLs.mjs";
2
+ import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
4
  import { McpServer } from "@modelcontextprotocol/server";
5
5
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
6
6
  import * as z from "zod/v4";
7
7
  // src/mcp/instructions.ts
8
- const INSTRUCTIONS = `Carnet holds the forks, the "On the table" line, sessions, the journal and the workspace memory that the \`rucher\` CLI renders. The session is resolved automatically; pass \`session\` only to target another one. The workflow rules are in the system prompt and the rucher skill: load the skill before dispatching, applying or reviewing forks.
8
+ const INSTRUCTIONS = `Carnet holds the forks, the Main line, sessions, the journal and the workspace memory that the \`rucher\` CLI renders. The session is resolved automatically; pass \`session\` only to target another one. The workflow rules are in the system prompt and the rucher skill: load the skill before launching agents or handling their results.
9
9
 
10
10
  Which tool, when:
11
- - Dispatch: agent_start, then launch the fork in a later message.
11
+ - Launch: agent_start with the agent's kind (research, analyze, implement, review), then launch it in a later message.
12
12
  - Each step of a fork's work: agent_step (answered, applying, applied, tested, committed, dropped).
13
- - Main agent working on something else: table_set, table_clear.
13
+ - Final actions, only when the human asks: agent_inject (research), agent_questions then agent_answer then agent_promote (analyze), review_findings then review_decide (review). review_context before launching a review.
14
+ - Main line text for work of your own: table_set, table_clear.
14
15
  - Other moves: agent_update, agent_drop, queue_reorder. Recall: agent_list, log_read, session_resume_info, session_list.
15
16
  - Memory: note_list before an approach, note_add and note_drop at the end of a step (main agent), note_cite when a note changed what you did.
16
17
  - Session: session_new when the human names it, session_drop only when asked.
@@ -42,6 +43,188 @@ function createSessionResolver({ carnet, env = process.env, ppid = process.ppid,
42
43
  return id;
43
44
  } };
44
45
  }
46
+ // src/report.ts
47
+ const HEADING = /^##\s+(.+?)\s*$/;
48
+ function normalize(text) {
49
+ return text.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "");
50
+ }
51
+ function hasSection(markdown, names) {
52
+ return extractSection(markdown, names) !== void 0;
53
+ }
54
+ function extractSection(markdown, names) {
55
+ const wanted = names.map(normalize);
56
+ const lines = markdown.split("\n");
57
+ const start = lines.findIndex((line) => {
58
+ const heading = HEADING.exec(line)?.[1];
59
+ return heading !== void 0 && wanted.some((name) => normalize(heading).includes(name));
60
+ });
61
+ if (start === -1) return void 0;
62
+ const rest = lines.slice(start + 1);
63
+ const end = rest.findIndex((line) => HEADING.test(line));
64
+ return (end === -1 ? rest : rest.slice(0, end)).join("\n").trim();
65
+ }
66
+ function readReport(path) {
67
+ return path && existsSync(path) ? readFileSync(path, "utf8") : void 0;
68
+ }
69
+ function appendToReport(path, markdown) {
70
+ const current = readReport(path);
71
+ if (current === void 0 || !path) return;
72
+ const separator = current.endsWith("\n\n") ? "" : current.endsWith("\n") ? "\n" : "\n\n";
73
+ appendFileSync(path, `${separator}${markdown.trimEnd()}\n`);
74
+ }
75
+ function planPath(report) {
76
+ return report.replace(/(\.md)?$/, ".plan.md");
77
+ }
78
+ // src/kinds.ts
79
+ function finalAction(agent) {
80
+ return FINAL_ACTIONS[agent.kind];
81
+ }
82
+ function finishWithItems(carnet, session, name, input) {
83
+ const agent = requireAgent(carnet, session, name);
84
+ if (input.findings?.length && agent.kind !== "review") throw new CarnetError("INVALID_KIND", `Only a review agent reports findings; ${name} is ${agent.kind}`);
85
+ const report = readReport(input.reportPath);
86
+ if (input.questions?.length) {
87
+ const open = carnet.questions.add(session, name, input.questions).filter((question) => question.answer === null);
88
+ if (report !== void 0 && !hasSection(report, ["questions"])) appendToReport(input.reportPath, renderQuestions(open));
89
+ }
90
+ if (input.findings?.length) {
91
+ const findings = carnet.findings.replace(session, name, input.findings);
92
+ if (report !== void 0 && !hasSection(report, ["findings"])) appendToReport(input.reportPath, renderFindings(findings));
93
+ }
94
+ const openQuestions = carnet.questions.list(session, name, true).length;
95
+ return carnet.agents.finish(session, name, {
96
+ reportPath: input.reportPath,
97
+ hasQuestions: openQuestions > 0 || input.hasQuestions === true
98
+ });
99
+ }
100
+ function requireAgent(carnet, session, name) {
101
+ const agent = carnet.agents.get(session, name);
102
+ if (!agent) throw new CarnetError("AGENT_NOT_FOUND", `No agent "${name}" in this session`);
103
+ return agent;
104
+ }
105
+ function formatQuestion(question) {
106
+ const lines = [`${question.n}/${question.total} ${question.text}`];
107
+ if (question.context) lines.push(` context: ${question.context}`);
108
+ lines.push(` recommended: ${question.recommendation}`);
109
+ if (question.alternatives.length) lines.push(` alternatives: ${question.alternatives.join(" | ")}`);
110
+ return lines.join("\n");
111
+ }
112
+ function openQuestionsText(carnet, session, name) {
113
+ requireAgent(carnet, session, name);
114
+ const open = carnet.questions.list(session, name, true);
115
+ if (!open.length) return `${name}: no open questions`;
116
+ const total = open[0]?.total ?? open.length;
117
+ return [`${name}: ${open.length} of ${total} open`, ...open.map(formatQuestion)].join("\n");
118
+ }
119
+ function today(carnet) {
120
+ return carnet.now().toISOString().slice(0, 10);
121
+ }
122
+ function answerQuestionsText(carnet, session, name, answers) {
123
+ const agent = requireAgent(carnet, session, name);
124
+ const questions = carnet.questions.answer(session, name, answers);
125
+ const lines = [...answers].sort((a, b) => a.n - b.n).map((answer) => `${answer.n}. ${answer.answer.trim()}`);
126
+ appendToReport(agent.reportPath, `## Answers (${today(carnet)})\n\n${lines.join("\n")}`);
127
+ const open = questions.filter((question) => question.answer === null).length;
128
+ if (open) return `answered ${answers.length} · ${open} of ${questions.length} open`;
129
+ const next = statusAfterAnswers(agent.kind);
130
+ const note = agent.kind === "analyze" ? "plan to validate" : void 0;
131
+ carnet.events.log(session, {
132
+ type: "answered",
133
+ agent: name,
134
+ note
135
+ });
136
+ carnet.agents.update(session, name, {
137
+ status: next,
138
+ note
139
+ });
140
+ const detail = note ? `, ${note}` : "";
141
+ return `all ${questions.length} answered · ${EMOJI[next]} ${name} ${next}${detail}`;
142
+ }
143
+ const FOR_MAIN = ["for the main", "pour le main"];
144
+ const PLAN = ["plan"];
145
+ function injectReport(carnet, session, name, input) {
146
+ const agent = requireAgent(carnet, session, name);
147
+ const report = readReport(agent.reportPath);
148
+ if (report === void 0) throw new CarnetError("REPORT_MISSING", `${name} has no report to inject yet`);
149
+ const names = input.section ? [input.section] : agent.kind === "analyze" || agent.promotedFrom === "analyze" ? PLAN : FOR_MAIN;
150
+ const text = input.full ? report.trim() : extractSection(report, names);
151
+ if (text === void 0) throw new CarnetError("SECTION_NOT_FOUND", `No "## ${names[0]}" section in ${name}'s report; pass section or full`);
152
+ const lineCount = text.split("\n").length;
153
+ const note = `${input.full ? "full report" : names[0]}, ${lineCount} lines`;
154
+ if (agent.kind === "research" && agent.status !== "closed") carnet.agents.close(session, name, {
155
+ type: "injected",
156
+ note,
157
+ link: agent.reportPath ?? void 0
158
+ });
159
+ else carnet.events.log(session, {
160
+ type: "injected",
161
+ agent: name,
162
+ note
163
+ });
164
+ return `${name} injected (${lineCount} lines)\n${text}`;
165
+ }
166
+ function promoteText(carnet, session, name, input) {
167
+ const current = requireAgent(carnet, session, name);
168
+ const agent = carnet.agents.promote(session, name, input);
169
+ const lines = [`${EMOJI.running} ${name} promoted to implement`];
170
+ if (current.reportPath && existsSync(current.reportPath)) {
171
+ const plan = planPath(current.reportPath);
172
+ copyFileSync(current.reportPath, plan);
173
+ lines.push(`plan kept: ${plan}`);
174
+ }
175
+ if (agent.worktree) lines.push(`worktree: ${agent.worktree}`);
176
+ if (agent.baseCommit) lines.push(`base: ${agent.baseCommit}`);
177
+ return lines.join("\n");
178
+ }
179
+ function reviewContext(carnet, session, target) {
180
+ const range = mainTargetRange(target);
181
+ if (range !== void 0) return range ? `target main, commits ${range}` : "target main, the uncommitted changes of the main repo";
182
+ const agent = requireAgent(carnet, session, target);
183
+ if (agent.kind !== "implement") throw new CarnetError("INVALID_TARGET", `${target} is ${agent.kind}, not implement`);
184
+ const lines = [`target ${target} (implement${agent.promotedFrom ? `, promoted from ${agent.promotedFrom}` : ""}, ${agent.status})`];
185
+ if (agent.task) lines.push(`task: ${agent.task}`);
186
+ if (agent.reportPath) lines.push(`report: ${agent.reportPath}`);
187
+ if (agent.worktree) lines.push(`worktree: ${agent.worktree}`);
188
+ if (agent.baseCommit) lines.push(`base: ${agent.baseCommit}`);
189
+ if (agent.reportPath && existsSync(planPath(agent.reportPath))) lines.push(`plan: ${planPath(agent.reportPath)}`);
190
+ const answered = carnet.questions.list(session, target).filter((question) => question.answer);
191
+ if (answered.length) {
192
+ lines.push("answers:");
193
+ for (const question of answered) lines.push(` ${question.n}. ${question.text} → ${question.answer}`);
194
+ }
195
+ return lines.join("\n");
196
+ }
197
+ function findingsText(carnet, session, name, pendingOnly) {
198
+ const agent = requireAgent(carnet, session, name);
199
+ const findings = carnet.findings.list(session, name, pendingOnly);
200
+ const all = carnet.findings.list(session, name);
201
+ if (!findings.length) return `${name}: ${all.length ? "no pending findings" : "no findings"}`;
202
+ const pending = all.filter((finding) => finding.decision === null).length;
203
+ const target = agent.target ? ` · target ${agent.target}` : "";
204
+ return [`${name}: ${pending} of ${all.length} pending${target}`, ...findings.map((finding) => {
205
+ const decided = finding.decision ? ` → ${finding.decision}` : "";
206
+ return `${formatFinding(finding)}${decided}`;
207
+ })].join("\n");
208
+ }
209
+ function decideText(carnet, session, name, decisions) {
210
+ const agent = requireAgent(carnet, session, name);
211
+ if (agent.kind !== "review") throw new CarnetError("INVALID_KIND", `${name} is ${agent.kind}, not review`);
212
+ if (decisions.some((item) => item.decision === "sent") && agent.target && mainTargetRange(agent.target) !== void 0) throw new CarnetError("INVALID_TARGET", `${name} reviews main: there is no agent to send findings to; fix or ignore them`);
213
+ const findings = carnet.findings.decide(session, name, decisions);
214
+ const pending = findings.filter((finding) => finding.decision === null).length;
215
+ if (pending) return `decided ${decisions.length} · ${pending} of ${findings.length} pending`;
216
+ const count = (decision) => findings.filter((finding) => finding.decision === decision).length;
217
+ const note = `${count("sent")} sent, ${count("fixed")} fixed, ${count("ignored")} ignored`;
218
+ carnet.agents.close(session, name, {
219
+ type: "triaged",
220
+ note,
221
+ link: agent.reportPath ?? void 0
222
+ });
223
+ const lines = [`${name} triaged: ${note}, closed`];
224
+ const sent = findings.filter((finding) => finding.decision === "sent");
225
+ if (sent.length && agent.target) lines.push(`send to ${agent.target}:`, ...sent.map(formatFinding));
226
+ return lines.join("\n");
227
+ }
45
228
  // src/mcp/tools.ts
46
229
  function defineTool(definition) {
47
230
  return definition;
@@ -54,6 +237,8 @@ const agentStart = defineTool({
54
237
  schema: z.object({
55
238
  name: agentName,
56
239
  task: z.string().min(1).describe("One-line task given to the fork"),
240
+ kind: z.enum(AGENT_KINDS).optional().describe("Agent type, always pass it: research (reads, reports for the main), analyze (plan and questions), implement (writes code), review (reads a diff, reports findings)"),
241
+ target: z.string().optional().describe("Review only, required there: the implement agent it reviews, or main[:<range>]"),
57
242
  base_commit: z.string().optional().describe("Commit the fork starts from"),
58
243
  worktree: z.string().optional().describe("Worktree path when the fork has one"),
59
244
  session
@@ -63,6 +248,8 @@ const agentStart = defineTool({
63
248
  const agent = carnet.agents.start(sessionId, {
64
249
  name: args.name,
65
250
  task: args.task,
251
+ kind: args.kind,
252
+ target: args.target,
66
253
  baseCommit: args.base_commit,
67
254
  worktree: args.worktree
68
255
  });
@@ -89,7 +276,9 @@ const agentUpdate = defineTool({
89
276
  });
90
277
  return { text: renderAgentLine({
91
278
  name: agent.name,
279
+ kind: agent.kind,
92
280
  status: agent.status,
281
+ action: null,
93
282
  emoji: agent.status === "closed" ? "" : EMOJI[agent.status],
94
283
  note: agent.note
95
284
  }) };
@@ -103,21 +292,46 @@ function copyReport(carnet, name, reportFile) {
103
292
  copyFileSync(reportFile, destination);
104
293
  return destination;
105
294
  }
295
+ const questionInput = z.object({
296
+ text: z.string().min(1),
297
+ context: z.string().optional().describe("One short line"),
298
+ recommendation: z.string().min(1),
299
+ alternatives: z.array(z.string().min(1)).max(3).optional().describe(`At most 3; list more in the text`)
300
+ });
301
+ const findingInput = z.object({
302
+ severity: z.enum(FINDING_SEVERITIES),
303
+ location: z.string().optional().describe("file:line"),
304
+ text: z.string().min(1),
305
+ fix: z.string().optional().describe("Proposed fix, short")
306
+ });
307
+ const DONE_WORDS = {
308
+ answer: "needs answers",
309
+ review: "ready for review",
310
+ apply: "ready to apply"
311
+ };
312
+ function doneOutcome(name, status) {
313
+ if (status === "closed") return `${name} closed`;
314
+ return `${EMOJI[status]} ${name} ${DONE_WORDS[status] ?? status}`;
315
+ }
106
316
  const agentDone = defineTool({
107
317
  name: "agent_done",
108
- description: "Forks call this as their LAST tool action, then reply with one line that carries no results. Copies the report to the workspace report destination and marks the agent ❓ answer (has_questions) or 👀 review once the fork stops.",
318
+ description: "Forks call this as their LAST tool action, then reply with one line that carries no results. Copies the report to the workspace report destination. Pass questions (and findings for a review) here only, never in the report: Carnet writes them into it. The agent then waits on ❓ answer when questions are open, else 📥 apply (implement) or 👀 review.",
109
319
  schema: z.object({
110
320
  name: agentName,
111
321
  report_path: z.string().min(1).describe("Absolute path of the markdown report"),
112
- has_questions: z.boolean().describe("true when the report asks the human something"),
322
+ questions: z.array(questionInput).optional().describe("Choices left to the human, each with a recommendation"),
323
+ findings: z.array(findingInput).optional().describe("Review agents only"),
324
+ has_questions: z.boolean().optional().describe("Only when the report asks something outside questions"),
113
325
  session
114
326
  }),
115
327
  run: (carnet, sessionId, args) => {
116
- const agent = carnet.agents.finish(sessionId, args.name, {
328
+ const agent = finishWithItems(carnet, sessionId, args.name, {
117
329
  reportPath: copyReport(carnet, args.name, args.report_path),
330
+ questions: args.questions,
331
+ findings: args.findings,
118
332
  hasQuestions: args.has_questions
119
333
  });
120
- const outcome = args.has_questions ? `${EMOJI.answer} ${agent.name} needs answers` : `${EMOJI.review} ${agent.name} ready for review`;
334
+ const outcome = doneOutcome(agent.name, agent.pendingStatus ?? agent.status);
121
335
  return { text: agent.status === "running" ? `${outcome} once you stop; reply now with one line that carries no results` : outcome };
122
336
  }
123
337
  });
@@ -135,18 +349,106 @@ const agentDrop = defineTool({
135
349
  });
136
350
  const agentList = defineTool({
137
351
  name: "agent_list",
138
- description: "List the open agents of the session with status, note, task and report path.",
139
- schema: z.object({ session }),
140
- run: (carnet, sessionId) => {
141
- const lines = carnet.agents.list(sessionId).map((agent) => {
352
+ description: "List the open agents of the session: kind, status, final action, note, task and report path.",
353
+ schema: z.object({
354
+ kind: z.enum(AGENT_KINDS).optional().describe("Only agents of this kind"),
355
+ session
356
+ }),
357
+ run: (carnet, sessionId, args) => {
358
+ const lines = carnet.agents.list(sessionId).filter((agent) => !args.kind || agent.kind === args.kind).map((agent) => {
142
359
  const emoji = agent.status === "closed" ? "" : EMOJI[agent.status];
360
+ const action = agent.status === "running" ? "" : ` → ${finalAction(agent)}`;
361
+ const target = agent.target ? ` on ${agent.target}` : "";
143
362
  const note = agent.note ? ` — ${agent.note}` : "";
144
363
  const report = agent.reportPath ? ` (report: ${agent.reportPath})` : "";
145
- return `${emoji} ${agent.name} [${agent.status}]${note}${report}`;
364
+ return `${emoji} ${agent.name} ${agent.kind}${target} [${agent.status}]${action}${note}${report}`;
146
365
  });
147
366
  return { text: lines.length ? lines.join("\n") : "no open agents" };
148
367
  }
149
368
  });
369
+ const agentQuestions = defineTool({
370
+ name: "agent_questions",
371
+ description: "Main agent only. An agent's open questions, numbered n/total, each with its recommendation and alternatives. Ask them one at a time unless the human wants them as text.",
372
+ schema: z.object({
373
+ name: agentName,
374
+ session
375
+ }),
376
+ run: (carnet, sessionId, args) => ({ text: openQuestionsText(carnet, sessionId, args.name) })
377
+ });
378
+ const agentAnswer = defineTool({
379
+ name: "agent_answer",
380
+ description: "Main agent only. Record the human's answers, one or several at once. Appends them to the report. With the last answer, logs answered and moves the agent on: an analyze to 👀 review (plan to validate), an implement to 📥 apply.",
381
+ schema: z.object({
382
+ name: agentName,
383
+ answers: z.array(z.object({
384
+ n: z.number().int().min(1),
385
+ answer: z.string().min(1)
386
+ })).min(1),
387
+ session
388
+ }),
389
+ run: (carnet, sessionId, args) => ({ text: answerQuestionsText(carnet, sessionId, args.name, args.answers) })
390
+ });
391
+ const agentInject = defineTool({
392
+ name: "agent_inject",
393
+ description: "Main agent only, when the human asks. Returns a report section for your context: 'For the main' by default, the plan for an analyze or promoted agent. Logs injected; closes a research agent. Works on closed agents.",
394
+ schema: z.object({
395
+ name: agentName,
396
+ section: z.string().optional().describe("Heading to extract instead of the default"),
397
+ full: z.boolean().optional().describe("The whole report, only when the human asks"),
398
+ session
399
+ }),
400
+ run: (carnet, sessionId, args) => ({ text: injectReport(carnet, sessionId, args.name, {
401
+ section: args.section,
402
+ full: args.full
403
+ }) })
404
+ });
405
+ const agentPromote = defineTool({
406
+ name: "agent_promote",
407
+ description: "Main agent only, when the human validates a plan. Turns an analyze agent into implement (same agent, running) and keeps its plan next to the report. Create the worktree first and pass it, then resume the fork with the answers.",
408
+ schema: z.object({
409
+ name: agentName,
410
+ worktree: z.string().optional().describe("Worktree created for the implementation"),
411
+ base_commit: z.string().optional().describe("Commit the worktree starts from"),
412
+ session
413
+ }),
414
+ run: (carnet, sessionId, args) => ({ text: promoteText(carnet, sessionId, args.name, {
415
+ worktree: args.worktree,
416
+ baseCommit: args.base_commit
417
+ }) })
418
+ });
419
+ const reviewContextTool = defineTool({
420
+ name: "review_context",
421
+ description: "Main agent only, before launching a review. What the reviewer needs about its target: task, report, worktree, base, plan and answers, or the main repo range.",
422
+ schema: z.object({
423
+ target: z.string().min(1).describe("Implement agent name, or main[:<range>]"),
424
+ session
425
+ }),
426
+ run: (carnet, sessionId, args) => ({ text: reviewContext(carnet, sessionId, args.target) })
427
+ });
428
+ const reviewFindings = defineTool({
429
+ name: "review_findings",
430
+ description: "Main agent only. A review's findings, blocking first, numbered n/total. Pending ones only by default.",
431
+ schema: z.object({
432
+ name: agentName,
433
+ all: z.boolean().optional().describe("Also the findings already decided"),
434
+ session
435
+ }),
436
+ run: (carnet, sessionId, args) => ({ text: findingsText(carnet, sessionId, args.name, args.all !== true) })
437
+ });
438
+ const reviewDecide = defineTool({
439
+ name: "review_decide",
440
+ description: "Main agent only. Record the human's decision on findings, one or several at once: sent (back to the implement agent), fixed (in main), ignored (reason required). With the last one, logs triaged, closes the review and lists the findings to send to the target.",
441
+ schema: z.object({
442
+ name: agentName,
443
+ decisions: z.array(z.object({
444
+ n: z.number().int().min(1),
445
+ decision: z.enum(FINDING_DECISIONS),
446
+ reason: z.string().optional()
447
+ })).min(1),
448
+ session
449
+ }),
450
+ run: (carnet, sessionId, args) => ({ text: decideText(carnet, sessionId, args.name, args.decisions) })
451
+ });
150
452
  const queueReorder = defineTool({
151
453
  name: "queue_reorder",
152
454
  description: "Main agent only. Set the order of the 'Waiting on you' list. Named agents come first in the given order, the others follow the default order (answer, review, rest).",
@@ -162,17 +464,15 @@ const queueReorder = defineTool({
162
464
  });
163
465
  const tableSet = defineTool({
164
466
  name: "table_set",
165
- description: "Main agent only. Set the 'On the table' line: what the main agent is handling now. main_working=true while you work yourself (⚙️); otherwise the status of the next human action.",
467
+ description: "Main agent only. Set the Main line: what the main agent is handling, and the next human action once its turn ends. The hooks show ⚙️ while the main agent works, whatever this line says.",
166
468
  schema: z.object({
167
469
  text: z.string().min(1).describe("Under 60 characters, no paths, no backticks"),
168
- main_working: z.boolean().optional().describe("Omitted: false when a status is given, else unchanged"),
169
- status: z.enum(USER_ACTION_STATUSES).optional().describe("Next human action when main_working is false; defaults to discussing"),
470
+ status: z.enum(USER_ACTION_STATUSES).optional().describe("Next human action once the turn ends; defaults to discussing"),
170
471
  session
171
472
  }),
172
473
  run: (carnet, sessionId, args) => {
173
474
  const item = carnet.table.set(sessionId, {
174
475
  text: args.text,
175
- mainWorking: args.main_working,
176
476
  status: args.status
177
477
  });
178
478
  return { text: renderTableLine(item) };
@@ -180,7 +480,7 @@ const tableSet = defineTool({
180
480
  });
181
481
  const agentStep = defineTool({
182
482
  name: "agent_step",
183
- description: "Main agent only. One call per step of a fork's work: logs the event, moves the agent to the next human action and keeps the 'On the table' line in sync. answered → apply, applying → ⚙️ table line, applied → test, tested → commit, committed (commit required) → closed, dropped (note = reason) → closed.",
483
+ description: "Main agent only. One call per step of a fork's work: logs the event, moves the agent to the next human action and keeps the Main line in sync; the note replaces the agent's note. answered → apply (implement) or review, applying → Main line (implement only), applied → test, tested → commit, committed (commit required) → closed, dropped (note = reason) → closed.",
184
484
  schema: z.object({
185
485
  name: agentName,
186
486
  step: z.enum(AGENT_STEPS),
@@ -193,11 +493,11 @@ const agentStep = defineTool({
193
493
  });
194
494
  const tableClear = defineTool({
195
495
  name: "table_clear",
196
- description: "Main agent only. Empty the 'On the table' line.",
496
+ description: "Main agent only. Empty the Main line.",
197
497
  schema: z.object({ session }),
198
498
  run: (carnet, sessionId) => {
199
499
  carnet.table.clear(sessionId);
200
- return { text: "On the table cleared" };
500
+ return { text: "Main line cleared" };
201
501
  }
202
502
  });
203
503
  const logEvent = defineTool({
@@ -281,7 +581,7 @@ const sessionResumeInfo = defineTool({
281
581
  }),
282
582
  run: (carnet, sessionId, args) => {
283
583
  const target = args.name ? carnet.sessions.find(args.name) : carnet.sessions.require(sessionId);
284
- const resume = `rucher resume ${target.name ?? target.id}`;
584
+ const resume = `rucher resume ${target.name ?? target.id} --ws ${target.workspace}`;
285
585
  return { text: `${resumeContext(carnet, target)}\n\nResume with: ${resume}` };
286
586
  }
287
587
  });
@@ -309,6 +609,13 @@ const TOOLS = [
309
609
  agentDrop,
310
610
  agentStep,
311
611
  agentList,
612
+ agentQuestions,
613
+ agentAnswer,
614
+ agentInject,
615
+ agentPromote,
616
+ reviewContextTool,
617
+ reviewFindings,
618
+ reviewDecide,
312
619
  queueReorder,
313
620
  tableSet,
314
621
  tableClear,