@rucher/carnet 0.0.0-stage → 0.2.0-beta.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/LICENSE +21 -0
- package/README.md +20 -2
- package/dist/carnet-CsFtIv2C.d.mts +447 -0
- package/dist/carnet-CsFtIv2C.d.mts.map +1 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +189 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mcp.d.mts +40 -0
- package/dist/mcp.d.mts.map +1 -0
- package/dist/mcp.mjs +513 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/resume-CQRf2jIa.mjs +1764 -0
- package/dist/resume-CQRf2jIa.mjs.map +1 -0
- package/package.json +54 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { $ as reportsDirectoryOf, A as DEFAULT_HALF_LIFE_DAYS, At as isAgentStatus, B as similarity, C as DEFAULT_PURGE_DAYS, Ct as sanitizeNote, D as MEMORY_MAX_CHARACTERS, Dt as MAIN_WORKING_EMOJI, E as shortId, Et as LEGEND, F as groupRepoNames, Ft as CarnetError, G as findGroupRoot, H as GROUP_DIRECTORY, I as isNoteKind, J as loadGroup, K as isGroupRoot, L as localDay, M as NOTE_KINDS, Mt as EVENT_TYPES, N as NOTE_TEXT_LIMIT, Nt as SESSION_EVENT_TYPES, O as memoryMaxCharacters, P as STALE_AFTER_ACTIVE_DAYS, Pt as isEventType, Q as reportPathFor, R as memoryHalfLife, S as renderTableLine, St as NOTE_MAX, T as MINIMUM_ID_PREFIX, Tt as EMOJI, U as GROUP_FILE, V as DB_FILE, W as REPORTS_DIRECTORY, X as repoNameFor, Y as locateGroup, Z as repoPathFor, _ as renderNoteLine, _t as migrate, a as sessionLabel, at as allHosts, b as renderSections, bt as PUBLISH_FALLBACK_MILLISECONDS, c as PAIRING_WINDOW_MILLISECONDS, ct as REPOS_START, d as formatClock, dt as groupSettings, et as readRegistry, f as MAIN_WORKING_SUFFIX, ft as replaceReposBlock, g as renderAgentLine, gt as openDatabase, h as SIMILAR_PREFIX, ht as MEMORY_DB, i as resumeContext, it as DEFAULT_HOST, j as DUPLICATE_SIMILARITY, jt as isUserActionStatus, k as renderMemory, kt as USER_ACTION_STATUSES, l as STOPPED_NOTE, lt as claudeCode, m as NOTES_HEADER, mt as transcriptTitle, n as RESUME_MAX_CHARACTERS, nt as rucherHome, o as Carnet, ot as hostById, p as NOTES_FOLD_LINES, pt as reposBlock, q as isInside, r as formatEventLine, rt as unregisterGroups, s as openCarnet, st as REPOS_END, t as RESUME_EVENTS, tt as registerGroup, u as buildStatusView, ut as groupInstructions, v as renderNotes, vt as migrations, w as purgeDays, wt as AGENT_STATUSES, x as renderStatus, xt as REPORTING_NOTE, y as renderNotesSummary, yt as schemaVersion, z as sessionNoteActivity } from "./resume-CQRf2jIa.mjs";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
// src/group/init.ts
|
|
6
|
+
function writeGroupFile(root, file) {
|
|
7
|
+
writeFileSync(join(root, GROUP_DIRECTORY, GROUP_FILE), `${JSON.stringify(file, null, 2)}\n`);
|
|
8
|
+
}
|
|
9
|
+
function resolveRepo(root, repo) {
|
|
10
|
+
const path = resolve(root, repo);
|
|
11
|
+
if (!existsSync(path)) throw new CarnetError("REPO_NOT_FOUND", `Repo path does not exist: ${path}`);
|
|
12
|
+
return path;
|
|
13
|
+
}
|
|
14
|
+
function initGroup(directory, options = {}) {
|
|
15
|
+
const root = resolve(directory);
|
|
16
|
+
const groupDirectory = join(root, GROUP_DIRECTORY);
|
|
17
|
+
if (existsSync(groupDirectory)) throw new CarnetError("GROUP_EXISTS", `${root} is already a Rucher group`);
|
|
18
|
+
const name = options.name ?? basename(root);
|
|
19
|
+
const repos = [...new Set((options.repos ?? []).map((repo) => resolveRepo(root, repo)))];
|
|
20
|
+
const names = repos.map((repo) => basename(repo));
|
|
21
|
+
const shared = names.find((repoName, index) => names.indexOf(repoName) !== index);
|
|
22
|
+
if (shared) throw new CarnetError("REPO_NAME_TAKEN", `Two repos are named ${shared}: give them distinct names`);
|
|
23
|
+
const hosts = (options.hosts?.length ? options.hosts : [DEFAULT_HOST]).map((id) => hostById(id).id);
|
|
24
|
+
mkdirSync(join(groupDirectory, REPORTS_DIRECTORY), { recursive: true });
|
|
25
|
+
writeGroupFile(root, {
|
|
26
|
+
name,
|
|
27
|
+
repos,
|
|
28
|
+
hosts
|
|
29
|
+
});
|
|
30
|
+
openDatabase(join(groupDirectory, DB_FILE)).close();
|
|
31
|
+
registerGroup({
|
|
32
|
+
name,
|
|
33
|
+
path: root
|
|
34
|
+
}, options.env);
|
|
35
|
+
return loadGroup(root);
|
|
36
|
+
}
|
|
37
|
+
function addGroupRepo(root, repo) {
|
|
38
|
+
const group = loadGroup(resolve(root));
|
|
39
|
+
const path = resolveRepo(group.root, repo);
|
|
40
|
+
const sameName = group.repos.find((existing) => existing !== path && basename(existing) === basename(path));
|
|
41
|
+
if (sameName) throw new CarnetError("REPO_NAME_TAKEN", `${group.name} already has a repo named ${basename(path)}: ${sameName}`);
|
|
42
|
+
if (!group.repos.includes(path)) writeGroupFile(group.root, {
|
|
43
|
+
name: group.name,
|
|
44
|
+
repos: [...group.repos, path],
|
|
45
|
+
hosts: group.hosts
|
|
46
|
+
});
|
|
47
|
+
return loadGroup(group.root);
|
|
48
|
+
}
|
|
49
|
+
function removeGroupRepo(root, repo) {
|
|
50
|
+
const group = loadGroup(resolve(root));
|
|
51
|
+
const path = resolve(group.root, repo);
|
|
52
|
+
if (!group.repos.includes(path)) throw new CarnetError("REPO_NOT_FOUND", `${path} is not a repo of ${group.name}`);
|
|
53
|
+
writeGroupFile(group.root, {
|
|
54
|
+
name: group.name,
|
|
55
|
+
repos: group.repos.filter((repo) => repo !== path),
|
|
56
|
+
hosts: group.hosts
|
|
57
|
+
});
|
|
58
|
+
return loadGroup(group.root);
|
|
59
|
+
}
|
|
60
|
+
// src/hook/session-end.ts
|
|
61
|
+
function handleSessionEnd(carnet, payload) {
|
|
62
|
+
if (!carnet.sessions.get(payload.session_id)) return void 0;
|
|
63
|
+
return carnet.sessions.end(payload.session_id);
|
|
64
|
+
}
|
|
65
|
+
// src/prompt/core-rules.ts
|
|
66
|
+
const CORE_RULES = `- Work can be parallel, review stays sequential: forks work at the same time, the human handles their results one at a time.
|
|
67
|
+
- The human keeps the hand: only the human launches forks, applies, tests and commits. Agents propose, they never push.
|
|
68
|
+
- Status lives in Carnet: agent statuses, the "On the table" line and the journal go through the Carnet tools, never into status files nor chat updates. Update before and after each piece of work.
|
|
69
|
+
- When a fork finishes, say only "<name> finished, report ready". Never summarise, quote or act on its report or final message until the human asks for that fork's report, even when answering about something else.
|
|
70
|
+
- Forks never commit, push, stash or record notes. A fork writes its report to a file, ending with a Learnings section, calls agent_done as its last tool action, then replies with one line that carries no results, such as "<name> done, report written". Only the main agent records notes, at the end of a step.
|
|
71
|
+
- To dispatch, apply or review forks, load the rucher skill: it holds the full workflow.`;
|
|
72
|
+
// src/prompt/prompt.ts
|
|
73
|
+
const PROMPT_FILE = "prompt.md";
|
|
74
|
+
const PROMPTS_DIRECTORY = "prompts";
|
|
75
|
+
function readIfPresent(path) {
|
|
76
|
+
if (!existsSync(path)) return void 0;
|
|
77
|
+
return readFileSync(path, "utf8").trim() || void 0;
|
|
78
|
+
}
|
|
79
|
+
function baseRules(env = process.env) {
|
|
80
|
+
return readIfPresent(join(rucherHome(env), "prompt.md")) ?? "- Work can be parallel, review stays sequential: forks work at the same time, the human handles their results one at a time.\n- The human keeps the hand: only the human launches forks, applies, tests and commits. Agents propose, they never push.\n- Status lives in Carnet: agent statuses, the \"On the table\" line and the journal go through the Carnet tools, never into status files nor chat updates. Update before and after each piece of work.\n- When a fork finishes, say only \"<name> finished, report ready\". Never summarise, quote or act on its report or final message until the human asks for that fork's report, even when answering about something else.\n- Forks never commit, push, stash or record notes. A fork writes its report to a file, ending with a Learnings section, calls agent_done as its last tool action, then replies with one line that carries no results, such as \"<name> done, report written\". Only the main agent records notes, at the end of a step.\n- To dispatch, apply or review forks, load the rucher skill: it holds the full workflow.";
|
|
81
|
+
}
|
|
82
|
+
function groupRules(group) {
|
|
83
|
+
return readIfPresent(join(group.root, GROUP_DIRECTORY, PROMPT_FILE));
|
|
84
|
+
}
|
|
85
|
+
function rulesText(group, env = process.env) {
|
|
86
|
+
const extra = groupRules(group);
|
|
87
|
+
const base = `Rucher rules:\n${baseRules(env)}`;
|
|
88
|
+
return extra ? `${base}\n\nRules of the ${group.name} group:\n${extra}` : base;
|
|
89
|
+
}
|
|
90
|
+
function rulesVersion(group, env = process.env) {
|
|
91
|
+
return createHash("sha256").update(rulesText(group, env)).digest("hex").slice(0, 12);
|
|
92
|
+
}
|
|
93
|
+
function assemblePrompt(group, session, env = process.env) {
|
|
94
|
+
const identity = `This is the Rucher session ${session.name ?? shortId(session.id)} (${session.kind}) of the ${group.name} group.`;
|
|
95
|
+
return {
|
|
96
|
+
text: `${rulesText(group, env)}\n\n${identity}\n`,
|
|
97
|
+
version: rulesVersion(group, env)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function appendPromptFile(group, session, env = process.env) {
|
|
101
|
+
const { text, version } = assemblePrompt(group, session, env);
|
|
102
|
+
const directory = join(group.root, GROUP_DIRECTORY, PROMPTS_DIRECTORY);
|
|
103
|
+
mkdirSync(directory, { recursive: true });
|
|
104
|
+
const path = join(directory, `${session.id}.md`);
|
|
105
|
+
writeFileSync(path, text);
|
|
106
|
+
return {
|
|
107
|
+
path,
|
|
108
|
+
version
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function compactReminder(group, env = process.env) {
|
|
112
|
+
return `The conversation was just compacted and this session was not started by rucher, so its system prompt no longer holds the Rucher rules. ${rulesText(group, env)}`;
|
|
113
|
+
}
|
|
114
|
+
const OUTSIDE_RUCHER_CONTEXT = "This session was started without rucher, so the Rucher rules are not in its system prompt. Follow the Carnet server instructions and load the rucher skill before dispatching or applying forks.";
|
|
115
|
+
const OUTSIDE_RUCHER_NOTICE = "rucher: session started without rucher, the Rucher rules are not in its system prompt (use rucher new, tmp or resume)";
|
|
116
|
+
const RULES_UPDATED_NOTICE = "rucher: rules updated, will apply after the next compaction or in a new session";
|
|
117
|
+
const SUBAGENT_RULES = "Rucher rules for sub-agents: never commit, push or stash. When your task asks for a report, write it to the file it names. If your prompt names you as a Carnet agent, call agent_update at meaningful progress and agent_done as your last tool action, then reply with one line.";
|
|
118
|
+
// src/hook/session-start.ts
|
|
119
|
+
const SOURCE_EVENTS = {
|
|
120
|
+
startup: "session.started",
|
|
121
|
+
resume: "session.resumed",
|
|
122
|
+
fork: "session.forked"
|
|
123
|
+
};
|
|
124
|
+
function adoptFork(carnet, session, env) {
|
|
125
|
+
const parentId = env.RUCHER_SESSION_ID;
|
|
126
|
+
if (!parentId || parentId === session.id || !carnet.sessions.get(parentId)) return session;
|
|
127
|
+
let fork = carnet.sessions.setParent(session.id, parentId);
|
|
128
|
+
carnet.memory.copyRepos(parentId, session.id);
|
|
129
|
+
const kind = env.RUCHER_SESSION_KIND;
|
|
130
|
+
if (kind === "active" || kind === "temp") fork = carnet.sessions.setKind(session.id, kind, env.RUCHER_SESSION_NAME || null);
|
|
131
|
+
return fork;
|
|
132
|
+
}
|
|
133
|
+
function startMemory(carnet, session, source, env) {
|
|
134
|
+
const options = {
|
|
135
|
+
maxCharacters: memoryMaxCharacters(env.RUCHER_MEMORY_MAX_CHARACTERS),
|
|
136
|
+
halfLifeDays: memoryHalfLife(env.RUCHER_MEMORY_HALF_LIFE_DAYS)
|
|
137
|
+
};
|
|
138
|
+
if (source === "startup" || source === "clear") return carnet.memory.atStart(session, options);
|
|
139
|
+
if (source === "resume" || source === "compact") return carnet.memory.ofSession(session, options);
|
|
140
|
+
}
|
|
141
|
+
function handleSessionStart(carnet, payload, env) {
|
|
142
|
+
let session = carnet.sessions.upsertFromHook(payload, env);
|
|
143
|
+
const source = payload.source ?? "";
|
|
144
|
+
if (source === "fork") session = adoptFork(carnet, session, env);
|
|
145
|
+
const event = SOURCE_EVENTS[source];
|
|
146
|
+
if (event) carnet.events.log(session.id, { type: event });
|
|
147
|
+
session = carnet.sessions.setStatus(session.id, "running");
|
|
148
|
+
carnet.sessions.purge(session.id, purgeDays(env.RUCHER_PURGE_DAYS));
|
|
149
|
+
const promptEnv = { RUCHER_HOME: env.RUCHER_HOME };
|
|
150
|
+
const launchedVersion = env.RUCHER_PROMPT_VERSION || null;
|
|
151
|
+
const contextParts = [];
|
|
152
|
+
const notices = [];
|
|
153
|
+
if (hostById(session.host).rendersSystemPrompt(source)) session = carnet.sessions.recordPromptVersion(session.id, launchedVersion);
|
|
154
|
+
if (source === "resume") contextParts.push(resumeContext(carnet, session));
|
|
155
|
+
const memory = startMemory(carnet, session, source, env);
|
|
156
|
+
if (memory) contextParts.push(memory);
|
|
157
|
+
if (source === "compact" && !launchedVersion) contextParts.push(compactReminder(carnet.group, promptEnv));
|
|
158
|
+
else if (!env.RUCHER_SESSION_ID && !session.promptVersion) {
|
|
159
|
+
contextParts.push(OUTSIDE_RUCHER_CONTEXT);
|
|
160
|
+
notices.push(OUTSIDE_RUCHER_NOTICE);
|
|
161
|
+
} else if (session.promptVersion && session.promptVersion !== rulesVersion(carnet.group, promptEnv)) notices.push(RULES_UPDATED_NOTICE);
|
|
162
|
+
const additionalContext = contextParts.length ? contextParts.join("\n\n") : void 0;
|
|
163
|
+
return {
|
|
164
|
+
session,
|
|
165
|
+
contextParts,
|
|
166
|
+
notices,
|
|
167
|
+
...additionalContext ? { additionalContext } : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// src/hook/user-prompt-submit.ts
|
|
171
|
+
function handleUserPromptSubmit(carnet, host, payload) {
|
|
172
|
+
carnet.sessions.ensure(payload.session_id, payload.cwd);
|
|
173
|
+
carnet.notes.recordActiveDay();
|
|
174
|
+
return carnet.sessions.adoptTitle(payload.session_id, host.promptTitle(payload));
|
|
175
|
+
}
|
|
176
|
+
// src/hook/post-tool-use.ts
|
|
177
|
+
function handleToolUse(carnet, payload, env) {
|
|
178
|
+
if (payload.agent_id) return void 0;
|
|
179
|
+
const repo = repoNameFor(carnet.group, payload.path);
|
|
180
|
+
if (!repo) return void 0;
|
|
181
|
+
const session = carnet.sessions.ensure(payload.session_id, payload.cwd);
|
|
182
|
+
return carnet.memory.forRepo(session, repo, {
|
|
183
|
+
maxCharacters: memoryMaxCharacters(env.RUCHER_MEMORY_MAX_CHARACTERS),
|
|
184
|
+
halfLifeDays: memoryHalfLife(env.RUCHER_MEMORY_HALF_LIFE_DAYS)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export { AGENT_STATUSES, CORE_RULES, Carnet, CarnetError, DB_FILE, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DEFAULT_PURGE_DAYS, DUPLICATE_SIMILARITY, EMOJI, EVENT_TYPES, GROUP_DIRECTORY, GROUP_FILE, LEGEND, MAIN_WORKING_EMOJI, MAIN_WORKING_SUFFIX, MEMORY_DB, MEMORY_MAX_CHARACTERS, MINIMUM_ID_PREFIX, NOTES_FOLD_LINES, NOTES_HEADER, NOTE_KINDS, NOTE_MAX, NOTE_TEXT_LIMIT, OUTSIDE_RUCHER_CONTEXT, OUTSIDE_RUCHER_NOTICE, PAIRING_WINDOW_MILLISECONDS, PROMPTS_DIRECTORY, PROMPT_FILE, PUBLISH_FALLBACK_MILLISECONDS, REPORTING_NOTE, REPORTS_DIRECTORY, REPOS_END, REPOS_START, RESUME_EVENTS, RESUME_MAX_CHARACTERS, RULES_UPDATED_NOTICE, SESSION_EVENT_TYPES, SIMILAR_PREFIX, STALE_AFTER_ACTIVE_DAYS, STOPPED_NOTE, SUBAGENT_RULES, USER_ACTION_STATUSES, addGroupRepo, allHosts, appendPromptFile, assemblePrompt, baseRules, buildStatusView, claudeCode, compactReminder, findGroupRoot, formatClock, formatEventLine, groupInstructions, groupRepoNames, groupRules, groupSettings, handleSessionEnd, handleSessionStart, handleToolUse, handleUserPromptSubmit, hostById, initGroup, isAgentStatus, isEventType, isGroupRoot, isInside, isNoteKind, isUserActionStatus, loadGroup, localDay, locateGroup, memoryHalfLife, memoryMaxCharacters, migrate, migrations, openCarnet, openDatabase, purgeDays, readRegistry, registerGroup, removeGroupRepo, renderAgentLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderSections, renderStatus, renderTableLine, replaceReposBlock, repoNameFor, repoPathFor, reportPathFor, reportsDirectoryOf, reposBlock, resumeContext, rucherHome, rulesText, rulesVersion, sanitizeNote, schemaVersion, sessionLabel, sessionNoteActivity, shortId, similarity, transcriptTitle, unregisterGroups };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/group/init.ts","../src/hook/session-end.ts","../src/prompt/core-rules.ts","../src/prompt/prompt.ts","../src/hook/session-start.ts","../src/hook/user-prompt-submit.ts","../src/hook/post-tool-use.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { basename, join, resolve } from 'node:path';\nimport { CarnetError } from '../errors.ts';\nimport { openDatabase } from '../db/open.ts';\nimport { DEFAULT_HOST, hostById } from '../hosts/host.ts';\nimport {\n DB_FILE,\n GROUP_DIRECTORY,\n GROUP_FILE,\n REPORTS_DIRECTORY,\n type Group,\n type GroupFile,\n loadGroup,\n} from './locate.ts';\nimport { registerGroup } from './registry.ts';\n\nexport interface InitOptions {\n name?: string | undefined;\n repos?: string[] | undefined;\n hosts?: string[] | undefined;\n env?: NodeJS.ProcessEnv | undefined;\n}\n\nfunction writeGroupFile(root: string, file: GroupFile): void {\n writeFileSync(join(root, GROUP_DIRECTORY, GROUP_FILE), `${JSON.stringify(file, null, 2)}\\n`);\n}\n\nfunction resolveRepo(root: string, repo: string): string {\n const path = resolve(root, repo);\n if (!existsSync(path))\n throw new CarnetError('REPO_NOT_FOUND', `Repo path does not exist: ${path}`);\n return path;\n}\n\nexport function initGroup(directory: string, options: InitOptions = {}): Group {\n const root = resolve(directory);\n const groupDirectory = join(root, GROUP_DIRECTORY);\n if (existsSync(groupDirectory)) {\n throw new CarnetError('GROUP_EXISTS', `${root} is already a Rucher group`);\n }\n const name = options.name ?? basename(root);\n const repos = [...new Set((options.repos ?? []).map((repo) => resolveRepo(root, repo)))];\n const names = repos.map((repo) => basename(repo));\n const shared = names.find((repoName, index) => names.indexOf(repoName) !== index);\n if (shared) {\n throw new CarnetError(\n 'REPO_NAME_TAKEN',\n `Two repos are named ${shared}: give them distinct names`,\n );\n }\n const hosts = (options.hosts?.length ? options.hosts : [DEFAULT_HOST]).map(\n (id) => hostById(id).id,\n );\n mkdirSync(join(groupDirectory, REPORTS_DIRECTORY), { recursive: true });\n writeGroupFile(root, { name, repos, hosts });\n openDatabase(join(groupDirectory, DB_FILE)).close();\n registerGroup({ name, path: root }, options.env);\n return loadGroup(root);\n}\n\nexport function addGroupRepo(root: string, repo: string): Group {\n const group = loadGroup(resolve(root));\n const path = resolveRepo(group.root, repo);\n const sameName = group.repos.find(\n (existing) => existing !== path && basename(existing) === basename(path),\n );\n // Notes reference repos by name, so two repos cannot share one.\n if (sameName) {\n throw new CarnetError(\n 'REPO_NAME_TAKEN',\n `${group.name} already has a repo named ${basename(path)}: ${sameName}`,\n );\n }\n if (!group.repos.includes(path)) {\n writeGroupFile(group.root, {\n name: group.name,\n repos: [...group.repos, path],\n hosts: group.hosts,\n });\n }\n return loadGroup(group.root);\n}\n\nexport function removeGroupRepo(root: string, repo: string): Group {\n const group = loadGroup(resolve(root));\n const path = resolve(group.root, repo);\n if (!group.repos.includes(path)) {\n throw new CarnetError('REPO_NOT_FOUND', `${path} is not a repo of ${group.name}`);\n }\n writeGroupFile(group.root, {\n name: group.name,\n repos: group.repos.filter((repo) => repo !== path),\n hosts: group.hosts,\n });\n return loadGroup(group.root);\n}\n","import type { Carnet } from '../carnet.ts';\nimport type { HostSessionEndPayload } from '../hosts/host.ts';\nimport type { Session } from '../sessions.ts';\n\nexport function handleSessionEnd(\n carnet: Carnet,\n payload: HostSessionEndPayload,\n): Session | undefined {\n if (!carnet.sessions.get(payload.session_id)) return undefined;\n return carnet.sessions.end(payload.session_id);\n}\n","// Generated from docs/workflow.md by pnpm run build. Do not edit.\nexport const CORE_RULES = `- Work can be parallel, review stays sequential: forks work at the same time, the human handles their results one at a time.\n- The human keeps the hand: only the human launches forks, applies, tests and commits. Agents propose, they never push.\n- Status lives in Carnet: agent statuses, the \"On the table\" line and the journal go through the Carnet tools, never into status files nor chat updates. Update before and after each piece of work.\n- When a fork finishes, say only \"<name> finished, report ready\". Never summarise, quote or act on its report or final message until the human asks for that fork's report, even when answering about something else.\n- Forks never commit, push, stash or record notes. A fork writes its report to a file, ending with a Learnings section, calls agent_done as its last tool action, then replies with one line that carries no results, such as \"<name> done, report written\". Only the main agent records notes, at the end of a step.\n- To dispatch, apply or review forks, load the rucher skill: it holds the full workflow.`;\n","import { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { GROUP_DIRECTORY, type Group } from '../group/locate.ts';\nimport { rucherHome } from '../group/registry.ts';\nimport { shortId, type SessionKind } from '../sessions.ts';\nimport { CORE_RULES } from './core-rules.ts';\n\nexport const PROMPT_FILE = 'prompt.md';\nexport const PROMPTS_DIRECTORY = 'prompts';\n\nexport interface PromptSession {\n id: string;\n name: string | null;\n kind: SessionKind;\n}\n\nexport interface AssembledPrompt {\n text: string;\n version: string;\n}\n\nexport interface AppendPromptFile {\n path: string;\n version: string;\n}\n\nfunction readIfPresent(path: string): string | undefined {\n if (!existsSync(path)) return undefined;\n const content = readFileSync(path, 'utf8').trim();\n return content || undefined;\n}\n\nexport function baseRules(env: NodeJS.ProcessEnv = process.env): string {\n return readIfPresent(join(rucherHome(env), PROMPT_FILE)) ?? CORE_RULES;\n}\n\nexport function groupRules(group: Group): string | undefined {\n return readIfPresent(join(group.root, GROUP_DIRECTORY, PROMPT_FILE));\n}\n\nexport function rulesText(group: Group, env: NodeJS.ProcessEnv = process.env): string {\n const extra = groupRules(group);\n const base = `Rucher rules:\\n${baseRules(env)}`;\n return extra ? `${base}\\n\\nRules of the ${group.name} group:\\n${extra}` : base;\n}\n\n// The identity block is left out so that renaming a session doesn't read as a rules change.\nexport function rulesVersion(group: Group, env: NodeJS.ProcessEnv = process.env): string {\n return createHash('sha256').update(rulesText(group, env)).digest('hex').slice(0, 12);\n}\n\nexport function assemblePrompt(\n group: Group,\n session: PromptSession,\n env: NodeJS.ProcessEnv = process.env,\n): AssembledPrompt {\n const label = session.name ?? shortId(session.id);\n const identity = `This is the Rucher session ${label} (${session.kind}) of the ${group.name} group.`;\n return { text: `${rulesText(group, env)}\\n\\n${identity}\\n`, version: rulesVersion(group, env) };\n}\n\nexport function appendPromptFile(\n group: Group,\n session: PromptSession,\n env: NodeJS.ProcessEnv = process.env,\n): AppendPromptFile {\n const { text, version } = assemblePrompt(group, session, env);\n const directory = join(group.root, GROUP_DIRECTORY, PROMPTS_DIRECTORY);\n mkdirSync(directory, { recursive: true });\n const path = join(directory, `${session.id}.md`);\n writeFileSync(path, text);\n return { path, version };\n}\n\nexport function compactReminder(group: Group, env: NodeJS.ProcessEnv = process.env): string {\n return `The conversation was just compacted and this session was not started by rucher, so its system prompt no longer holds the Rucher rules. ${rulesText(group, env)}`;\n}\n\nexport const OUTSIDE_RUCHER_CONTEXT =\n 'This session was started without rucher, so the Rucher rules are not in its system prompt. Follow the Carnet server instructions and load the rucher skill before dispatching or applying forks.';\n\nexport const OUTSIDE_RUCHER_NOTICE =\n 'rucher: session started without rucher, the Rucher rules are not in its system prompt (use rucher new, tmp or resume)';\n\nexport const RULES_UPDATED_NOTICE =\n 'rucher: rules updated, will apply after the next compaction or in a new session';\n\nexport const SUBAGENT_RULES =\n 'Rucher rules for sub-agents: never commit, push or stash. When your task asks for a report, write it to the file it names. If your prompt names you as a Carnet agent, call agent_update at meaningful progress and agent_done as your last tool action, then reply with one line.';\n","import type { Carnet } from '../carnet.ts';\nimport type { SessionEventType } from '../events.ts';\nimport {\n compactReminder,\n OUTSIDE_RUCHER_CONTEXT,\n OUTSIDE_RUCHER_NOTICE,\n RULES_UPDATED_NOTICE,\n rulesVersion,\n} from '../prompt/prompt.ts';\nimport { hostById } from '../hosts/host.ts';\nimport { memoryMaxCharacters } from '../memory.ts';\nimport { memoryHalfLife } from '../notes.ts';\nimport { purgeDays } from '../purge.ts';\nimport { resumeContext } from '../resume.ts';\nimport type { HookEnv, HookSessionPayload, Session } from '../sessions.ts';\n\nexport interface SessionStartResult {\n session: Session;\n additionalContext?: string;\n contextParts: string[];\n notices: string[];\n}\n\nconst SOURCE_EVENTS: Readonly<Record<string, SessionEventType>> = {\n startup: 'session.started',\n resume: 'session.resumed',\n fork: 'session.forked',\n};\n\n// A fork gets a new id from the host; the launcher's env still carries the parent's.\nfunction adoptFork(carnet: Carnet, session: Session, env: HookEnv): Session {\n const parentId = env.RUCHER_SESSION_ID;\n if (!parentId || parentId === session.id || !carnet.sessions.get(parentId)) return session;\n let fork = carnet.sessions.setParent(session.id, parentId);\n carnet.memory.copyRepos(parentId, session.id);\n const kind = env.RUCHER_SESSION_KIND;\n if (kind === 'active' || kind === 'temp') {\n fork = carnet.sessions.setKind(session.id, kind, env.RUCHER_SESSION_NAME || null);\n }\n return fork;\n}\n\n// A fork inherits its parent's conversation, notes included.\nfunction startMemory(\n carnet: Carnet,\n session: Session,\n source: string,\n env: HookEnv,\n): string | undefined {\n const options = {\n maxCharacters: memoryMaxCharacters(env.RUCHER_MEMORY_MAX_CHARACTERS),\n halfLifeDays: memoryHalfLife(env.RUCHER_MEMORY_HALF_LIFE_DAYS),\n };\n if (source === 'startup' || source === 'clear') return carnet.memory.atStart(session, options);\n if (source === 'resume' || source === 'compact') return carnet.memory.ofSession(session, options);\n return undefined;\n}\n\nexport function handleSessionStart(\n carnet: Carnet,\n payload: HookSessionPayload,\n env: HookEnv,\n): SessionStartResult {\n let session = carnet.sessions.upsertFromHook(payload, env);\n const source = payload.source ?? '';\n if (source === 'fork') session = adoptFork(carnet, session, env);\n const event = SOURCE_EVENTS[source];\n if (event) carnet.events.log(session.id, { type: event });\n session = carnet.sessions.setStatus(session.id, 'running');\n carnet.sessions.purge(session.id, purgeDays(env.RUCHER_PURGE_DAYS));\n\n const promptEnv = { RUCHER_HOME: env.RUCHER_HOME };\n const launchedVersion = env.RUCHER_PROMPT_VERSION || null;\n const contextParts: string[] = [];\n const notices: string[] = [];\n if (hostById(session.host).rendersSystemPrompt(source)) {\n session = carnet.sessions.recordPromptVersion(session.id, launchedVersion);\n }\n if (source === 'resume') contextParts.push(resumeContext(carnet, session));\n const memory = startMemory(carnet, session, source, env);\n if (memory) contextParts.push(memory);\n if (source === 'compact' && !launchedVersion) {\n contextParts.push(compactReminder(carnet.group, promptEnv));\n } else if (!env.RUCHER_SESSION_ID && !session.promptVersion) {\n contextParts.push(OUTSIDE_RUCHER_CONTEXT);\n notices.push(OUTSIDE_RUCHER_NOTICE);\n } else if (\n session.promptVersion &&\n session.promptVersion !== rulesVersion(carnet.group, promptEnv)\n ) {\n notices.push(RULES_UPDATED_NOTICE);\n }\n const additionalContext = contextParts.length ? contextParts.join('\\n\\n') : undefined;\n return { session, contextParts, notices, ...(additionalContext ? { additionalContext } : {}) };\n}\n","import type { Carnet } from '../carnet.ts';\nimport type { Host, HostPromptPayload } from '../hosts/host.ts';\nimport type { Session } from '../sessions.ts';\n\nexport function handleUserPromptSubmit(\n carnet: Carnet,\n host: Host,\n payload: HostPromptPayload,\n): Session {\n carnet.sessions.ensure(payload.session_id, payload.cwd);\n carnet.notes.recordActiveDay();\n return carnet.sessions.adoptTitle(payload.session_id, host.promptTitle(payload));\n}\n","import type { Carnet } from '../carnet.ts';\nimport { repoNameFor } from '../group/locate.ts';\nimport type { HostToolPayload } from '../hosts/host.ts';\nimport { memoryMaxCharacters } from '../memory.ts';\nimport { memoryHalfLife } from '../notes.ts';\nimport type { HookEnv } from '../sessions.ts';\n\nexport function handleToolUse(\n carnet: Carnet,\n payload: HostToolPayload,\n env: HookEnv,\n): string | undefined {\n // session_repos tracks the main conversation; a subagent's context is not it.\n if (payload.agent_id) return undefined;\n const repo = repoNameFor(carnet.group, payload.path);\n if (!repo) return undefined;\n const session = carnet.sessions.ensure(payload.session_id, payload.cwd);\n return carnet.memory.forRepo(session, repo, {\n maxCharacters: memoryMaxCharacters(env.RUCHER_MEMORY_MAX_CHARACTERS),\n halfLifeDays: memoryHalfLife(env.RUCHER_MEMORY_HALF_LIFE_DAYS),\n });\n}\n"],"mappings":";;;;;AAuBA,SAAS,eAAe,MAAc,MAAuB;CAC3D,cAAc,KAAK,MAAM,iBAAiB,UAAU,GAAG,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE,GAAG;AAC7F;AAEA,SAAS,YAAY,MAAc,MAAsB;CACvD,MAAM,OAAO,QAAQ,MAAM,IAAI;CAC/B,IAAI,CAAC,WAAW,IAAI,GAClB,MAAM,IAAI,YAAY,kBAAkB,6BAA6B,MAAM;CAC7E,OAAO;AACT;AAEA,SAAgB,UAAU,WAAmB,UAAuB,CAAC,GAAU;CAC7E,MAAM,OAAO,QAAQ,SAAS;CAC9B,MAAM,iBAAiB,KAAK,MAAM,eAAe;CACjD,IAAI,WAAW,cAAc,GAC3B,MAAM,IAAI,YAAY,gBAAgB,GAAG,KAAK,2BAA2B;CAE3E,MAAM,OAAO,QAAQ,QAAQ,SAAS,IAAI;CAC1C,MAAM,QAAQ,CAAC,GAAG,IAAI,KAAK,QAAQ,SAAS,CAAC,EAAA,CAAG,KAAK,SAAS,YAAY,MAAM,IAAI,CAAC,CAAC,CAAC;CACvF,MAAM,QAAQ,MAAM,KAAK,SAAS,SAAS,IAAI,CAAC;CA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AC5E,OAAO;EAAE;EAAS;EAAc;EAAS,GAAI,oBAAoB,EAAE,kBAAkB,IAAI,CAAC;CAAG;AAC/F;;AC1FA,SAAgB,uBACd,QACA,MACA,SACS;CACT,OAAO,SAAS,OAAO,QAAQ,YAAY,QAAQ,GAAG;CACtD,OAAO,MAAM,gBAAgB;CAC7B,OAAO,OAAO,SAAS,WAAW,QAAQ,YAAY,KAAK,YAAY,OAAO,CAAC;AACjF;;ACLA,SAAgB,cACd,QACA,SACA,KACoB;CAEpB,IAAI,QAAQ,UAAU,OAAO,KAAA;CAC7B,MAAM,OAAO,YAAY,OAAO,OAAO,QAAQ,IAAI;CACnD,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,MAAM,UAAU,OAAO,SAAS,OAAO,QAAQ,YAAY,QAAQ,GAAG;CACtE,OAAO,OAAO,OAAO,QAAQ,SAAS,MAAM;EAC1C,eAAe,oBAAoB,IAAI,4BAA4B;EACnE,cAAc,eAAe,IAAI,4BAA4B;CAC/D,CAAC;AACH"}
|
package/dist/mcp.d.mts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { r as OpenCarnetOptions, t as Carnet, vt as Host } from "./carnet-CsFtIv2C.mjs";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
|
+
import { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
|
|
4
|
+
import * as z from "zod/v4";
|
|
5
|
+
export declare const INSTRUCTIONS = "Carnet tracks sub-agents (forks), the \"On the table\" line, sessions, the journal and the group memory, in a shared database the `rucher` CLI renders. Status goes through these tools only: never status files, never status updates in the chat. Your session is resolved automatically; pass `session` only to target another one. The full workflow is the rucher skill: load it before dispatching, applying or reviewing forks.\n\nMain agent:\n- agent_start before dispatching a fork (name, task), in an earlier message than the launch. Launch it with the agent name as the Agent description and a prompt starting with \"You are fork `<name>`.\" Names are short, no paths.\n- table_set with main_working=true before applying, testing or fixing yourself; table_set with a status, or table_clear, when done.\n- log_event when a step is answered, applied, tested, committed or dropped.\n- When a fork finishes: say only \"<name> finished, report ready\", copy its report to the destination agent_start gave and call agent_update with that report_path. Present a fork's report only when the human asks for it: never summarise or act on it, or on the fork's final message, before.\n- agent_update to move an agent to the next human action; agent_drop once committed or abandoned; queue_reorder to change the order; agent_list to recall where things stand.\n- note_add at the end of a step for what was learned, decided or ruled out; note_drop with the reason when a note proves wrong; promote the Learnings of fork reports.\n- session_new when the human names this session; session_list, session_resume_info and log_read to recall sessions or the journal; session_drop only when the human asks.\n\nForks:\n- agent_update (status running, short note) at meaningful progress.\n- agent_done with the report path as your LAST tool action, has_questions=true when the report asks the human something, then reply with one line that carries no results (\"<name> done, report written\").\n- Never agent_start, table_set or note_add: end the report with a Learnings section. Both roles: note_cite when a note changed what you did.\n\nStatuses (the NEXT action): running ⏳ fork working · discussing 💬 · answer ❓ · review 👀 · apply 📥 · test 🧪 · commit ✅ · branch 🌿. Notes and table text: under 60 characters, no paths, no backticks.";
|
|
6
|
+
interface SessionResolverOptions {
|
|
7
|
+
carnet: Carnet;
|
|
8
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
9
|
+
ppid?: number | undefined;
|
|
10
|
+
cwd?: string | undefined;
|
|
11
|
+
host?: Host | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface SessionResolver {
|
|
14
|
+
resolve(override?: string): string;
|
|
15
|
+
}
|
|
16
|
+
export declare function createSessionResolver({ carnet, env, ppid, cwd, host }: SessionResolverOptions): SessionResolver;
|
|
17
|
+
export declare const SERVER_NAME = "carnet";
|
|
18
|
+
export declare const SERVER_VERSION = "0.0.0";
|
|
19
|
+
interface CarnetServerOptions extends Omit<SessionResolverOptions, 'carnet'> {
|
|
20
|
+
carnet: Carnet | (() => Carnet);
|
|
21
|
+
}
|
|
22
|
+
export declare function createCarnetServer(options: CarnetServerOptions): McpServer;
|
|
23
|
+
interface ServeCarnetOptions extends OpenCarnetOptions {
|
|
24
|
+
carnet?: Carnet;
|
|
25
|
+
ppid?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function serveCarnet(options?: ServeCarnetOptions): StdioServerHandle;
|
|
28
|
+
interface ToolOutput {
|
|
29
|
+
text: string;
|
|
30
|
+
data?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface ToolDefinition<Schema extends z.ZodObject = z.ZodObject> {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
schema: Schema;
|
|
36
|
+
run: (carnet: Carnet, sessionId: string, args: z.infer<Schema>) => ToolOutput;
|
|
37
|
+
}
|
|
38
|
+
export declare const TOOLS: readonly ToolDefinition[];
|
|
39
|
+
export type { CarnetServerOptions, ServeCarnetOptions, SessionResolver, SessionResolverOptions, ToolDefinition, ToolOutput };
|
|
40
|
+
//# sourceMappingURL=mcp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp/instructions.ts","../src/mcp/session.ts","../src/mcp/server.ts","../src/mcp/tools.ts"],"mappings":";;;;qBAAa;UCMI;EACf,QAAQ;EACR,MAAM,OAAO;EACb;EACA;EACA,OAAO;;UAGQ;EACf,QAAQ;;wBAGM,wBACd,QACA,KACA,MACA,KACA,QACC,yBAAyB;qBCXf;qBACA;UAEI,4BAA4B,KAAK;EAChD,QAAQ,gBAAgB;;wBAOV,mBAAmB,SAAS,sBAAsB;UAgCjD,2BAA2B;EAC1C,SAAS;EACT;;wBAGc,YAAY,UAAS,qBAA0B;UClD9C;EACf;EACA,OAAO;;UAGQ,eAAe,eAAe,EAAE,YAAY,EAAE;EAC7D;EACA;EACA,QAAQ;EACR,MAAM,QAAQ,QAAQ,mBAAmB,MAAM,EAAE,MAAM,YAAY;;qBA+YxD,gBAAgB"}
|