kith-coord 0.1.7 → 0.1.9
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/CHANGELOG.md +26 -1
- package/CONTRIBUTING.md +7 -1
- package/README.md +37 -19
- package/bin/kith-menubar +0 -0
- package/dist/cli/index.js +14623 -7720
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +424 -7
- package/dist/index.js +5390 -1595
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +5 -2
- package/docs/integrations.md +17 -6
- package/docs/protocol/tools.v1.json +205 -29
- package/docs/protocol.md +32 -2
- package/docs/reliability.md +5 -1
- package/docs/roadmap.md +1 -1
- package/docs/sessions-and-mutexes.md +51 -0
- package/docs/usage.md +38 -10
- package/package.json +10 -2
- package/server.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as node_sqlite from 'node:sqlite';
|
|
2
2
|
import { DatabaseSync } from 'node:sqlite';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Load node:sqlite on first use. A process that never opens a database (a pass-through hook, `kith help`)
|
|
6
|
+
* then neither pays for the module nor prints Node's experimental-feature warning.
|
|
7
|
+
*/
|
|
8
|
+
declare function sqliteDatabase(): typeof DatabaseSync;
|
|
4
9
|
interface CoordEvent {
|
|
5
10
|
id: number;
|
|
6
11
|
timestamp: number;
|
|
@@ -72,6 +77,7 @@ interface SessionRegistration {
|
|
|
72
77
|
declare class FencingAndAgentManager {
|
|
73
78
|
private readonly coordDb;
|
|
74
79
|
static readonly DEFAULT_LEASE_MS: number;
|
|
80
|
+
static readonly IDLE_CONFLICT_MS: number;
|
|
75
81
|
private readonly capabilities;
|
|
76
82
|
private static ownWindowsStart;
|
|
77
83
|
private static inspectionFailure;
|
|
@@ -97,7 +103,26 @@ declare class FencingAndAgentManager {
|
|
|
97
103
|
heartbeat(agentId: string, leaseDurationMs?: number): AgentRecord;
|
|
98
104
|
getAgent(agentId: string): AgentRecord | null;
|
|
99
105
|
listAgents(onlyActive?: boolean): AgentRecord[];
|
|
106
|
+
private lastIgnoredPurge;
|
|
107
|
+
/** Fast SQLite probe so startup cleanup does zero Git work on clean repositories. */
|
|
108
|
+
hasIgnoredCleanupTargets(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Drop recorded conflicts, file claims, and AST contract/dep rows on paths Git ignores
|
|
111
|
+
* (dev-server logs, traces, build output). Older versions recorded them; they must neither block
|
|
112
|
+
* a session nor survive an upgrade.
|
|
113
|
+
*/
|
|
114
|
+
purgeIgnoredClaims(force?: boolean): {
|
|
115
|
+
conflicts: number;
|
|
116
|
+
locks: number;
|
|
117
|
+
};
|
|
100
118
|
reapDeadAgents(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Operator escape hatch: release an agent's claims and mark it dead without its session token.
|
|
121
|
+
* Used by `kith session clear` for an auto-session whose capability was lost or is stuck.
|
|
122
|
+
*/
|
|
123
|
+
forceReclaimAgent(agentId: string, reason?: string): boolean;
|
|
124
|
+
/** Delete recorded conflicts involving `agentId`, or every conflict when omitted. */
|
|
125
|
+
clearConflicts(agentId?: string): number;
|
|
101
126
|
completeAgentSession(agentId: string): void;
|
|
102
127
|
abandonAgentSession(agentId: string): void;
|
|
103
128
|
private reclaim;
|
|
@@ -194,6 +219,104 @@ declare function previewIntegration(repoRoot: string, agent: AgentRecord): {
|
|
|
194
219
|
reason?: undefined;
|
|
195
220
|
};
|
|
196
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Handoffs carry what an agent learned across a session boundary. Coordination state alone loses it: when a
|
|
224
|
+
* session ends, its claims are released and its task is requeued as if untouched. This module is storage only,
|
|
225
|
+
* with no Git or filesystem access, so it is safe to call inside a write transaction (session reclaim, task
|
|
226
|
+
* completion). Everything an agent writes into a handoff is untrusted text for the next reader.
|
|
227
|
+
*/
|
|
228
|
+
declare const HANDOFF_KINDS: readonly ["progress", "blocked", "done", "abandoned"];
|
|
229
|
+
type HandoffKind = (typeof HANDOFF_KINDS)[number];
|
|
230
|
+
/** Kinds an agent may write itself. `abandoned` is recorded by Kith when a session ends without a note. */
|
|
231
|
+
declare const AGENT_HANDOFF_KINDS: readonly ["progress", "blocked", "done"];
|
|
232
|
+
interface HandoffRecord {
|
|
233
|
+
id: string;
|
|
234
|
+
task_id: string | null;
|
|
235
|
+
task_title: string | null;
|
|
236
|
+
task_status: string | null;
|
|
237
|
+
agent_id: string;
|
|
238
|
+
client: string;
|
|
239
|
+
kind: HandoffKind;
|
|
240
|
+
source: 'agent' | 'auto';
|
|
241
|
+
summary: string;
|
|
242
|
+
done: string[];
|
|
243
|
+
remaining: string[];
|
|
244
|
+
learned: string[];
|
|
245
|
+
failed: string[];
|
|
246
|
+
files: string[];
|
|
247
|
+
scope: string[];
|
|
248
|
+
branch: string | null;
|
|
249
|
+
worktree_path: string | null;
|
|
250
|
+
transcript_ref: string | null;
|
|
251
|
+
created_at: number;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface WriteHandoffParams {
|
|
255
|
+
agentId: string;
|
|
256
|
+
taskId?: string;
|
|
257
|
+
kind: (typeof AGENT_HANDOFF_KINDS)[number];
|
|
258
|
+
summary: string;
|
|
259
|
+
done?: string[];
|
|
260
|
+
remaining?: string[];
|
|
261
|
+
learned?: string[];
|
|
262
|
+
failed?: string[];
|
|
263
|
+
files?: string[];
|
|
264
|
+
transcriptRef?: string;
|
|
265
|
+
/** Hand the task back: requeue it and release its claims so another agent can take it. Not valid with `done`. */
|
|
266
|
+
releaseTask?: boolean;
|
|
267
|
+
}
|
|
268
|
+
declare class HandoffEngine {
|
|
269
|
+
private readonly coordDb;
|
|
270
|
+
private readonly fencing;
|
|
271
|
+
constructor(coordDb: CoordDatabase, fencing: FencingAndAgentManager);
|
|
272
|
+
/** Record what the agent learned. Optionally hand its task back to the queue. */
|
|
273
|
+
write(params: WriteHandoffParams): {
|
|
274
|
+
handoff: HandoffRecord;
|
|
275
|
+
released: boolean;
|
|
276
|
+
};
|
|
277
|
+
recent(sinceMs?: number): HandoffRecord[];
|
|
278
|
+
/** Open handoffs, newest first: what a reader checking status should know is still unfinished. */
|
|
279
|
+
unresolved(limit?: number): HandoffRecord[];
|
|
280
|
+
private normalizeScopes;
|
|
281
|
+
/**
|
|
282
|
+
* Handoffs that matter to a claim: those for the same task first, then unfinished ones whose scope or files overlap
|
|
283
|
+
* the claimed scope, then at most two completion notes for the same area.
|
|
284
|
+
*/
|
|
285
|
+
relevantTo(params: {
|
|
286
|
+
taskId?: string | null;
|
|
287
|
+
scopeGlobs: string[];
|
|
288
|
+
limit?: number;
|
|
289
|
+
}): HandoffRecord[];
|
|
290
|
+
list(filter?: {
|
|
291
|
+
taskId?: string;
|
|
292
|
+
agentId?: string;
|
|
293
|
+
scopeGlobs?: string[];
|
|
294
|
+
includeResolved?: boolean;
|
|
295
|
+
limit?: number;
|
|
296
|
+
}): HandoffRecord[];
|
|
297
|
+
}
|
|
298
|
+
interface CompactHandoff {
|
|
299
|
+
id: string;
|
|
300
|
+
kind: HandoffKind;
|
|
301
|
+
source: 'agent' | 'auto';
|
|
302
|
+
agentId: string;
|
|
303
|
+
client: string;
|
|
304
|
+
taskId: string | null;
|
|
305
|
+
taskTitle: string | null;
|
|
306
|
+
summary: string;
|
|
307
|
+
summaryTruncated?: boolean;
|
|
308
|
+
done: string[];
|
|
309
|
+
remaining: string[];
|
|
310
|
+
learned: string[];
|
|
311
|
+
failed: string[];
|
|
312
|
+
files: string[];
|
|
313
|
+
filesOmitted?: number;
|
|
314
|
+
scope: string[];
|
|
315
|
+
branch: string | null;
|
|
316
|
+
transcriptRef: string | null;
|
|
317
|
+
createdAt: number;
|
|
318
|
+
}
|
|
319
|
+
|
|
197
320
|
type SymbolKind = 'function' | 'type' | 'interface' | 'class' | 'schema' | 'route' | 'const';
|
|
198
321
|
interface ExtractedSymbol {
|
|
199
322
|
symbolName: string;
|
|
@@ -261,8 +384,9 @@ declare class LockEngine {
|
|
|
261
384
|
constructor(coordDb: CoordDatabase, fencing: FencingAndAgentManager);
|
|
262
385
|
static normalizePattern(repoRoot: string, rawPattern: string): string;
|
|
263
386
|
static normalizeFile(repoRoot: string, file: string): string;
|
|
264
|
-
|
|
387
|
+
static literalScope(file: string): string;
|
|
265
388
|
private rootForAgent;
|
|
389
|
+
private activeWorktreeRoots;
|
|
266
390
|
private wildcardHasAliases;
|
|
267
391
|
/** Exact overlap for the documented scope grammar; legacy unsupported locks block conservatively. */
|
|
268
392
|
static patternsOverlap(rawA: string, rawB: string): boolean;
|
|
@@ -344,6 +468,7 @@ declare class DependencyAndContractEngine {
|
|
|
344
468
|
* Scans a repository directory to index initial file dependencies and exported contracts.
|
|
345
469
|
*/
|
|
346
470
|
indexRepositoryFiles(dirPath?: string): number;
|
|
471
|
+
private static readonly SKIP_DIRS;
|
|
347
472
|
private walkSourceFiles;
|
|
348
473
|
/**
|
|
349
474
|
* Automatically parses a modified file's imports and exports, updates the dependency graph
|
|
@@ -399,6 +524,7 @@ declare class ShadowGitEngine {
|
|
|
399
524
|
private readonly fencing;
|
|
400
525
|
constructor(coordDb: CoordDatabase, fencing: FencingAndAgentManager);
|
|
401
526
|
isGitRepository(dir?: string): boolean;
|
|
527
|
+
private blobAt;
|
|
402
528
|
getHeadCommit(dir?: string): string | null;
|
|
403
529
|
private getShadowIndexPath;
|
|
404
530
|
/**
|
|
@@ -415,6 +541,12 @@ declare class ShadowGitEngine {
|
|
|
415
541
|
}>;
|
|
416
542
|
worktreeDir?: string;
|
|
417
543
|
}): string | null;
|
|
544
|
+
/**
|
|
545
|
+
* HEAD moves when anyone commits (including via a temporary index). Entries the agent never
|
|
546
|
+
* touched must follow HEAD, or committed work reads as an uncommitted divergence and later
|
|
547
|
+
* surfaces as a false merge conflict.
|
|
548
|
+
*/
|
|
549
|
+
private rebaseShadowIndex;
|
|
418
550
|
/**
|
|
419
551
|
* Runs `git merge-tree --write-tree` across `agentId`'s dirty shadow commit and every
|
|
420
552
|
* other active agent's dirty shadow commit (or branch).
|
|
@@ -424,6 +556,32 @@ declare class ShadowGitEngine {
|
|
|
424
556
|
content?: string;
|
|
425
557
|
}>, worktreeDir?: string): DirtyMergeProbeResult;
|
|
426
558
|
probePairConflict(agentA: string, commitA: string, agentB: string, commitB: string): DirtyMergeProbeResult;
|
|
559
|
+
/** Remove orphaned shadow Git index files left behind by dead or completed sessions. */
|
|
560
|
+
pruneStaleShadowIndexes(dryRun?: boolean): number;
|
|
561
|
+
/** Counts from the most recent {@link pruneFalseConflicts} call. Tests assert the probe budget. */
|
|
562
|
+
lastConflictHygiene: {
|
|
563
|
+
mergeFileProbes: number;
|
|
564
|
+
headReads: number;
|
|
565
|
+
removed: number;
|
|
566
|
+
probeDir: string | null;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Drop stored conflicts that are no longer real. 0.1.8 already refuses to record a side equal
|
|
570
|
+
* to HEAD, or two identical sides, while probing. Rows written before that commit, or before
|
|
571
|
+
* HEAD moved, stay until something reads them. `git merge-file` runs only for triples not
|
|
572
|
+
* already settled, at most `maxMergeProbes` per call, and the decision is cached by HEAD sha
|
|
573
|
+
* plus conflict id so a later status read does not spawn those processes again. Probe files
|
|
574
|
+
* live in the system temp directory and are removed before this returns.
|
|
575
|
+
*/
|
|
576
|
+
pruneFalseConflicts(maxMergeProbes?: number): number;
|
|
577
|
+
private blobsAtCommit;
|
|
578
|
+
/** `conflict` is a real overlap. `error` is not cached, so a later read can retry the probe. */
|
|
579
|
+
private blobsMergeCleanly;
|
|
580
|
+
/** Prefer the system temp dir. If that lives inside this checkout, step outside it. */
|
|
581
|
+
private mergeProbeParent;
|
|
582
|
+
private hygieneCachePath;
|
|
583
|
+
private readHygieneCache;
|
|
584
|
+
private writeHygieneCache;
|
|
427
585
|
listConflicts(): ConflictRecord[];
|
|
428
586
|
}
|
|
429
587
|
|
|
@@ -449,6 +607,23 @@ interface BashGuardPostReport {
|
|
|
449
607
|
authorizedModifiedFiles: string[];
|
|
450
608
|
quarantinedViolations: QuarantineRecord[];
|
|
451
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Checkouts whose index should be resynced after a command that ran `git update-ref`.
|
|
612
|
+
* Each directory is the worktree root of a classified `update-ref` (after `git -C` and `cd`).
|
|
613
|
+
* Unparsed commands and stdin batches yield nothing, so the post-hook does not reset an unrelated index.
|
|
614
|
+
*/
|
|
615
|
+
declare function refUpdateResyncRoots(command: string, startDir: string): string[];
|
|
616
|
+
/**
|
|
617
|
+
* True when a shell command is purely observational (e.g. `ls`, `tail`, `git status`, `stack.mjs status`)
|
|
618
|
+
* and contains no file-redirection or write primitives.
|
|
619
|
+
*/
|
|
620
|
+
declare function isReadOnlyShellCommand(command: string): boolean;
|
|
621
|
+
/**
|
|
622
|
+
* True when `command` explicitly references `relPath` (or its filename) and contains a write/mutation
|
|
623
|
+
* indicator. Prevents blaming unrelated or read-only commands for concurrent edits made by the live
|
|
624
|
+
* lock holder in a shared checkout.
|
|
625
|
+
*/
|
|
626
|
+
declare function commandTargetsFileForWrite(command: string, relPath: string): boolean;
|
|
452
627
|
declare class BashMerkleGuard {
|
|
453
628
|
private readonly coordDb;
|
|
454
629
|
private readonly fencing;
|
|
@@ -466,7 +641,21 @@ declare class BashMerkleGuard {
|
|
|
466
641
|
}): {
|
|
467
642
|
safe: boolean;
|
|
468
643
|
reason?: string;
|
|
644
|
+
deferred?: boolean;
|
|
469
645
|
};
|
|
646
|
+
/**
|
|
647
|
+
* Post-hook half of a deferred shared-checkout update-ref. Literal SHAs are decided in
|
|
648
|
+
* checkCommandSafety; shell variables are checked against the commit that landed.
|
|
649
|
+
*/
|
|
650
|
+
settleDeferredRefUpdate(params: {
|
|
651
|
+
agentId: string;
|
|
652
|
+
command: string;
|
|
653
|
+
}): {
|
|
654
|
+
warnings: string[];
|
|
655
|
+
reverted: boolean;
|
|
656
|
+
};
|
|
657
|
+
private refHost;
|
|
658
|
+
private recordedTasks;
|
|
470
659
|
private getSnapshotFilePath;
|
|
471
660
|
/**
|
|
472
661
|
* Captures a Merkle snapshot of workspace files before a Bash tool execution.
|
|
@@ -486,6 +675,7 @@ declare class BashMerkleGuard {
|
|
|
486
675
|
restoreLockedFiles?: boolean;
|
|
487
676
|
}): BashGuardPostReport;
|
|
488
677
|
private quarantineAndRevertFile;
|
|
678
|
+
private static readonly SKIP_DIRS;
|
|
489
679
|
private walkWorkspaceFiles;
|
|
490
680
|
listQuarantined(): QuarantineRecord[];
|
|
491
681
|
}
|
|
@@ -508,6 +698,7 @@ interface SpeculativeMergeResult {
|
|
|
508
698
|
mergedCommitSha: string | null;
|
|
509
699
|
diagnostics: string;
|
|
510
700
|
}
|
|
701
|
+
declare function runVerificationCommand(command: string, cwd: string, env: NodeJS.ProcessEnv, timeoutMs?: number): string;
|
|
511
702
|
declare class SpeculativeMergeTrain {
|
|
512
703
|
private readonly coordDb;
|
|
513
704
|
private readonly fencing;
|
|
@@ -523,10 +714,19 @@ declare class SpeculativeMergeTrain {
|
|
|
523
714
|
worktreePath?: string | null;
|
|
524
715
|
verificationCmd?: string | null;
|
|
525
716
|
commitMessage?: string;
|
|
717
|
+
waitTimeoutMs?: number;
|
|
718
|
+
verificationTimeoutMs?: number;
|
|
526
719
|
}): SpeculativeMergeResult;
|
|
527
720
|
private gitHead;
|
|
528
721
|
private gitBranch;
|
|
529
|
-
|
|
722
|
+
/** Paths with uncommitted changes in the target checkout. Untracked directories end in `/`. Kith's own state is excluded. */
|
|
723
|
+
private dirtyTargetPaths;
|
|
724
|
+
private diffNames;
|
|
725
|
+
/** Paths a merge of `sourceSha` will bring into the target: the source's own changes since the merge base. */
|
|
726
|
+
private pathsChangedBySource;
|
|
727
|
+
private pathsBetween;
|
|
728
|
+
/** Refuse only when the target has uncommitted edits to a file the integration will write. */
|
|
729
|
+
private requireNoTargetOverlap;
|
|
530
730
|
private cleanupStageWorktree;
|
|
531
731
|
getEntry(id: string): MergeTrainEntry | null;
|
|
532
732
|
listQueue(): MergeTrainEntry[];
|
|
@@ -705,6 +905,91 @@ declare class IntentAndTaskEngine {
|
|
|
705
905
|
}): TaskRecord[];
|
|
706
906
|
}
|
|
707
907
|
|
|
908
|
+
/**
|
|
909
|
+
* How a repository's agents share files. `worktrees` gives each agent an isolated Git worktree and integrates through
|
|
910
|
+
* a merge train. `main` keeps every agent in the one checkout, coordinating through scope claims; it is the model for
|
|
911
|
+
* teams that work on the main branch and treat worktrees as overhead. The mode is repository-wide shared state.
|
|
912
|
+
*/
|
|
913
|
+
declare const WORKFLOW_MODES: readonly ["worktrees", "main"];
|
|
914
|
+
type WorkflowMode = (typeof WORKFLOW_MODES)[number];
|
|
915
|
+
|
|
916
|
+
interface BriefAgent {
|
|
917
|
+
agentId: string;
|
|
918
|
+
client: string;
|
|
919
|
+
state: 'live' | 'stale';
|
|
920
|
+
lastSeenMs: number;
|
|
921
|
+
tasks: Array<{
|
|
922
|
+
id: string;
|
|
923
|
+
title: string;
|
|
924
|
+
scope: string[];
|
|
925
|
+
}>;
|
|
926
|
+
claims: number;
|
|
927
|
+
recentFiles?: string[];
|
|
928
|
+
}
|
|
929
|
+
interface BriefHandoff extends CompactHandoff {
|
|
930
|
+
ageMs: number;
|
|
931
|
+
moreItems?: boolean;
|
|
932
|
+
}
|
|
933
|
+
interface Brief {
|
|
934
|
+
repository: string;
|
|
935
|
+
mode: WorkflowMode;
|
|
936
|
+
state: 'ready' | 'none' | 'unavailable';
|
|
937
|
+
error?: string;
|
|
938
|
+
observedAt: number;
|
|
939
|
+
scope?: string[];
|
|
940
|
+
active: BriefAgent[];
|
|
941
|
+
/** Claims held by others that overlap `scope`; only present when a scope was given. */
|
|
942
|
+
blockers: Array<{
|
|
943
|
+
agentId: string;
|
|
944
|
+
pattern: string;
|
|
945
|
+
mode: string;
|
|
946
|
+
}>;
|
|
947
|
+
/** `count` is recent queued work; `stale` is queued work nobody has touched for two weeks, counted but not listed. */
|
|
948
|
+
queued: {
|
|
949
|
+
count: number;
|
|
950
|
+
stale: number;
|
|
951
|
+
next: Array<{
|
|
952
|
+
id: string;
|
|
953
|
+
title: string;
|
|
954
|
+
scope: string[];
|
|
955
|
+
hasHandoff: boolean;
|
|
956
|
+
}>;
|
|
957
|
+
};
|
|
958
|
+
handoffs: BriefHandoff[];
|
|
959
|
+
conflicts: Array<{
|
|
960
|
+
agents: [string, string];
|
|
961
|
+
file: string;
|
|
962
|
+
severity: string;
|
|
963
|
+
}>;
|
|
964
|
+
empty: boolean;
|
|
965
|
+
notice: string;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
interface CommitParams {
|
|
969
|
+
agentId?: string;
|
|
970
|
+
sessionToken?: string;
|
|
971
|
+
message: string;
|
|
972
|
+
files?: string[];
|
|
973
|
+
callerPid?: number;
|
|
974
|
+
home?: string;
|
|
975
|
+
}
|
|
976
|
+
interface CommitResult {
|
|
977
|
+
ok: boolean;
|
|
978
|
+
commit: string | null;
|
|
979
|
+
branch: string | null;
|
|
980
|
+
files: string[];
|
|
981
|
+
agentId: string | null;
|
|
982
|
+
message: string;
|
|
983
|
+
error?: string;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Commits only the specified (or caller-recorded) files using a temporary Git index,
|
|
987
|
+
* `git commit-tree`, and compare-and-swap `git update-ref`, then syncs those paths in
|
|
988
|
+
* `.git/index` so shared-checkout `main` sessions never sweep sibling edits or leave
|
|
989
|
+
* phantom staged deletions/modifications.
|
|
990
|
+
*/
|
|
991
|
+
declare function commitScopedFiles(engine: KithEngine, params: CommitParams): CommitResult;
|
|
992
|
+
|
|
708
993
|
interface LinkedWorkspaceContract {
|
|
709
994
|
alias: string;
|
|
710
995
|
sourceRepo: string;
|
|
@@ -773,7 +1058,18 @@ declare class KithEngine {
|
|
|
773
1058
|
readonly mergeTrain: SpeculativeMergeTrain;
|
|
774
1059
|
readonly bashGuard: BashMerkleGuard;
|
|
775
1060
|
readonly broker: ResourceBroker;
|
|
1061
|
+
readonly handoffs: HandoffEngine;
|
|
776
1062
|
constructor(repoRoot?: string, customDbPath?: string);
|
|
1063
|
+
/** The repository's workflow mode. Shared by every agent and worktree; `worktrees` unless someone chose `main`. */
|
|
1064
|
+
workflowMode(): WorkflowMode;
|
|
1065
|
+
/** True when `workflow_mode` was explicitly written to `meta` rather than falling back to the default. */
|
|
1066
|
+
workflowModeConfigured(): boolean;
|
|
1067
|
+
setWorkflowMode(mode: WorkflowMode): WorkflowMode;
|
|
1068
|
+
commit(params: CommitParams): CommitResult;
|
|
1069
|
+
/** Read-only situational summary from live state: who is active on what, open handoffs, conflicts, claims that overlap a scope. */
|
|
1070
|
+
brief(options?: {
|
|
1071
|
+
scopeGlobs?: string[];
|
|
1072
|
+
}): Brief;
|
|
777
1073
|
/**
|
|
778
1074
|
* Executes the complete PostToolUse pipeline whenever an agent writes or edits a file:
|
|
779
1075
|
* 1. Extracts AST exports/imports and updates the Contract Blackboard & Import Graph
|
|
@@ -811,8 +1107,15 @@ declare class KithEngine {
|
|
|
811
1107
|
crossRepoWarnings: string[];
|
|
812
1108
|
crossRepoComplete: boolean;
|
|
813
1109
|
resources: ResourceRecord[];
|
|
1110
|
+
workflowMode: "worktrees" | "main";
|
|
1111
|
+
workflowModeConfigured: boolean;
|
|
814
1112
|
mergeQueue: MergeTrainEntry[];
|
|
815
1113
|
quarantined: QuarantineRecord[];
|
|
1114
|
+
handoffs: {
|
|
1115
|
+
untrusted: true;
|
|
1116
|
+
notice: string;
|
|
1117
|
+
items: CompactHandoff[];
|
|
1118
|
+
};
|
|
816
1119
|
mutexWaiters: Record<string, node_sqlite.SQLOutputValue>[];
|
|
817
1120
|
commandGuards: Record<string, node_sqlite.SQLOutputValue>[];
|
|
818
1121
|
workspaces: WorkspaceObservation[];
|
|
@@ -846,6 +1149,13 @@ declare class KithEngine {
|
|
|
846
1149
|
isolateWorktree?: boolean;
|
|
847
1150
|
}): {
|
|
848
1151
|
worktree: SpawnedWorktree | null;
|
|
1152
|
+
workflowMode: "worktrees" | "main";
|
|
1153
|
+
notes: string[];
|
|
1154
|
+
handoffs: {
|
|
1155
|
+
untrusted: true;
|
|
1156
|
+
notice: string;
|
|
1157
|
+
items: CompactHandoff[];
|
|
1158
|
+
};
|
|
849
1159
|
linkedContracts: LinkedWorkspaceContract[];
|
|
850
1160
|
crossRepoWarnings: string[];
|
|
851
1161
|
crossRepoComplete: boolean;
|
|
@@ -861,6 +1171,13 @@ declare class KithEngine {
|
|
|
861
1171
|
isolateWorktree?: boolean;
|
|
862
1172
|
}): {
|
|
863
1173
|
worktree: SpawnedWorktree | null;
|
|
1174
|
+
workflowMode: "worktrees" | "main";
|
|
1175
|
+
notes: string[];
|
|
1176
|
+
handoffs: {
|
|
1177
|
+
untrusted: true;
|
|
1178
|
+
notice: string;
|
|
1179
|
+
items: CompactHandoff[];
|
|
1180
|
+
};
|
|
864
1181
|
publishedContracts: ContractRecord[];
|
|
865
1182
|
linkedContracts: LinkedWorkspaceContract[];
|
|
866
1183
|
crossRepoWarnings: string[];
|
|
@@ -881,6 +1198,13 @@ declare class KithEngine {
|
|
|
881
1198
|
signal?: AbortSignal;
|
|
882
1199
|
}): Promise<{
|
|
883
1200
|
worktree: SpawnedWorktree | null;
|
|
1201
|
+
workflowMode: "worktrees" | "main";
|
|
1202
|
+
notes: string[];
|
|
1203
|
+
handoffs: {
|
|
1204
|
+
untrusted: true;
|
|
1205
|
+
notice: string;
|
|
1206
|
+
items: CompactHandoff[];
|
|
1207
|
+
};
|
|
884
1208
|
publishedContracts: ContractRecord[];
|
|
885
1209
|
linkedContracts: LinkedWorkspaceContract[];
|
|
886
1210
|
crossRepoWarnings: string[];
|
|
@@ -901,6 +1225,13 @@ declare class KithEngine {
|
|
|
901
1225
|
signal?: AbortSignal;
|
|
902
1226
|
}): Promise<{
|
|
903
1227
|
worktree: SpawnedWorktree | null;
|
|
1228
|
+
workflowMode: "worktrees" | "main";
|
|
1229
|
+
notes: string[];
|
|
1230
|
+
handoffs: {
|
|
1231
|
+
untrusted: true;
|
|
1232
|
+
notice: string;
|
|
1233
|
+
items: CompactHandoff[];
|
|
1234
|
+
};
|
|
904
1235
|
linkedContracts: LinkedWorkspaceContract[];
|
|
905
1236
|
crossRepoWarnings: string[];
|
|
906
1237
|
crossRepoComplete: boolean;
|
|
@@ -928,11 +1259,17 @@ declare class KithEngine {
|
|
|
928
1259
|
fencingToken?: number;
|
|
929
1260
|
mergeBranch?: string;
|
|
930
1261
|
verificationCmd?: string;
|
|
1262
|
+
waitTimeoutMs?: number;
|
|
931
1263
|
}): {
|
|
932
1264
|
ok: boolean;
|
|
933
1265
|
mergeResult: SpeculativeMergeResult;
|
|
934
1266
|
error: string;
|
|
935
1267
|
completedTasks?: undefined;
|
|
1268
|
+
} | {
|
|
1269
|
+
ok: boolean;
|
|
1270
|
+
mergeResult: null;
|
|
1271
|
+
error: string;
|
|
1272
|
+
completedTasks?: undefined;
|
|
936
1273
|
} | {
|
|
937
1274
|
ok: boolean;
|
|
938
1275
|
completedTasks: TaskRecord[];
|
|
@@ -955,9 +1292,19 @@ declare function isWithin(root: string, target: string): boolean;
|
|
|
955
1292
|
declare function repositoryFile(root: string, file: string): string;
|
|
956
1293
|
/** Git's common directory identifies shared coordination; Git operations stay in this checkout. */
|
|
957
1294
|
declare function discoverRepository(input: string): RepositoryLayout;
|
|
1295
|
+
/**
|
|
1296
|
+
* When a workspace directory (such as a multi-repo parent folder) is not itself a Git repository,
|
|
1297
|
+
* discover immediate child directories that are Git repositories.
|
|
1298
|
+
*/
|
|
1299
|
+
declare function discoverChildRepositories(input: string): RepositoryLayout[];
|
|
958
1300
|
/** Read-only probe using an existing directory; uncertain results retain exclusion. */
|
|
959
1301
|
declare function caseSensitivePaths(root: string): boolean;
|
|
960
1302
|
|
|
1303
|
+
declare function extractRecentAgentFiles(rows: Array<{
|
|
1304
|
+
agent_id: string;
|
|
1305
|
+
event_type: string;
|
|
1306
|
+
payload_json: string;
|
|
1307
|
+
}>): Record<string, string[]>;
|
|
961
1308
|
/** Copies a consistent stopped-state set before opening SQLite, so even SHM reconstruction cannot touch original recovery files. */
|
|
962
1309
|
declare function readCoordinationState(directory?: string, options?: {
|
|
963
1310
|
ownersOnly?: boolean;
|
|
@@ -990,10 +1337,17 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
990
1337
|
mutexWaiters: Record<string, unknown>[];
|
|
991
1338
|
commandGuards: Record<string, unknown>[];
|
|
992
1339
|
events: Record<string, unknown>[];
|
|
1340
|
+
recentAgentFiles: Record<string, string[]>;
|
|
993
1341
|
workspaces: ReturnType<typeof observeWorkspaces>;
|
|
1342
|
+
handoffs: HandoffRecord[];
|
|
1343
|
+
workflowMode: WorkflowMode;
|
|
1344
|
+
workflowModeConfigured: boolean;
|
|
994
1345
|
} | {
|
|
995
1346
|
state: "ready";
|
|
996
1347
|
schemaVersion: number;
|
|
1348
|
+
handoffs: HandoffRecord[];
|
|
1349
|
+
workflowMode: "worktrees" | "main";
|
|
1350
|
+
workflowModeConfigured: boolean;
|
|
997
1351
|
fencingEpoch: number;
|
|
998
1352
|
agents: AgentRecord[];
|
|
999
1353
|
tasks: {
|
|
@@ -1015,6 +1369,7 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
1015
1369
|
events: {
|
|
1016
1370
|
payload: any;
|
|
1017
1371
|
}[];
|
|
1372
|
+
recentAgentFiles: Record<string, string[]>;
|
|
1018
1373
|
workspaces: WorkspaceObservation[];
|
|
1019
1374
|
protocolVersion: string;
|
|
1020
1375
|
observedAt: number;
|
|
@@ -1041,10 +1396,17 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
1041
1396
|
scope_globs: any;
|
|
1042
1397
|
}[];
|
|
1043
1398
|
locks: Record<string, unknown>[];
|
|
1399
|
+
conflicts: {
|
|
1400
|
+
details: any;
|
|
1401
|
+
}[];
|
|
1402
|
+
handoffs: HandoffRecord[];
|
|
1403
|
+
workflowMode: "worktrees" | "main";
|
|
1404
|
+
workflowModeConfigured: boolean;
|
|
1044
1405
|
resources: Record<string, unknown>[];
|
|
1045
1406
|
mutexWaiters: Record<string, unknown>[];
|
|
1046
1407
|
commandGuards: Record<string, unknown>[];
|
|
1047
1408
|
mergeQueue: Record<string, unknown>[];
|
|
1409
|
+
recentAgentFiles: Record<string, string[]>;
|
|
1048
1410
|
truncated: boolean;
|
|
1049
1411
|
protocolVersion: string;
|
|
1050
1412
|
observedAt: number;
|
|
@@ -1058,12 +1420,19 @@ declare function readCoordinationState(directory?: string, options?: {
|
|
|
1058
1420
|
};
|
|
1059
1421
|
error: string | undefined;
|
|
1060
1422
|
fencingEpoch: number;
|
|
1061
|
-
conflicts: Record<string, unknown>[];
|
|
1062
1423
|
contracts: Record<string, unknown>[];
|
|
1063
1424
|
quarantined: Record<string, unknown>[];
|
|
1064
1425
|
events: Record<string, unknown>[];
|
|
1065
1426
|
workspaces: ReturnType<typeof observeWorkspaces>;
|
|
1066
1427
|
};
|
|
1428
|
+
/**
|
|
1429
|
+
* The brief, read from a private snapshot: it never creates state, migrates, reaps or writes, so it is safe to run from
|
|
1430
|
+
* any shell, hook or agent whether or not that process ever joined Kith.
|
|
1431
|
+
*/
|
|
1432
|
+
declare function readBrief(directory?: string, options?: {
|
|
1433
|
+
scopeGlobs?: string[];
|
|
1434
|
+
handoffLimit?: number;
|
|
1435
|
+
}): Brief;
|
|
1067
1436
|
/** Recovery is an inspection report: it never clears guards, expires claims, deletes worktrees or restores files. */
|
|
1068
1437
|
declare function recoveryReport(directory?: string): {
|
|
1069
1438
|
retainedWorktrees: {
|
|
@@ -1108,7 +1477,11 @@ declare function recoveryReport(directory?: string): {
|
|
|
1108
1477
|
mutexWaiters: Record<string, unknown>[];
|
|
1109
1478
|
commandGuards: Record<string, unknown>[];
|
|
1110
1479
|
events: Record<string, unknown>[];
|
|
1480
|
+
recentAgentFiles: Record<string, string[]>;
|
|
1111
1481
|
workspaces: ReturnType<typeof observeWorkspaces>;
|
|
1482
|
+
handoffs: HandoffRecord[];
|
|
1483
|
+
workflowMode: WorkflowMode;
|
|
1484
|
+
workflowModeConfigured: boolean;
|
|
1112
1485
|
} | {
|
|
1113
1486
|
retainedWorktrees: {
|
|
1114
1487
|
path: string;
|
|
@@ -1127,6 +1500,9 @@ declare function recoveryReport(directory?: string): {
|
|
|
1127
1500
|
};
|
|
1128
1501
|
state: "ready";
|
|
1129
1502
|
schemaVersion: number;
|
|
1503
|
+
handoffs: HandoffRecord[];
|
|
1504
|
+
workflowMode: "worktrees" | "main";
|
|
1505
|
+
workflowModeConfigured: boolean;
|
|
1130
1506
|
fencingEpoch: number;
|
|
1131
1507
|
agents: AgentRecord[];
|
|
1132
1508
|
tasks: {
|
|
@@ -1148,6 +1524,7 @@ declare function recoveryReport(directory?: string): {
|
|
|
1148
1524
|
events: {
|
|
1149
1525
|
payload: any;
|
|
1150
1526
|
}[];
|
|
1527
|
+
recentAgentFiles: Record<string, string[]>;
|
|
1151
1528
|
workspaces: WorkspaceObservation[];
|
|
1152
1529
|
protocolVersion: string;
|
|
1153
1530
|
observedAt: number;
|
|
@@ -1189,10 +1566,17 @@ declare function recoveryReport(directory?: string): {
|
|
|
1189
1566
|
scope_globs: any;
|
|
1190
1567
|
}[];
|
|
1191
1568
|
locks: Record<string, unknown>[];
|
|
1569
|
+
conflicts: {
|
|
1570
|
+
details: any;
|
|
1571
|
+
}[];
|
|
1572
|
+
handoffs: HandoffRecord[];
|
|
1573
|
+
workflowMode: "worktrees" | "main";
|
|
1574
|
+
workflowModeConfigured: boolean;
|
|
1192
1575
|
resources: Record<string, unknown>[];
|
|
1193
1576
|
mutexWaiters: Record<string, unknown>[];
|
|
1194
1577
|
commandGuards: Record<string, unknown>[];
|
|
1195
1578
|
mergeQueue: Record<string, unknown>[];
|
|
1579
|
+
recentAgentFiles: Record<string, string[]>;
|
|
1196
1580
|
truncated: boolean;
|
|
1197
1581
|
protocolVersion: string;
|
|
1198
1582
|
observedAt: number;
|
|
@@ -1206,14 +1590,47 @@ declare function recoveryReport(directory?: string): {
|
|
|
1206
1590
|
};
|
|
1207
1591
|
error: string | undefined;
|
|
1208
1592
|
fencingEpoch: number;
|
|
1209
|
-
conflicts: Record<string, unknown>[];
|
|
1210
1593
|
contracts: Record<string, unknown>[];
|
|
1211
1594
|
quarantined: Record<string, unknown>[];
|
|
1212
1595
|
events: Record<string, unknown>[];
|
|
1213
1596
|
workspaces: ReturnType<typeof observeWorkspaces>;
|
|
1214
1597
|
};
|
|
1215
1598
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1599
|
+
interface GcOptions {
|
|
1600
|
+
dryRun?: boolean;
|
|
1601
|
+
staleDays?: number;
|
|
1602
|
+
force?: boolean;
|
|
1603
|
+
}
|
|
1604
|
+
interface GcPreservedItem {
|
|
1605
|
+
path: string;
|
|
1606
|
+
branch: string | null;
|
|
1607
|
+
reason: 'active-session' | 'open-handoff' | 'dirty' | 'unmerged';
|
|
1608
|
+
}
|
|
1609
|
+
interface GcReport {
|
|
1610
|
+
ok: boolean;
|
|
1611
|
+
dryRun: boolean;
|
|
1612
|
+
repository: string;
|
|
1613
|
+
nothingToClean: boolean;
|
|
1614
|
+
reapedAgents: number;
|
|
1615
|
+
prunedShadowIndexes: number;
|
|
1616
|
+
removedWorktrees: string[];
|
|
1617
|
+
deletedBranches: string[];
|
|
1618
|
+
preservedWorktrees: GcPreservedItem[];
|
|
1619
|
+
prunedExpiredLocks: number;
|
|
1620
|
+
prunedOperations: number;
|
|
1621
|
+
prunedDoneTasks: number;
|
|
1622
|
+
prunedOldEvents: number;
|
|
1623
|
+
prunedDeadAgents: number;
|
|
1624
|
+
prunedArtifacts: number;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Resyncs `.git/index` entries that drifted behind `HEAD` after temporary-index `update-ref` commits
|
|
1628
|
+
* without touching any files in the working tree.
|
|
1629
|
+
*/
|
|
1630
|
+
declare function resyncStaleIndexEntries(repoRoot: string): number;
|
|
1631
|
+
declare function gcCoordination(directory?: string, options?: GcOptions): GcReport;
|
|
1632
|
+
|
|
1633
|
+
declare const KITH_VERSION = "0.1.9";
|
|
1634
|
+
declare const KITH_PROTOCOL_VERSION = "1.6.0";
|
|
1218
1635
|
|
|
1219
|
-
export { type AcquireLockResult, type AgentRecord, type AgentUnreadDelta, AstAnalyzer, type BashGuardPostReport, BashMerkleGuard, type BlastRadiusAlert, CoWWorktreeManager, type ConflictRecord, type ContractRecord, CoordDatabase, type CoordEvent, type DeclareIntentResult, DependencyAndContractEngine, type DirtyMergeProbeResult, type ExtractedImport, type ExtractedSymbol, FencingAndAgentManager, type FileAstAnalysis, type FileModificationReport, type FileSnapshotEntry, IntentAndTaskEngine, KITH_PROTOCOL_VERSION, KITH_VERSION, KithEngine, type LinkedWorkspaceContract, type LockConflict, LockEngine, type LockRecord, type MergeTrainEntry, type PostFileEditHookResult, type QuarantineRecord, type RepositoryLayout, ResourceBroker, type ResourceRecord, SessionOwnershipError, type SessionRegistration, ShadowGitEngine, type SpawnedWorktree, type SpeculativeMergeResult, SpeculativeMergeTrain, StaleFencingTokenError, type SupervisedCommandOptions, type SwarmPrompts, type SymbolKind, type TaskRecord, type WorkspaceContractReport, type WorkspaceObservation, type WorktreeChange, buildSwarmPrompts, caseSensitivePaths, discoverRepository, inspectWorkspaceContracts, isWithin, observeWorkspaces, physicalPath, previewIntegration, readCoordinationState, recoveryReport, repositoryFile, verifyCrossRepoImportsForFile, worktreeChanges };
|
|
1636
|
+
export { type AcquireLockResult, type AgentRecord, type AgentUnreadDelta, AstAnalyzer, type BashGuardPostReport, BashMerkleGuard, type BlastRadiusAlert, CoWWorktreeManager, type CommitParams, type CommitResult, type ConflictRecord, type ContractRecord, CoordDatabase, type CoordEvent, type DeclareIntentResult, DependencyAndContractEngine, type DirtyMergeProbeResult, type ExtractedImport, type ExtractedSymbol, FencingAndAgentManager, type FileAstAnalysis, type FileModificationReport, type FileSnapshotEntry, type GcOptions, type GcPreservedItem, type GcReport, IntentAndTaskEngine, KITH_PROTOCOL_VERSION, KITH_VERSION, KithEngine, type LinkedWorkspaceContract, type LockConflict, LockEngine, type LockRecord, type MergeTrainEntry, type PostFileEditHookResult, type QuarantineRecord, type RepositoryLayout, ResourceBroker, type ResourceRecord, SessionOwnershipError, type SessionRegistration, ShadowGitEngine, type SpawnedWorktree, type SpeculativeMergeResult, SpeculativeMergeTrain, StaleFencingTokenError, type SupervisedCommandOptions, type SwarmPrompts, type SymbolKind, type TaskRecord, type WorkspaceContractReport, type WorkspaceObservation, type WorktreeChange, buildSwarmPrompts, caseSensitivePaths, commandTargetsFileForWrite, commitScopedFiles, discoverChildRepositories, discoverRepository, extractRecentAgentFiles, gcCoordination, inspectWorkspaceContracts, isReadOnlyShellCommand, isWithin, observeWorkspaces, physicalPath, previewIntegration, readBrief, readCoordinationState, recoveryReport, refUpdateResyncRoots, repositoryFile, resyncStaleIndexEntries, runVerificationCommand, sqliteDatabase, verifyCrossRepoImportsForFile, worktreeChanges };
|