mainflow 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +817 -213
- package/dist/facts.d.ts +64 -2
- package/dist/facts.js +64 -3
- package/dist/grant-commands.d.ts +1 -1
- package/dist/hooks.d.ts +514 -3
- package/dist/hooks.js +66 -35
- package/dist/host-BJnrv8xF.js +7300 -0
- package/dist/host.js +1 -1
- package/dist/index-DV6Gqu8K.d.ts +423 -0
- package/dist/{launch-BKKoCyTj.js → launch-DefacJEL.js} +2 -2
- package/dist/launch.js +1 -1
- package/dist/native/mainflow-swap-linux-x64 +0 -0
- package/dist/native/mainflow-swap.c +67 -0
- package/dist/operation-Bp4U2bx3.js +2862 -0
- package/dist/retro-formats-ECy0gGOL.js +30 -0
- package/dist/ui-CiapFoik.js +658 -0
- package/dist/web/assets/index-CyQML0b0.css +1 -0
- package/dist/web/assets/index-tAb99n75.js +82 -0
- package/dist/web/index.html +2 -2
- package/package.json +3 -1
- package/dist/host-CeN3dvXg.js +0 -3268
- package/dist/index-bIFT1ORw.d.ts +0 -46
- package/dist/ui-D_9x6XNs.js +0 -501
- package/dist/web/assets/index-BUxmYhLT.css +0 -1
- package/dist/web/assets/index-ypKt0hMg.js +0 -80
package/dist/hooks.d.ts
CHANGED
|
@@ -1,3 +1,507 @@
|
|
|
1
|
+
import { a as Decision, d as OpsEntry, g as Task, i as ChecklistItem, l as Issue, m as Session, n as ActionBlock, s as Finding, t as Action, u as Mainline } from "./index-DV6Gqu8K.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../core/dist/ids/allocators.d.ts
|
|
4
|
+
/** The letters ids start with. */
|
|
5
|
+
type IdPrefix = 'm' | 't' | 'd' | 'i' | 'f' | 'c' | 'r' | 'a';
|
|
6
|
+
/** One id an operation needs. */
|
|
7
|
+
interface IdRequest {
|
|
8
|
+
prefix: IdPrefix;
|
|
9
|
+
/** Ids already used in the scope the new one goes into */
|
|
10
|
+
taken: readonly string[];
|
|
11
|
+
/** The reference an id makes in this scope, like id => `m001/t002#${id}`; allocations are reported as references */
|
|
12
|
+
ref: (id: string) => string;
|
|
13
|
+
}
|
|
14
|
+
interface Allocation {
|
|
15
|
+
id: string;
|
|
16
|
+
/** The reference the id makes, e.g. m001/t002#c003 */
|
|
17
|
+
ref: string;
|
|
18
|
+
/** Numbered while offline; the sync server confirms it or gives another when it is taken */
|
|
19
|
+
provisional: boolean;
|
|
20
|
+
/** The provisional reference this id replaces, when the sender's number was taken */
|
|
21
|
+
replaced?: string;
|
|
22
|
+
}
|
|
23
|
+
interface IdAllocator {
|
|
24
|
+
readonly mode: 'local' | 'server' | 'offline';
|
|
25
|
+
next(request: IdRequest): Allocation;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../core/dist/ops/document.d.ts
|
|
29
|
+
/** What an operation needs from its caller besides its input. */
|
|
30
|
+
interface OpContext {
|
|
31
|
+
/**
|
|
32
|
+
* The caller's local time to the minute, like 2026-09-24T15:30. Dates and times an operation writes come
|
|
33
|
+
* from it, so an operation run where the clock is in another time zone, such as UTC in Workers, writes the
|
|
34
|
+
* same dates as one run on the caller's machine.
|
|
35
|
+
*/
|
|
36
|
+
now: string;
|
|
37
|
+
/** Who numbers new entries (src/ids/); without one, the next free id, final at once */
|
|
38
|
+
ids?: IdAllocator;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region ../core/dist/storage/types.d.ts
|
|
42
|
+
/** One name inside a directory. */
|
|
43
|
+
interface Entry {
|
|
44
|
+
name: string;
|
|
45
|
+
dir: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** What an operation may read. */
|
|
48
|
+
interface HubReader {
|
|
49
|
+
/** The text of a file, or null when it does not exist. */
|
|
50
|
+
read(path: string): string | null;
|
|
51
|
+
/** The files and directories directly inside `dir`, sorted by name; empty when `dir` does not exist. */
|
|
52
|
+
list(dir: string): Entry[];
|
|
53
|
+
/** How messages name a path, such as the absolute file path on disk. */
|
|
54
|
+
where(path: string): string;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region ../core/dist/ids/renumber.d.ts
|
|
58
|
+
/** One id the sync server replaced, as references: the provisional one and the one the entry has now. */
|
|
59
|
+
interface Renumbering {
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../core/dist/ops/draft.d.ts
|
|
65
|
+
/** One change to a hub's storage. */
|
|
66
|
+
type Change = {
|
|
67
|
+
kind: 'write';
|
|
68
|
+
path: string;
|
|
69
|
+
text: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'append';
|
|
72
|
+
path: string;
|
|
73
|
+
text: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'makeDir';
|
|
76
|
+
path: string;
|
|
77
|
+
} | {
|
|
78
|
+
kind: 'remove';
|
|
79
|
+
path: string;
|
|
80
|
+
};
|
|
81
|
+
/** Something the writer should be told although the operation went through, such as a file kept against its request. */
|
|
82
|
+
interface Notice {
|
|
83
|
+
path: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
interface OpResult<T> {
|
|
87
|
+
/** What the operation reports back, such as the entry it created */
|
|
88
|
+
value: T;
|
|
89
|
+
/** The changes to apply, in order */
|
|
90
|
+
changes: Change[];
|
|
91
|
+
/** Ids this operation numbered, as references like m014, m001/t007 or claude-code-1a2b3c4d#a003, in the order it numbered them */
|
|
92
|
+
allocated: string[];
|
|
93
|
+
/** Provisional ids the allocator replaced because they were taken, with the ids the entries have instead */
|
|
94
|
+
renumbered: Renumbering[];
|
|
95
|
+
notices: Notice[];
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region ../core/dist/ops/status.d.ts
|
|
99
|
+
/** What a new criterion or checklist item says: what to do and when it counts as done. */
|
|
100
|
+
interface ListItemInput {
|
|
101
|
+
text: string;
|
|
102
|
+
doneWhen: string;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region ../core/dist/ops/hub.d.ts
|
|
106
|
+
/** Register a repository the hub's tasks may point at; `path` is relative to the hub root. */
|
|
107
|
+
declare function addRepo(hub: HubReader, input: {
|
|
108
|
+
name: string;
|
|
109
|
+
path: string;
|
|
110
|
+
}): OpResult<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Register another hub whose documents this hub's references may point at, as `{name}:m001`. `path` is relative
|
|
113
|
+
* to this hub's root; the caller checks that it holds that hub under the same name.
|
|
114
|
+
*/
|
|
115
|
+
declare function addHub(hub: HubReader, input: {
|
|
116
|
+
name: string;
|
|
117
|
+
path: string;
|
|
118
|
+
}): OpResult<string>;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region ../core/dist/ops/mainlines.d.ts
|
|
121
|
+
interface MainlineInput {
|
|
122
|
+
slug: string;
|
|
123
|
+
title: string;
|
|
124
|
+
}
|
|
125
|
+
declare function createMainline(hub: HubReader, input: MainlineInput, ctx: OpContext): OpResult<{
|
|
126
|
+
id: string;
|
|
127
|
+
dir: string;
|
|
128
|
+
}>;
|
|
129
|
+
/** Move a mainline to another status; done is refused while criteria are open or decisions are proposed. */
|
|
130
|
+
declare function setMainlineStatus(hub: HubReader, input: {
|
|
131
|
+
id: string;
|
|
132
|
+
status: string;
|
|
133
|
+
expectedVersion?: string;
|
|
134
|
+
}, ctx: OpContext): OpResult<Mainline>;
|
|
135
|
+
/** Rename a mainline. References use its ID, so they keep resolving and show the new title. */
|
|
136
|
+
declare function setMainlineTitle(hub: HubReader, input: {
|
|
137
|
+
id: string;
|
|
138
|
+
title: string;
|
|
139
|
+
expectedVersion?: string;
|
|
140
|
+
}): OpResult<Mainline>;
|
|
141
|
+
declare function setMainlineArchived(hub: HubReader, input: {
|
|
142
|
+
id: string;
|
|
143
|
+
archived: boolean;
|
|
144
|
+
expectedVersion?: string;
|
|
145
|
+
}, ctx: OpContext): OpResult<Mainline>;
|
|
146
|
+
/** Add an open criterion at the end of the mainline's list, numbered by the context's allocator. */
|
|
147
|
+
declare function addCriterion(hub: HubReader, input: ListItemInput & {
|
|
148
|
+
mainline: string;
|
|
149
|
+
}, ctx: OpContext): OpResult<{
|
|
150
|
+
ref: string;
|
|
151
|
+
}>;
|
|
152
|
+
declare function setCriterion(hub: HubReader, input: {
|
|
153
|
+
ref: string;
|
|
154
|
+
done: boolean;
|
|
155
|
+
evidence?: string;
|
|
156
|
+
expectedVersion?: string;
|
|
157
|
+
}, ctx: OpContext): OpResult<Mainline>;
|
|
158
|
+
/** What `criterion set` rewrites; at least one must be given. `done` stays as it is; use criterion check/uncheck for that. */
|
|
159
|
+
interface CriterionTextPatch {
|
|
160
|
+
text?: string;
|
|
161
|
+
doneWhen?: string;
|
|
162
|
+
}
|
|
163
|
+
/** Rewrite a criterion's text or doneWhen, leaving done and evidence as they are. */
|
|
164
|
+
declare function setCriterionText(hub: HubReader, input: {
|
|
165
|
+
ref: string;
|
|
166
|
+
patch: CriterionTextPatch;
|
|
167
|
+
expectedVersion?: string;
|
|
168
|
+
}): OpResult<Mainline>;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region ../core/dist/ops/tasks.d.ts
|
|
171
|
+
interface TaskInput {
|
|
172
|
+
slug: string;
|
|
173
|
+
title: string;
|
|
174
|
+
kind?: string;
|
|
175
|
+
parent?: string | null;
|
|
176
|
+
repo?: string | null;
|
|
177
|
+
}
|
|
178
|
+
declare function createTask(hub: HubReader, input: TaskInput & {
|
|
179
|
+
mainline: string;
|
|
180
|
+
}, ctx: OpContext): OpResult<{
|
|
181
|
+
ref: string;
|
|
182
|
+
dir: string;
|
|
183
|
+
}>;
|
|
184
|
+
/**
|
|
185
|
+
* What `task set` changes: the status with the fields a transition needs, and the repository and branch
|
|
186
|
+
* the task works on. Title, parent and prose are written in task.md directly.
|
|
187
|
+
*/
|
|
188
|
+
interface TaskPatch {
|
|
189
|
+
status?: string;
|
|
190
|
+
repo?: string | null;
|
|
191
|
+
/** Required with status blocked; cleared when the task leaves blocked */
|
|
192
|
+
blockedBy?: {
|
|
193
|
+
reason: string;
|
|
194
|
+
waitingFor?: string;
|
|
195
|
+
signal?: string;
|
|
196
|
+
};
|
|
197
|
+
branch?: string;
|
|
198
|
+
worktree?: string;
|
|
199
|
+
base?: string;
|
|
200
|
+
merge?: string;
|
|
201
|
+
}
|
|
202
|
+
declare function updateTask(hub: HubReader, input: {
|
|
203
|
+
ref: string;
|
|
204
|
+
patch: TaskPatch;
|
|
205
|
+
expectedVersion?: string;
|
|
206
|
+
}, ctx: OpContext): OpResult<Task>;
|
|
207
|
+
/** Add an open item at the end of the task's checklist, numbered by the context's allocator. */
|
|
208
|
+
declare function addChecklistItem(hub: HubReader, input: ListItemInput & {
|
|
209
|
+
task: string;
|
|
210
|
+
serves?: string[];
|
|
211
|
+
}, ctx: OpContext): OpResult<{
|
|
212
|
+
ref: string;
|
|
213
|
+
item: ChecklistItem;
|
|
214
|
+
}>;
|
|
215
|
+
declare function setChecklistItem(hub: HubReader, input: {
|
|
216
|
+
ref: string;
|
|
217
|
+
done: boolean;
|
|
218
|
+
evidence?: string;
|
|
219
|
+
expectedVersion?: string;
|
|
220
|
+
}, ctx: OpContext): OpResult<Task>;
|
|
221
|
+
/** Mark an item as no longer needed, naming what replaced it when something did. */
|
|
222
|
+
declare function dropChecklistItem(hub: HubReader, input: {
|
|
223
|
+
ref: string;
|
|
224
|
+
supersededBy?: string;
|
|
225
|
+
note?: string;
|
|
226
|
+
expectedVersion?: string;
|
|
227
|
+
}): OpResult<Task>;
|
|
228
|
+
/** Bring a dropped item back as an open one: clears dropped and supersededBy, keeps the note. */
|
|
229
|
+
declare function undropChecklistItem(hub: HubReader, input: {
|
|
230
|
+
ref: string;
|
|
231
|
+
expectedVersion?: string;
|
|
232
|
+
}): OpResult<Task>;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region ../core/dist/ops/decisions.d.ts
|
|
235
|
+
interface DecisionInput {
|
|
236
|
+
slug: string;
|
|
237
|
+
title: string;
|
|
238
|
+
/** proposed while the question is open; accepted by default */
|
|
239
|
+
status?: string;
|
|
240
|
+
by?: string;
|
|
241
|
+
/** explicit when the decider named an option, recommended when they went with the recommendation */
|
|
242
|
+
basis?: string;
|
|
243
|
+
/** Tasks and items the decision shapes; the checklist items among them wait while it is proposed */
|
|
244
|
+
affects?: string[];
|
|
245
|
+
}
|
|
246
|
+
declare function createDecision(hub: HubReader, input: DecisionInput & {
|
|
247
|
+
mainline: string;
|
|
248
|
+
}, ctx: OpContext): OpResult<{
|
|
249
|
+
ref: string;
|
|
250
|
+
file: string;
|
|
251
|
+
}>;
|
|
252
|
+
/** Who settled a decision, and whether they named an option or went with the recommendation. */
|
|
253
|
+
interface DecisionSettlement {
|
|
254
|
+
by?: string;
|
|
255
|
+
basis?: string;
|
|
256
|
+
}
|
|
257
|
+
/** Settle a proposed decision: record who decided, how and when; the items it affects stop waiting for it. */
|
|
258
|
+
declare function acceptDecision(hub: HubReader, input: {
|
|
259
|
+
ref: string;
|
|
260
|
+
expectedVersion?: string;
|
|
261
|
+
} & DecisionSettlement, ctx: OpContext): OpResult<Decision>;
|
|
262
|
+
declare function supersedeDecision(hub: HubReader, input: {
|
|
263
|
+
ref: string;
|
|
264
|
+
by: string;
|
|
265
|
+
expectedVersion?: string;
|
|
266
|
+
}, ctx: OpContext): OpResult<Decision>;
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region ../core/dist/ops/hub-items.d.ts
|
|
269
|
+
interface HubItemInput {
|
|
270
|
+
slug: string;
|
|
271
|
+
title: string;
|
|
272
|
+
origin?: string;
|
|
273
|
+
labels?: string[];
|
|
274
|
+
}
|
|
275
|
+
declare function createIssue(hub: HubReader, input: HubItemInput, ctx: OpContext): OpResult<{
|
|
276
|
+
id: string;
|
|
277
|
+
file: string;
|
|
278
|
+
}>;
|
|
279
|
+
/** Schedule an issue into the task that will carry it out. */
|
|
280
|
+
declare function planIssue(hub: HubReader, input: {
|
|
281
|
+
id: string;
|
|
282
|
+
task: string;
|
|
283
|
+
expectedVersion?: string;
|
|
284
|
+
}): OpResult<Issue>;
|
|
285
|
+
declare function closeIssue(hub: HubReader, input: {
|
|
286
|
+
id: string;
|
|
287
|
+
resolution: string;
|
|
288
|
+
expectedVersion?: string;
|
|
289
|
+
}, ctx: OpContext): OpResult<Issue>;
|
|
290
|
+
declare function reopenIssue(hub: HubReader, input: {
|
|
291
|
+
id: string;
|
|
292
|
+
expectedVersion?: string;
|
|
293
|
+
}): OpResult<Issue>;
|
|
294
|
+
/** Archive or unarchive an issue; the status stays as it is, so a closed issue is visible until archived. */
|
|
295
|
+
declare function setIssueArchived(hub: HubReader, input: {
|
|
296
|
+
id: string;
|
|
297
|
+
archived: boolean;
|
|
298
|
+
expectedVersion?: string;
|
|
299
|
+
}, ctx: OpContext): OpResult<Issue>;
|
|
300
|
+
declare function createFinding(hub: HubReader, input: HubItemInput, ctx: OpContext): OpResult<{
|
|
301
|
+
id: string;
|
|
302
|
+
file: string;
|
|
303
|
+
}>;
|
|
304
|
+
declare function setFindingStatus(hub: HubReader, input: {
|
|
305
|
+
id: string;
|
|
306
|
+
status: string;
|
|
307
|
+
expectedVersion?: string;
|
|
308
|
+
}, ctx: OpContext): OpResult<Finding>;
|
|
309
|
+
/** Archive or unarchive a finding; the status stays as it is, so an obsolete finding is visible until archived. */
|
|
310
|
+
declare function setFindingArchived(hub: HubReader, input: {
|
|
311
|
+
id: string;
|
|
312
|
+
archived: boolean;
|
|
313
|
+
expectedVersion?: string;
|
|
314
|
+
}, ctx: OpContext): OpResult<Finding>;
|
|
315
|
+
/** Append one external operation to ops/{YYYY-MM}.log; the log is never rewritten. `at` defaults to the context's time. */
|
|
316
|
+
declare function appendOps(hub: HubReader, input: Omit<OpsEntry, 'at'> & {
|
|
317
|
+
at?: string;
|
|
318
|
+
}, ctx: OpContext): OpResult<OpsEntry>;
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region ../core/dist/ops/sections.d.ts
|
|
321
|
+
/** Add text at the end of a section of a document's body; the front matter is kept as it is written. */
|
|
322
|
+
declare function appendSection(hub: HubReader, input: {
|
|
323
|
+
ref: string;
|
|
324
|
+
section: string;
|
|
325
|
+
text: string;
|
|
326
|
+
}): OpResult<{
|
|
327
|
+
file: string;
|
|
328
|
+
}>;
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region ../core/dist/ops/files.d.ts
|
|
331
|
+
type Removal = 'removed' | 'absent' | 'kept';
|
|
332
|
+
/**
|
|
333
|
+
* Remove the file at `path` when it is still the version the deleter had, given as its content hash (`base`).
|
|
334
|
+
* A deletion only takes away what the deleter saw: when the file changed since, such as an action another
|
|
335
|
+
* environment added to a session at the same time, removing it would lose that change unseen. The file is kept
|
|
336
|
+
* as it is now and a notice tells the deleter why. A file that is already gone stays gone.
|
|
337
|
+
*/
|
|
338
|
+
declare function removeFile(hub: HubReader, input: {
|
|
339
|
+
path: string;
|
|
340
|
+
base: string;
|
|
341
|
+
}): OpResult<Removal>;
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region ../core/dist/ops/sessions.d.ts
|
|
344
|
+
interface SessionInput {
|
|
345
|
+
/** The caller picks the id, such as `{agent}-{8 random hex}`, since an operation draws no random numbers */
|
|
346
|
+
id: string;
|
|
347
|
+
agent: string;
|
|
348
|
+
cwd: string;
|
|
349
|
+
delegatedFrom?: string | null;
|
|
350
|
+
handoffFrom?: string | null;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Start a session. Taking over from another session moves its unfinished actions into this one and marks
|
|
354
|
+
* the other session handed-off, so the queue continues where it stopped.
|
|
355
|
+
*/
|
|
356
|
+
declare function startSession(hub: HubReader, input: SessionInput, ctx: OpContext): OpResult<Session>;
|
|
357
|
+
/**
|
|
358
|
+
* Start the session unless it already exists. An existing paused or ended session becomes active again, and
|
|
359
|
+
* an archived one comes back into view, since resumed work should not stay hidden.
|
|
360
|
+
*/
|
|
361
|
+
declare function ensureSession(hub: HubReader, input: SessionInput, ctx: OpContext): OpResult<{
|
|
362
|
+
session: Session;
|
|
363
|
+
created: boolean;
|
|
364
|
+
}>;
|
|
365
|
+
/**
|
|
366
|
+
* Take over another session's unfinished actions into a session that already exists, such as one a host hook
|
|
367
|
+
* created when the conversation opened. The receiving session must have nothing unfinished of its own, so the
|
|
368
|
+
* carried queue is not mixed into work already under way; its finished actions stay and the carried ones are
|
|
369
|
+
* numbered after them.
|
|
370
|
+
*/
|
|
371
|
+
declare function handoffSession(hub: HubReader, input: {
|
|
372
|
+
id: string;
|
|
373
|
+
from: string;
|
|
374
|
+
}, ctx: OpContext): OpResult<Session>;
|
|
375
|
+
/** Environment facts a platform adapter learns about a session; only the given fields change. */
|
|
376
|
+
type SessionInfo = Partial<Pick<Session, 'transcript' | 'worktree' | 'branch' | 'model' | 'effort' | 'description' | 'depth' | 'summary'>>;
|
|
377
|
+
declare function setSessionInfo(hub: HubReader, input: {
|
|
378
|
+
id: string;
|
|
379
|
+
info: SessionInfo;
|
|
380
|
+
}): OpResult<Session>;
|
|
381
|
+
/** Remember the digest of what the last turn reminder listed in full; null forgets it, so the next reminder lists everything again. */
|
|
382
|
+
declare function setReminderDigest(hub: HubReader, input: {
|
|
383
|
+
id: string;
|
|
384
|
+
digest: string | null;
|
|
385
|
+
}): OpResult<Session>;
|
|
386
|
+
declare function setSessionStatus(hub: HubReader, input: {
|
|
387
|
+
id: string;
|
|
388
|
+
status: string;
|
|
389
|
+
}): OpResult<Session>;
|
|
390
|
+
type Settled = 'removed' | 'ended' | 'kept';
|
|
391
|
+
/**
|
|
392
|
+
* Settle a session when its turn ends. A session that tracked no action, and whose subagents tracked none, leaves
|
|
393
|
+
* no record, since nothing in it points at the hub's work. Then every active main session with no action left to
|
|
394
|
+
* do and no subagent still running ends, the others as well as this one: another session may have finished its
|
|
395
|
+
* last action, or it was closed before its own turn could settle it. The next prompt or action brings it back.
|
|
396
|
+
*/
|
|
397
|
+
declare function settleSession(hub: HubReader, input: {
|
|
398
|
+
id: string;
|
|
399
|
+
}): OpResult<Settled>;
|
|
400
|
+
/** Archive or unarchive a session; the status stays as it is, so an ended session is visible until archived. */
|
|
401
|
+
declare function setSessionArchived(hub: HubReader, input: {
|
|
402
|
+
id: string;
|
|
403
|
+
archived: boolean;
|
|
404
|
+
}, ctx: OpContext): OpResult<Session>;
|
|
405
|
+
interface ActionInput {
|
|
406
|
+
session: string;
|
|
407
|
+
do: string;
|
|
408
|
+
serves: string[];
|
|
409
|
+
before?: string;
|
|
410
|
+
}
|
|
411
|
+
/** Queue an action; the value is its reference, like claude-code-1a2b3c4d#a003. */
|
|
412
|
+
declare function addAction(hub: HubReader, input: ActionInput, ctx: OpContext): OpResult<string>;
|
|
413
|
+
interface ActionPatch {
|
|
414
|
+
status?: string;
|
|
415
|
+
do?: string;
|
|
416
|
+
serves?: string[];
|
|
417
|
+
before?: string;
|
|
418
|
+
note?: string;
|
|
419
|
+
/** Required with status blocked; cleared when the action leaves blocked */
|
|
420
|
+
blockedBy?: ActionBlock;
|
|
421
|
+
}
|
|
422
|
+
declare function updateAction(hub: HubReader, input: {
|
|
423
|
+
ref: string;
|
|
424
|
+
patch: ActionPatch;
|
|
425
|
+
}, ctx: OpContext): OpResult<Action>;
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region ../core/dist/ops/protocol.d.ts
|
|
428
|
+
/**
|
|
429
|
+
* Every operation by name. A name is the CLI command that sends it with the words joined by a dot, the noun
|
|
430
|
+
* first (`new task` sends `task.new`); a pair of commands that set and clear one thing shares an operation
|
|
431
|
+
* (`item check` and `item uncheck` send `item.check`, with done true or false). The operations no command sends
|
|
432
|
+
* are listed in COMMANDLESS_OPERATIONS with who sends them.
|
|
433
|
+
*/
|
|
434
|
+
declare const OPERATION_NAMES: readonly ['repo.add', 'hub.add', 'mainline.new', 'mainline.set', 'mainline.title', 'mainline.archive', 'criterion.add', 'criterion.check', 'criterion.set', 'task.new', 'task.set', 'item.add', 'item.check', 'item.drop', 'item.undrop', 'decision.new', 'decision.accept', 'decision.supersede', 'issue.new', 'issue.plan', 'issue.close', 'issue.reopen', 'issue.archive', 'finding.new', 'finding.set', 'finding.archive', 'ops.add', 'section.append', 'session.start', 'session.ensure', 'session.handoff', 'session.info', 'session.reminder', 'session.set', 'session.settle', 'session.archive', 'action.add', 'action.set', 'file.remove'];
|
|
435
|
+
type OperationName = (typeof OPERATION_NAMES)[number];
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region ../core/dist/ops/operations.d.ts
|
|
438
|
+
/**
|
|
439
|
+
* The operations by name, for a server that receives them from elsewhere. The names are the protocol's
|
|
440
|
+
* (OPERATION_NAMES in protocol.ts): the table must hold every one of them and nothing else. `migrate` and `init`
|
|
441
|
+
* are absent: migration rewrites the whole hub in one go and a new hub starts on the caller's machine, so neither
|
|
442
|
+
* is sent as an operation.
|
|
443
|
+
*/
|
|
444
|
+
declare const OPERATIONS: {
|
|
445
|
+
readonly 'repo.add': typeof addRepo;
|
|
446
|
+
readonly 'hub.add': typeof addHub;
|
|
447
|
+
readonly 'mainline.new': typeof createMainline;
|
|
448
|
+
readonly 'mainline.set': typeof setMainlineStatus;
|
|
449
|
+
readonly 'mainline.title': typeof setMainlineTitle;
|
|
450
|
+
readonly 'mainline.archive': typeof setMainlineArchived;
|
|
451
|
+
readonly 'criterion.add': typeof addCriterion;
|
|
452
|
+
readonly 'criterion.check': typeof setCriterion;
|
|
453
|
+
readonly 'criterion.set': typeof setCriterionText;
|
|
454
|
+
readonly 'task.new': typeof createTask;
|
|
455
|
+
readonly 'task.set': typeof updateTask;
|
|
456
|
+
readonly 'item.add': typeof addChecklistItem;
|
|
457
|
+
readonly 'item.check': typeof setChecklistItem;
|
|
458
|
+
readonly 'item.drop': typeof dropChecklistItem;
|
|
459
|
+
readonly 'item.undrop': typeof undropChecklistItem;
|
|
460
|
+
readonly 'decision.new': typeof createDecision;
|
|
461
|
+
readonly 'decision.accept': typeof acceptDecision;
|
|
462
|
+
readonly 'decision.supersede': typeof supersedeDecision;
|
|
463
|
+
readonly 'issue.new': typeof createIssue;
|
|
464
|
+
readonly 'issue.plan': typeof planIssue;
|
|
465
|
+
readonly 'issue.close': typeof closeIssue;
|
|
466
|
+
readonly 'issue.reopen': typeof reopenIssue;
|
|
467
|
+
readonly 'issue.archive': typeof setIssueArchived;
|
|
468
|
+
readonly 'finding.new': typeof createFinding;
|
|
469
|
+
readonly 'finding.set': typeof setFindingStatus;
|
|
470
|
+
readonly 'finding.archive': typeof setFindingArchived;
|
|
471
|
+
readonly 'ops.add': typeof appendOps;
|
|
472
|
+
readonly 'section.append': typeof appendSection;
|
|
473
|
+
readonly 'session.start': typeof startSession;
|
|
474
|
+
readonly 'session.ensure': typeof ensureSession;
|
|
475
|
+
readonly 'session.handoff': typeof handoffSession;
|
|
476
|
+
readonly 'session.info': typeof setSessionInfo;
|
|
477
|
+
readonly 'session.reminder': typeof setReminderDigest;
|
|
478
|
+
readonly 'session.set': typeof setSessionStatus;
|
|
479
|
+
readonly 'session.settle': typeof settleSession;
|
|
480
|
+
readonly 'session.archive': typeof setSessionArchived;
|
|
481
|
+
readonly 'action.add': typeof addAction;
|
|
482
|
+
readonly 'action.set': typeof updateAction;
|
|
483
|
+
readonly 'file.remove': typeof removeFile;
|
|
484
|
+
};
|
|
485
|
+
type OperationInput<N extends OperationName> = Parameters<(typeof OPERATIONS)[N]>[1];
|
|
486
|
+
type OperationValue<N extends OperationName> = ReturnType<(typeof OPERATIONS)[N]>['value'];
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/remote/operation.d.ts
|
|
489
|
+
/** What a write reports: the operation's value, and what its caller tells the user about it. */
|
|
490
|
+
interface Written<N extends OperationName = OperationName> {
|
|
491
|
+
value: OperationValue<N>;
|
|
492
|
+
/** Waiting in the outbox, not yet answered by the sync server; new entries in `value` have provisional ids */
|
|
493
|
+
queued: boolean;
|
|
494
|
+
/** Why nothing sends the outbox for now: no sync client runs and none could be started */
|
|
495
|
+
stopped?: string;
|
|
496
|
+
/** Why a sync client was started although one was expected to run */
|
|
497
|
+
restarted?: string;
|
|
498
|
+
/** Provisional ids the server gave to other entries, so this write's entries got the ids after the arrow */
|
|
499
|
+
renumbered: Renumbering[];
|
|
500
|
+
/** What the operation said about the write although it went through, such as a file it kept */
|
|
501
|
+
notices: Notice[];
|
|
502
|
+
}
|
|
503
|
+
type HubWrite = <N extends OperationName>(op: N, input: OperationInput<N>) => Promise<Written<N>>;
|
|
504
|
+
//#endregion
|
|
1
505
|
//#region src/hooks.d.ts
|
|
2
506
|
/** Fields Claude Code sends on stdin to every command hook, plus the ones specific to the events handled here. */
|
|
3
507
|
export interface ClaudeCodePayload {
|
|
@@ -36,6 +540,11 @@ export interface HookContext {
|
|
|
36
540
|
warn?: (message: string) => void;
|
|
37
541
|
/** $CLAUDE_PROJECT_DIR: where the session was opened; events in PROJECT_HUB_EVENTS find the hub from it first */
|
|
38
542
|
projectDir?: string;
|
|
543
|
+
/**
|
|
544
|
+
* How the hub a handler runs in is written; runHook sets it. In remote mode it applies the operation here and puts
|
|
545
|
+
* it in the hub's outbox, as the writing commands do, so a hook's write is never a direct edit (src/remote/operation.ts).
|
|
546
|
+
*/
|
|
547
|
+
write?: HubWrite;
|
|
39
548
|
}
|
|
40
549
|
/**
|
|
41
550
|
* Read a hook's stdin: one JSON object, as Claude Code sends it. Anything else is null, including arrays,
|
|
@@ -43,7 +552,9 @@ export interface HookContext {
|
|
|
43
552
|
*/
|
|
44
553
|
export declare function parsePayload(text: string): ClaudeCodePayload | null;
|
|
45
554
|
export declare const claudeCodeSessionId: (raw: string) => string;
|
|
46
|
-
type Handler = (root: string, ctx: HookContext
|
|
555
|
+
type Handler = (root: string, ctx: HookContext & {
|
|
556
|
+
write: HubWrite;
|
|
557
|
+
}) => Promise<string | null> | string | null;
|
|
47
558
|
/** How a hub's interface is linked from a reply: through its /open route, which shows the address in the app. */
|
|
48
559
|
export declare const openLink: (hub: string) => (path: string) => string;
|
|
49
560
|
/** Why an event could not run its handler: outside a hub, the handler threw, or stdin was not JSON. */
|
|
@@ -63,8 +574,8 @@ export declare function hookFallback(platform: string, event: string, ctx: HookC
|
|
|
63
574
|
* failure is reported on stderr while the caller still exits 0. Events listed in the fallbacks print their
|
|
64
575
|
* fallback instead of staying silent.
|
|
65
576
|
*/
|
|
66
|
-
export declare function runHook(platform: string, event: string, ctx: HookContext): {
|
|
577
|
+
export declare function runHook(platform: string, event: string, ctx: HookContext): Promise<{
|
|
67
578
|
stdout: string | null;
|
|
68
579
|
error: string | null;
|
|
69
|
-
}
|
|
580
|
+
}>;
|
|
70
581
|
//#endregion
|