swarm-mail 0.1.3 → 0.2.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/README.md +4 -0
- package/bin/daemon-cli.ts +304 -0
- package/dist/beads/adapter.d.ts +38 -0
- package/dist/beads/adapter.d.ts.map +1 -0
- package/dist/beads/blocked-cache.d.ts +21 -0
- package/dist/beads/blocked-cache.d.ts.map +1 -0
- package/dist/beads/comments.d.ts +21 -0
- package/dist/beads/comments.d.ts.map +1 -0
- package/dist/beads/dependencies.d.ts +58 -0
- package/dist/beads/dependencies.d.ts.map +1 -0
- package/dist/beads/events.d.ts +163 -0
- package/dist/beads/events.d.ts.map +1 -0
- package/dist/beads/flush-manager.d.ts +71 -0
- package/dist/beads/flush-manager.d.ts.map +1 -0
- package/dist/beads/index.d.ts +25 -0
- package/dist/beads/index.d.ts.map +1 -0
- package/dist/beads/jsonl.d.ts +103 -0
- package/dist/beads/jsonl.d.ts.map +1 -0
- package/dist/beads/labels.d.ts +21 -0
- package/dist/beads/labels.d.ts.map +1 -0
- package/dist/beads/merge.d.ts +99 -0
- package/dist/beads/merge.d.ts.map +1 -0
- package/dist/beads/migrations.d.ts +41 -0
- package/dist/beads/migrations.d.ts.map +1 -0
- package/dist/beads/operations.d.ts +56 -0
- package/dist/beads/operations.d.ts.map +1 -0
- package/dist/beads/projections.d.ts +103 -0
- package/dist/beads/projections.d.ts.map +1 -0
- package/dist/beads/queries.d.ts +77 -0
- package/dist/beads/queries.d.ts.map +1 -0
- package/dist/beads/store.d.ts +98 -0
- package/dist/beads/store.d.ts.map +1 -0
- package/dist/beads/validation.d.ts +75 -0
- package/dist/beads/validation.d.ts.map +1 -0
- package/dist/daemon.d.ts +139 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8314 -4513
- package/dist/pglite.d.ts +78 -5
- package/dist/pglite.d.ts.map +1 -1
- package/dist/socket-adapter.d.ts +78 -0
- package/dist/socket-adapter.d.ts.map +1 -0
- package/dist/streams/debug.d.ts.map +1 -1
- package/dist/streams/effect/ask.integration-test.d.ts +8 -0
- package/dist/streams/effect/ask.integration-test.d.ts.map +1 -0
- package/dist/streams/effect/cursor.integration-test.d.ts +2 -0
- package/dist/streams/effect/cursor.integration-test.d.ts.map +1 -0
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/leader-election.d.ts +44 -0
- package/dist/streams/leader-election.d.ts.map +1 -0
- package/dist/streams/migrations.d.ts +1 -1
- package/dist/streams/migrations.d.ts.map +1 -1
- package/dist/streams/store.d.ts.map +1 -1
- package/dist/streams/store.integration-test.d.ts +2 -0
- package/dist/streams/store.integration-test.d.ts.map +1 -0
- package/dist/types/beads-adapter.d.ts +397 -0
- package/dist/types/beads-adapter.d.ts.map +1 -0
- package/package.json +15 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlushManager - Debounced JSONL export to file
|
|
3
|
+
*
|
|
4
|
+
* Automatically exports dirty beads to a JSONL file on a debounced timer.
|
|
5
|
+
* Prevents excessive writes while ensuring changes are persisted.
|
|
6
|
+
*
|
|
7
|
+
* Based on steveyegge/beads flush_manager.go
|
|
8
|
+
*
|
|
9
|
+
* @module beads/flush-manager
|
|
10
|
+
*/
|
|
11
|
+
import type { BeadsAdapter } from "../types/beads-adapter.js";
|
|
12
|
+
export interface FlushManagerOptions {
|
|
13
|
+
adapter: BeadsAdapter;
|
|
14
|
+
projectKey: string;
|
|
15
|
+
outputPath: string;
|
|
16
|
+
debounceMs?: number;
|
|
17
|
+
onFlush?: (result: FlushResult) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface FlushResult {
|
|
20
|
+
beadsExported: number;
|
|
21
|
+
bytesWritten: number;
|
|
22
|
+
duration: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* FlushManager handles debounced export of dirty beads to JSONL
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* ```ts
|
|
29
|
+
* const manager = new FlushManager({
|
|
30
|
+
* adapter,
|
|
31
|
+
* projectKey: "/path/to/project",
|
|
32
|
+
* outputPath: ".beads/issues.jsonl",
|
|
33
|
+
* debounceMs: 30000,
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Schedule flushes as beads change
|
|
37
|
+
* manager.scheduleFlush();
|
|
38
|
+
*
|
|
39
|
+
* // Clean up
|
|
40
|
+
* manager.stop();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class FlushManager {
|
|
44
|
+
private adapter;
|
|
45
|
+
private projectKey;
|
|
46
|
+
private outputPath;
|
|
47
|
+
private debounceMs;
|
|
48
|
+
private onFlush?;
|
|
49
|
+
private timer;
|
|
50
|
+
private flushing;
|
|
51
|
+
constructor(options: FlushManagerOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Schedule a flush (debounced)
|
|
54
|
+
*
|
|
55
|
+
* If a flush is already scheduled, resets the timer.
|
|
56
|
+
*/
|
|
57
|
+
scheduleFlush(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Force immediate flush
|
|
60
|
+
*
|
|
61
|
+
* Exports all dirty beads to the output file.
|
|
62
|
+
*/
|
|
63
|
+
flush(): Promise<FlushResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Stop the flush manager
|
|
66
|
+
*
|
|
67
|
+
* Clears any pending timers. Does NOT flush pending changes.
|
|
68
|
+
*/
|
|
69
|
+
stop(): void;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=flush-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush-manager.d.ts","sourceRoot":"","sources":["../../src/beads/flush-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAgC;IAChD,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,mBAAmB;IAQxC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAcrB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IA8DnC;;;;OAIG;IACH,IAAI,IAAI,IAAI;CAMb"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beads Module - Event-sourced issue tracking
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - BeadsAdapter interface and types
|
|
6
|
+
* - Migration definitions
|
|
7
|
+
* - Projection functions
|
|
8
|
+
* - Store operations (append, read, replay)
|
|
9
|
+
* - Event type definitions
|
|
10
|
+
*
|
|
11
|
+
* @module beads
|
|
12
|
+
*/
|
|
13
|
+
export type { Bead, BeadAdapter, BeadComment, BeadDependency, BeadLabel, BeadsAdapter, BeadsAdapterFactory, BeadsSchemaAdapter, BeadStatus, BeadType, CommentAdapter, CreateBeadOptions, DependencyAdapter, DependencyRelationship, EpicAdapter, LabelAdapter, QueryAdapter, QueryBeadsOptions, UpdateBeadOptions, } from "../types/beads-adapter.js";
|
|
14
|
+
export type { BeadEvent, BaseBeadEvent, BeadCreatedEvent, BeadUpdatedEvent, BeadStatusChangedEvent, BeadClosedEvent, BeadReopenedEvent, BeadDeletedEvent, BeadDependencyAddedEvent, BeadDependencyRemovedEvent, BeadLabelAddedEvent, BeadLabelRemovedEvent, BeadCommentAddedEvent, BeadCommentUpdatedEvent, BeadCommentDeletedEvent, BeadEpicChildAddedEvent, BeadEpicChildRemovedEvent, BeadEpicClosureEligibleEvent, BeadAssignedEvent, BeadWorkStartedEvent, BeadCompactedEvent, } from "./events.js";
|
|
15
|
+
export { createBeadsAdapter } from "./adapter.js";
|
|
16
|
+
export { beadsMigration, beadsMigrations } from "./migrations.js";
|
|
17
|
+
export { appendBeadEvent, readBeadEvents, replayBeadEvents, type ReadBeadEventsOptions, } from "./store.js";
|
|
18
|
+
export { clearAllDirtyBeads, clearDirtyBead, getBead, getBlockedBeads, getBlockers, getComments, getDependencies, getDependents, getDirtyBeads, getInProgressBeads, getLabels, getNextReadyBead, isBlocked, markBeadDirty, queryBeads, updateProjections, } from "./projections.js";
|
|
19
|
+
export { wouldCreateCycle, getOpenBlockers, rebuildBeadBlockedCache, rebuildAllBlockedCaches, invalidateBlockedCache, } from "./dependencies.js";
|
|
20
|
+
export { getBeadsByLabel, getAllLabels, } from "./labels.js";
|
|
21
|
+
export { getCommentById, getCommentThread, } from "./comments.js";
|
|
22
|
+
export { exportToJSONL, exportDirtyBeads, importFromJSONL, parseJSONL, serializeToJSONL, computeContentHash, type BeadExport, type ExportOptions, type ImportOptions, type ImportResult, } from "./jsonl.js";
|
|
23
|
+
export { FlushManager, type FlushManagerOptions, type FlushResult, } from "./flush-manager.js";
|
|
24
|
+
export { merge3Way, mergeJsonl, isTombstone, isExpiredTombstone, DEFAULT_TOMBSTONE_TTL_MS, MIN_TOMBSTONE_TTL_MS, CLOCK_SKEW_GRACE_MS, STATUS_TOMBSTONE, type IssueKey, type MergeResult, type MergeOptions, } from "./merge.js";
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/beads/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,YAAY,EACV,IAAI,EACJ,WAAW,EACX,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACV,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSONL Export/Import for Beads
|
|
3
|
+
*
|
|
4
|
+
* Implements git sync via JSONL format compatible with steveyegge/beads.
|
|
5
|
+
* Features:
|
|
6
|
+
* - Full export to JSONL string
|
|
7
|
+
* - Incremental dirty bead export
|
|
8
|
+
* - Import with hash-based deduplication
|
|
9
|
+
* - Parse/serialize individual lines
|
|
10
|
+
*
|
|
11
|
+
* @module beads/jsonl
|
|
12
|
+
*/
|
|
13
|
+
import type { BeadsAdapter } from "../types/beads-adapter.js";
|
|
14
|
+
/**
|
|
15
|
+
* JSONL export format matching steveyegge/beads
|
|
16
|
+
*
|
|
17
|
+
* One JSON object per line. Field names match the Go struct tags.
|
|
18
|
+
*/
|
|
19
|
+
export interface BeadExport {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
status: "open" | "in_progress" | "blocked" | "closed" | "tombstone";
|
|
24
|
+
priority: number;
|
|
25
|
+
issue_type: "bug" | "feature" | "task" | "epic" | "chore";
|
|
26
|
+
created_at: string;
|
|
27
|
+
updated_at: string;
|
|
28
|
+
closed_at?: string;
|
|
29
|
+
assignee?: string;
|
|
30
|
+
parent_id?: string;
|
|
31
|
+
dependencies: Array<{
|
|
32
|
+
depends_on_id: string;
|
|
33
|
+
type: string;
|
|
34
|
+
}>;
|
|
35
|
+
labels: string[];
|
|
36
|
+
comments: Array<{
|
|
37
|
+
author: string;
|
|
38
|
+
text: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export interface ExportOptions {
|
|
42
|
+
includeDeleted?: boolean;
|
|
43
|
+
beadIds?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface ImportOptions {
|
|
46
|
+
dryRun?: boolean;
|
|
47
|
+
skipExisting?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface ImportResult {
|
|
50
|
+
created: number;
|
|
51
|
+
updated: number;
|
|
52
|
+
skipped: number;
|
|
53
|
+
errors: Array<{
|
|
54
|
+
beadId: string;
|
|
55
|
+
error: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Serialize a bead to a JSONL line
|
|
60
|
+
*/
|
|
61
|
+
export declare function serializeToJSONL(bead: BeadExport): string;
|
|
62
|
+
/**
|
|
63
|
+
* Parse JSONL string to bead exports
|
|
64
|
+
*
|
|
65
|
+
* Skips empty lines. Throws on invalid JSON.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseJSONL(jsonl: string): BeadExport[];
|
|
68
|
+
/**
|
|
69
|
+
* Compute SHA-256 content hash for deduplication
|
|
70
|
+
*
|
|
71
|
+
* Uses canonical JSON encoding (sorted keys) for stability.
|
|
72
|
+
* Includes timestamps to detect any change.
|
|
73
|
+
*/
|
|
74
|
+
export declare function computeContentHash(bead: BeadExport): string;
|
|
75
|
+
/**
|
|
76
|
+
* Export all beads to JSONL string
|
|
77
|
+
*
|
|
78
|
+
* By default excludes deleted beads (tombstones).
|
|
79
|
+
* Includes dependencies, labels, and comments.
|
|
80
|
+
*/
|
|
81
|
+
export declare function exportToJSONL(adapter: BeadsAdapter, projectKey: string, options?: ExportOptions): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Export only dirty beads (incremental)
|
|
84
|
+
*
|
|
85
|
+
* Returns JSONL and list of bead IDs that were exported.
|
|
86
|
+
*/
|
|
87
|
+
export declare function exportDirtyBeads(adapter: BeadsAdapter, projectKey: string): Promise<{
|
|
88
|
+
jsonl: string;
|
|
89
|
+
beadIds: string[];
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Import beads from JSONL string
|
|
93
|
+
*
|
|
94
|
+
* Features:
|
|
95
|
+
* - Creates new beads
|
|
96
|
+
* - Updates existing beads
|
|
97
|
+
* - Hash-based deduplication (skips if content unchanged)
|
|
98
|
+
* - Imports dependencies, labels, comments
|
|
99
|
+
* - Dry run mode for preview
|
|
100
|
+
* - Skip existing mode
|
|
101
|
+
*/
|
|
102
|
+
export declare function importFromJSONL(adapter: BeadsAdapter, projectKey: string, jsonl: string, options?: ImportOptions): Promise<ImportResult>;
|
|
103
|
+
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../src/beads/jsonl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAa9D;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAyBtD;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAI3D;AAMD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA2EjB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAa/C;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAqBvB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Label Operations
|
|
3
|
+
*
|
|
4
|
+
* Simple label management for categorizing beads.
|
|
5
|
+
* Labels are string tags that can be queried for grouping and filtering.
|
|
6
|
+
*
|
|
7
|
+
* Reference: steveyegge/beads/internal/storage/sqlite/labels.go
|
|
8
|
+
*
|
|
9
|
+
* @module beads/labels
|
|
10
|
+
*/
|
|
11
|
+
import type { DatabaseAdapter } from "../types/database.js";
|
|
12
|
+
import type { Bead } from "../types/beads-adapter.js";
|
|
13
|
+
/**
|
|
14
|
+
* Get all beads with a specific label
|
|
15
|
+
*/
|
|
16
|
+
export declare function getBeadsByLabel(db: DatabaseAdapter, projectKey: string, label: string): Promise<Bead[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Get all unique labels for a project
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAllLabels(db: DatabaseAdapter, projectKey: string): Promise<string[]>;
|
|
21
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/beads/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,eAAe,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,EAAE,CAAC,CASjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,eAAe,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CASnB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3-Way Merge Driver for Beads JSONL
|
|
3
|
+
*
|
|
4
|
+
* Ported from steveyegge/beads internal/merge/merge.go (MIT License)
|
|
5
|
+
* Original by @neongreen: https://github.com/neongreen/mono/tree/main/beads-merge
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - 3-way merge of JSONL bead files
|
|
9
|
+
* - Tombstone semantics (soft-delete wins over live, expired allows resurrection)
|
|
10
|
+
* - Field-level merge with updated_at tiebreaker
|
|
11
|
+
* - Deterministic conflict resolution (no manual intervention needed)
|
|
12
|
+
*
|
|
13
|
+
* ## Tombstone Rules
|
|
14
|
+
* - Tombstone always wins over live issue (unless expired)
|
|
15
|
+
* - Expired tombstones allow resurrection (live issue wins)
|
|
16
|
+
* - Two tombstones: later deleted_at wins
|
|
17
|
+
*
|
|
18
|
+
* ## Field Merge Rules
|
|
19
|
+
* - title/description: latest updated_at wins
|
|
20
|
+
* - status: closed wins over open, tombstone wins over all
|
|
21
|
+
* - priority: higher priority wins (lower number = more urgent)
|
|
22
|
+
* - notes: concatenate on conflict
|
|
23
|
+
* - dependencies: union (deduplicated)
|
|
24
|
+
*
|
|
25
|
+
* @module beads/merge
|
|
26
|
+
*/
|
|
27
|
+
import type { BeadExport } from "./jsonl.js";
|
|
28
|
+
/** Default TTL for tombstones (30 days) */
|
|
29
|
+
export declare const DEFAULT_TOMBSTONE_TTL_MS: number;
|
|
30
|
+
/** Minimum TTL for tombstones (7 days) - safety limit */
|
|
31
|
+
export declare const MIN_TOMBSTONE_TTL_MS: number;
|
|
32
|
+
/** Clock skew grace period (1 hour) - added to TTL for distributed systems */
|
|
33
|
+
export declare const CLOCK_SKEW_GRACE_MS: number;
|
|
34
|
+
/** Tombstone status constant */
|
|
35
|
+
export declare const STATUS_TOMBSTONE = "tombstone";
|
|
36
|
+
/**
|
|
37
|
+
* Issue key for matching across base/left/right
|
|
38
|
+
*
|
|
39
|
+
* Uses ID + created_at + created_by for uniqueness (handles ID collisions)
|
|
40
|
+
*/
|
|
41
|
+
export interface IssueKey {
|
|
42
|
+
id: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
createdBy?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Merge result
|
|
48
|
+
*/
|
|
49
|
+
export interface MergeResult {
|
|
50
|
+
/** Successfully merged beads */
|
|
51
|
+
merged: BeadExport[];
|
|
52
|
+
/** Conflict markers (for manual resolution if needed) */
|
|
53
|
+
conflicts: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Merge options
|
|
57
|
+
*/
|
|
58
|
+
export interface MergeOptions {
|
|
59
|
+
/** Custom tombstone TTL in milliseconds (default: 30 days) */
|
|
60
|
+
tombstoneTtlMs?: number;
|
|
61
|
+
/** Enable debug logging */
|
|
62
|
+
debug?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if a bead is a tombstone (soft-deleted)
|
|
66
|
+
*/
|
|
67
|
+
export declare function isTombstone(bead: BeadExport): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a tombstone has expired (resurrection allowed)
|
|
70
|
+
*
|
|
71
|
+
* @param bead - The bead to check
|
|
72
|
+
* @param ttlMs - TTL in milliseconds (default: 30 days)
|
|
73
|
+
* @returns true if tombstone is expired, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
export declare function isExpiredTombstone(bead: BeadExport, ttlMs?: number): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Perform 3-way merge of JSONL bead arrays
|
|
78
|
+
*
|
|
79
|
+
* @param base - Common ancestor (e.g., git merge-base)
|
|
80
|
+
* @param left - Local changes (e.g., HEAD)
|
|
81
|
+
* @param right - Remote changes (e.g., MERGE_HEAD)
|
|
82
|
+
* @param options - Merge options
|
|
83
|
+
* @returns Merged beads and any conflicts
|
|
84
|
+
*/
|
|
85
|
+
export declare function merge3Way(base: BeadExport[], left: BeadExport[], right: BeadExport[], options?: MergeOptions): MergeResult;
|
|
86
|
+
/**
|
|
87
|
+
* Merge JSONL strings (convenience wrapper)
|
|
88
|
+
*
|
|
89
|
+
* @param baseJsonl - Base JSONL string
|
|
90
|
+
* @param leftJsonl - Left JSONL string
|
|
91
|
+
* @param rightJsonl - Right JSONL string
|
|
92
|
+
* @param options - Merge options
|
|
93
|
+
* @returns Merged JSONL string
|
|
94
|
+
*/
|
|
95
|
+
export declare function mergeJsonl(baseJsonl: string, leftJsonl: string, rightJsonl: string, options?: MergeOptions): {
|
|
96
|
+
jsonl: string;
|
|
97
|
+
conflicts: string[];
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/beads/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,2CAA2C;AAC3C,eAAO,MAAM,wBAAwB,QAA2B,CAAC;AAEjE,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,QAA0B,CAAC;AAE5D,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,QAAiB,CAAC;AAElD,gCAAgC;AAChC,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAM5C;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,yDAAyD;IACzD,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA0BD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,KAAK,GAAE,MAAiC,GACvC,OAAO,CAyBT;AAwUD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE,YAAiB,GACzB,WAAW,CA0Jb;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,YAAiB,GACzB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAoBxC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beads Schema Migration (v6)
|
|
3
|
+
*
|
|
4
|
+
* Adds beads-specific tables to the shared PGLite database.
|
|
5
|
+
* This migration extends the existing swarm-mail schema.
|
|
6
|
+
*
|
|
7
|
+
* ## Migration Strategy
|
|
8
|
+
* - Migration v6 adds beads tables to existing swarm-mail schema (v1-v5)
|
|
9
|
+
* - Shares same PGLite database instance and migration system
|
|
10
|
+
* - Uses same schema_version table for tracking
|
|
11
|
+
*
|
|
12
|
+
* ## Tables Created
|
|
13
|
+
* - beads: Core bead records (parallel to steveyegge/beads issues table)
|
|
14
|
+
* - bead_dependencies: Dependency relationships between beads
|
|
15
|
+
* - bead_labels: String tags for categorization
|
|
16
|
+
* - bead_comments: Comments/notes on beads
|
|
17
|
+
* - blocked_beads_cache: Materialized view for fast blocked queries
|
|
18
|
+
* - dirty_beads: Tracks beads that need JSONL export
|
|
19
|
+
*
|
|
20
|
+
* ## Design Notes
|
|
21
|
+
* - Uses BIGINT for timestamps (Unix ms, like swarm-mail events)
|
|
22
|
+
* - Uses TEXT for IDs (like steveyegge/beads)
|
|
23
|
+
* - CASCADE deletes for referential integrity
|
|
24
|
+
* - Indexes for common query patterns
|
|
25
|
+
* - CHECK constraints for data integrity
|
|
26
|
+
*
|
|
27
|
+
* @module beads/migrations
|
|
28
|
+
*/
|
|
29
|
+
import type { Migration } from "../streams/migrations.js";
|
|
30
|
+
/**
|
|
31
|
+
* Migration v6: Add beads tables
|
|
32
|
+
*
|
|
33
|
+
* This migration is designed to be appended to the existing migrations array
|
|
34
|
+
* in src/streams/migrations.ts.
|
|
35
|
+
*/
|
|
36
|
+
export declare const beadsMigration: Migration;
|
|
37
|
+
/**
|
|
38
|
+
* Export as array for convenience
|
|
39
|
+
*/
|
|
40
|
+
export declare const beadsMigrations: Migration[];
|
|
41
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/beads/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,SAoH5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,EAAqB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bead Operations - High-level CRUD operations using BeadsAdapter
|
|
3
|
+
*
|
|
4
|
+
* Convenience functions that wrap BeadsAdapter with validation.
|
|
5
|
+
* Plugin tools should use these operations instead of calling adapter directly.
|
|
6
|
+
*
|
|
7
|
+
* ## Layering
|
|
8
|
+
* - BeadsAdapter: Low-level event sourcing operations
|
|
9
|
+
* - operations.ts: High-level validated CRUD (THIS FILE)
|
|
10
|
+
* - Plugin tools: Type-safe Zod-validated wrappers
|
|
11
|
+
*/
|
|
12
|
+
import type { BeadsAdapter, Bead, QueryBeadsOptions } from "../types/beads-adapter.js";
|
|
13
|
+
import { type CreateBeadOptions, type UpdateBeadOptions } from "./validation.js";
|
|
14
|
+
/**
|
|
15
|
+
* Create a new bead with validation
|
|
16
|
+
*
|
|
17
|
+
* @throws {Error} If validation fails
|
|
18
|
+
*/
|
|
19
|
+
export declare function createBead(adapter: BeadsAdapter, projectKey: string, options: CreateBeadOptions): Promise<Bead>;
|
|
20
|
+
/**
|
|
21
|
+
* Get a bead by ID
|
|
22
|
+
*
|
|
23
|
+
* @returns Bead or null if not found
|
|
24
|
+
*/
|
|
25
|
+
export declare function getBead(adapter: BeadsAdapter, projectKey: string, beadId: string): Promise<Bead | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Update a bead with validation
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} If validation fails or bead not found
|
|
30
|
+
*/
|
|
31
|
+
export declare function updateBead(adapter: BeadsAdapter, projectKey: string, beadId: string, updates: UpdateBeadOptions): Promise<Bead>;
|
|
32
|
+
/**
|
|
33
|
+
* Close a bead
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} If bead not found
|
|
36
|
+
*/
|
|
37
|
+
export declare function closeBead(adapter: BeadsAdapter, projectKey: string, beadId: string, reason: string, closedBy?: string): Promise<Bead>;
|
|
38
|
+
/**
|
|
39
|
+
* Reopen a closed bead
|
|
40
|
+
*
|
|
41
|
+
* @throws {Error} If bead not found or invalid transition
|
|
42
|
+
*/
|
|
43
|
+
export declare function reopenBead(adapter: BeadsAdapter, projectKey: string, beadId: string, reopenedBy?: string): Promise<Bead>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a bead (soft delete - creates tombstone)
|
|
46
|
+
*
|
|
47
|
+
* @throws {Error} If bead not found
|
|
48
|
+
*/
|
|
49
|
+
export declare function deleteBead(adapter: BeadsAdapter, projectKey: string, beadId: string, reason: string, deletedBy?: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Search beads by title
|
|
52
|
+
*
|
|
53
|
+
* Simple text search across bead titles with optional filters.
|
|
54
|
+
*/
|
|
55
|
+
export declare function searchBeads(adapter: BeadsAdapter, projectKey: string, query: string, filter?: QueryBeadsOptions): Promise<Bead[]>;
|
|
56
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/beads/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,IAAI,EACJ,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAEtB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,EAAE,CAAC,CAejB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beads Projections Layer - Update and query materialized views
|
|
3
|
+
*
|
|
4
|
+
* Projections are the read-side of CQRS. They update denormalized
|
|
5
|
+
* materialized views when events are appended, and provide query methods.
|
|
6
|
+
*
|
|
7
|
+
* ## Architecture
|
|
8
|
+
* - Event store is source of truth (write side)
|
|
9
|
+
* - Projections are cached views (read side)
|
|
10
|
+
* - Events trigger projection updates
|
|
11
|
+
* - Queries read from projections (fast)
|
|
12
|
+
*
|
|
13
|
+
* ## Key projections:
|
|
14
|
+
* - beads table: Main bead records
|
|
15
|
+
* - bead_dependencies: Dependency relationships
|
|
16
|
+
* - bead_labels: String tags
|
|
17
|
+
* - bead_comments: Comments/notes
|
|
18
|
+
* - blocked_beads_cache: Cached blocker lookups
|
|
19
|
+
* - dirty_beads: Tracks changes for export
|
|
20
|
+
*
|
|
21
|
+
* @module beads/projections
|
|
22
|
+
*/
|
|
23
|
+
import type { DatabaseAdapter } from "../types/database.js";
|
|
24
|
+
import type { Bead, BeadComment, BeadDependency, QueryBeadsOptions } from "../types/beads-adapter.js";
|
|
25
|
+
type BeadEvent = {
|
|
26
|
+
type: string;
|
|
27
|
+
project_key: string;
|
|
28
|
+
bead_id: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Update projections based on an event
|
|
34
|
+
*
|
|
35
|
+
* This is called by the event store after appending an event.
|
|
36
|
+
* Routes to specific handlers based on event type.
|
|
37
|
+
*/
|
|
38
|
+
export declare function updateProjections(db: DatabaseAdapter, event: BeadEvent): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Get a bead by ID
|
|
41
|
+
*/
|
|
42
|
+
export declare function getBead(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<Bead | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Query beads with filters
|
|
45
|
+
*/
|
|
46
|
+
export declare function queryBeads(db: DatabaseAdapter, projectKey: string, options?: QueryBeadsOptions): Promise<Bead[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Get dependencies for a bead
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDependencies(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<BeadDependency[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Get beads that depend on this bead
|
|
53
|
+
*/
|
|
54
|
+
export declare function getDependents(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<BeadDependency[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Check if bead is blocked
|
|
57
|
+
*/
|
|
58
|
+
export declare function isBlocked(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Get blockers for a bead
|
|
61
|
+
*/
|
|
62
|
+
export declare function getBlockers(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Get labels for a bead
|
|
65
|
+
*/
|
|
66
|
+
export declare function getLabels(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<string[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Get comments for a bead
|
|
69
|
+
*/
|
|
70
|
+
export declare function getComments(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<BeadComment[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Get next ready bead (unblocked, highest priority)
|
|
73
|
+
*/
|
|
74
|
+
export declare function getNextReadyBead(db: DatabaseAdapter, projectKey: string): Promise<Bead | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Get all in-progress beads
|
|
77
|
+
*/
|
|
78
|
+
export declare function getInProgressBeads(db: DatabaseAdapter, projectKey: string): Promise<Bead[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Get all blocked beads with their blockers
|
|
81
|
+
*/
|
|
82
|
+
export declare function getBlockedBeads(db: DatabaseAdapter, projectKey: string): Promise<Array<{
|
|
83
|
+
bead: Bead;
|
|
84
|
+
blockers: string[];
|
|
85
|
+
}>>;
|
|
86
|
+
/**
|
|
87
|
+
* Mark bead as dirty for JSONL export
|
|
88
|
+
*/
|
|
89
|
+
export declare function markBeadDirty(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Get all dirty beads
|
|
92
|
+
*/
|
|
93
|
+
export declare function getDirtyBeads(db: DatabaseAdapter, projectKey: string): Promise<string[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Clear dirty flag after export
|
|
96
|
+
*/
|
|
97
|
+
export declare function clearDirtyBead(db: DatabaseAdapter, projectKey: string, beadId: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Clear all dirty flags
|
|
100
|
+
*/
|
|
101
|
+
export declare function clearAllDirtyBeads(db: DatabaseAdapter, projectKey: string): Promise<void>;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=projections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projections.d.ts","sourceRoot":"","sources":["../../src/beads/projections.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beads Query Functions
|
|
3
|
+
*
|
|
4
|
+
* High-level query functions for common bead operations:
|
|
5
|
+
* - Ready work (unblocked beads with sort policies)
|
|
6
|
+
* - Blocked issues with blockers
|
|
7
|
+
* - Epics eligible for closure
|
|
8
|
+
* - Stale issues
|
|
9
|
+
* - Statistics
|
|
10
|
+
*
|
|
11
|
+
* Based on steveyegge/beads query patterns.
|
|
12
|
+
*
|
|
13
|
+
* @module beads/queries
|
|
14
|
+
*/
|
|
15
|
+
import type { Bead, BeadStatus, BeadsAdapter } from "../types/beads-adapter.js";
|
|
16
|
+
/**
|
|
17
|
+
* Sort policy for ready work queries
|
|
18
|
+
*
|
|
19
|
+
* - hybrid (default): Recent issues (<48h) by priority, older by age
|
|
20
|
+
* - priority: Always priority first, then creation date
|
|
21
|
+
* - oldest: Creation date ascending (backlog clearing)
|
|
22
|
+
*/
|
|
23
|
+
export type SortPolicy = "hybrid" | "priority" | "oldest";
|
|
24
|
+
export interface ReadyWorkOptions {
|
|
25
|
+
limit?: number;
|
|
26
|
+
assignee?: string;
|
|
27
|
+
unassigned?: boolean;
|
|
28
|
+
labels?: string[];
|
|
29
|
+
sortPolicy?: SortPolicy;
|
|
30
|
+
}
|
|
31
|
+
export interface BlockedBead {
|
|
32
|
+
bead: Bead;
|
|
33
|
+
blockers: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface EpicStatus {
|
|
36
|
+
epic_id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
total_children: number;
|
|
39
|
+
closed_children: number;
|
|
40
|
+
}
|
|
41
|
+
export interface StaleOptions {
|
|
42
|
+
status?: BeadStatus;
|
|
43
|
+
limit?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface Statistics {
|
|
46
|
+
total_beads: number;
|
|
47
|
+
open: number;
|
|
48
|
+
in_progress: number;
|
|
49
|
+
closed: number;
|
|
50
|
+
blocked: number;
|
|
51
|
+
ready: number;
|
|
52
|
+
by_type: Record<string, number>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get ready work (unblocked, prioritized)
|
|
56
|
+
*
|
|
57
|
+
* By default returns both 'open' and 'in_progress' beads so epics/tasks
|
|
58
|
+
* ready to close are visible (matching steveyegge/beads behavior).
|
|
59
|
+
*/
|
|
60
|
+
export declare function getReadyWork(adapter: BeadsAdapter, projectKey: string, options?: ReadyWorkOptions): Promise<Bead[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all blocked beads with their blockers
|
|
63
|
+
*/
|
|
64
|
+
export declare function getBlockedIssues(adapter: BeadsAdapter, projectKey: string): Promise<BlockedBead[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get epics eligible for closure (all children closed)
|
|
67
|
+
*/
|
|
68
|
+
export declare function getEpicsEligibleForClosure(adapter: BeadsAdapter, projectKey: string): Promise<EpicStatus[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get stale issues (not updated in N days)
|
|
71
|
+
*/
|
|
72
|
+
export declare function getStaleIssues(adapter: BeadsAdapter, projectKey: string, days: number, options?: StaleOptions): Promise<Bead[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Get aggregate statistics
|
|
75
|
+
*/
|
|
76
|
+
export declare function getStatistics(adapter: BeadsAdapter, projectKey: string): Promise<Statistics>;
|
|
77
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/beads/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,EAAE,CAAC,CA2DjB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBxB;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CA4BvB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,IAAI,EAAE,CAAC,CAmCjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CA4ErB"}
|