@rucher/carnet 0.2.0-beta.7 → 0.2.0
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/{carnet-jmxAmm-u.d.mts → carnet-DHw_oXJs.d.mts} +39 -145
- package/dist/carnet-DHw_oXJs.d.mts.map +1 -0
- package/dist/index.d.mts +6 -23
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -100
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +2 -2
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +22 -329
- package/dist/mcp.mjs.map +1 -1
- package/dist/{steps-Bd8FlgLs.mjs → steps-4ZTrBzcd.mjs} +116 -523
- package/dist/steps-4ZTrBzcd.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/carnet-jmxAmm-u.d.mts.map +0 -1
- package/dist/steps-Bd8FlgLs.mjs.map +0 -1
package/dist/mcp.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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";
|
|
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
|
|
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.
|
|
9
9
|
|
|
10
10
|
Which tool, when:
|
|
11
|
-
-
|
|
11
|
+
- Dispatch: agent_start, then launch the fork in a later message.
|
|
12
12
|
- Each step of a fork's work: agent_step (answered, applying, applied, tested, committed, dropped).
|
|
13
|
-
-
|
|
14
|
-
- Main line text for work of your own: table_set, table_clear.
|
|
13
|
+
- Main agent working on something else: table_set, table_clear.
|
|
15
14
|
- Other moves: agent_update, agent_drop, queue_reorder. Recall: agent_list, log_read, session_resume_info, session_list.
|
|
16
15
|
- 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.
|
|
17
16
|
- Session: session_new when the human names it, session_drop only when asked.
|
|
@@ -43,188 +42,6 @@ function createSessionResolver({ carnet, env = process.env, ppid = process.ppid,
|
|
|
43
42
|
return id;
|
|
44
43
|
} };
|
|
45
44
|
}
|
|
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
|
-
}
|
|
228
45
|
// src/mcp/tools.ts
|
|
229
46
|
function defineTool(definition) {
|
|
230
47
|
return definition;
|
|
@@ -237,8 +54,6 @@ const agentStart = defineTool({
|
|
|
237
54
|
schema: z.object({
|
|
238
55
|
name: agentName,
|
|
239
56
|
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>]"),
|
|
242
57
|
base_commit: z.string().optional().describe("Commit the fork starts from"),
|
|
243
58
|
worktree: z.string().optional().describe("Worktree path when the fork has one"),
|
|
244
59
|
session
|
|
@@ -248,8 +63,6 @@ const agentStart = defineTool({
|
|
|
248
63
|
const agent = carnet.agents.start(sessionId, {
|
|
249
64
|
name: args.name,
|
|
250
65
|
task: args.task,
|
|
251
|
-
kind: args.kind,
|
|
252
|
-
target: args.target,
|
|
253
66
|
baseCommit: args.base_commit,
|
|
254
67
|
worktree: args.worktree
|
|
255
68
|
});
|
|
@@ -276,9 +89,7 @@ const agentUpdate = defineTool({
|
|
|
276
89
|
});
|
|
277
90
|
return { text: renderAgentLine({
|
|
278
91
|
name: agent.name,
|
|
279
|
-
kind: agent.kind,
|
|
280
92
|
status: agent.status,
|
|
281
|
-
action: null,
|
|
282
93
|
emoji: agent.status === "closed" ? "" : EMOJI[agent.status],
|
|
283
94
|
note: agent.note
|
|
284
95
|
}) };
|
|
@@ -292,46 +103,21 @@ function copyReport(carnet, name, reportFile) {
|
|
|
292
103
|
copyFileSync(reportFile, destination);
|
|
293
104
|
return destination;
|
|
294
105
|
}
|
|
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
|
-
}
|
|
316
106
|
const agentDone = defineTool({
|
|
317
107
|
name: "agent_done",
|
|
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
|
|
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.",
|
|
319
109
|
schema: z.object({
|
|
320
110
|
name: agentName,
|
|
321
111
|
report_path: z.string().min(1).describe("Absolute path of the markdown report"),
|
|
322
|
-
|
|
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"),
|
|
112
|
+
has_questions: z.boolean().describe("true when the report asks the human something"),
|
|
325
113
|
session
|
|
326
114
|
}),
|
|
327
115
|
run: (carnet, sessionId, args) => {
|
|
328
|
-
const agent =
|
|
116
|
+
const agent = carnet.agents.finish(sessionId, args.name, {
|
|
329
117
|
reportPath: copyReport(carnet, args.name, args.report_path),
|
|
330
|
-
questions: args.questions,
|
|
331
|
-
findings: args.findings,
|
|
332
118
|
hasQuestions: args.has_questions
|
|
333
119
|
});
|
|
334
|
-
const outcome =
|
|
120
|
+
const outcome = args.has_questions ? `${EMOJI.answer} ${agent.name} needs answers` : `${EMOJI.review} ${agent.name} ready for review`;
|
|
335
121
|
return { text: agent.status === "running" ? `${outcome} once you stop; reply now with one line that carries no results` : outcome };
|
|
336
122
|
}
|
|
337
123
|
});
|
|
@@ -349,106 +135,18 @@ const agentDrop = defineTool({
|
|
|
349
135
|
});
|
|
350
136
|
const agentList = defineTool({
|
|
351
137
|
name: "agent_list",
|
|
352
|
-
description: "List the open agents of the session
|
|
353
|
-
schema: z.object({
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}),
|
|
357
|
-
run: (carnet, sessionId, args) => {
|
|
358
|
-
const lines = carnet.agents.list(sessionId).filter((agent) => !args.kind || agent.kind === args.kind).map((agent) => {
|
|
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) => {
|
|
359
142
|
const emoji = agent.status === "closed" ? "" : EMOJI[agent.status];
|
|
360
|
-
const action = agent.status === "running" ? "" : ` → ${finalAction(agent)}`;
|
|
361
|
-
const target = agent.target ? ` on ${agent.target}` : "";
|
|
362
143
|
const note = agent.note ? ` — ${agent.note}` : "";
|
|
363
144
|
const report = agent.reportPath ? ` (report: ${agent.reportPath})` : "";
|
|
364
|
-
return `${emoji} ${agent.name}
|
|
145
|
+
return `${emoji} ${agent.name} [${agent.status}]${note}${report}`;
|
|
365
146
|
});
|
|
366
147
|
return { text: lines.length ? lines.join("\n") : "no open agents" };
|
|
367
148
|
}
|
|
368
149
|
});
|
|
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
|
-
});
|
|
452
150
|
const queueReorder = defineTool({
|
|
453
151
|
name: "queue_reorder",
|
|
454
152
|
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).",
|
|
@@ -464,15 +162,17 @@ const queueReorder = defineTool({
|
|
|
464
162
|
});
|
|
465
163
|
const tableSet = defineTool({
|
|
466
164
|
name: "table_set",
|
|
467
|
-
description: "Main agent only. Set the
|
|
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.",
|
|
468
166
|
schema: z.object({
|
|
469
167
|
text: z.string().min(1).describe("Under 60 characters, no paths, no backticks"),
|
|
470
|
-
|
|
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"),
|
|
471
170
|
session
|
|
472
171
|
}),
|
|
473
172
|
run: (carnet, sessionId, args) => {
|
|
474
173
|
const item = carnet.table.set(sessionId, {
|
|
475
174
|
text: args.text,
|
|
175
|
+
mainWorking: args.main_working,
|
|
476
176
|
status: args.status
|
|
477
177
|
});
|
|
478
178
|
return { text: renderTableLine(item) };
|
|
@@ -480,7 +180,7 @@ const tableSet = defineTool({
|
|
|
480
180
|
});
|
|
481
181
|
const agentStep = defineTool({
|
|
482
182
|
name: "agent_step",
|
|
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
|
|
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.",
|
|
484
184
|
schema: z.object({
|
|
485
185
|
name: agentName,
|
|
486
186
|
step: z.enum(AGENT_STEPS),
|
|
@@ -493,11 +193,11 @@ const agentStep = defineTool({
|
|
|
493
193
|
});
|
|
494
194
|
const tableClear = defineTool({
|
|
495
195
|
name: "table_clear",
|
|
496
|
-
description: "Main agent only. Empty the
|
|
196
|
+
description: "Main agent only. Empty the 'On the table' line.",
|
|
497
197
|
schema: z.object({ session }),
|
|
498
198
|
run: (carnet, sessionId) => {
|
|
499
199
|
carnet.table.clear(sessionId);
|
|
500
|
-
return { text: "
|
|
200
|
+
return { text: "On the table cleared" };
|
|
501
201
|
}
|
|
502
202
|
});
|
|
503
203
|
const logEvent = defineTool({
|
|
@@ -581,7 +281,7 @@ const sessionResumeInfo = defineTool({
|
|
|
581
281
|
}),
|
|
582
282
|
run: (carnet, sessionId, args) => {
|
|
583
283
|
const target = args.name ? carnet.sessions.find(args.name) : carnet.sessions.require(sessionId);
|
|
584
|
-
const resume = `rucher resume ${target.name ?? target.id}
|
|
284
|
+
const resume = `rucher resume ${target.name ?? target.id}`;
|
|
585
285
|
return { text: `${resumeContext(carnet, target)}\n\nResume with: ${resume}` };
|
|
586
286
|
}
|
|
587
287
|
});
|
|
@@ -609,13 +309,6 @@ const TOOLS = [
|
|
|
609
309
|
agentDrop,
|
|
610
310
|
agentStep,
|
|
611
311
|
agentList,
|
|
612
|
-
agentQuestions,
|
|
613
|
-
agentAnswer,
|
|
614
|
-
agentInject,
|
|
615
|
-
agentPromote,
|
|
616
|
-
reviewContextTool,
|
|
617
|
-
reviewFindings,
|
|
618
|
-
reviewDecide,
|
|
619
312
|
queueReorder,
|
|
620
313
|
tableSet,
|
|
621
314
|
tableClear,
|