@rucher/carnet 0.2.0-beta.7 → 0.2.0-beta.8
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/README.md +2 -2
- package/dist/{carnet-jmxAmm-u.d.mts → carnet-MC9WeQ6h.d.mts} +22 -8
- package/dist/carnet-MC9WeQ6h.d.mts.map +1 -0
- package/dist/index.d.mts +13 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +72 -12
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +4 -2
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +19 -16
- package/dist/mcp.mjs.map +1 -1
- package/dist/{steps-Bd8FlgLs.mjs → steps-xzr8iVWn.mjs} +139 -39
- package/dist/steps-xzr8iVWn.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/carnet-jmxAmm-u.d.mts.map +0 -1
- package/dist/steps-Bd8FlgLs.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @rucher/carnet
|
|
2
2
|
|
|
3
|
-
Shared state for Rucher: workspaces, sessions, agents, the
|
|
3
|
+
Shared state for Rucher: workspaces, sessions, agents, the Main line and the event journal, stored in one SQLite database for every workspace (`~/.local/share/rucher/carnet.db`, via `node:sqlite`), with workspaces defined in `~/.config/rucher/workspaces/<name>/workspace.json`.
|
|
4
4
|
|
|
5
|
-
Used by the `rucher` CLI and the Carnet MCP server. See [
|
|
5
|
+
Used by the `rucher` CLI and the Carnet MCP server. See the [documentation](https://github.com/Florian-Varrin/Rucher/blob/master/docs/README.md) in the [repository](https://github.com/Florian-Varrin/Rucher).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { openCarnet } from '@rucher/carnet';
|
|
@@ -27,25 +27,27 @@ interface LogEventInput {
|
|
|
27
27
|
note?: string | undefined;
|
|
28
28
|
}
|
|
29
29
|
declare function isEventType(value: unknown): value is EventType;
|
|
30
|
-
declare const AGENT_STATUSES: readonly ['running', 'discussing', 'answer', 'review', 'apply', 'test', '
|
|
30
|
+
declare const AGENT_STATUSES: readonly ['running', 'discussing', 'answer', 'review', 'apply', 'test', 'closed'];
|
|
31
31
|
type AgentStatus = (typeof AGENT_STATUSES)[number];
|
|
32
|
-
declare const USER_ACTION_STATUSES: readonly ['discussing', 'answer', 'review', 'apply', 'test'
|
|
32
|
+
declare const USER_ACTION_STATUSES: readonly ['discussing', 'answer', 'review', 'apply', 'test'];
|
|
33
33
|
type UserActionStatus = (typeof USER_ACTION_STATUSES)[number];
|
|
34
34
|
declare const EMOJI: Record<Exclude<AgentStatus, 'closed'>, string>;
|
|
35
35
|
declare const MAIN_WORKING_EMOJI = "⚙️";
|
|
36
36
|
declare const MAIN_WAITING_EMOJI = "⏸";
|
|
37
37
|
declare const MAIN_FAILED_EMOJI = "⚠";
|
|
38
|
-
declare const LEGEND = "⚙️ main working · ⏸ waiting on you · ⚠ turn failed · 💬 discussing · ❓ answer · 👀 review · 📥 apply · 🧪 test ·
|
|
38
|
+
declare const LEGEND = "⚙️ main working · ⏸ waiting on you · ⚠ turn failed · 💬 discussing · ❓ answer · 👀 review · 📥 apply · 🧪 test · ⏳ running";
|
|
39
39
|
declare const KIND_ABBREVIATIONS: {
|
|
40
40
|
readonly research: 'rs';
|
|
41
41
|
readonly analyze: 'an';
|
|
42
42
|
readonly implement: 'im';
|
|
43
43
|
readonly review: 'rv';
|
|
44
44
|
};
|
|
45
|
-
declare
|
|
45
|
+
declare function kindTag(kind: keyof typeof KIND_ABBREVIATIONS): string;
|
|
46
|
+
declare const KIND_TAG_PATTERN: RegExp;
|
|
47
|
+
declare const KIND_LEGEND = "[rs] research · [an] analyze · [im] implement · [rv] review";
|
|
46
48
|
declare function isAgentStatus(value: unknown): value is AgentStatus;
|
|
47
49
|
declare function isUserActionStatus(value: unknown): value is UserActionStatus;
|
|
48
|
-
declare const OPEN_AGENT_STATUSES: readonly ["running", "discussing", "answer", "review", "apply", "test"
|
|
50
|
+
declare const OPEN_AGENT_STATUSES: readonly ["running", "discussing", "answer", "review", "apply", "test"];
|
|
49
51
|
declare const AGENT_KINDS: readonly ['research', 'analyze', 'implement', 'review'];
|
|
50
52
|
type AgentKind = (typeof AGENT_KINDS)[number];
|
|
51
53
|
declare const DEFAULT_AGENT_KIND: AgentKind;
|
|
@@ -56,6 +58,7 @@ interface Agent {
|
|
|
56
58
|
kind: AgentKind;
|
|
57
59
|
promotedFrom: AgentKind | null;
|
|
58
60
|
target: string | null;
|
|
61
|
+
blockedOn: string | null;
|
|
59
62
|
task: string | null;
|
|
60
63
|
status: AgentStatus;
|
|
61
64
|
note: string | null;
|
|
@@ -81,6 +84,7 @@ interface UpdateAgentInput {
|
|
|
81
84
|
status: AgentStatus;
|
|
82
85
|
note?: string | null | undefined;
|
|
83
86
|
reportPath?: string | undefined;
|
|
87
|
+
blockedOn?: string | null | undefined;
|
|
84
88
|
}
|
|
85
89
|
interface FinishAgentInput {
|
|
86
90
|
reportPath: string;
|
|
@@ -233,6 +237,7 @@ interface Host {
|
|
|
233
237
|
renameInstruction(name: string): string;
|
|
234
238
|
transcriptFiles(session: Session, env?: NodeJS.ProcessEnv): string[];
|
|
235
239
|
hasConversation(session: Session, env?: NodeJS.ProcessEnv): boolean;
|
|
240
|
+
continues(parent: Session, childId: string, env?: NodeJS.ProcessEnv): boolean;
|
|
236
241
|
renderRunDirectory(workspace: Workspace): HostRender;
|
|
237
242
|
}
|
|
238
243
|
declare const DEFAULT_HOST = "claude-code";
|
|
@@ -255,6 +260,7 @@ interface Session {
|
|
|
255
260
|
lastTitle: string | null;
|
|
256
261
|
parentId: string | null;
|
|
257
262
|
promptVersion: string | null;
|
|
263
|
+
pluginVersion: string | null;
|
|
258
264
|
createdAt: string;
|
|
259
265
|
lastActiveAt: string;
|
|
260
266
|
endedAt: string | null;
|
|
@@ -271,6 +277,7 @@ interface HookEnv {
|
|
|
271
277
|
RUCHER_PROMPT_VERSION?: string | undefined;
|
|
272
278
|
RUCHER_MEMORY_MAX_CHARACTERS?: string | undefined;
|
|
273
279
|
RUCHER_MEMORY_HALF_LIFE_DAYS?: string | undefined;
|
|
280
|
+
CLAUDE_CONFIG_DIR?: string | undefined;
|
|
274
281
|
}
|
|
275
282
|
interface CreateSessionInput {
|
|
276
283
|
id: string;
|
|
@@ -430,6 +437,9 @@ interface NoteActivity {
|
|
|
430
437
|
declare function sessionNoteActivity(ctx: Ctx, session: string): NoteActivity[];
|
|
431
438
|
declare const TURNS: readonly ['working', 'waiting', 'failed'];
|
|
432
439
|
type Turn = (typeof TURNS)[number];
|
|
440
|
+
interface TurnOptions {
|
|
441
|
+
trackTurn?: boolean | undefined;
|
|
442
|
+
}
|
|
433
443
|
interface StatusLine {
|
|
434
444
|
name: string;
|
|
435
445
|
kind: AgentKind;
|
|
@@ -444,6 +454,7 @@ interface StatusView {
|
|
|
444
454
|
table: TableItem | null;
|
|
445
455
|
turn: Turn | null;
|
|
446
456
|
waiting: StatusLine[];
|
|
457
|
+
blocked: StatusLine[];
|
|
447
458
|
running: StatusLine[];
|
|
448
459
|
notes: NoteActivity[];
|
|
449
460
|
}
|
|
@@ -465,10 +476,12 @@ interface MemoryScope {
|
|
|
465
476
|
declare function renderMemory(scope: MemoryScope, maxCharacters?: number): string;
|
|
466
477
|
declare const MAIN_HEADER = "Main";
|
|
467
478
|
declare const MAIN_WORKING_SUFFIX = "(main working)";
|
|
479
|
+
declare const BLOCKED_HEADER = "Waiting on agents";
|
|
468
480
|
declare const MAIN_WAITING_SUFFIX = "(waiting on you)";
|
|
469
481
|
declare const MAIN_FAILED_SUFFIX = "(turn failed)";
|
|
470
482
|
declare function renderTableLine(item: TableItem): string;
|
|
471
|
-
declare
|
|
483
|
+
declare const MAIN_IDLE = "idle";
|
|
484
|
+
declare function renderMainLine(item: TableItem | null, turn: Turn | null): string;
|
|
472
485
|
declare function renderAgentLine(line: StatusLine, nameWidth?: number): string;
|
|
473
486
|
declare const NOTES_HEADER = "Notes";
|
|
474
487
|
declare const NOTES_FOLD_LINES = 5;
|
|
@@ -508,6 +521,7 @@ declare class Carnet {
|
|
|
508
521
|
default: () => Session | undefined;
|
|
509
522
|
byName: (name: string) => Session | undefined;
|
|
510
523
|
byHostProcess: (host: string, processId: number) => Session | undefined;
|
|
524
|
+
recordPluginVersion: (id: string, version: string | null) => void;
|
|
511
525
|
recordPromptVersion: (id: string, version: string | null) => Session;
|
|
512
526
|
setParent: (id: string, parentId: string) => Session;
|
|
513
527
|
setStatus: (id: string, status: SessionStatus) => Session;
|
|
@@ -598,5 +612,5 @@ interface ResolvedCarnet {
|
|
|
598
612
|
}
|
|
599
613
|
declare function openResolvedCarnet(options?: OpenCarnetOptions): ResolvedCarnet;
|
|
600
614
|
declare function openWorkspaceCarnet(workspace: Workspace | null, options?: OpenCarnetOptions): Carnet;
|
|
601
|
-
export {
|
|
602
|
-
//# sourceMappingURL=carnet-
|
|
615
|
+
export { NoteKind as $, dropWorkspace as $t, renderMemory as A, USER_ACTION_STATUSES as An, ResumeCommand as At, AddNoteResult as B, SESSION_EVENT_TYPES as Bn, resolveWorkspace as Bt, renderNotesSummary as C, KIND_LEGEND as Cn, HostRender as Ct, MEMORY_MAX_CHARACTERS as D, MAIN_WAITING_EMOJI as Dn, HostSubagentPayload as Dt, renderTableLine as E, MAIN_FAILED_EMOJI as En, HostStopPayload as Et, formatClock as F, AgentEventType as Fn, WorkspaceResolution as Ft, ListNotesOptions as G, INSTRUCTIONS_FILE as Gt, DEFAULT_HALF_LIFE_DAYS as H, isEventType as Hn, AGENTS_FILE as Ht, TURNS as I, CarnetEvent as In, isInside as It, Note as J, WorkspaceFile as Jt, NOTE_KINDS as K, WORKSPACE_FILE as Kt, Turn as L, EVENT_TYPES as Ln, repoNameFor as Lt, StatusView as M, isAgentStatus as Mn, hostById as Mt, StatusViewOptions as N, isUserActionStatus as Nn, ResolveWorkspaceOptions as Nt, MemoryOptions as O, MAIN_WORKING_EMOJI as On, HostToolPayload as Ot, buildStatusView as P, kindTag as Pn, WorkspaceOrigin as Pt, NoteDetail as Q, definitionInstructions as Qt, TurnOptions as R, EventType as Rn, repoPathFor as Rt, renderNotes as S, KIND_ABBREVIATIONS as Sn, HostPromptPayload as St, renderStatus as T, LEGEND as Tn, HostSessionPayload as Tt, DUPLICATE_SIMILARITY as U, CreateWorkspaceOptions as Ut, CiteNoteInput as V, SessionEventType as Vn, workspaceLabel as Vt, DropNoteInput as W, DropWorkspaceOptions as Wt, NoteActivityKind as X, addWorkspaceRepo as Xt, NoteActivity as Y, WorkspaceRepo as Yt, NoteCitation as Z, createWorkspace as Zt, RenderOptions as _, isAgentKind as _n, SessionKind as _t, openCarnet as a, workspaceExists as an, sessionNoteActivity as at, renderMainLine as b, AgentStatus as bn, DEFAULT_HOST as bt, BLOCKED_HEADER as c, Agent as cn, SetTableInput as ct, MAIN_IDLE as d, FinishAgentInput as dn, CreateSessionInput as dt, expandHome as en, STALE_AFTER_ACTIVE_DAYS as et, MAIN_WAITING_SUFFIX as f, ListAgentsOptions as fn, HookEnv as ft, NotesMode as g, UpdateAgentInput as gn, Session as gt, NOTES_HEADER as h, StartAgentInput as hn, MINIMUM_ID_PREFIX as ht, ResolvedCarnet as i, removeWorkspaceRepo as in, memoryHalfLife as it, StatusLine as j, UserActionStatus as jn, allHosts as jt, memoryMaxCharacters as k, OPEN_AGENT_STATUSES as kn, LaunchOptions as kt, MAIN_FAILED_SUFFIX as l, AgentKind as ln, TableItem as lt, NOTES_FOLD_LINES as m, REPORTING_NOTE as mn, ListSessionsOptions as mt, CarnetOptions as n, listWorkspaces as nn, isNoteKind as nt, openResolvedCarnet as o, workspaceHosts as on, similarity as ot, MAIN_WORKING_SUFFIX as p, PUBLISH_FALLBACK_MILLISECONDS as pn, HookSessionPayload as pt, NOTE_TEXT_LIMIT as q, Workspace as qt, OpenCarnetOptions as r, loadWorkspace as rn, localDay as rt, openWorkspaceCarnet as s, AGENT_KINDS as sn, workspaceRepoNames as st, Carnet as t, isWorkspaceName as tn, WeightedNote as tt, MAIN_HEADER as u, DEFAULT_AGENT_KIND as un, MergeResult as ut, SIMILAR_PREFIX as v, statusWhenDone as vn, SessionStatus as vt, renderSections as w, KIND_TAG_PATTERN as wn, HostSessionEndPayload as wt, renderNoteLine as x, EMOJI as xn, Host as xt, renderAgentLine as y, AGENT_STATUSES as yn, shortId as yt, AddNoteInput as z, LogEventInput as zn, requireWorkspace as zt };
|
|
616
|
+
//# sourceMappingURL=carnet-MC9WeQ6h.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carnet-MC9WeQ6h.d.mts","names":["_$__merge_ts0.MergeResult","_$__agents_ts0.Agent","_$__questions_ts0.Question","_$__findings_ts0.Finding","_$__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/events.ts","../src/status/model.ts","../src/agents.ts","../src/workspace/workspace.ts","../src/workspace/locate.ts","../src/hosts/host.ts","../src/sessions.ts","../src/merge.ts","../src/questions.ts","../src/findings.ts","../src/table.ts","../src/notes.ts","../src/turn.ts","../src/status/view.ts","../src/memory.ts","../src/status/render.ts","../src/carnet.ts"],"mappings":";UAEiB;EACf,IAAI;EACJ,WAAW;EAEX;;cCFW;cAaA;KAOD,yBAAyB;KACzB,2BAA2B;KAC3B,YAAY,iBAAiB;UAIxB;EACf;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN;EACA;EACA;EACA;;iBAqBc,YAAY,iBAAiB,SAAS;cCnEzC;KAUD,sBAAsB;cAErB;KAED,2BAA2B;cAE1B,OAAO,OAAO,QAAQ;cAStB;cACA;cACA;cAEA;cAGA;WACX;WACA;WACA;WACA;;iBAIc,QAAQ,mBAAmB;cAI9B,kBAAgB;cAE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A;EACA;EACA;EACA;;UAGe;EACf;EACA;;cCtBW;KACD,0BAA0B;cAEzB;KACD,0BAA0B;UAErB;EACf,UAAU;EACV;EACA;EACA;;UAGe;EACf;EACA;EACA,UAAU;EACV;EACA;EACA;EACA,UAAU;EACV;;UAGe;EACf;EACA,UAAU;EACV;;UCzBe;EACf;EACA;EACA,QAAQ;EACR;;UAGe;EACf;EACA,SAAS;;cCVE;KACD,mBAAmB;cAElB;cACA;cACA;cACA;iBAIG,WAAW,gBAAgB,SAAS;iBAIpC,eAAe;UAKd;EACf;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe,qBAAqB;EACpC;EACA;;UAGe,mBAAmB;EAClC,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;iBA0Cc,mBAAmB,WAAW;iBAqB9B,WAAW,eAAe;iBAS1B,SAAS,MAAM;KAsQnB;UAEK;EACf,UAAU;EACV;EACA,MAAM;EACN;EACA;EACA;EACA;;iBAec,oBAAoB,KAAK,KAAK,kBAAkB;cC3bnD;KACD,eAAe;UAEV;EAEf;;UCGe;EACf;EACA,MAAM;EACN,QAAQ;EACR;EAEA;EACA;;UAGe;EACf;EACA;EACA,OAAO;EACP,MAAM;EACN,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;;UAGQ;EACf,OAAO;;iBAiFO,YAAY,MAAM;iBAMlB,gBACd,KAAK,KACL,SAAS,SACT,UAAS,oBACR;cChHU;iBAWG,oBAAoB;UAKnB;EACf;EACA;;UAGQ;EACR;EACA,OAAO;;iBAsBO,aAAa,OAAO,aAAa;cC1CpC;cACA;cACA;cACA;cACA;iBAEG,gBAAgB,MAAM;cAUzB;iBAEG,eAAe,MAAM,kBAAkB,MAAM;iB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iBASc,WAAW,UAAS,oBAAyB;UAI5C;EACf,QAAQ;EACR,YAAY;;iBAGE,mBAAmB,UAAS,oBAAyB;iBAWrD,oBACd,WAAW,kBACX,UAAS,oBACR"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as NoteKind, $t as dropWorkspace, A as renderMemory, An as USER_ACTION_STATUSES, At as ResumeCommand, B as AddNoteResult, Bn as SESSION_EVENT_TYPES, Bt as resolveWorkspace, C as renderNotesSummary, Cn as KIND_LEGEND, Ct as HostRender, D as MEMORY_MAX_CHARACTERS, Dn as MAIN_WAITING_EMOJI, Dt as HostSubagentPayload, E as renderTableLine, En as MAIN_FAILED_EMOJI, Et as HostStopPayload, F as formatClock, Fn as AgentEventType, Ft as WorkspaceResolution, G as ListNotesOptions, Gt as INSTRUCTIONS_FILE, H as DEFAULT_HALF_LIFE_DAYS, Hn as isEventType, Ht as AGENTS_FILE, I as TURNS, In as CarnetEvent, It as isInside, J as Note, Jt as WorkspaceFile, K as NOTE_KINDS, Kt as WORKSPACE_FILE, L as Turn, Ln as EVENT_TYPES, Lt as repoNameFor, M as StatusView, Mn as isAgentStatus, Mt as hostById, N as StatusViewOptions, Nn as isUserActionStatus, Nt as ResolveWorkspaceOptions, O as MemoryOptions, On as MAIN_WORKING_EMOJI, Ot as HostToolPayload, P as buildStatusView, Pn as kindTag, Pt as WorkspaceOrigin, Q as NoteDetail, Qt as definitionInstructions, R as TurnOptions, Rn as EventType, Rt as repoPathFor, S as renderNotes, Sn as KIND_ABBREVIATIONS, St as HostPromptPayload, T as renderStatus, Tn as LEGEND, Tt as HostSessionPayload, U as DUPLICATE_SIMILARITY, Ut as CreateWorkspaceOptions, V as CiteNoteInput, Vn as SessionEventType, Vt as workspaceLabel, W as DropNoteInput, Wt as DropWorkspaceOptions, X as NoteActivityKind, Xt as addWorkspaceRepo, Y as NoteActivity, Yt as WorkspaceRepo, Z as NoteCitation, Zt as createWorkspace, _ as RenderOptions, _n as isAgentKind, _t as SessionKind, a as openCarnet, an as workspaceExists, at as sessionNoteActivity, b as renderMainLine, bn as AgentStatus, bt as DEFAULT_HOST, c as BLOCKED_HEADER, cn as Agent, ct as SetTableInput, d as MAIN_IDLE, dn as FinishAgentInput, dt as CreateSessionInput, en as expandHome, et as STALE_AFTER_ACTIVE_DAYS, f as MAIN_WAITING_SUFFIX, fn as ListAgentsOptions, ft as HookEnv, g as NotesMode, gn as UpdateAgentInput, gt as Session, h as NOTES_HEADER, hn as StartAgentInput, ht as MINIMUM_ID_PREFIX, i as ResolvedCarnet, in as removeWorkspaceRepo, it as memoryHalfLife, j as StatusLine, jn as UserActionStatus, jt as allHosts, k as memoryMaxCharacters, kn as OPEN_AGENT_STATUSES, kt as LaunchOptions, l as MAIN_FAILED_SUFFIX, ln as AgentKind, lt as TableItem, m as NOTES_FOLD_LINES, mn as REPORTING_NOTE, mt as ListSessionsOptions, n as CarnetOptions, nn as listWorkspaces, nt as isNoteKind, o as openResolvedCarnet, on as workspaceHosts, ot as similarity, p as MAIN_WORKING_SUFFIX, pn as PUBLISH_FALLBACK_MILLISECONDS, pt as HookSessionPayload, q as NOTE_TEXT_LIMIT, qt as Workspace, r as OpenCarnetOptions, rn as loadWorkspace, rt as localDay, s as openWorkspaceCarnet, sn as AGENT_KINDS, st as workspaceRepoNames, t as Carnet, tn as isWorkspaceName, tt as WeightedNote, u as MAIN_HEADER, un as DEFAULT_AGENT_KIND, ut as MergeResult, v as SIMILAR_PREFIX, vn as statusWhenDone, vt as SessionStatus, w as renderSections, wn as KIND_TAG_PATTERN, wt as HostSessionEndPayload, x as renderNoteLine, xn as EMOJI, xt as Host, y as renderAgentLine, yn as AGENT_STATUSES, yt as shortId, z as AddNoteInput, zn as LogEventInput, zt as requireWorkspace } from "./carnet-MC9WeQ6h.mjs";
|
|
2
2
|
import { DatabaseSync } from "node:sqlite";
|
|
3
3
|
interface MoveOptions {
|
|
4
4
|
merge?: boolean | undefined;
|
|
@@ -24,7 +24,7 @@ export declare function openDatabase(path: string): DatabaseSync;
|
|
|
24
24
|
export declare const migrations: readonly string[];
|
|
25
25
|
export declare function schemaVersion(db: DatabaseSync): number;
|
|
26
26
|
export declare function migrate(db: DatabaseSync): void;
|
|
27
|
-
type CarnetErrorCode = 'NO_WORKSPACE' | 'WORKSPACE_EXISTS' | 'WORKSPACE_NOT_FOUND' | 'WORKSPACE_NAME_INVALID' | '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' | 'SESSION_CWD_MISSING' | 'RUN_DIRECTORY_FILE_CONFLICT' | 'WORKSPACE_INSTRUCTIONS_CONFLICT' | 'AGENT_EXISTS' | 'AGENT_NOT_FOUND' | 'INVALID_TARGET' | 'INVALID_KIND' | 'INVALID_QUESTIONS' | 'QUESTION_NOT_FOUND' | 'FINDING_NOT_FOUND' | 'REASON_REQUIRED' | 'SECTION_NOT_FOUND' | 'REPORT_MISSING' | 'INVALID_STATUS' | 'INVALID_EVENT_TYPE' | 'COMMIT_REQUIRED';
|
|
27
|
+
type CarnetErrorCode = 'NO_WORKSPACE' | 'WORKSPACE_EXISTS' | 'WORKSPACE_NOT_FOUND' | 'WORKSPACE_NAME_INVALID' | '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' | 'SESSION_CWD_MISSING' | 'RUN_DIRECTORY_FILE_CONFLICT' | 'WORKSPACE_INSTRUCTIONS_CONFLICT' | 'AGENT_EXISTS' | 'AGENT_NOT_FOUND' | 'INVALID_TARGET' | 'INVALID_BLOCKER' | 'INVALID_KIND' | 'INVALID_QUESTIONS' | 'QUESTION_NOT_FOUND' | 'FINDING_NOT_FOUND' | 'REASON_REQUIRED' | 'SECTION_NOT_FOUND' | 'REPORT_MISSING' | 'INVALID_STATUS' | 'INVALID_EVENT_TYPE' | 'COMMIT_REQUIRED';
|
|
28
28
|
export declare class CarnetError extends Error {
|
|
29
29
|
readonly code: CarnetErrorCode;
|
|
30
30
|
constructor(code: CarnetErrorCode, message: string);
|
|
@@ -79,8 +79,8 @@ export declare const OUTSIDE_RUCHER_NOTICE = "rucher: session started without ru
|
|
|
79
79
|
export declare const RULES_UPDATED_NOTICE = "rucher: rules updated, will apply after the next compaction or in a new session";
|
|
80
80
|
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, follow the contract of its kind, call agent_update at meaningful progress and agent_done as your last tool action, then reply with one line.";
|
|
81
81
|
export declare 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 agents, triggers their final action (inject, validate, apply, triage), applies, tests and commits. Agents propose, they never push.\n- Status lives in Carnet: agent statuses, the Main 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 an agent finishes, say only \"<name> finished, report ready\". Never summarise, quote or act on its report or final message until the human asks for that report or its final action, even when answering about something else.\n- Agents never commit, push, stash or record notes. An agent follows its kind's contract, 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 launch agents or handle their results, load the rucher skill: it holds the full workflow.";
|
|
82
|
-
export declare function handleUserPromptSubmit(carnet: Carnet, host: Host, payload: HostPromptPayload): Session;
|
|
83
|
-
export declare function handleToolUse(carnet: Carnet, payload: HostToolPayload, env: HookEnv): string | undefined;
|
|
82
|
+
export declare function handleUserPromptSubmit(carnet: Carnet, host: Host, payload: HostPromptPayload, options?: TurnOptions): Session;
|
|
83
|
+
export declare function handleToolUse(carnet: Carnet, payload: HostToolPayload, env: HookEnv, options?: TurnOptions): string | undefined;
|
|
84
84
|
export declare const WAITING_TOOL = "AskUserQuestion";
|
|
85
85
|
export declare function handleToolStart(carnet: Carnet, payload: HostToolPayload): void;
|
|
86
86
|
export declare function guardSubagentCall(carnet: Carnet, payload: HostToolPayload, scratchRoot: string): string | undefined;
|
|
@@ -114,6 +114,14 @@ export declare const PAIRING_WINDOW_MILLISECONDS = 60000;
|
|
|
114
114
|
export declare const STOPPED_NOTE = "stopped without agent_done";
|
|
115
115
|
export declare const NOTE_MAX = 60;
|
|
116
116
|
export declare function sanitizeNote(text: string): string;
|
|
117
|
+
export declare const STATUS_LINE_LABEL = "rucher";
|
|
118
|
+
export declare function renderStatusLine(view: StatusView, lag?: string | null): string;
|
|
119
|
+
export declare function statusLinePath(sessionId: string, env?: NodeJS.ProcessEnv): string;
|
|
120
|
+
interface StatusLineOptions {
|
|
121
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
122
|
+
lag?: string | null | undefined;
|
|
123
|
+
}
|
|
124
|
+
export declare function writeStatusLine(carnet: Carnet, sessionId: string, options?: StatusLineOptions): void;
|
|
117
125
|
type OpenAgentStatus = (typeof OPEN_AGENT_STATUSES)[number];
|
|
118
126
|
export declare const AGENT_STEPS: readonly ['answered', 'applying', 'applied', 'tested', 'committed', 'dropped'];
|
|
119
127
|
type AgentStep = (typeof AGENT_STEPS)[number];
|
|
@@ -141,5 +149,5 @@ export declare function markdownCopy(content: string): string;
|
|
|
141
149
|
export declare function removeStaleCopies(directory: string, keep: ReadonlySet<string>): string[];
|
|
142
150
|
export declare function writeGenerated(path: string, content: string): boolean;
|
|
143
151
|
export declare function mergeSettings(base: Record<string, unknown>, extra: Record<string, unknown>): Record<string, unknown>;
|
|
144
|
-
export { AGENTS_FILE, AGENT_KINDS, AGENT_STATUSES, type AddNoteInput, type AddNoteResult, type Agent, type AgentEventType, type AgentKind, type AgentStatus, type AgentStep, type AppendPromptFile, type AssembledPrompt, Carnet, type CarnetErrorCode, type CarnetEvent, type CarnetOptions, type CiteNoteInput, type CreateSessionInput, type CreateWorkspaceOptions, DEFAULT_AGENT_KIND, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DUPLICATE_SIMILARITY, type DropNoteInput, type DropWorkspaceOptions, EMOJI, EVENT_TYPES, type EventType, type FinishAgentInput, type HookEnv, type HookSessionPayload, type Host, type HostPromptPayload, type HostRender, type HostSessionEndPayload, type HostSessionPayload, type HostSubagentPayload, type HostToolPayload, INSTRUCTIONS_FILE, KIND_ABBREVIATIONS, KIND_LEGEND, LEGEND, type LaunchOptions, type ListAgentsOptions, type ListNotesOptions, type ListSessionsOptions, type LogEventInput, MAIN_FAILED_EMOJI, MAIN_FAILED_SUFFIX, MAIN_HEADER, MAIN_WAITING_EMOJI, MAIN_WAITING_SUFFIX, 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, type RenderOptions, type RenderResult, type ResolveWorkspaceOptions, type ResolvedCarnet, type ResumeCommand, type ResumeContextOptions, type RucherPaths, type RunDirectoryRenderOptions, 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 StatusViewOptions, type StepAgentInput, TURNS, type TableItem, type Turn, USER_ACTION_STATUSES, type UpdateAgentInput, type UserActionStatus, WORKSPACE_FILE, type WeightedNote, type Workspace, type WorkspaceFile, type WorkspaceOrigin, type WorkspaceRepo, type WorkspaceResolution, addWorkspaceRepo, allHosts, buildStatusView, createWorkspace, definitionInstructions, dropWorkspace, expandHome, formatClock, hostById, isAgentKind, isAgentStatus, isEventType, isInside, isNoteKind, isUserActionStatus, isWorkspaceName, listWorkspaces, loadWorkspace, localDay, memoryHalfLife, memoryMaxCharacters, openCarnet, openResolvedCarnet, openWorkspaceCarnet, removeWorkspaceRepo, renderAgentLine, renderMainLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderSections, renderStatus, renderTableLine, repoNameFor, repoPathFor, requireWorkspace, resolveWorkspace, sessionNoteActivity, shortId, similarity, statusWhenDone, workspaceExists, workspaceHosts, workspaceLabel, workspaceRepoNames };
|
|
152
|
+
export { AGENTS_FILE, AGENT_KINDS, AGENT_STATUSES, type AddNoteInput, type AddNoteResult, type Agent, type AgentEventType, type AgentKind, type AgentStatus, type AgentStep, type AppendPromptFile, type AssembledPrompt, BLOCKED_HEADER, Carnet, type CarnetErrorCode, type CarnetEvent, type CarnetOptions, type CiteNoteInput, type CreateSessionInput, type CreateWorkspaceOptions, DEFAULT_AGENT_KIND, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DUPLICATE_SIMILARITY, type DropNoteInput, type DropWorkspaceOptions, EMOJI, EVENT_TYPES, type EventType, type FinishAgentInput, type HookEnv, type HookSessionPayload, type Host, type HostPromptPayload, type HostRender, type HostSessionEndPayload, type HostSessionPayload, type HostSubagentPayload, type HostToolPayload, INSTRUCTIONS_FILE, KIND_ABBREVIATIONS, KIND_LEGEND, KIND_TAG_PATTERN, LEGEND, type LaunchOptions, type ListAgentsOptions, type ListNotesOptions, type ListSessionsOptions, type LogEventInput, MAIN_FAILED_EMOJI, MAIN_FAILED_SUFFIX, MAIN_HEADER, MAIN_IDLE, MAIN_WAITING_EMOJI, MAIN_WAITING_SUFFIX, 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, type RenderOptions, type RenderResult, type ResolveWorkspaceOptions, type ResolvedCarnet, type ResumeCommand, type ResumeContextOptions, type RucherPaths, type RunDirectoryRenderOptions, 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 StatusLineOptions, type StatusView, type StatusViewOptions, type StepAgentInput, TURNS, type TableItem, type Turn, type TurnOptions, USER_ACTION_STATUSES, type UpdateAgentInput, type UserActionStatus, WORKSPACE_FILE, type WeightedNote, type Workspace, type WorkspaceFile, type WorkspaceOrigin, type WorkspaceRepo, type WorkspaceResolution, addWorkspaceRepo, allHosts, buildStatusView, createWorkspace, definitionInstructions, dropWorkspace, expandHome, formatClock, hostById, isAgentKind, isAgentStatus, isEventType, isInside, isNoteKind, isUserActionStatus, isWorkspaceName, kindTag, listWorkspaces, loadWorkspace, localDay, memoryHalfLife, memoryMaxCharacters, openCarnet, openResolvedCarnet, openWorkspaceCarnet, removeWorkspaceRepo, renderAgentLine, renderMainLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderSections, renderStatus, renderTableLine, repoNameFor, repoPathFor, requireWorkspace, resolveWorkspace, sessionNoteActivity, shortId, similarity, statusWhenDone, workspaceExists, workspaceHosts, workspaceLabel, workspaceRepoNames };
|
|
145
153
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/move.ts","../src/workspace-rows.ts","../src/db/open.ts","../src/db/schema.ts","../src/errors.ts","../src/paths.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/guard.ts","../src/hosts/claude-code.ts","../src/purge.ts","../src/resume.ts","../src/subagents.ts","../src/status/note.ts","../src/steps.ts","../src/render.ts","../src/run-directory-files.ts"],"mappings":";;UAIiB;EACf;EACA;;UAGe;EACf,SAAS;EACT,MAAM;EACN;EACA;EACA;EACA;EACA;;wBAwBc,YACd,QAAQ,QACR,mBACA,yBACA,UAAS,cACR;wBC/Ba,qBAAqB,IAAI,cAAc;wBAOvC,yBAAyB,IAAI,cAAc,cAAc;wBAiBzD,qBAAqB,IAAI,cAAc;wBAIvC,uBAAuB,IAAI,eAAe;wBAU1C,oBAAoB,IAAI,eAAe;qBCjD1C;wBAEG,aAAa,eAAe;qBCQ/B;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/move.ts","../src/workspace-rows.ts","../src/db/open.ts","../src/db/schema.ts","../src/errors.ts","../src/paths.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/guard.ts","../src/hosts/claude-code.ts","../src/purge.ts","../src/resume.ts","../src/subagents.ts","../src/status/note.ts","../src/status/line.ts","../src/steps.ts","../src/render.ts","../src/run-directory-files.ts"],"mappings":";;UAIiB;EACf;EACA;;UAGe;EACf,SAAS;EACT,MAAM;EACN;EACA;EACA;EACA;EACA;;wBAwBc,YACd,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;wBCDa,cACd,QAAQ,QACR,SAAS,iBACT,KAAK,SACL,UAAS;qBAcE;wBAGG,gBAAgB,QAAQ,QAAQ,SAAS;wBAKzC,kBACd,QAAQ,QACR,SAAS,iBACT;qBCnCW,eAAa;UAGT;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EAEA;;wBA+Cc,cAAc,OAAO;wBA2BrB,gBAAgB,gCAAgC;wBC+BhD,gBAAgB;wBAsFhB,kBAAkB,WAAW,YAAY;qBA2D5C,YAAY;qBCtQZ;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;qBCJhB;wBAeG,iBAAiB,MAAM,YAAY;wBAenC,eAAe,mBAAmB,MAAM,OAAO;UAI9C;EACf,MAAM,OAAO;EACb;;wBAKc,gBACd,QAAQ,QACR,mBACA,UAAS;KC7CN,0BAA0B;qBAElB;KAQD,oBAAoB;UAEf;EACf;EACA,MAAM;EACN;EACA;EACA,OAAO;;wBAYO,UAAU,QAAQ,QAAQ,iBAAiB,OAAO;UC9BjD;EACf;EACA;EACA;;UAGe;EACf,MAAM,OAAO;EACb;;wBAGc,mBACd,WAAW,WACX,UAAS,4BACR;qBCfU;qBAkBA;wBAEG,aAAa;wBAWb,kBAAkB,mBAAmB,MAAM;wBAa3C,eAAe,cAAc;wBAiB7B,cACd,MAAM,yBACN,OAAO,0BACN"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { mkdirSync } from "node:fs";
|
|
3
|
-
import { isAbsolute, relative, resolve } from "node:path";
|
|
1
|
+
import { $ as requireWorkspace, $t as corePromptPath, A as renderNotesSummary, An as MAIN_FAILED_EMOJI, At as workspaceRules, B as DUPLICATE_SIMILARITY, Bn as isEventType, Bt as dropWorkspace, C as NOTES_FOLD_LINES, Cn as sanitizeNote, Ct as appendPromptFile, D as renderMainLine, Dn as KIND_LEGEND, Dt as outsideRucherContext, E as renderAgentLine, En as KIND_ABBREVIATIONS, Et as compactReminder, F as purgeDays, Fn as isAgentStatus, Ft as INSTRUCTIONS_FILE, G as localDay, Gt as removeWorkspaceRepo, H as NOTE_TEXT_LIMIT, Ht as isWorkspaceName, I as MEMORY_MAX_CHARACTERS, In as isUserActionStatus, It as WORKSPACE_FILE, J as similarity, K as memoryHalfLife, Kt as workspaceExists, L as memoryMaxCharacters, Ln as kindTag, Lt as addWorkspaceRepo, M as renderStatus, Mn as MAIN_WORKING_EMOJI, Mt as MINIMUM_ID_PREFIX, N as renderTableLine, Nt as shortId, O as renderNoteLine, On as KIND_TAG_PATTERN, Ot as rulesText, P as DEFAULT_PURGE_DAYS, Pn as USER_ACTION_STATUSES, Pt as AGENTS_FILE, Q as repoPathFor, R as renderMemory, Rn as EVENT_TYPES, Rt as createWorkspace, S as MAIN_WORKING_SUFFIX, Sn as NOTE_MAX, St as SUBAGENT_RULES, T as SIMILAR_PREFIX, Tn as EMOJI, Tt as baseRules, U as STALE_AFTER_ACTIVE_DAYS, Ut as listWorkspaces, V as NOTE_KINDS, Vn as CarnetError, Vt as expandHome, W as isNoteKind, Wt as loadWorkspace, X as isInside, Y as workspaceRepoNames, Z as repoNameFor, _ as BLOCKED_HEADER, _n as REPORTING_NOTE, _t as removeStaleCopies, a as formatEventLine, an as rucherPaths, at as workspaceLastActive, b as MAIN_IDLE, bt as PROMPT_FILE, c as Carnet, cn as MEMORY_DB, ct as allHosts, d as openWorkspaceCarnet, dn as migrations, dt as transcriptTitle, en as databasePath, et as resolveWorkspace, f as PAIRING_WINDOW_MILLISECONDS, fn as schemaVersion, ft as workspaceSettings, g as TURNS, gn as PUBLISH_FALLBACK_MILLISECONDS, gt as mergeSettings, h as formatClock, ht as markdownCopy, i as RESUME_MAX_CHARACTERS, in as reportsDirectory, it as sessionWorkspaceName, j as renderSections, jn as MAIN_WAITING_EMOJI, jt as CORE_RULES, k as renderNotes, kn as LEGEND, kt as rulesVersion, l as openCarnet, ln as openDatabase, lt as hostById, m as buildStatusView, mn as DEFAULT_AGENT_KIND, mt as MARKDOWN_MARKER, n as stepAgent, nn as promptsDirectory, nt as archiveWorkspaceSessions, o as resumeContext, on as workspaceDefinition, ot as workspaceSessionCounts, p as STOPPED_NOTE, pn as AGENT_KINDS, pt as GENERATED_MARKER, q as sessionNoteActivity, qt as workspaceHosts, r as RESUME_EVENTS, rn as reportPath, rt as deleteWorkspaceNotes, s as sessionLabel, sn as workspacesDirectory, st as DEFAULT_HOST, t as AGENT_STEPS, tn as defaultRunDirectory, tt as workspaceLabel, u as openResolvedCarnet, un as migrate, ut as claudeCode, v as MAIN_FAILED_SUFFIX, vn as isAgentKind, vt as writeGenerated, w as NOTES_HEADER, wn as AGENT_STATUSES, wt as assemblePrompt, x as MAIN_WAITING_SUFFIX, xn as statusWhenDone, xt as RULES_UPDATED_NOTICE, y as MAIN_HEADER, yt as OUTSIDE_RUCHER_NOTICE, z as DEFAULT_HALF_LIFE_DAYS, zn as SESSION_EVENT_TYPES, zt as definitionInstructions } from "./steps-xzr8iVWn.mjs";
|
|
2
|
+
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
// src/move.ts
|
|
5
5
|
function count(carnet, sql, ...parameters) {
|
|
6
6
|
return Number(carnet.db.prepare(sql).get(...parameters).total);
|
|
@@ -60,6 +60,17 @@ function adoptFork(carnet, session, env) {
|
|
|
60
60
|
if (kind === "active" || kind === "temp") fork = carnet.sessions.setKind(session.id, kind, env.RUCHER_SESSION_NAME || null);
|
|
61
61
|
return fork;
|
|
62
62
|
}
|
|
63
|
+
function adoptContinuation(carnet, session, env) {
|
|
64
|
+
const parentId = env.RUCHER_SESSION_ID;
|
|
65
|
+
const parent = parentId && parentId !== session.id ? carnet.sessions.get(parentId) : void 0;
|
|
66
|
+
if (!parent) return void 0;
|
|
67
|
+
const hostEnv = env.CLAUDE_CONFIG_DIR ? { CLAUDE_CONFIG_DIR: env.CLAUDE_CONFIG_DIR } : {};
|
|
68
|
+
if (!hostById(session.host).continues(parent, session.id, hostEnv)) return void 0;
|
|
69
|
+
carnet.memory.copyRepos(parent.id, session.id);
|
|
70
|
+
let merged = carnet.sessions.merge(parent.id, session.id).session;
|
|
71
|
+
merged = carnet.sessions.recordPromptVersion(merged.id, parent.promptVersion);
|
|
72
|
+
return parent.parentId ? carnet.sessions.setParent(merged.id, parent.parentId) : merged;
|
|
73
|
+
}
|
|
63
74
|
function startMemory(carnet, session, source, env) {
|
|
64
75
|
const options = {
|
|
65
76
|
maxCharacters: memoryMaxCharacters(env.RUCHER_MEMORY_MAX_CHARACTERS),
|
|
@@ -70,8 +81,14 @@ function startMemory(carnet, session, source, env) {
|
|
|
70
81
|
}
|
|
71
82
|
function handleSessionStart(carnet, payload, env) {
|
|
72
83
|
let session = carnet.sessions.upsertFromHook(payload, env);
|
|
73
|
-
|
|
74
|
-
if (source === "fork")
|
|
84
|
+
let source = payload.source ?? "";
|
|
85
|
+
if (source === "fork") {
|
|
86
|
+
const continued = adoptContinuation(carnet, session, env);
|
|
87
|
+
if (continued) {
|
|
88
|
+
session = continued;
|
|
89
|
+
source = "resume";
|
|
90
|
+
} else session = adoptFork(carnet, session, env);
|
|
91
|
+
}
|
|
75
92
|
const event = SOURCE_EVENTS[source];
|
|
76
93
|
if (event) carnet.events.log(session.id, { type: event });
|
|
77
94
|
session = carnet.sessions.setStatus(session.id, "running");
|
|
@@ -99,9 +116,9 @@ function handleSessionStart(carnet, payload, env) {
|
|
|
99
116
|
};
|
|
100
117
|
}
|
|
101
118
|
// src/hook/user-prompt-submit.ts
|
|
102
|
-
function handleUserPromptSubmit(carnet, host, payload) {
|
|
119
|
+
function handleUserPromptSubmit(carnet, host, payload, options = {}) {
|
|
103
120
|
carnet.sessions.ensure(payload.session_id, payload.cwd);
|
|
104
|
-
carnet.turn.start(payload.session_id);
|
|
121
|
+
if (options.trackTurn ?? true) carnet.turn.start(payload.session_id);
|
|
105
122
|
carnet.notes.recordActiveDay();
|
|
106
123
|
return carnet.sessions.adoptTitle(payload.session_id, host.promptTitle(payload));
|
|
107
124
|
}
|
|
@@ -136,7 +153,8 @@ const READ_ONLY_BASH = [
|
|
|
136
153
|
}
|
|
137
154
|
];
|
|
138
155
|
const PUBLISH_BASH = /\bgit\s+(commit|push|stash)\b/;
|
|
139
|
-
const REDIRECT = /(?:^|[^<>&\d])\d
|
|
156
|
+
const REDIRECT = /(?:^|[^<>&\d=-])\d?>>?(?!=)\s*([^\s;&|)]+)/g;
|
|
157
|
+
const QUOTED = /'[^']*'|"(?:[^"\\]|\\.)*"/g;
|
|
140
158
|
function inside(path, folder) {
|
|
141
159
|
const rest = relative(resolve(folder), resolve(path));
|
|
142
160
|
return rest === "" || !rest.startsWith("..") && !isAbsolute(rest);
|
|
@@ -151,7 +169,7 @@ function writableRedirect(target, input) {
|
|
|
151
169
|
function readOnlyBashViolation(input) {
|
|
152
170
|
const command = input.command ?? "";
|
|
153
171
|
for (const rule of READ_ONLY_BASH) if (rule.pattern.test(command)) return rule.label;
|
|
154
|
-
for (const match of command.matchAll(REDIRECT)) if (!writableRedirect(match[1] ?? "", input)) return `redirect to ${match[1]}`;
|
|
172
|
+
for (const match of command.replace(QUOTED, "''").matchAll(REDIRECT)) if (!writableRedirect(match[1] ?? "", input)) return `redirect to ${match[1]}`;
|
|
155
173
|
}
|
|
156
174
|
function guardToolCall(input) {
|
|
157
175
|
const contract = `the ${input.kind} contract`;
|
|
@@ -175,9 +193,9 @@ function kindOfAgentType(agentType) {
|
|
|
175
193
|
return /^rucher[\w-]*:(research|review)$/.exec(agentType ?? "")?.[1];
|
|
176
194
|
}
|
|
177
195
|
// src/hook/post-tool-use.ts
|
|
178
|
-
function handleToolUse(carnet, payload, env) {
|
|
196
|
+
function handleToolUse(carnet, payload, env, options = {}) {
|
|
179
197
|
if (payload.agent_id) return void 0;
|
|
180
|
-
carnet.turn.start(payload.session_id);
|
|
198
|
+
if (options.trackTurn ?? true) carnet.turn.start(payload.session_id);
|
|
181
199
|
const repo = repoNameFor(carnet.workspace, payload.path);
|
|
182
200
|
if (!repo) return void 0;
|
|
183
201
|
const session = carnet.sessions.ensure(payload.session_id, payload.cwd);
|
|
@@ -206,6 +224,48 @@ function guardSubagentCall(carnet, payload, scratchRoot) {
|
|
|
206
224
|
scratchRoot
|
|
207
225
|
});
|
|
208
226
|
}
|
|
227
|
+
// src/status/line.ts
|
|
228
|
+
const STATUS_LINE_LABEL = "rucher";
|
|
229
|
+
const TURN_LABELS = {
|
|
230
|
+
working: "⚙️ working",
|
|
231
|
+
waiting: "⏸ waiting on you",
|
|
232
|
+
failed: "⚠ turn failed"
|
|
233
|
+
};
|
|
234
|
+
function counts(lines) {
|
|
235
|
+
const byEmoji = /* @__PURE__ */ new Map();
|
|
236
|
+
for (const line of lines) byEmoji.set(line.emoji, (byEmoji.get(line.emoji) ?? 0) + 1);
|
|
237
|
+
return [...byEmoji].map(([emoji, count]) => `${emoji}${count}`).join(" ");
|
|
238
|
+
}
|
|
239
|
+
function renderStatusLine(view, lag = null) {
|
|
240
|
+
if (lag) return `${STATUS_LINE_LABEL} · ${lag}`;
|
|
241
|
+
const parts = [];
|
|
242
|
+
if (view.turn) parts.push(TURN_LABELS[view.turn]);
|
|
243
|
+
const [next] = view.waiting;
|
|
244
|
+
if (next) {
|
|
245
|
+
const action = next.action ? ` ${next.action}` : "";
|
|
246
|
+
parts.push(`next: ${next.emoji} ${kindTag(next.kind)} ${next.name}${action}`);
|
|
247
|
+
parts.push(counts(view.waiting));
|
|
248
|
+
}
|
|
249
|
+
if (view.running.length > 0) parts.push(`${EMOJI.running}${view.running.length}`);
|
|
250
|
+
if (view.blocked.length > 0) parts.push(`⛓${view.blocked.length}`);
|
|
251
|
+
return parts.length === 0 ? "" : [STATUS_LINE_LABEL, ...parts].join(" · ");
|
|
252
|
+
}
|
|
253
|
+
function statusLinePath(sessionId, env) {
|
|
254
|
+
return join(rucherPaths(env).state, "status", `${sessionId}.txt`);
|
|
255
|
+
}
|
|
256
|
+
function writeStatusLine(carnet, sessionId, options = {}) {
|
|
257
|
+
const path = statusLinePath(sessionId, options.env);
|
|
258
|
+
const session = carnet.sessions.get(sessionId);
|
|
259
|
+
if (!session || session.status === "archived") {
|
|
260
|
+
rmSync(path, { force: true });
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const line = renderStatusLine(carnet.status.view(session), options.lag ?? null);
|
|
264
|
+
mkdirSync(join(path, ".."), { recursive: true });
|
|
265
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
266
|
+
writeFileSync(temporary, line ? `${line}\n` : "");
|
|
267
|
+
renameSync(temporary, path);
|
|
268
|
+
}
|
|
209
269
|
// src/render.ts
|
|
210
270
|
function renderRunDirectory(workspace, options = {}) {
|
|
211
271
|
mkdirSync(workspace.runDirectory, { recursive: true });
|
|
@@ -222,6 +282,6 @@ function renderRunDirectory(workspace, options = {}) {
|
|
|
222
282
|
}
|
|
223
283
|
return result;
|
|
224
284
|
}
|
|
225
|
-
export { AGENTS_FILE, AGENT_KINDS, AGENT_STATUSES, AGENT_STEPS, CORE_RULES, Carnet, CarnetError, DEFAULT_AGENT_KIND, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DEFAULT_PURGE_DAYS, DUPLICATE_SIMILARITY, EMOJI, EVENT_TYPES, GENERATED_MARKER, GUARDED_TOOLS, INSTRUCTIONS_FILE, KIND_ABBREVIATIONS, KIND_LEGEND, LEGEND, MAIN_FAILED_EMOJI, MAIN_FAILED_SUFFIX, MAIN_HEADER, MAIN_WAITING_EMOJI, MAIN_WAITING_SUFFIX, MAIN_WORKING_EMOJI, MAIN_WORKING_SUFFIX, MARKDOWN_MARKER, 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, PROMPT_FILE, PUBLISH_FALLBACK_MILLISECONDS, REPORTING_NOTE, RESUME_EVENTS, RESUME_MAX_CHARACTERS, RULES_UPDATED_NOTICE, SESSION_EVENT_TYPES, SIMILAR_PREFIX, STALE_AFTER_ACTIVE_DAYS, STOPPED_NOTE, SUBAGENT_RULES, TURNS, USER_ACTION_STATUSES, WAITING_TOOL, WORKSPACE_FILE, addWorkspaceRepo, allHosts, appendPromptFile, archiveWorkspaceSessions, assemblePrompt, baseRules, buildStatusView, claudeCode, compactReminder, corePromptPath, createWorkspace, databasePath, defaultRunDirectory, definitionInstructions, deleteWorkspaceNotes, dropWorkspace, expandHome, formatClock, formatEventLine, guardSubagentCall, guardToolCall, handleSessionEnd, handleSessionStart, handleStop, handleToolStart, handleToolUse, handleUserPromptSubmit, hostById, isAgentKind, isAgentStatus, isEventType, isInside, isNoteKind, isUserActionStatus, isWorkspaceName, kindOfAgentType, listWorkspaces, loadWorkspace, localDay, markdownCopy, memoryHalfLife, memoryMaxCharacters, mergeSettings, migrate, migrations, moveSession, openCarnet, openDatabase, openResolvedCarnet, openWorkspaceCarnet, outsideRucherContext, promptsDirectory, purgeDays, removeStaleCopies, removeWorkspaceRepo, renderAgentLine, renderMainLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderRunDirectory, renderSections, renderStatus, renderTableLine, repoNameFor, repoPathFor, reportPath, reportsDirectory, requireWorkspace, resolveWorkspace, resumeContext, rucherPaths, rulesText, rulesVersion, sanitizeNote, schemaVersion, sessionLabel, sessionNoteActivity, sessionWorkspaceName, shortId, similarity, statusWhenDone, stepAgent, transcriptTitle, workspaceDefinition, workspaceExists, workspaceHosts, workspaceLabel, workspaceLastActive, workspaceRepoNames, workspaceRules, workspaceSessionCounts, workspaceSettings, workspacesDirectory, writeGenerated };
|
|
285
|
+
export { AGENTS_FILE, AGENT_KINDS, AGENT_STATUSES, AGENT_STEPS, BLOCKED_HEADER, CORE_RULES, Carnet, CarnetError, DEFAULT_AGENT_KIND, DEFAULT_HALF_LIFE_DAYS, DEFAULT_HOST, DEFAULT_PURGE_DAYS, DUPLICATE_SIMILARITY, EMOJI, EVENT_TYPES, GENERATED_MARKER, GUARDED_TOOLS, INSTRUCTIONS_FILE, KIND_ABBREVIATIONS, KIND_LEGEND, KIND_TAG_PATTERN, LEGEND, MAIN_FAILED_EMOJI, MAIN_FAILED_SUFFIX, MAIN_HEADER, MAIN_IDLE, MAIN_WAITING_EMOJI, MAIN_WAITING_SUFFIX, MAIN_WORKING_EMOJI, MAIN_WORKING_SUFFIX, MARKDOWN_MARKER, 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, PROMPT_FILE, PUBLISH_FALLBACK_MILLISECONDS, REPORTING_NOTE, RESUME_EVENTS, RESUME_MAX_CHARACTERS, RULES_UPDATED_NOTICE, SESSION_EVENT_TYPES, SIMILAR_PREFIX, STALE_AFTER_ACTIVE_DAYS, STATUS_LINE_LABEL, STOPPED_NOTE, SUBAGENT_RULES, TURNS, USER_ACTION_STATUSES, WAITING_TOOL, WORKSPACE_FILE, addWorkspaceRepo, allHosts, appendPromptFile, archiveWorkspaceSessions, assemblePrompt, baseRules, buildStatusView, claudeCode, compactReminder, corePromptPath, createWorkspace, databasePath, defaultRunDirectory, definitionInstructions, deleteWorkspaceNotes, dropWorkspace, expandHome, formatClock, formatEventLine, guardSubagentCall, guardToolCall, handleSessionEnd, handleSessionStart, handleStop, handleToolStart, handleToolUse, handleUserPromptSubmit, hostById, isAgentKind, isAgentStatus, isEventType, isInside, isNoteKind, isUserActionStatus, isWorkspaceName, kindOfAgentType, kindTag, listWorkspaces, loadWorkspace, localDay, markdownCopy, memoryHalfLife, memoryMaxCharacters, mergeSettings, migrate, migrations, moveSession, openCarnet, openDatabase, openResolvedCarnet, openWorkspaceCarnet, outsideRucherContext, promptsDirectory, purgeDays, removeStaleCopies, removeWorkspaceRepo, renderAgentLine, renderMainLine, renderMemory, renderNoteLine, renderNotes, renderNotesSummary, renderRunDirectory, renderSections, renderStatus, renderStatusLine, renderTableLine, repoNameFor, repoPathFor, reportPath, reportsDirectory, requireWorkspace, resolveWorkspace, resumeContext, rucherPaths, rulesText, rulesVersion, sanitizeNote, schemaVersion, sessionLabel, sessionNoteActivity, sessionWorkspaceName, shortId, similarity, statusLinePath, statusWhenDone, stepAgent, transcriptTitle, workspaceDefinition, workspaceExists, workspaceHosts, workspaceLabel, workspaceLastActive, workspaceRepoNames, workspaceRules, workspaceSessionCounts, workspaceSettings, workspacesDirectory, writeGenerated, writeStatusLine };
|
|
226
286
|
|
|
227
287
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/move.ts","../src/hook/session-end.ts","../src/hook/session-start.ts","../src/hook/user-prompt-submit.ts","../src/guard.ts","../src/hook/post-tool-use.ts","../src/render.ts"],"sourcesContent":["import 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 keptNotes: number;\n}\n\nfunction count(carnet: Carnet, sql: string, ...parameters: string[]): number {\n return Number((carnet.db.prepare(sql).get(...parameters) as { total: number }).total);\n}\n\nfunction agentNames(carnet: Carnet, session: string): string[] {\n return (\n carnet.db\n .prepare('SELECT name FROM agents WHERE session = ? ORDER BY started_at, rowid')\n .all(session) as unknown as { name: string }[]\n ).map((row) => row.name);\n}\n\nfunction sessionNamed(carnet: Carnet, workspace: string, name: string): Session | null {\n const row = carnet.db\n .prepare('SELECT id FROM sessions WHERE workspace = ? AND name = ?')\n .get(workspace, name) as { id: string } | undefined;\n return row ? carnet.sessions.require(row.id) : null;\n}\n\n// One database holds every workspace: moving a session only changes its workspace, and its agents,\n// events and table line follow its id. Notes stay in the workspace they were written in.\nexport function moveSession(\n carnet: Carnet,\n sessionId: string,\n targetWorkspace: string,\n options: MoveOptions = {},\n): MoveResult {\n const session = carnet.sessions.require(sessionId);\n if (session.workspace !== (carnet.workspace?.name ?? null)) {\n throw new CarnetError('SESSION_NOT_FOUND', `Unknown session ${sessionId}`);\n }\n if (session.workspace === targetWorkspace) {\n throw new CarnetError('SESSION_MOVE_INVALID', 'The session is already in this workspace');\n }\n const into = session.name ? sessionNamed(carnet, targetWorkspace, session.name) : null;\n if (into && !options.merge) {\n throw new CarnetError(\n 'SESSION_NAME_TAKEN',\n `Workspace ${targetWorkspace} already has session ${into.name}: pass --merge to merge into it`,\n );\n }\n const agents = agentNames(carnet, session.id);\n const taken = new Set(into ? agentNames(carnet, into.id) : []);\n const hasTable = (id: string) =>\n carnet.db.prepare('SELECT 1 FROM table_items WHERE session = ?').get(id) !== undefined;\n const result: MoveResult = {\n session,\n into,\n movedAgents: agents.filter((name) => !taken.has(name)),\n skippedAgents: agents.filter((name) => taken.has(name)),\n movedEvents: count(\n carnet,\n 'SELECT COUNT(*) AS total FROM events WHERE session = ?',\n session.id,\n ),\n movedTable: hasTable(session.id) && !(into && hasTable(into.id)),\n keptNotes: count(\n carnet,\n 'SELECT COUNT(*) AS total FROM notes WHERE session = ? OR dropped_session = ?',\n session.id,\n session.id,\n ),\n };\n if (options.dryRun) return result;\n if (into) carnet.sessions.merge(session.id, into.id);\n carnet.db\n .prepare('UPDATE sessions SET workspace = ? WHERE id = ?')\n .run(targetWorkspace, session.id);\n return result;\n}\n","import type { Carnet } from '../carnet.ts';\nimport type { HostSessionEndPayload, HostStopPayload } 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 carnet.turn.end(payload.session_id);\n return carnet.sessions.end(payload.session_id);\n}\n\n// A failed turn stays visible until the next one starts, so the human sees it went wrong.\nexport function handleStop(carnet: Carnet, payload: HostStopPayload): void {\n if (payload.failed) carnet.turn.fail(payload.session_id);\n else carnet.turn.end(payload.session_id);\n}\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 // A compaction happens inside a turn; any other start follows a turn that may have died unseen.\n if (source !== 'compact') carnet.turn.end(session.id);\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.workspace, promptEnv));\n } else if (!env.RUCHER_SESSION_ID && !session.promptVersion) {\n contextParts.push(outsideRucherContext(carnet.workspace, promptEnv));\n notices.push(OUTSIDE_RUCHER_NOTICE);\n } else if (\n session.promptVersion &&\n session.promptVersion !== rulesVersion(carnet.workspace, 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.turn.start(payload.session_id);\n carnet.notes.recordActiveDay();\n return carnet.sessions.adoptTitle(payload.session_id, host.promptTitle(payload));\n}\n","import { isAbsolute, relative, resolve } from 'node:path';\nimport type { AgentKind } from './agents.ts';\n\nexport const GUARDED_TOOLS = new Set(['Edit', 'Write', 'NotebookEdit', 'Bash']);\nconst FILE_TOOLS = new Set(['Edit', 'Write', 'NotebookEdit']);\n\nexport interface GuardInput {\n kind: AgentKind;\n toolName: string;\n filePath?: string | undefined;\n command?: string | undefined;\n cwd?: string | undefined;\n worktree?: string | null | undefined;\n // Claude Code's per-session temporary folder, where agents write their reports.\n scratchRoot: string;\n}\n\nconst READ_ONLY_BASH: { pattern: RegExp; label: string }[] = [\n { pattern: /(^|[^\\w-])(rm|mv|cp|tee|truncate|chmod|chown|ln)\\s/, label: 'file change' },\n { pattern: /\\bsed\\s+(-\\w*\\s+)*-i/, label: 'sed -i' },\n {\n pattern:\n /\\bgit\\s+(add|commit|push|stash|reset|checkout|switch|merge|rebase|cherry-pick|apply|restore|rm|mv|tag)\\b/,\n label: 'git write',\n },\n {\n pattern:\n /\\b(npm|pnpm|yarn|bun)\\s+(i|install|add|remove|rm|uninstall|update|up)\\b|\\bpip3?\\s+install\\b/,\n label: 'package install',\n },\n];\n\nconst PUBLISH_BASH = /\\bgit\\s+(commit|push|stash)\\b/;\nconst REDIRECT = /(?:^|[^<>&\\d])\\d?>>?\\s*([^\\s;&|)]+)/g;\n\nfunction inside(path: string, folder: string): boolean {\n const rest = relative(resolve(folder), resolve(path));\n return rest === '' || (!rest.startsWith('..') && !isAbsolute(rest));\n}\n\nfunction absolute(path: string, cwd: string | undefined): string {\n return isAbsolute(path) ? path : resolve(cwd ?? '/', path);\n}\n\nfunction writableRedirect(target: string, input: GuardInput): boolean {\n if (target === '/dev/null' || target.startsWith('&')) return true;\n return inside(absolute(target, input.cwd), input.scratchRoot);\n}\n\nfunction readOnlyBashViolation(input: GuardInput): string | undefined {\n const command = input.command ?? '';\n for (const rule of READ_ONLY_BASH) if (rule.pattern.test(command)) return rule.label;\n for (const match of command.matchAll(REDIRECT)) {\n if (!writableRedirect(match[1] ?? '', input)) return `redirect to ${match[1]}`;\n }\n return undefined;\n}\n\nexport function guardToolCall(input: GuardInput): string | undefined {\n const contract = `the ${input.kind} contract`;\n if (input.kind === 'implement') {\n if (input.toolName === 'Bash') {\n return PUBLISH_BASH.test(input.command ?? '')\n ? `${contract} forbids git commit, push and stash: the human commits`\n : undefined;\n }\n if (!input.worktree || !input.filePath) return undefined;\n const path = absolute(input.filePath, input.cwd);\n if (inside(path, input.worktree) || inside(path, input.scratchRoot)) return undefined;\n return `${contract} limits writes to its worktree ${input.worktree}`;\n }\n if (FILE_TOOLS.has(input.toolName)) {\n if (input.filePath && inside(absolute(input.filePath, input.cwd), input.scratchRoot)) {\n return undefined;\n }\n return `${contract} is read-only: write only the report in the scratchpad`;\n }\n if (input.toolName === 'Bash') {\n const violation = readOnlyBashViolation(input);\n return violation ? `${contract} is read-only: ${violation} is not allowed` : undefined;\n }\n return undefined;\n}\n\n// Cold plugin agents may run without a Carnet row; their type names the kind.\nexport function kindOfAgentType(agentType: string | undefined): AgentKind | undefined {\n const match = /^rucher[\\w-]*:(research|review)$/.exec(agentType ?? '');\n return match?.[1] as AgentKind | undefined;\n}\n","import type { Carnet } from '../carnet.ts';\nimport { guardToolCall, kindOfAgentType } from '../guard.ts';\nimport { repoNameFor } from '../workspace/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 and the turn track the main conversation; a subagent's context is not it.\n if (payload.agent_id) return undefined;\n carnet.turn.start(payload.session_id);\n const repo = repoNameFor(carnet.workspace, 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\nexport const WAITING_TOOL = 'AskUserQuestion';\n\n// The turn is still running, but blocked on the human's answer.\nexport function handleToolStart(carnet: Carnet, payload: HostToolPayload): void {\n if (payload.agent_id || payload.tool_name !== WAITING_TOOL) return;\n carnet.turn.wait(payload.session_id);\n}\n\nexport function guardSubagentCall(\n carnet: Carnet,\n payload: HostToolPayload,\n scratchRoot: string,\n): string | undefined {\n if (!payload.agent_id || !payload.tool_name) return undefined;\n const agent = carnet.agents.byHostAgentId(payload.session_id, payload.agent_id);\n const kind = agent?.kind ?? kindOfAgentType(payload.agent_type);\n if (!kind) return undefined;\n return guardToolCall({\n kind,\n toolName: payload.tool_name,\n filePath: payload.file_path,\n command: payload.command,\n cwd: payload.cwd,\n worktree: agent?.worktree,\n scratchRoot,\n });\n}\n","import { mkdirSync } from 'node:fs';\nimport { type Workspace, workspaceHosts } from './workspace/workspace.ts';\nimport { hostById } from './hosts/host.ts';\nimport { reportsDirectory } from './paths.ts';\n\nexport interface RenderResult {\n runDirectory: string;\n written: string[];\n removed: string[];\n}\n\nexport interface RunDirectoryRenderOptions {\n env?: NodeJS.ProcessEnv | undefined;\n host?: string | undefined;\n}\n\nexport function renderRunDirectory(\n workspace: Workspace,\n options: RunDirectoryRenderOptions = {},\n): RenderResult {\n mkdirSync(workspace.runDirectory, { recursive: true });\n mkdirSync(reportsDirectory(workspace), { recursive: true });\n const result: RenderResult = { runDirectory: workspace.runDirectory, written: [], removed: [] };\n for (const id of options.host ? [options.host] : workspaceHosts(workspace)) {\n const rendered = hostById(id).renderRunDirectory(workspace);\n result.written.push(...rendered.written);\n result.removed.push(...rendered.removed);\n }\n return result;\n}\n"],"mappings":";;;;AAmBA,SAAS,MAAM,QAAgB,KAAa,GAAG,YAA8B;CAC3E,OAAO,OAAQ,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAuB,KAAK;AACtF;AAEA,SAAS,WAAW,QAAgB,SAA2B;CAC7D,OACE,OAAO,GACJ,QAAQ,sEAAsE,CAAC,CAC/E,IAAI,OAAO,CAAC,CACf,KAAK,QAAQ,IAAI,IAAI;AACzB;AAEA,SAAS,aAAa,QAAgB,WAAmB,MAA8B;CACrF,MAAM,MAAM,OAAO,GAChB,QAAQ,0DAA0D,CAAC,CACnE,IAAI,WAAW,IAAI;CACtB,OAAO,MAAM,OAAO,SAAS,QAAQ,IAAI,EAAE,IAAI;AACjD;AAIA,SAAgB,YACd,QACA,WACA,iBACA,UAAuB,CAAC,GACZ;CACZ,MAAM,UAAU,OAAO,SAAS,QAAQ,SAAS;CACjD,IAAI,QAAQ,eAAe,OAAO,WAAW,QAAQ,OACnD,MAAM,IAAI,YAAY,qBAAqB,mBAAmB,WAAW;CAE3E,IAAI,QAAQ,cAAc,iBACxB,MAAM,IAAI,YAAY,wBAAwB,0CAA0C;CAE1F,MAAM,OAAO,QAAQ,OAAO,aAAa,QAAQ,iBAAiB,QAAQ,IAAI,IAAI;CAClF,IAAI,QAAQ,CAAC,QAAQ,OACnB,MAAM,IAAI,YACR,sBACA,aAAa,gBAAgB,uBAAuB,KAAK,KAAK,gCAChE;CAEF,MAAM,SAAS,WAAW,QAAQ,QAAQ,EAAE;CAC5C,MAAM,QAAQ,IAAI,IAAI,OAAO,WAAW,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC;CAC7D,MAAM,YAAY,OAChB,OAAO,GAAG,QAAQ,6CAA6C,CAAC,CAAC,IAAI,EAAE,MAA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AAe,SAAS,GAAG;EAC1E,MAAM,WAAW,SAAS,EAAE,CAAC,CAAC,mBAAmB,SAAS;EAC1D,OAAO,QAAQ,KAAK,GAAG,SAAS,OAAO;EACvC,OAAO,QAAQ,KAAK,GAAG,SAAS,OAAO;CACzC;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/move.ts","../src/hook/session-end.ts","../src/hook/session-start.ts","../src/hook/user-prompt-submit.ts","../src/guard.ts","../src/hook/post-tool-use.ts","../src/status/line.ts","../src/render.ts"],"sourcesContent":["import 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 keptNotes: number;\n}\n\nfunction count(carnet: Carnet, sql: string, ...parameters: string[]): number {\n return Number((carnet.db.prepare(sql).get(...parameters) as { total: number }).total);\n}\n\nfunction agentNames(carnet: Carnet, session: string): string[] {\n return (\n carnet.db\n .prepare('SELECT name FROM agents WHERE session = ? ORDER BY started_at, rowid')\n .all(session) as unknown as { name: string }[]\n ).map((row) => row.name);\n}\n\nfunction sessionNamed(carnet: Carnet, workspace: string, name: string): Session | null {\n const row = carnet.db\n .prepare('SELECT id FROM sessions WHERE workspace = ? AND name = ?')\n .get(workspace, name) as { id: string } | undefined;\n return row ? carnet.sessions.require(row.id) : null;\n}\n\n// One database holds every workspace: moving a session only changes its workspace, and its agents,\n// events and Main line follow its id. Notes stay in the workspace they were written in.\nexport function moveSession(\n carnet: Carnet,\n sessionId: string,\n targetWorkspace: string,\n options: MoveOptions = {},\n): MoveResult {\n const session = carnet.sessions.require(sessionId);\n if (session.workspace !== (carnet.workspace?.name ?? null)) {\n throw new CarnetError('SESSION_NOT_FOUND', `Unknown session ${sessionId}`);\n }\n if (session.workspace === targetWorkspace) {\n throw new CarnetError('SESSION_MOVE_INVALID', 'The session is already in this workspace');\n }\n const into = session.name ? sessionNamed(carnet, targetWorkspace, session.name) : null;\n if (into && !options.merge) {\n throw new CarnetError(\n 'SESSION_NAME_TAKEN',\n `Workspace ${targetWorkspace} already has session ${into.name}: pass --merge to merge into it`,\n );\n }\n const agents = agentNames(carnet, session.id);\n const taken = new Set(into ? agentNames(carnet, into.id) : []);\n const hasTable = (id: string) =>\n carnet.db.prepare('SELECT 1 FROM table_items WHERE session = ?').get(id) !== undefined;\n const result: MoveResult = {\n session,\n into,\n movedAgents: agents.filter((name) => !taken.has(name)),\n skippedAgents: agents.filter((name) => taken.has(name)),\n movedEvents: count(\n carnet,\n 'SELECT COUNT(*) AS total FROM events WHERE session = ?',\n session.id,\n ),\n movedTable: hasTable(session.id) && !(into && hasTable(into.id)),\n keptNotes: count(\n carnet,\n 'SELECT COUNT(*) AS total FROM notes WHERE session = ? OR dropped_session = ?',\n session.id,\n session.id,\n ),\n };\n if (options.dryRun) return result;\n if (into) carnet.sessions.merge(session.id, into.id);\n carnet.db\n .prepare('UPDATE sessions SET workspace = ? WHERE id = ?')\n .run(targetWorkspace, session.id);\n return result;\n}\n","import type { Carnet } from '../carnet.ts';\nimport type { HostSessionEndPayload, HostStopPayload } 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 carnet.turn.end(payload.session_id);\n return carnet.sessions.end(payload.session_id);\n}\n\n// A failed turn stays visible until the next one starts, so the human sees it went wrong.\nexport function handleStop(carnet: Carnet, payload: HostStopPayload): void {\n if (payload.failed) carnet.turn.fail(payload.session_id);\n else carnet.turn.end(payload.session_id);\n}\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// Claude Code carrying the conversation on under a new id is the same session, not a fork:\n// the new id takes the parent's name, agents, Main line and journal.\nfunction adoptContinuation(carnet: Carnet, session: Session, env: HookEnv): Session | undefined {\n const parentId = env.RUCHER_SESSION_ID;\n const parent = parentId && parentId !== session.id ? carnet.sessions.get(parentId) : undefined;\n if (!parent) return undefined;\n const hostEnv = env.CLAUDE_CONFIG_DIR ? { CLAUDE_CONFIG_DIR: env.CLAUDE_CONFIG_DIR } : {};\n if (!hostById(session.host).continues(parent, session.id, hostEnv)) return undefined;\n carnet.memory.copyRepos(parent.id, session.id);\n let merged = carnet.sessions.merge(parent.id, session.id).session;\n merged = carnet.sessions.recordPromptVersion(merged.id, parent.promptVersion);\n return parent.parentId ? carnet.sessions.setParent(merged.id, parent.parentId) : merged;\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 let source = payload.source ?? '';\n if (source === 'fork') {\n const continued = adoptContinuation(carnet, session, env);\n if (continued) {\n session = continued;\n source = 'resume';\n } else {\n session = adoptFork(carnet, session, env);\n }\n }\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 // A compaction happens inside a turn; any other start follows a turn that may have died unseen.\n if (source !== 'compact') carnet.turn.end(session.id);\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.workspace, promptEnv));\n } else if (!env.RUCHER_SESSION_ID && !session.promptVersion) {\n contextParts.push(outsideRucherContext(carnet.workspace, promptEnv));\n notices.push(OUTSIDE_RUCHER_NOTICE);\n } else if (\n session.promptVersion &&\n session.promptVersion !== rulesVersion(carnet.workspace, 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';\nimport type { TurnOptions } from '../turn.ts';\n\nexport function handleUserPromptSubmit(\n carnet: Carnet,\n host: Host,\n payload: HostPromptPayload,\n options: TurnOptions = {},\n): Session {\n carnet.sessions.ensure(payload.session_id, payload.cwd);\n if (options.trackTurn ?? true) carnet.turn.start(payload.session_id);\n carnet.notes.recordActiveDay();\n return carnet.sessions.adoptTitle(payload.session_id, host.promptTitle(payload));\n}\n","import { isAbsolute, relative, resolve } from 'node:path';\nimport type { AgentKind } from './agents.ts';\n\nexport const GUARDED_TOOLS = new Set(['Edit', 'Write', 'NotebookEdit', 'Bash']);\nconst FILE_TOOLS = new Set(['Edit', 'Write', 'NotebookEdit']);\n\nexport interface GuardInput {\n kind: AgentKind;\n toolName: string;\n filePath?: string | undefined;\n command?: string | undefined;\n cwd?: string | undefined;\n worktree?: string | null | undefined;\n // Claude Code's per-session temporary folder, where agents write their reports.\n scratchRoot: string;\n}\n\nconst READ_ONLY_BASH: { pattern: RegExp; label: string }[] = [\n { pattern: /(^|[^\\w-])(rm|mv|cp|tee|truncate|chmod|chown|ln)\\s/, label: 'file change' },\n { pattern: /\\bsed\\s+(-\\w*\\s+)*-i/, label: 'sed -i' },\n {\n pattern:\n /\\bgit\\s+(add|commit|push|stash|reset|checkout|switch|merge|rebase|cherry-pick|apply|restore|rm|mv|tag)\\b/,\n label: 'git write',\n },\n {\n pattern:\n /\\b(npm|pnpm|yarn|bun)\\s+(i|install|add|remove|rm|uninstall|update|up)\\b|\\bpip3?\\s+install\\b/,\n label: 'package install',\n },\n];\n\nconst PUBLISH_BASH = /\\bgit\\s+(commit|push|stash)\\b/;\n// `=>`, `>=` and `->` are operators of an inline script, not redirects.\nconst REDIRECT = /(?:^|[^<>&\\d=-])\\d?>>?(?!=)\\s*([^\\s;&|)]+)/g;\nconst QUOTED = /'[^']*'|\"(?:[^\"\\\\]|\\\\.)*\"/g;\n\nfunction inside(path: string, folder: string): boolean {\n const rest = relative(resolve(folder), resolve(path));\n return rest === '' || (!rest.startsWith('..') && !isAbsolute(rest));\n}\n\nfunction absolute(path: string, cwd: string | undefined): string {\n return isAbsolute(path) ? path : resolve(cwd ?? '/', path);\n}\n\nfunction writableRedirect(target: string, input: GuardInput): boolean {\n if (target === '/dev/null' || target.startsWith('&')) return true;\n return inside(absolute(target, input.cwd), input.scratchRoot);\n}\n\nfunction readOnlyBashViolation(input: GuardInput): string | undefined {\n const command = input.command ?? '';\n for (const rule of READ_ONLY_BASH) if (rule.pattern.test(command)) return rule.label;\n // A `>` inside quotes is text handed to a program, not a redirect of the shell.\n for (const match of command.replace(QUOTED, \"''\").matchAll(REDIRECT)) {\n if (!writableRedirect(match[1] ?? '', input)) return `redirect to ${match[1]}`;\n }\n return undefined;\n}\n\nexport function guardToolCall(input: GuardInput): string | undefined {\n const contract = `the ${input.kind} contract`;\n if (input.kind === 'implement') {\n if (input.toolName === 'Bash') {\n return PUBLISH_BASH.test(input.command ?? '')\n ? `${contract} forbids git commit, push and stash: the human commits`\n : undefined;\n }\n if (!input.worktree || !input.filePath) return undefined;\n const path = absolute(input.filePath, input.cwd);\n if (inside(path, input.worktree) || inside(path, input.scratchRoot)) return undefined;\n return `${contract} limits writes to its worktree ${input.worktree}`;\n }\n if (FILE_TOOLS.has(input.toolName)) {\n if (input.filePath && inside(absolute(input.filePath, input.cwd), input.scratchRoot)) {\n return undefined;\n }\n return `${contract} is read-only: write only the report in the scratchpad`;\n }\n if (input.toolName === 'Bash') {\n const violation = readOnlyBashViolation(input);\n return violation ? `${contract} is read-only: ${violation} is not allowed` : undefined;\n }\n return undefined;\n}\n\n// Cold plugin agents may run without a Carnet row; their type names the kind.\nexport function kindOfAgentType(agentType: string | undefined): AgentKind | undefined {\n const match = /^rucher[\\w-]*:(research|review)$/.exec(agentType ?? '');\n return match?.[1] as AgentKind | undefined;\n}\n","import type { Carnet } from '../carnet.ts';\nimport { guardToolCall, kindOfAgentType } from '../guard.ts';\nimport { repoNameFor } from '../workspace/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';\nimport type { TurnOptions } from '../turn.ts';\n\nexport function handleToolUse(\n carnet: Carnet,\n payload: HostToolPayload,\n env: HookEnv,\n options: TurnOptions = {},\n): string | undefined {\n // session_repos and the turn track the main conversation; a subagent's context is not it.\n if (payload.agent_id) return undefined;\n if (options.trackTurn ?? true) carnet.turn.start(payload.session_id);\n const repo = repoNameFor(carnet.workspace, 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\nexport const WAITING_TOOL = 'AskUserQuestion';\n\n// The turn is still running, but blocked on the human's answer.\nexport function handleToolStart(carnet: Carnet, payload: HostToolPayload): void {\n if (payload.agent_id || payload.tool_name !== WAITING_TOOL) return;\n carnet.turn.wait(payload.session_id);\n}\n\nexport function guardSubagentCall(\n carnet: Carnet,\n payload: HostToolPayload,\n scratchRoot: string,\n): string | undefined {\n if (!payload.agent_id || !payload.tool_name) return undefined;\n const agent = carnet.agents.byHostAgentId(payload.session_id, payload.agent_id);\n const kind = agent?.kind ?? kindOfAgentType(payload.agent_type);\n if (!kind) return undefined;\n return guardToolCall({\n kind,\n toolName: payload.tool_name,\n filePath: payload.file_path,\n command: payload.command,\n cwd: payload.cwd,\n worktree: agent?.worktree,\n scratchRoot,\n });\n}\n","import { mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { Carnet } from '../carnet.ts';\nimport { rucherPaths } from '../paths.ts';\nimport { EMOJI, kindTag } from './model.ts';\nimport type { StatusLine, StatusView } from './view.ts';\n\nexport const STATUS_LINE_LABEL = 'rucher';\n\nconst TURN_LABELS = {\n working: '⚙️ working',\n waiting: '⏸ waiting on you',\n failed: '⚠ turn failed',\n} as const;\n\nfunction counts(lines: readonly StatusLine[]): string {\n const byEmoji = new Map<string, number>();\n for (const line of lines) byEmoji.set(line.emoji, (byEmoji.get(line.emoji) ?? 0) + 1);\n return [...byEmoji].map(([emoji, count]) => `${emoji}${count}`).join(' ');\n}\n\n// One line for Claude Code: what the main agent does, the next thing waiting on the human, then counts.\nexport function renderStatusLine(view: StatusView, lag: string | null = null): string {\n if (lag) return `${STATUS_LINE_LABEL} · ${lag}`;\n const parts: string[] = [];\n if (view.turn) parts.push(TURN_LABELS[view.turn]);\n const [next] = view.waiting;\n if (next) {\n const action = next.action ? ` ${next.action}` : '';\n parts.push(`next: ${next.emoji} ${kindTag(next.kind)} ${next.name}${action}`);\n parts.push(counts(view.waiting));\n }\n if (view.running.length > 0) parts.push(`${EMOJI.running}${view.running.length}`);\n if (view.blocked.length > 0) parts.push(`⛓${view.blocked.length}`);\n return parts.length === 0 ? '' : [STATUS_LINE_LABEL, ...parts].join(' · ');\n}\n\nexport function statusLinePath(sessionId: string, env?: NodeJS.ProcessEnv): string {\n return join(rucherPaths(env).state, 'status', `${sessionId}.txt`);\n}\n\nexport interface StatusLineOptions {\n env?: NodeJS.ProcessEnv | undefined;\n lag?: string | null | undefined;\n}\n\n// Claude Code reads this file on every refresh, so it is written once per change instead of\n// computed by a process per refresh.\nexport function writeStatusLine(\n carnet: Carnet,\n sessionId: string,\n options: StatusLineOptions = {},\n): void {\n const path = statusLinePath(sessionId, options.env);\n const session = carnet.sessions.get(sessionId);\n if (!session || session.status === 'archived') {\n rmSync(path, { force: true });\n return;\n }\n const line = renderStatusLine(carnet.status.view(session), options.lag ?? null);\n mkdirSync(join(path, '..'), { recursive: true });\n const temporary = `${path}.${process.pid}.tmp`;\n writeFileSync(temporary, line ? `${line}\\n` : '');\n renameSync(temporary, path);\n}\n","import { mkdirSync } from 'node:fs';\nimport { type Workspace, workspaceHosts } from './workspace/workspace.ts';\nimport { hostById } from './hosts/host.ts';\nimport { reportsDirectory } from './paths.ts';\n\nexport interface RenderResult {\n runDirectory: string;\n written: string[];\n removed: string[];\n}\n\nexport interface RunDirectoryRenderOptions {\n env?: NodeJS.ProcessEnv | undefined;\n host?: string | undefined;\n}\n\nexport function renderRunDirectory(\n workspace: Workspace,\n options: RunDirectoryRenderOptions = {},\n): RenderResult {\n mkdirSync(workspace.runDirectory, { recursive: true });\n mkdirSync(reportsDirectory(workspace), { recursive: true });\n const result: RenderResult = { runDirectory: workspace.runDirectory, written: [], removed: [] };\n for (const id of options.host ? [options.host] : workspaceHosts(workspace)) {\n const rendered = hostById(id).renderRunDirectory(workspace);\n result.written.push(...rendered.written);\n result.removed.push(...rendered.removed);\n }\n return result;\n}\n"],"mappings":";;;;AAmBA,SAAS,MAAM,QAAgB,KAAa,GAAG,YAA8B;CAC3E,OAAO,OAAQ,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAuB,KAAK;AACtF;AAEA,SAAS,WAAW,QAAgB,SAA2B;CAC7D,OACE,OAAO,GACJ,QAAQ,sEAAsE,CAAC,CAC/E,IAAI,OAAO,CAAC,CACf,KAAK,QAAQ,IAAI,IAAI;AACzB;AAEA,SAAS,aAAa,QAAgB,WAAmB,MAA8B;CACrF,MAAM,MAAM,OAAO,GAChB,QAAQ,0DAA0D,CAAC,CACnE,IAAI,WAAW,IAAI;CACtB,OAAO,MAAM,OAAO,SAAS,QAAQ,IAAI,EAAE,IAAI;AACjD;AAIA,SAAgB,YACd,QACA,WACA,iBACA,UAAuB,CAAC,GACZ;CACZ,MAAM,UAAU,OAAO,SAAS,QAAQ,SAAS;CACjD,IA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,MAAM,OAAO,iBAAiB,OAAO,OAAO,KAAK,OAAO,GAAG,QAAQ,OAAO,IAAI;CAC9E,UAAU,KAAK,MAAM,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAC/C,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,IAAI;CACzC,cAAc,WAAW,OAAO,GAAG,KAAK,MAAM,EAAE;CAChD,WAAW,WAAW,IAAI;AAC5B;;AChDA,SAAgB,mBACd,WACA,UAAqC,CAAC,GACxB;CACd,UAAU,UAAU,cAAc,EAAE,WAAW,KAAK,CAAC;CACrD,UAAU,iBAAiB,SAAS,GAAG,EAAE,WAAW,KAAK,CAAC;CAC1D,MAAM,SAAuB;EAAE,cAAc,UAAU;EAAc,SAAS,CAAC;EAAG,SAAS,CAAC;CAAE;CAC9F,KAAK,MAAM,MAAM,QAAQ,OAAO,CAAC,QAAQ,IAAI,IAAI,eAAe,SAAS,GAAG;EAC1E,MAAM,WAAW,SAAS,EAAE,CAAC,CAAC,mBAAmB,SAAS;EAC1D,OAAO,QAAQ,KAAK,GAAG,SAAS,OAAO;EACvC,OAAO,QAAQ,KAAK,GAAG,SAAS,OAAO;CACzC;CACA,OAAO;AACT"}
|
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, xt as Host } from "./carnet-MC9WeQ6h.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 holds the forks, the Main line, sessions, the journal and the workspace memory that the `rucher` CLI renders. The session is resolved automatically; pass `session` only to target another one. The workflow rules are in the system prompt and the rucher skill: load the skill before launching agents or handling their results.\n\nWhich tool, when:\n- Launch: agent_start with the agent's kind (research, analyze, implement, review), then launch it in a later message.\n- Each step of a fork's work: agent_step (answered, applying, applied, tested, committed, dropped).\n- Final actions, only when the human asks: agent_inject (research), agent_questions then agent_answer then agent_promote (analyze), review_findings then review_decide (review). review_context before launching a review.\n- Main line text for work of your own: 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
|
|
5
|
+
export declare const INSTRUCTIONS = "Carnet holds the forks, the Main line, sessions, the journal and the workspace memory that the `rucher` CLI renders. The session is resolved automatically; pass `session` only to target another one. The workflow rules are in the system prompt and the rucher skill: load the skill before launching agents or handling their results.\n\nWhich tool, when:\n- Launch: agent_start with the agent's kind (research, analyze, implement, review), then launch it in a later message.\n- Each step of a fork's work: agent_step (answered, applying, applied, tested, committed, dropped).\n- Final actions, only when the human asks: agent_inject (research), agent_questions then agent_answer then agent_promote (analyze), review_findings then review_decide (review). review_context before launching a review.\n- Main line text for work of your own: 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 🧪. 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;
|
|
@@ -18,11 +18,13 @@ export declare const SERVER_NAME = "carnet";
|
|
|
18
18
|
export declare const SERVER_VERSION = "0.0.0";
|
|
19
19
|
interface CarnetServerOptions extends Omit<SessionResolverOptions, 'carnet'> {
|
|
20
20
|
carnet: Carnet | (() => Carnet);
|
|
21
|
+
afterTool?: ((carnet: Carnet, sessionId: string) => void) | undefined;
|
|
21
22
|
}
|
|
22
23
|
export declare function createCarnetServer(options: CarnetServerOptions): McpServer;
|
|
23
24
|
interface ServeCarnetOptions extends OpenCarnetOptions {
|
|
24
25
|
carnet?: Carnet;
|
|
25
26
|
ppid?: number;
|
|
27
|
+
afterTool?: CarnetServerOptions['afterTool'];
|
|
26
28
|
}
|
|
27
29
|
export declare function serveCarnet(options?: ServeCarnetOptions): StdioServerHandle;
|
|
28
30
|
interface ToolOutput {
|
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;;
|
|
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;EACxB,cAAc,QAAQ,QAAQ;;wBAOhB,mBAAmB,SAAS,sBAAsB;UAiCjD,2BAA2B;EAC1C,SAAS;EACT;EACA,YAAY;;wBAGE,YAAY,UAAS,qBAA0B;UChC9C;EACf;;UAGe,eAAe,eAAe,EAAE,YAAY,EAAE;EAC7D;EACA;EACA,QAAQ;EACR,MAAM,QAAQ,QAAQ,mBAAmB,MAAM,EAAE,MAAM,YAAY;;qBAilBxD,gBAAgB"}
|