@rucher/carnet 0.2.0-beta.0 → 0.2.0-beta.2
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-CsFtIv2C.d.mts → carnet-Dbkz_bzM.d.mts} +9 -4
- package/dist/carnet-Dbkz_bzM.d.mts.map +1 -0
- package/dist/index.d.mts +29 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +91 -5
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +2 -3
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +78 -130
- package/dist/mcp.mjs.map +1 -1
- package/dist/{resume-CQRf2jIa.mjs → steps-CIQ9Nay1.mjs} +105 -13
- package/dist/steps-CIQ9Nay1.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/carnet-CsFtIv2C.d.mts.map +0 -1
- package/dist/resume-CQRf2jIa.mjs.map +0 -1
|
@@ -12,6 +12,7 @@ declare const MAIN_WORKING_EMOJI = "⚙️";
|
|
|
12
12
|
declare const LEGEND = "⚙️ main working · 💬 discussing · ❓ answer · 👀 review · 📥 apply · 🧪 test · ✅ commit · 🌿 branch · ⏳ running";
|
|
13
13
|
declare function isAgentStatus(value: unknown): value is AgentStatus;
|
|
14
14
|
declare function isUserActionStatus(value: unknown): value is UserActionStatus;
|
|
15
|
+
declare const OPEN_AGENT_STATUSES: readonly ["running", "discussing", "answer", "review", "apply", "test", "commit", "branch"];
|
|
15
16
|
interface Agent {
|
|
16
17
|
session: string;
|
|
17
18
|
name: string;
|
|
@@ -75,8 +76,11 @@ declare function loadGroup(root: string): Group;
|
|
|
75
76
|
interface LocateOptions {
|
|
76
77
|
cwd?: string;
|
|
77
78
|
env?: NodeJS.ProcessEnv;
|
|
79
|
+
sessionId?: string | undefined;
|
|
78
80
|
}
|
|
79
|
-
declare function
|
|
81
|
+
declare function pinnedGroup(env: NodeJS.ProcessEnv): Group | null;
|
|
82
|
+
declare function locateGroup({ cwd, env, sessionId }?: LocateOptions): Group;
|
|
83
|
+
declare function ambiguousGroupContext(reason: string): string;
|
|
80
84
|
interface HostSessionPayload {
|
|
81
85
|
session_id: string;
|
|
82
86
|
cwd?: string | undefined;
|
|
@@ -211,7 +215,7 @@ interface TableItem {
|
|
|
211
215
|
}
|
|
212
216
|
interface SetTableInput {
|
|
213
217
|
text: string;
|
|
214
|
-
mainWorking
|
|
218
|
+
mainWorking?: boolean | undefined;
|
|
215
219
|
status?: UserActionStatus | undefined;
|
|
216
220
|
}
|
|
217
221
|
declare const EVENT_TYPES: readonly ['started', 'finished', 'answered', 'applied', 'tested', 'committed', 'dropped'];
|
|
@@ -443,5 +447,6 @@ interface OpenCarnetOptions extends LocateOptions, CarnetOptions {
|
|
|
443
447
|
dbPath?: string;
|
|
444
448
|
}
|
|
445
449
|
declare function openCarnet(options?: OpenCarnetOptions): Carnet;
|
|
446
|
-
|
|
447
|
-
|
|
450
|
+
declare function openGroupCarnet(group: Group, options?: OpenCarnetOptions): Carnet;
|
|
451
|
+
export { EventType as $, UpdateAgentInput as $t, DEFAULT_HALF_LIFE_DAYS as A, GROUP_DIRECTORY as At, NoteDetail as B, loadGroup as Bt, StatusLine as C, HostSubagentPayload as Ct, AddNoteInput as D, allHosts as Dt, formatClock as E, ResumeCommand as Et, NOTE_TEXT_LIMIT as F, REPORTS_DIRECTORY as Ft, isNoteKind as G, reportPathFor as Gt, STALE_AFTER_ACTIVE_DAYS as H, pinnedGroup as Ht, Note as I, ambiguousGroupContext as It, sessionNoteActivity as J, FinishAgentInput as Jt, localDay as K, reportsDirectoryOf as Kt, NoteActivity as L, findGroupRoot as Lt, DropNoteInput as M, Group as Mt, ListNotesOptions as N, GroupFile as Nt, AddNoteResult as O, hostById as Ot, NOTE_KINDS as P, LocateOptions as Pt, EVENT_TYPES as Q, StartAgentInput as Qt, NoteActivityKind as R, isGroupRoot as Rt, renderMemory as S, HostSessionPayload as St, buildStatusView as T, LaunchOptions as Tt, WeightedNote as U, repoNameFor as Ut, NoteKind as V, locateGroup as Vt, groupRepoNames as W, repoPathFor as Wt, AgentEventType as X, PUBLISH_FALLBACK_MILLISECONDS as Xt, similarity as Y, ListAgentsOptions as Yt, CarnetEvent as Z, REPORTING_NOTE as Zt, renderStatus as _, ContextFileResult as _t, openGroupCarnet as a, OPEN_AGENT_STATUSES as an, TableItem as at, MemoryOptions as b, HostPromptPayload as bt, NOTES_HEADER as c, isAgentStatus as cn, HookEnv as ct, SIMILAR_PREFIX as d, MINIMUM_ID_PREFIX as dt, AGENT_STATUSES as en, LogEventInput as et, renderAgentLine as f, Session as ft, renderSections as g, ContextFile as gt, renderNotesSummary as h, shortId as ht, openCarnet as i, MAIN_WORKING_EMOJI as in, SetTableInput as it, DUPLICATE_SIMILARITY as j, GROUP_FILE as jt, CiteNoteInput as k, DB_FILE as kt, NotesMode as l, isUserActionStatus as ln, HookSessionPayload as lt, renderNotes as m, SessionStatus as mt, CarnetOptions as n, EMOJI as nn, SessionEventType as nt, MAIN_WORKING_SUFFIX as o, USER_ACTION_STATUSES as on, MergeResult as ot, renderNoteLine as p, SessionKind as pt, memoryHalfLife as q, Agent as qt, OpenCarnetOptions as r, LEGEND as rn, isEventType as rt, NOTES_FOLD_LINES as s, UserActionStatus as sn, CreateSessionInput as st, Carnet as t, AgentStatus as tn, SESSION_EVENT_TYPES as tt, RenderOptions as u, ListSessionsOptions as ut, renderTableLine as v, DEFAULT_HOST as vt, StatusView as w, HostToolPayload as wt, memoryMaxCharacters as x, HostSessionEndPayload as xt, MEMORY_MAX_CHARACTERS as y, Host as yt, NoteCitation as z, isInside as zt };
|
|
452
|
+
//# sourceMappingURL=carnet-Dbkz_bzM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carnet-Dbkz_bzM.d.mts","names":["_$__merge_ts0.MergeResult","_$__agents_ts0.Agent","_$__table_ts0.TableItem","_$__events_ts0.CarnetEvent","_$__notes_ts0.AddNoteResult","_$__notes_ts0.Note","_$__notes_ts0.NoteDetail","_$__notes_ts0.WeightedNote","_$__notes_ts0.NoteCitation","_$__notes_ts0.NoteActivity","_$__status_view_ts0.StatusView"],"sources":["../src/context.ts","../src/status/model.ts","../src/agents.ts","../src/group/locate.ts","../src/hosts/host.ts","../src/sessions.ts","../src/merge.ts","../src/table.ts","../src/events.ts","../src/notes.ts","../src/status/view.ts","../src/memory.ts","../src/status/render.ts","../src/carnet.ts"],"mappings":";UAEiB;EACf,IAAI;EACJ,WAAW;;cCJA;KAYD,sBAAsB;cAErB;KAUD,2BAA2B;cAE1B,OAAO,OAAO,QAAQ;cAWtB;cAEA;iBAGG,cAAc,iBAAiB,SAAS;iBAIxC,mBAAmB,iBAAiB,SAAS;cAIhD;UC5CI;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf,QAAQ;EACR;EACA;;UAGe;EACf;EACA;;UAGe;EACf;;cAuCW;cACA;cC3EA;cACA;cACA;cACA;UAEI;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;iBAGc,SAAS,mBAAmB;iBAQ5B,YAAY,OAAO,OAAO;iBAM1B,YAAY,OAAO,OAAO;iBAS1B,cAAc;iBAWd,mBAAmB,OAAO;iBAI1B,cAAc,OAAO,OAAO;iBAI5B,YAAY;iBAIZ,UAAU,eAAe;UAaxB;EACf;EACA,MAAM,OAAO;EACb;;iBAyBc,YAAY,KAAK,OAAO,aAAa;iBAKrC,cACd,KACA,KACA,cACC,gBAAqB;iBA6BR,sBAAsB;UClJrB;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA,KAAK,OAAO,OAAO,0BA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AC;IAChB,SAAM,SAAY,SAAO,UAAY;IAErC,WAAQ,SAAY;;EAGtB;;UAKe,0BAA0B,eAAe;EACxD;;iBAGc,WAAW,UAAS,oBAAyB;iBAI7C,gBAAgB,OAAO,OAAO,UAAS,oBAAyB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as EventType, $t as UpdateAgentInput, A as DEFAULT_HALF_LIFE_DAYS, At as GROUP_DIRECTORY, B as NoteDetail, Bt as loadGroup, C as StatusLine, Ct as HostSubagentPayload, D as AddNoteInput, Dt as allHosts, E as formatClock, Et as ResumeCommand, F as NOTE_TEXT_LIMIT, Ft as REPORTS_DIRECTORY, G as isNoteKind, Gt as reportPathFor, H as STALE_AFTER_ACTIVE_DAYS, Ht as pinnedGroup, I as Note, It as ambiguousGroupContext, J as sessionNoteActivity, Jt as FinishAgentInput, K as localDay, Kt as reportsDirectoryOf, L as NoteActivity, Lt as findGroupRoot, M as DropNoteInput, Mt as Group, N as ListNotesOptions, Nt as GroupFile, O as AddNoteResult, Ot as hostById, P as NOTE_KINDS, Pt as LocateOptions, Q as EVENT_TYPES, Qt as StartAgentInput, R as NoteActivityKind, Rt as isGroupRoot, S as renderMemory, St as HostSessionPayload, T as buildStatusView, Tt as LaunchOptions, U as WeightedNote, Ut as repoNameFor, V as NoteKind, Vt as locateGroup, W as groupRepoNames, Wt as repoPathFor, X as AgentEventType, Xt as PUBLISH_FALLBACK_MILLISECONDS, Y as similarity, Yt as ListAgentsOptions, Z as CarnetEvent, Zt as REPORTING_NOTE, _ as renderStatus, _t as ContextFileResult, a as openGroupCarnet, an as OPEN_AGENT_STATUSES, at as TableItem, b as MemoryOptions, bt as HostPromptPayload, c as NOTES_HEADER, cn as isAgentStatus, ct as HookEnv, d as SIMILAR_PREFIX, dt as MINIMUM_ID_PREFIX, en as AGENT_STATUSES, et as LogEventInput, f as renderAgentLine, ft as Session, g as renderSections, gt as ContextFile, h as renderNotesSummary, ht as shortId, i as openCarnet, in as MAIN_WORKING_EMOJI, it as SetTableInput, j as DUPLICATE_SIMILARITY, jt as GROUP_FILE, k as CiteNoteInput, kt as DB_FILE, l as NotesMode, ln as isUserActionStatus, lt as HookSessionPayload, m as renderNotes, mt as SessionStatus, n as CarnetOptions, nn as EMOJI, nt as SessionEventType, o as MAIN_WORKING_SUFFIX, on as USER_ACTION_STATUSES, ot as MergeResult, p as renderNoteLine, pt as SessionKind, q as memoryHalfLife, qt as Agent, r as OpenCarnetOptions, rn as LEGEND, rt as isEventType, s as NOTES_FOLD_LINES, sn as UserActionStatus, st as CreateSessionInput, t as Carnet, tn as AgentStatus, tt as SESSION_EVENT_TYPES, u as RenderOptions, ut as ListSessionsOptions, v as renderTableLine, vt as DEFAULT_HOST, w as StatusView, wt as HostToolPayload, x as memoryMaxCharacters, xt as HostSessionEndPayload, y as MEMORY_MAX_CHARACTERS, yt as Host, z as NoteCitation, zt as isInside } from "./carnet-Dbkz_bzM.mjs";
|
|
2
2
|
import { DatabaseSync } from "node:sqlite";
|
|
3
|
+
interface MoveOptions {
|
|
4
|
+
merge?: boolean | undefined;
|
|
5
|
+
dryRun?: boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface MoveResult {
|
|
8
|
+
session: Session;
|
|
9
|
+
into: Session | null;
|
|
10
|
+
movedAgents: string[];
|
|
11
|
+
skippedAgents: string[];
|
|
12
|
+
movedEvents: number;
|
|
13
|
+
movedTable: boolean;
|
|
14
|
+
unlinkedNotes: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function moveSession(source: Carnet, sessionId: string, target: Carnet, options?: MoveOptions): MoveResult;
|
|
3
17
|
export declare const MEMORY_DB = ":memory:";
|
|
4
18
|
export declare function openDatabase(path: string): DatabaseSync;
|
|
5
19
|
export declare const migrations: readonly string[];
|
|
6
20
|
export declare function schemaVersion(db: DatabaseSync): number;
|
|
7
21
|
export declare function migrate(db: DatabaseSync): void;
|
|
8
|
-
type CarnetErrorCode = 'NO_GROUP' | 'GROUP_EXISTS' | 'REPO_NOT_FOUND' | 'REPO_NAME_TAKEN' | 'NOTE_NOT_FOUND' | 'INVALID_NOTE' | 'UNKNOWN_HOST' | 'NO_SESSION' | 'SESSION_NOT_FOUND' | 'SESSION_AMBIGUOUS' | 'SESSION_NAME_TAKEN' | 'SESSION_NAME_REQUIRED' | 'SESSION_RUNNING' | 'SESSION_KIND_INVALID' | 'SESSION_MERGE_INVALID' | 'AGENT_EXISTS' | 'AGENT_NOT_FOUND' | 'INVALID_STATUS' | 'INVALID_EVENT_TYPE' | 'TABLE_STATUS_WITH_MAIN_WORKING';
|
|
22
|
+
type CarnetErrorCode = 'NO_GROUP' | 'GROUP_AMBIGUOUS' | 'GROUP_EXISTS' | 'REPO_NOT_FOUND' | 'REPO_NAME_TAKEN' | 'NOTE_NOT_FOUND' | 'INVALID_NOTE' | 'UNKNOWN_HOST' | 'NO_SESSION' | 'SESSION_NOT_FOUND' | 'SESSION_AMBIGUOUS' | 'SESSION_NAME_TAKEN' | 'SESSION_NAME_REQUIRED' | 'SESSION_RUNNING' | 'SESSION_KIND_INVALID' | 'SESSION_MERGE_INVALID' | 'SESSION_EXISTS' | 'SESSION_MOVE_INVALID' | 'AGENT_EXISTS' | 'AGENT_NOT_FOUND' | 'INVALID_STATUS' | 'INVALID_EVENT_TYPE' | 'COMMIT_REQUIRED' | 'TABLE_STATUS_WITH_MAIN_WORKING';
|
|
9
23
|
export declare class CarnetError extends Error {
|
|
10
24
|
readonly code: CarnetErrorCode;
|
|
11
25
|
constructor(code: CarnetErrorCode, message: string);
|
|
@@ -57,7 +71,7 @@ export declare function rulesVersion(group: Group, env?: NodeJS.ProcessEnv): str
|
|
|
57
71
|
export declare function assemblePrompt(group: Group, session: PromptSession, env?: NodeJS.ProcessEnv): AssembledPrompt;
|
|
58
72
|
export declare function appendPromptFile(group: Group, session: PromptSession, env?: NodeJS.ProcessEnv): AppendPromptFile;
|
|
59
73
|
export declare function compactReminder(group: Group, env?: NodeJS.ProcessEnv): string;
|
|
60
|
-
export declare
|
|
74
|
+
export declare function outsideRucherContext(group: Group, env?: NodeJS.ProcessEnv): string;
|
|
61
75
|
export declare const OUTSIDE_RUCHER_NOTICE = "rucher: session started without rucher, the Rucher rules are not in its system prompt (use rucher new, tmp or resume)";
|
|
62
76
|
export declare const RULES_UPDATED_NOTICE = "rucher: rules updated, will apply after the next compaction or in a new session";
|
|
63
77
|
export declare 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.";
|
|
@@ -87,5 +101,16 @@ export declare const PAIRING_WINDOW_MILLISECONDS = 60000;
|
|
|
87
101
|
export declare const STOPPED_NOTE = "stopped without agent_done";
|
|
88
102
|
export declare const NOTE_MAX = 60;
|
|
89
103
|
export declare function sanitizeNote(text: string): string;
|
|
90
|
-
|
|
104
|
+
type OpenAgentStatus = (typeof OPEN_AGENT_STATUSES)[number];
|
|
105
|
+
export declare const AGENT_STEPS: readonly ['answered', 'applying', 'applied', 'tested', 'committed', 'dropped'];
|
|
106
|
+
type AgentStep = (typeof AGENT_STEPS)[number];
|
|
107
|
+
interface StepAgentInput {
|
|
108
|
+
name: string;
|
|
109
|
+
step: AgentStep;
|
|
110
|
+
commit?: string | undefined;
|
|
111
|
+
note?: string | undefined;
|
|
112
|
+
next?: OpenAgentStatus | undefined;
|
|
113
|
+
}
|
|
114
|
+
export declare function stepAgent(carnet: Carnet, session: string, input: StepAgentInput): string;
|
|
115
|
+
export { AGENT_STATUSES, type AddNoteInput, type AddNoteResult, type Agent, type AgentEventType, type AgentStatus, type AgentStep, type AppendPromptFile, type AssembledPrompt, Carnet, type CarnetErrorCode, type CarnetEvent, type CarnetOptions, type CiteNoteInput, type ContextFile, type ContextFileResult, type CreateSessionInput, DB_FILE, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DUPLICATE_SIMILARITY, type DropNoteInput, EMOJI, EVENT_TYPES, type EventType, type FinishAgentInput, GROUP_DIRECTORY, GROUP_FILE, type Group, type GroupFile, type GroupReference, type HookEnv, type HookSessionPayload, type Host, type HostPromptPayload, type HostSessionEndPayload, type HostSessionPayload, type HostSubagentPayload, type HostToolPayload, type InitOptions, LEGEND, type LaunchOptions, type ListAgentsOptions, type ListNotesOptions, type ListSessionsOptions, type LocateOptions, type LogEventInput, MAIN_WORKING_EMOJI, MAIN_WORKING_SUFFIX, MEMORY_MAX_CHARACTERS, MINIMUM_ID_PREFIX, type MemoryOptions, type MergeResult, type MoveOptions, type MoveResult, NOTES_FOLD_LINES, NOTES_HEADER, NOTE_KINDS, NOTE_TEXT_LIMIT, type Note, type NoteActivity, type NoteActivityKind, type NoteCitation, type NoteDetail, type NoteKind, type NotesMode, type OpenCarnetOptions, PUBLISH_FALLBACK_MILLISECONDS, type PromptSession, REPORTING_NOTE, REPORTS_DIRECTORY, type RenderOptions, type ResumeCommand, type ResumeContextOptions, SESSION_EVENT_TYPES, SIMILAR_PREFIX, STALE_AFTER_ACTIVE_DAYS, type Session, type SessionEventType, type SessionKind, type SessionStartResult, type SessionStatus, type SetTableInput, type StartAgentInput, type StatusLine, type StatusView, type StepAgentInput, type TableItem, USER_ACTION_STATUSES, type UpdateAgentInput, type UserActionStatus, type WeightedNote, allHosts, ambiguousGroupContext, buildStatusView, findGroupRoot, formatClock, groupRepoNames, hostById, isAgentStatus, isEventType, isGroupRoot, isInside, isNoteKind, isUserActionStatus, loadGroup, localDay, locateGroup, memoryHalfLife, memoryMaxCharacters, openCarnet, openGroupCarnet, pinnedGroup, renderAgentLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderSections, renderStatus, renderTableLine, repoNameFor, repoPathFor, reportPathFor, reportsDirectoryOf, sessionNoteActivity, shortId, similarity };
|
|
91
116
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/db/open.ts","../src/db/schema.ts","../src/errors.ts","../src/group/init.ts","../src/group/registry.ts","../src/hook/session-end.ts","../src/hook/session-start.ts","../src/prompt/prompt.ts","../src/prompt/core-rules.ts","../src/hook/user-prompt-submit.ts","../src/hook/post-tool-use.ts","../src/hosts/claude-code.ts","../src/purge.ts","../src/resume.ts","../src/subagents.ts","../src/status/note.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/move.ts","../src/db/open.ts","../src/db/schema.ts","../src/errors.ts","../src/group/init.ts","../src/group/registry.ts","../src/hook/session-end.ts","../src/hook/session-start.ts","../src/prompt/prompt.ts","../src/prompt/core-rules.ts","../src/hook/user-prompt-submit.ts","../src/hook/post-tool-use.ts","../src/hosts/claude-code.ts","../src/purge.ts","../src/resume.ts","../src/subagents.ts","../src/status/note.ts","../src/steps.ts"],"mappings":";;UAKiB;EACf;EACA;;UAGe;EACf,SAAS;EACT,MAAM;EACN;EACA;EACA;EACA;EACA;;wBA8Cc,YACd,QAAQ,QACR,mBACA,QAAQ,QACR,UAAS,cACR;qBCjEU;wBAEG,aAAa,eAAe;qBCH/B;wBAgLG,cAAc,IAAI;wBASlB,QAAQ,IAAI;KC3LhB;qBA0BC,oBAAoB;WAEpB,MAAM;EADjB,YACW,MAAM,iBACf;;UCba;EACf;EACA;EACA;EACA,MAAM,OAAO;;wBAcC,UAAU,mBAAmB,UAAS,cAAmB;wBA0BzD,aAAa,cAAc,eAAe;wBAuB1C,gBAAgB,cAAc,eAAe;UC/E5C;EACf;EACA;;wBAOc,WAAW,MAAK,OAAO;wBAQvB,aAAa,MAAM,OAAO,aAAa;wBAmBvC,cACd,WAAW,gBACX,MAAM,OAAO,aACZ;wBAOa,iBAAiB,iBAAiB,MAAM,OAAO,aAAa;wBC9C5D,iBACd,QAAQ,QACR,SAAS,wBACR;UCSc;EACf,SAAS;EACT;EACA;EACA;;wBAsCc,mBACd,QAAQ,QACR,SAAS,oBACT,KAAK,UACJ;qBCtDU;qBACA;UAEI;EACf;EACA;EACA,MAAM;;UAGS;EACf;EACA;;UAGe;EACf;EACA;;wBASc,UAAU,MAAK,OAAO;wBAItB,WAAW,OAAO;wBAIlB,UAAU,OAAO,OAAO,MAAK,OAAO;wBAOpC,aAAa,OAAO,OAAO,MAAK,OAAO;wBAIvC,eACd,OAAO,OACP,SAAS,eACT,MAAK,OAAO,aACX;wBAMa,iBACd,OAAO,OACP,SAAS,eACT,MAAK,OAAO,aACX;wBASa,gBAAgB,OAAO,OAAO,MAAK,OAAO;wBAI1C,qBAAqB,OAAO,OAAO,MAAK,OAAO;qBAIlD;qBAGA;qBAGA;qBCxFA;wBCGG,uBACd,QAAQ,QACR,MAAM,MACN,SAAS,oBACR;wBCDa,cACd,QAAQ,QACR,SAAS,iBACT,KAAK;qBCmBM;qBACA;wBA6DG,gBAAgB;wBAkBhB,WAAW,OAAO;wBAOlB,kBAAkB,iBAAiB,OAAO;wBAO1C,kBAAkB,OAAO;wBAiBzB,cAAc,OAAO;qBA6DxB,YAAY;qBCvMZ;wBAGG,UAAU;qBCAb;qBACA;UAEI;EACf;EACA;;wBAGc,gBAAgB,OAAO;wBAYvB,aAAa,SAAS;wBAKtB,cACd,QAAQ,QACR,SAAS,WACP,QAAwB,kBAAyC;qBC7BxD;qBACA;qBCLA;wBAWG,aAAa;KCPxB,0BAA0B;qBAElB;KAQD,oBAAoB;UAEf;EACf;EACA,MAAM;EACN;EACA;EACA,OAAO;;wBAkBO,UAAU,QAAQ,QAAQ,iBAAiB,OAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,91 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as locateGroup, A as MEMORY_MAX_CHARACTERS, At as EMOJI, B as localDay, Bt as CarnetError, C as renderSections, Ct as migrations, D as purgeDays, Dt as NOTE_MAX, E as DEFAULT_PURGE_DAYS, Et as REPORTING_NOTE, F as NOTE_KINDS, Ft as isAgentStatus, G as GROUP_DIRECTORY, H as sessionNoteActivity, I as NOTE_TEXT_LIMIT, It as isUserActionStatus, J as ambiguousGroupContext, K as GROUP_FILE, L as STALE_AFTER_ACTIVE_DAYS, Lt as EVENT_TYPES, M as renderMemory, Mt as MAIN_WORKING_EMOJI, N as DEFAULT_HALF_LIFE_DAYS, O as MINIMUM_ID_PREFIX, Ot as sanitizeNote, P as DUPLICATE_SIMILARITY, Pt as USER_ACTION_STATUSES, Q as loadGroup, R as groupRepoNames, Rt as SESSION_EVENT_TYPES, S as renderNotesSummary, St as migrate, T as renderTableLine, Tt as PUBLISH_FALLBACK_MILLISECONDS, U as similarity, V as memoryHalfLife, W as DB_FILE, X as isGroupRoot, Y as findGroupRoot, Z as isInside, _ as NOTES_HEADER, _t as replaceReposBlock, a as formatEventLine, at as readRegistry, b as renderNoteLine, bt as MEMORY_DB, c as Carnet, ct as unregisterGroups, d as PAIRING_WINDOW_MILLISECONDS, dt as hostById, et as pinnedGroup, f as STOPPED_NOTE, ft as REPOS_END, g as NOTES_FOLD_LINES, gt as groupSettings, h as MAIN_WORKING_SUFFIX, ht as groupInstructions, i as RESUME_MAX_CHARACTERS, it as reportsDirectoryOf, j as memoryMaxCharacters, jt as LEGEND, k as shortId, kt as AGENT_STATUSES, l as openCarnet, lt as DEFAULT_HOST, m as formatClock, mt as claudeCode, n as stepAgent, nt as repoPathFor, o as resumeContext, ot as registerGroup, p as buildStatusView, pt as REPOS_START, q as REPORTS_DIRECTORY, r as RESUME_EVENTS, rt as reportPathFor, s as sessionLabel, st as rucherHome, t as AGENT_STEPS, tt as repoNameFor, u as openGroupCarnet, ut as allHosts, v as SIMILAR_PREFIX, vt as reposBlock, w as renderStatus, wt as schemaVersion, x as renderNotes, xt as openDatabase, y as renderAgentLine, yt as transcriptTitle, z as isNoteKind, zt as isEventType } from "./steps-CIQ9Nay1.mjs";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, join, resolve } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
+
// src/move.ts
|
|
6
|
+
function rows(db, sql, ...parameters) {
|
|
7
|
+
return db.prepare(sql).all(...parameters);
|
|
8
|
+
}
|
|
9
|
+
function count(db, sql, ...parameters) {
|
|
10
|
+
return Number(db.prepare(sql).get(...parameters).total);
|
|
11
|
+
}
|
|
12
|
+
function insert(db, table, row) {
|
|
13
|
+
const columns = Object.keys(row);
|
|
14
|
+
db.prepare(`INSERT INTO ${table} (${columns.join(", ")}) VALUES (${columns.map(() => "?").join(", ")})`).run(...columns.map((column) => row[column] ?? null));
|
|
15
|
+
}
|
|
16
|
+
function inTransaction(db, run) {
|
|
17
|
+
db.exec("BEGIN");
|
|
18
|
+
try {
|
|
19
|
+
run();
|
|
20
|
+
db.exec("COMMIT");
|
|
21
|
+
} catch (error) {
|
|
22
|
+
db.exec("ROLLBACK");
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function existingTarget(target, session, merge) {
|
|
27
|
+
const sameId = target.sessions.get(session.id);
|
|
28
|
+
const [named] = session.name ? rows(target.db, "SELECT id FROM sessions WHERE name = ?", session.name) : [];
|
|
29
|
+
const existing = sameId ?? (named ? target.sessions.get(named.id) : null) ?? null;
|
|
30
|
+
if (existing && !merge) throw new CarnetError(sameId ? "SESSION_EXISTS" : "SESSION_NAME_TAKEN", `Group ${target.group.name} already has session ${existing.name ?? existing.id}: pass --merge to merge into it`);
|
|
31
|
+
return existing;
|
|
32
|
+
}
|
|
33
|
+
function moveSession(source, sessionId, target, options = {}) {
|
|
34
|
+
if (source.group.root === target.group.root) throw new CarnetError("SESSION_MOVE_INVALID", "The session is already in this group");
|
|
35
|
+
const session = source.sessions.require(sessionId);
|
|
36
|
+
const into = existingTarget(target, session, options.merge === true);
|
|
37
|
+
const intoId = into?.id ?? session.id;
|
|
38
|
+
const takenNames = new Set(rows(target.db, "SELECT name FROM agents WHERE session = ?", intoId).map((row) => row.name));
|
|
39
|
+
const agents = rows(source.db, "SELECT * FROM agents WHERE session = ? ORDER BY started_at, rowid", session.id);
|
|
40
|
+
const movedAgents = agents.filter((agent) => !takenNames.has(agent.name));
|
|
41
|
+
const events = rows(source.db, "SELECT * FROM events WHERE session = ? ORDER BY at, id", session.id);
|
|
42
|
+
const [table] = rows(source.db, "SELECT * FROM table_items WHERE session = ?", session.id);
|
|
43
|
+
const targetHasTable = rows(target.db, "SELECT 1 FROM table_items WHERE session = ?", intoId).length > 0;
|
|
44
|
+
const movedTable = table !== void 0 && !targetHasTable;
|
|
45
|
+
const unlinkedNotes = count(source.db, "SELECT COUNT(*) AS total FROM notes WHERE session = ? OR dropped_session = ?", session.id, session.id);
|
|
46
|
+
const result = {
|
|
47
|
+
session,
|
|
48
|
+
into,
|
|
49
|
+
movedAgents: movedAgents.map((agent) => agent.name),
|
|
50
|
+
skippedAgents: agents.filter((agent) => takenNames.has(agent.name)).map((agent) => agent.name),
|
|
51
|
+
movedEvents: events.length,
|
|
52
|
+
movedTable,
|
|
53
|
+
unlinkedNotes
|
|
54
|
+
};
|
|
55
|
+
if (options.dryRun) return result;
|
|
56
|
+
inTransaction(target.db, () => {
|
|
57
|
+
if (!into) {
|
|
58
|
+
const [row] = rows(source.db, "SELECT * FROM sessions WHERE id = ?", session.id);
|
|
59
|
+
if (row) insert(target.db, "sessions", {
|
|
60
|
+
...row,
|
|
61
|
+
parent_id: null
|
|
62
|
+
});
|
|
63
|
+
} else if (into.name === null && session.name !== null) target.db.prepare("UPDATE sessions SET name = ?, kind = 'active' WHERE id = ?").run(session.name, intoId);
|
|
64
|
+
for (const agent of movedAgents) insert(target.db, "agents", {
|
|
65
|
+
...agent,
|
|
66
|
+
session: intoId
|
|
67
|
+
});
|
|
68
|
+
for (const { id: _id, ...event } of events) insert(target.db, "events", {
|
|
69
|
+
...event,
|
|
70
|
+
session: intoId
|
|
71
|
+
});
|
|
72
|
+
if (table && movedTable) insert(target.db, "table_items", {
|
|
73
|
+
...table,
|
|
74
|
+
session: intoId
|
|
75
|
+
});
|
|
76
|
+
for (const repo of rows(source.db, "SELECT * FROM session_repos WHERE session = ?", session.id)) target.db.prepare("INSERT OR IGNORE INTO session_repos (session, repo, injected_at) VALUES (?, ?, ?)").run(intoId, repo.repo ?? null, repo.injected_at ?? null);
|
|
77
|
+
});
|
|
78
|
+
inTransaction(source.db, () => {
|
|
79
|
+
for (const table of [
|
|
80
|
+
"agents",
|
|
81
|
+
"events",
|
|
82
|
+
"table_items"
|
|
83
|
+
]) source.db.prepare(`DELETE FROM ${table} WHERE session = ?`).run(session.id);
|
|
84
|
+
source.db.prepare("UPDATE sessions SET parent_id = NULL WHERE parent_id = ?").run(session.id);
|
|
85
|
+
source.db.prepare("DELETE FROM sessions WHERE id = ?").run(session.id);
|
|
86
|
+
});
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
5
89
|
// src/group/init.ts
|
|
6
90
|
function writeGroupFile(root, file) {
|
|
7
91
|
writeFileSync(join(root, GROUP_DIRECTORY, GROUP_FILE), `${JSON.stringify(file, null, 2)}\n`);
|
|
@@ -84,7 +168,7 @@ function groupRules(group) {
|
|
|
84
168
|
}
|
|
85
169
|
function rulesText(group, env = process.env) {
|
|
86
170
|
const extra = groupRules(group);
|
|
87
|
-
const base = `Rucher rules:\n${baseRules(env)}`;
|
|
171
|
+
const base = `Rucher rules, always follow them:\n${baseRules(env)}`;
|
|
88
172
|
return extra ? `${base}\n\nRules of the ${group.name} group:\n${extra}` : base;
|
|
89
173
|
}
|
|
90
174
|
function rulesVersion(group, env = process.env) {
|
|
@@ -111,7 +195,9 @@ function appendPromptFile(group, session, env = process.env) {
|
|
|
111
195
|
function compactReminder(group, env = process.env) {
|
|
112
196
|
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
197
|
}
|
|
114
|
-
|
|
198
|
+
function outsideRucherContext(group, env = process.env) {
|
|
199
|
+
return `This session was started without rucher, so its system prompt does not hold the Rucher rules. ${rulesText(group, env)}`;
|
|
200
|
+
}
|
|
115
201
|
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
202
|
const RULES_UPDATED_NOTICE = "rucher: rules updated, will apply after the next compaction or in a new session";
|
|
117
203
|
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.";
|
|
@@ -156,7 +242,7 @@ function handleSessionStart(carnet, payload, env) {
|
|
|
156
242
|
if (memory) contextParts.push(memory);
|
|
157
243
|
if (source === "compact" && !launchedVersion) contextParts.push(compactReminder(carnet.group, promptEnv));
|
|
158
244
|
else if (!env.RUCHER_SESSION_ID && !session.promptVersion) {
|
|
159
|
-
contextParts.push(
|
|
245
|
+
contextParts.push(outsideRucherContext(carnet.group, promptEnv));
|
|
160
246
|
notices.push(OUTSIDE_RUCHER_NOTICE);
|
|
161
247
|
} else if (session.promptVersion && session.promptVersion !== rulesVersion(carnet.group, promptEnv)) notices.push(RULES_UPDATED_NOTICE);
|
|
162
248
|
const additionalContext = contextParts.length ? contextParts.join("\n\n") : void 0;
|
|
@@ -184,6 +270,6 @@ function handleToolUse(carnet, payload, env) {
|
|
|
184
270
|
halfLifeDays: memoryHalfLife(env.RUCHER_MEMORY_HALF_LIFE_DAYS)
|
|
185
271
|
});
|
|
186
272
|
}
|
|
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,
|
|
273
|
+
export { AGENT_STATUSES, AGENT_STEPS, 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_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, ambiguousGroupContext, 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, moveSession, openCarnet, openDatabase, openGroupCarnet, outsideRucherContext, pinnedGroup, 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, stepAgent, transcriptTitle, unregisterGroups };
|
|
188
274
|
|
|
189
275
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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: memory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AAQ,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"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/move.ts","../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 type { DatabaseSync, SQLInputValue } from 'node:sqlite';\nimport type { Carnet } from './carnet.ts';\nimport { CarnetError } from './errors.ts';\nimport type { Session } from './sessions.ts';\n\nexport interface MoveOptions {\n merge?: boolean | undefined;\n dryRun?: boolean | undefined;\n}\n\nexport interface MoveResult {\n session: Session;\n into: Session | null;\n movedAgents: string[];\n skippedAgents: string[];\n movedEvents: number;\n movedTable: boolean;\n unlinkedNotes: number;\n}\n\ntype Row = Record<string, SQLInputValue>;\n\nfunction rows(db: DatabaseSync, sql: string, ...parameters: SQLInputValue[]): Row[] {\n return db.prepare(sql).all(...parameters) as Row[];\n}\n\nfunction count(db: DatabaseSync, sql: string, ...parameters: SQLInputValue[]): number {\n return Number((db.prepare(sql).get(...parameters) as { total: number }).total);\n}\n\nfunction insert(db: DatabaseSync, table: string, row: Row): void {\n const columns = Object.keys(row);\n db.prepare(\n `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${columns.map(() => '?').join(', ')})`,\n ).run(...columns.map((column) => row[column] ?? null));\n}\n\nfunction inTransaction(db: DatabaseSync, run: () => void): void {\n db.exec('BEGIN');\n try {\n run();\n db.exec('COMMIT');\n } catch (error) {\n db.exec('ROLLBACK');\n throw error;\n }\n}\n\nfunction existingTarget(target: Carnet, session: Session, merge: boolean): Session | null {\n const sameId = target.sessions.get(session.id);\n const [named] = session.name\n ? rows(target.db, 'SELECT id FROM sessions WHERE name = ?', session.name)\n : [];\n const existing = sameId ?? (named ? target.sessions.get(named.id as string) : null) ?? null;\n if (existing && !merge) {\n throw new CarnetError(\n sameId ? 'SESSION_EXISTS' : 'SESSION_NAME_TAKEN',\n `Group ${target.group.name} already has session ${existing.name ?? existing.id}: pass --merge to merge into it`,\n );\n }\n return existing;\n}\n\nexport function moveSession(\n source: Carnet,\n sessionId: string,\n target: Carnet,\n options: MoveOptions = {},\n): MoveResult {\n if (source.group.root === target.group.root) {\n throw new CarnetError('SESSION_MOVE_INVALID', 'The session is already in this group');\n }\n const session = source.sessions.require(sessionId);\n const into = existingTarget(target, session, options.merge === true);\n const intoId = into?.id ?? session.id;\n const takenNames = new Set(\n rows(target.db, 'SELECT name FROM agents WHERE session = ?', intoId).map((row) => row.name),\n );\n const agents = rows(\n source.db,\n 'SELECT * FROM agents WHERE session = ? ORDER BY started_at, rowid',\n session.id,\n );\n const movedAgents = agents.filter((agent) => !takenNames.has(agent.name));\n const events = rows(\n source.db,\n 'SELECT * FROM events WHERE session = ? ORDER BY at, id',\n session.id,\n );\n const [table] = rows(source.db, 'SELECT * FROM table_items WHERE session = ?', session.id);\n const targetHasTable =\n rows(target.db, 'SELECT 1 FROM table_items WHERE session = ?', intoId).length > 0;\n const movedTable = table !== undefined && !targetHasTable;\n const unlinkedNotes = count(\n source.db,\n 'SELECT COUNT(*) AS total FROM notes WHERE session = ? OR dropped_session = ?',\n session.id,\n session.id,\n );\n const result: MoveResult = {\n session,\n into,\n movedAgents: movedAgents.map((agent) => agent.name as string),\n skippedAgents: agents\n .filter((agent) => takenNames.has(agent.name))\n .map((agent) => agent.name as string),\n movedEvents: events.length,\n movedTable,\n unlinkedNotes,\n };\n if (options.dryRun) return result;\n\n inTransaction(target.db, () => {\n if (!into) {\n const [row] = rows(source.db, 'SELECT * FROM sessions WHERE id = ?', session.id);\n // The parent is a session of the source group, unknown here.\n if (row) insert(target.db, 'sessions', { ...row, parent_id: null });\n } else if (into.name === null && session.name !== null) {\n target.db\n .prepare(\"UPDATE sessions SET name = ?, kind = 'active' WHERE id = ?\")\n .run(session.name, intoId);\n }\n for (const agent of movedAgents) insert(target.db, 'agents', { ...agent, session: intoId });\n for (const { id: _id, ...event } of events) {\n insert(target.db, 'events', { ...event, session: intoId });\n }\n if (table && movedTable) insert(target.db, 'table_items', { ...table, session: intoId });\n for (const repo of rows(\n source.db,\n 'SELECT * FROM session_repos WHERE session = ?',\n session.id,\n )) {\n target.db\n .prepare(\n 'INSERT OR IGNORE INTO session_repos (session, repo, injected_at) VALUES (?, ?, ?)',\n )\n .run(intoId, repo.repo ?? null, repo.injected_at ?? null);\n }\n });\n\n // Notes belong to their group: they stay, only their link to the moved session goes.\n inTransaction(source.db, () => {\n for (const table of ['agents', 'events', 'table_items']) {\n source.db.prepare(`DELETE FROM ${table} WHERE session = ?`).run(session.id);\n }\n source.db.prepare('UPDATE sessions SET parent_id = NULL WHERE parent_id = ?').run(session.id);\n source.db.prepare('DELETE FROM sessions WHERE id = ?').run(session.id);\n });\n return result;\n}\n","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, always follow them:\\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 function outsideRucherContext(group: Group, env: NodeJS.ProcessEnv = process.env): string {\n return `This session was started without rucher, so its system prompt does not hold the Rucher rules. ${rulesText(group, env)}`;\n}\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 outsideRucherContext,\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(outsideRucherContext(carnet.group, promptEnv));\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":";;;;;AAsBA,SAAS,KAAK,IAAkB,KAAa,GAAG,YAAoC;CAClF,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,UAAU;AAC1C;AAEA,SAAS,MAAM,IAAkB,KAAa,GAAG,YAAqC;CACpF,OAAO,OAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAuB,KAAK;AAC/E;AAEA,SAAS,OAAO,IAAkB,OAAe,KAAgB;CAC/D,MAAM,UAAU,OAAO,KAAK,GAAG;CAC/B,GAAG,QACD,eAAe,MAAM,IAAI,QAAQ,KAAK,IAAI,EAAE,YAAY,QAAQ,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,EAC5F,CAAC,CAAC,IAAI,GAAG,QAAQ,KAAK,WAAW,IAAI,WAAW,IAAI,CAAC;AACvD;AAEA,SAAS,cAAc,IAAkB,KAAuB;CAC9D,GAAG,KAAK,OAAO;CACf,IAAI;EACF,IAAI;EACJ,GAAG,KAAK,QAAQ;CAClB,SAAS,OAAO;EACd,GAAG,KAAK,UAAU;EAClB,MAAM;CACR;AACF;AAEA,SAAS,eAAe,QAAgB,SAAkB,OAAgC;CACxF,MAAM,SAAS,OAAO,SAAS,IAAI,QAAQ,E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,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
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as OpenCarnetOptions, t as Carnet,
|
|
1
|
+
import { r as OpenCarnetOptions, t as Carnet, yt as Host } from "./carnet-Dbkz_bzM.mjs";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
3
|
import { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
|
-
export declare const INSTRUCTIONS = "Carnet
|
|
5
|
+
export declare const INSTRUCTIONS = "Carnet holds the forks, the \"On the table\" line, sessions, the journal and the group 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.\n\nWhich tool, when:\n- Dispatch: agent_start, then launch the fork in a later message.\n- Each step of a fork's work: agent_step (answered, applying, applied, tested, committed, dropped).\n- Main agent working on something else: table_set, table_clear.\n- Other moves: agent_update, agent_drop, queue_reorder. Recall: agent_list, log_read, session_resume_info, session_list.\n- 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.\n- Session: session_new when the human names it, session_drop only when asked.\n- Fork: agent_update (running, short note) at progress, agent_done last.\n\nStatuses (the NEXT action): running ⏳ · discussing 💬 · answer ❓ · review 👀 · apply 📥 · test 🧪 · commit ✅ · branch 🌿. Notes and table text: under 60 characters, no paths, no backticks.";
|
|
6
6
|
interface SessionResolverOptions {
|
|
7
7
|
carnet: Carnet;
|
|
8
8
|
env?: NodeJS.ProcessEnv | undefined;
|
|
@@ -27,7 +27,6 @@ interface ServeCarnetOptions extends OpenCarnetOptions {
|
|
|
27
27
|
export declare function serveCarnet(options?: ServeCarnetOptions): StdioServerHandle;
|
|
28
28
|
interface ToolOutput {
|
|
29
29
|
text: string;
|
|
30
|
-
data?: Record<string, unknown>;
|
|
31
30
|
}
|
|
32
31
|
interface ToolDefinition<Schema extends z.ZodObject = z.ZodObject> {
|
|
33
32
|
name: string;
|
package/dist/mcp.d.mts.map
CHANGED
|
@@ -1 +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;
|
|
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;UChD9C;EACf;;UAGe,eAAe,eAAe,EAAE,YAAY,EAAE;EAC7D;EACA;EACA,QAAQ;EACR,MAAM,QAAQ,QAAQ,mBAAmB,MAAM,EAAE,MAAM,YAAY;;qBAuaxD,gBAAgB"}
|