@sudocode-ai/integration-beads 0.1.13
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-utils.d.ts +76 -0
- package/dist/cli-utils.d.ts.map +1 -0
- package/dist/cli-utils.js +169 -0
- package/dist/cli-utils.js.map +1 -0
- package/dist/hash-utils.d.ts +24 -0
- package/dist/hash-utils.d.ts.map +1 -0
- package/dist/hash-utils.js +55 -0
- package/dist/hash-utils.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +472 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonl-utils.d.ts +87 -0
- package/dist/jsonl-utils.d.ts.map +1 -0
- package/dist/jsonl-utils.js +192 -0
- package/dist/jsonl-utils.js.map +1 -0
- package/dist/watcher.d.ts +81 -0
- package/dist/watcher.d.ts.map +1 -0
- package/dist/watcher.js +252 -0
- package/dist/watcher.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI utilities for Beads integration
|
|
3
|
+
*
|
|
4
|
+
* Provides detection and execution of the Beads CLI (`beads` or `bd` command).
|
|
5
|
+
* When CLI is available, we prefer using it for write operations as it
|
|
6
|
+
* ensures compatibility with Beads' own data format and validations.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if Beads CLI is available on the system
|
|
10
|
+
*
|
|
11
|
+
* Checks for both `beads` and `bd` commands.
|
|
12
|
+
* Result is cached for the lifetime of the process.
|
|
13
|
+
*
|
|
14
|
+
* @returns True if Beads CLI is available
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBeadsCLIAvailable(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Get the Beads CLI command name
|
|
19
|
+
*
|
|
20
|
+
* @returns 'beads' or 'bd' depending on what's available, or null if not available
|
|
21
|
+
*/
|
|
22
|
+
export declare function getBeadsCLICommand(): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Execute a Beads CLI command
|
|
25
|
+
*
|
|
26
|
+
* @param args - Command arguments (without the beads/bd prefix)
|
|
27
|
+
* @param cwd - Working directory for the command
|
|
28
|
+
* @param beadsDir - Optional path to .beads directory (sets BEADS_DIR env var)
|
|
29
|
+
* @returns Command output as string
|
|
30
|
+
* @throws Error if CLI not available or command fails
|
|
31
|
+
*/
|
|
32
|
+
export declare function execBeadsCommand(args: string[], cwd: string, beadsDir?: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Parse the output of `beads create` to extract the new issue ID
|
|
35
|
+
*
|
|
36
|
+
* Expected output formats (varies by version):
|
|
37
|
+
* - "Created issue beads-a1b2c3d4"
|
|
38
|
+
* - "beads-a1b2c3d4"
|
|
39
|
+
* - "✓ Created issue: beads-xxx-yyy" (newer versions with emoji)
|
|
40
|
+
* - "✓ Created issue: myproject-abc" (project-derived prefix)
|
|
41
|
+
*
|
|
42
|
+
* @param output - Command output from beads create
|
|
43
|
+
* @returns The extracted issue ID
|
|
44
|
+
* @throws Error if ID cannot be parsed
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseBeadsCreateOutput(output: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Create an issue using the Beads CLI
|
|
49
|
+
*
|
|
50
|
+
* @param cwd - Working directory (project root)
|
|
51
|
+
* @param title - Issue title
|
|
52
|
+
* @param options - Additional options
|
|
53
|
+
* @returns The created issue ID
|
|
54
|
+
*/
|
|
55
|
+
export declare function createIssueViaCLI(cwd: string, title: string, options?: {
|
|
56
|
+
priority?: number;
|
|
57
|
+
tags?: string[];
|
|
58
|
+
content?: string;
|
|
59
|
+
beadsDir?: string;
|
|
60
|
+
}): string;
|
|
61
|
+
/**
|
|
62
|
+
* Close an issue using the Beads CLI
|
|
63
|
+
*
|
|
64
|
+
* @param cwd - Working directory (project root)
|
|
65
|
+
* @param issueId - Issue ID to close
|
|
66
|
+
* @param reason - Optional reason for closing
|
|
67
|
+
* @param beadsDir - Optional path to .beads directory
|
|
68
|
+
*/
|
|
69
|
+
export declare function closeIssueViaCLI(cwd: string, issueId: string, reason?: string, beadsDir?: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Clear the CLI availability cache
|
|
72
|
+
*
|
|
73
|
+
* Useful for testing or when the system state may have changed.
|
|
74
|
+
*/
|
|
75
|
+
export declare function clearCLICache(): void;
|
|
76
|
+
//# sourceMappingURL=cli-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAmB7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAKlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CA2BR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA0B7D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,MAAM,CAmBR;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI utilities for Beads integration
|
|
3
|
+
*
|
|
4
|
+
* Provides detection and execution of the Beads CLI (`beads` or `bd` command).
|
|
5
|
+
* When CLI is available, we prefer using it for write operations as it
|
|
6
|
+
* ensures compatibility with Beads' own data format and validations.
|
|
7
|
+
*/
|
|
8
|
+
import { execSync, spawnSync } from "child_process";
|
|
9
|
+
/** Cached CLI availability result */
|
|
10
|
+
let cliAvailableCache = null;
|
|
11
|
+
/** Cached CLI command name */
|
|
12
|
+
let cliCommandCache = null;
|
|
13
|
+
/**
|
|
14
|
+
* Check if Beads CLI is available on the system
|
|
15
|
+
*
|
|
16
|
+
* Checks for both `beads` and `bd` commands.
|
|
17
|
+
* Result is cached for the lifetime of the process.
|
|
18
|
+
*
|
|
19
|
+
* @returns True if Beads CLI is available
|
|
20
|
+
*/
|
|
21
|
+
export function isBeadsCLIAvailable() {
|
|
22
|
+
if (cliAvailableCache !== null) {
|
|
23
|
+
return cliAvailableCache;
|
|
24
|
+
}
|
|
25
|
+
// Try 'beads' first, then 'bd'
|
|
26
|
+
for (const cmd of ["beads", "bd"]) {
|
|
27
|
+
try {
|
|
28
|
+
execSync(`${cmd} --version`, { stdio: "ignore" });
|
|
29
|
+
cliAvailableCache = true;
|
|
30
|
+
cliCommandCache = cmd;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Command not found, try next
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
cliAvailableCache = false;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the Beads CLI command name
|
|
42
|
+
*
|
|
43
|
+
* @returns 'beads' or 'bd' depending on what's available, or null if not available
|
|
44
|
+
*/
|
|
45
|
+
export function getBeadsCLICommand() {
|
|
46
|
+
if (!isBeadsCLIAvailable()) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return cliCommandCache;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Execute a Beads CLI command
|
|
53
|
+
*
|
|
54
|
+
* @param args - Command arguments (without the beads/bd prefix)
|
|
55
|
+
* @param cwd - Working directory for the command
|
|
56
|
+
* @param beadsDir - Optional path to .beads directory (sets BEADS_DIR env var)
|
|
57
|
+
* @returns Command output as string
|
|
58
|
+
* @throws Error if CLI not available or command fails
|
|
59
|
+
*/
|
|
60
|
+
export function execBeadsCommand(args, cwd, beadsDir) {
|
|
61
|
+
const cmd = getBeadsCLICommand();
|
|
62
|
+
if (!cmd) {
|
|
63
|
+
throw new Error("Beads CLI is not available");
|
|
64
|
+
}
|
|
65
|
+
const result = spawnSync(cmd, args, {
|
|
66
|
+
cwd,
|
|
67
|
+
encoding: "utf-8",
|
|
68
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
69
|
+
env: {
|
|
70
|
+
...process.env,
|
|
71
|
+
// Set BEADS_DIR if provided so CLI knows where to find .beads
|
|
72
|
+
...(beadsDir ? { BEADS_DIR: beadsDir } : {}),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
if (result.error) {
|
|
76
|
+
throw result.error;
|
|
77
|
+
}
|
|
78
|
+
if (result.status !== 0) {
|
|
79
|
+
const stderr = result.stderr?.trim() || "Unknown error";
|
|
80
|
+
throw new Error(`Beads command failed: ${stderr}`);
|
|
81
|
+
}
|
|
82
|
+
return result.stdout || "";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parse the output of `beads create` to extract the new issue ID
|
|
86
|
+
*
|
|
87
|
+
* Expected output formats (varies by version):
|
|
88
|
+
* - "Created issue beads-a1b2c3d4"
|
|
89
|
+
* - "beads-a1b2c3d4"
|
|
90
|
+
* - "✓ Created issue: beads-xxx-yyy" (newer versions with emoji)
|
|
91
|
+
* - "✓ Created issue: myproject-abc" (project-derived prefix)
|
|
92
|
+
*
|
|
93
|
+
* @param output - Command output from beads create
|
|
94
|
+
* @returns The extracted issue ID
|
|
95
|
+
* @throws Error if ID cannot be parsed
|
|
96
|
+
*/
|
|
97
|
+
export function parseBeadsCreateOutput(output) {
|
|
98
|
+
// Match "Created issue: <id>" pattern first (most reliable)
|
|
99
|
+
const createdMatch = output.match(/Created issue:\s*([a-zA-Z0-9-]+)/);
|
|
100
|
+
if (createdMatch) {
|
|
101
|
+
return createdMatch[1];
|
|
102
|
+
}
|
|
103
|
+
// Try to find a beads ID pattern - matches beads-xxx or beads-xxx-yyy format
|
|
104
|
+
const beadsMatch = output.match(/\b(beads-[a-zA-Z0-9]+-[a-zA-Z0-9]+)\b/);
|
|
105
|
+
if (beadsMatch) {
|
|
106
|
+
return beadsMatch[1];
|
|
107
|
+
}
|
|
108
|
+
// Simpler beads-xxx format
|
|
109
|
+
const simpleBeadsMatch = output.match(/\b(beads-[a-f0-9]+)\b/i);
|
|
110
|
+
if (simpleBeadsMatch) {
|
|
111
|
+
return simpleBeadsMatch[1];
|
|
112
|
+
}
|
|
113
|
+
// Try to find any ID pattern like "bd-xxxx" or similar
|
|
114
|
+
const altMatch = output.match(/\b([a-z]+-[a-f0-9]+)\b/i);
|
|
115
|
+
if (altMatch) {
|
|
116
|
+
return altMatch[1];
|
|
117
|
+
}
|
|
118
|
+
throw new Error(`Could not parse issue ID from beads output: ${output}`);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create an issue using the Beads CLI
|
|
122
|
+
*
|
|
123
|
+
* @param cwd - Working directory (project root)
|
|
124
|
+
* @param title - Issue title
|
|
125
|
+
* @param options - Additional options
|
|
126
|
+
* @returns The created issue ID
|
|
127
|
+
*/
|
|
128
|
+
export function createIssueViaCLI(cwd, title, options) {
|
|
129
|
+
// Use --no-db to work with JSONL only (no SQLite required)
|
|
130
|
+
const args = ["--no-db", "create", title];
|
|
131
|
+
if (options?.priority !== undefined) {
|
|
132
|
+
args.push("-p", String(options.priority));
|
|
133
|
+
}
|
|
134
|
+
if (options?.tags?.length) {
|
|
135
|
+
for (const tag of options.tags) {
|
|
136
|
+
args.push("-t", tag);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Note: content may need to be added via update after creation
|
|
140
|
+
// depending on beads CLI capabilities
|
|
141
|
+
const output = execBeadsCommand(args, cwd, options?.beadsDir);
|
|
142
|
+
return parseBeadsCreateOutput(output);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Close an issue using the Beads CLI
|
|
146
|
+
*
|
|
147
|
+
* @param cwd - Working directory (project root)
|
|
148
|
+
* @param issueId - Issue ID to close
|
|
149
|
+
* @param reason - Optional reason for closing
|
|
150
|
+
* @param beadsDir - Optional path to .beads directory
|
|
151
|
+
*/
|
|
152
|
+
export function closeIssueViaCLI(cwd, issueId, reason, beadsDir) {
|
|
153
|
+
// Use --no-db to work with JSONL only (no SQLite required)
|
|
154
|
+
const args = ["--no-db", "close", issueId];
|
|
155
|
+
if (reason) {
|
|
156
|
+
args.push("--reason", reason);
|
|
157
|
+
}
|
|
158
|
+
execBeadsCommand(args, cwd, beadsDir);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Clear the CLI availability cache
|
|
162
|
+
*
|
|
163
|
+
* Useful for testing or when the system state may have changed.
|
|
164
|
+
*/
|
|
165
|
+
export function clearCLICache() {
|
|
166
|
+
cliAvailableCache = null;
|
|
167
|
+
cliCommandCache = null;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=cli-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../src/cli-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEpD,qCAAqC;AACrC,IAAI,iBAAiB,GAAmB,IAAI,CAAC;AAE7C,8BAA8B;AAC9B,IAAI,eAAe,GAAkB,IAAI,CAAC;AAE1C;;;;;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
|
+
* Provides canonical hashing that produces consistent hashes regardless
|
|
5
|
+
* of JSON key ordering, enabling reliable change detection.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Compute a canonical hash for an entity
|
|
9
|
+
*
|
|
10
|
+
* The hash is stable regardless of JSON key ordering, making it suitable
|
|
11
|
+
* for detecting actual content changes vs just serialization differences.
|
|
12
|
+
*
|
|
13
|
+
* @param entity - The entity to hash
|
|
14
|
+
* @returns SHA-256 hash of the canonicalized JSON
|
|
15
|
+
*/
|
|
16
|
+
export declare function computeCanonicalHash(entity: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* Compute hash from raw JSON string (for files)
|
|
19
|
+
*
|
|
20
|
+
* @param content - Raw file content
|
|
21
|
+
* @returns SHA-256 hash of the content
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeContentHash(content: string): string;
|
|
24
|
+
//# sourceMappingURL=hash-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-utils.d.ts","sourceRoot":"","sources":["../src/hash-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash utilities for content-based change detection
|
|
3
|
+
*
|
|
4
|
+
* Provides canonical hashing that produces consistent hashes regardless
|
|
5
|
+
* of JSON key ordering, enabling reliable change detection.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "crypto";
|
|
8
|
+
/**
|
|
9
|
+
* Recursively sort object keys to ensure consistent serialization
|
|
10
|
+
*
|
|
11
|
+
* This is critical because JSON.stringify doesn't guarantee key order,
|
|
12
|
+
* so {"a":1,"b":2} and {"b":2,"a":1} would produce different hashes
|
|
13
|
+
* without this normalization.
|
|
14
|
+
*/
|
|
15
|
+
function sortObjectKeys(obj) {
|
|
16
|
+
if (obj === null || obj === undefined) {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(obj)) {
|
|
20
|
+
return obj.map(sortObjectKeys);
|
|
21
|
+
}
|
|
22
|
+
if (typeof obj === "object") {
|
|
23
|
+
const sorted = {};
|
|
24
|
+
const keys = Object.keys(obj).sort();
|
|
25
|
+
for (const key of keys) {
|
|
26
|
+
sorted[key] = sortObjectKeys(obj[key]);
|
|
27
|
+
}
|
|
28
|
+
return sorted;
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compute a canonical hash for an entity
|
|
34
|
+
*
|
|
35
|
+
* The hash is stable regardless of JSON key ordering, making it suitable
|
|
36
|
+
* for detecting actual content changes vs just serialization differences.
|
|
37
|
+
*
|
|
38
|
+
* @param entity - The entity to hash
|
|
39
|
+
* @returns SHA-256 hash of the canonicalized JSON
|
|
40
|
+
*/
|
|
41
|
+
export function computeCanonicalHash(entity) {
|
|
42
|
+
const sorted = sortObjectKeys(entity);
|
|
43
|
+
const json = JSON.stringify(sorted);
|
|
44
|
+
return createHash("sha256").update(json).digest("hex");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compute hash from raw JSON string (for files)
|
|
48
|
+
*
|
|
49
|
+
* @param content - Raw file content
|
|
50
|
+
* @returns SHA-256 hash of the content
|
|
51
|
+
*/
|
|
52
|
+
export function computeContentHash(content) {
|
|
53
|
+
return createHash("sha256").update(content).digest("hex");
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=hash-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-utils.js","sourceRoot":"","sources":["../src/hash-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ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
3
|
+
*
|
|
4
|
+
* Provides integration with Beads - a local file-based issue tracking format.
|
|
5
|
+
* Beads stores issues in a .beads directory with JSONL files similar to sudocode.
|
|
6
|
+
*/
|
|
7
|
+
import type { IntegrationPlugin } from "@sudocode-ai/types";
|
|
8
|
+
/**
|
|
9
|
+
* Beads-specific configuration options
|
|
10
|
+
*/
|
|
11
|
+
export interface BeadsOptions {
|
|
12
|
+
/** Path to the .beads directory (relative to project root) */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Prefix for issue IDs imported from beads (default: "bd") */
|
|
15
|
+
issue_prefix?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Beads integration plugin
|
|
19
|
+
*/
|
|
20
|
+
declare const beadsPlugin: IntegrationPlugin;
|
|
21
|
+
export default beadsPlugin;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EASlB,MAAM,oBAAoB,CAAC;AAoB5B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,QAAA,MAAM,WAAW,EAAE,iBAkHlB,CAAC;AAybF,eAAe,WAAW,CAAC"}
|