opencode-gitbutler 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -79
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1282,6 +1282,21 @@ function createRewordManager(deps) {
|
|
|
1282
1282
|
}
|
|
1283
1283
|
|
|
1284
1284
|
// src/plugin.ts
|
|
1285
|
+
async function toUUID(input) {
|
|
1286
|
+
const data = new TextEncoder().encode(input);
|
|
1287
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
1288
|
+
const hex = [...new Uint8Array(hash)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1289
|
+
return [
|
|
1290
|
+
hex.slice(0, 8),
|
|
1291
|
+
hex.slice(8, 12),
|
|
1292
|
+
`4${hex.slice(12, 15)}`,
|
|
1293
|
+
`8${hex.slice(15, 18)}`,
|
|
1294
|
+
hex.slice(18, 30)
|
|
1295
|
+
].join("-");
|
|
1296
|
+
}
|
|
1297
|
+
function sessionCacheKey(rootSessionID, filePath) {
|
|
1298
|
+
return `${rootSessionID}\x00${filePath}`;
|
|
1299
|
+
}
|
|
1285
1300
|
function createGitButlerPlugin(config = { ...DEFAULT_CONFIG }) {
|
|
1286
1301
|
return async ({ client, directory, worktree }) => {
|
|
1287
1302
|
const cwd = worktree ?? directory;
|
|
@@ -1371,18 +1386,6 @@ function createGitButlerPlugin(config = { ...DEFAULT_CONFIG }) {
|
|
|
1371
1386
|
cachedStatus = { data: fresh, timestamp: Date.now() };
|
|
1372
1387
|
return fresh;
|
|
1373
1388
|
}
|
|
1374
|
-
async function toUUID(input) {
|
|
1375
|
-
const data = new TextEncoder().encode(input);
|
|
1376
|
-
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
1377
|
-
const hex = [...new Uint8Array(hash)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1378
|
-
return [
|
|
1379
|
-
hex.slice(0, 8),
|
|
1380
|
-
hex.slice(8, 12),
|
|
1381
|
-
`4${hex.slice(12, 15)}`,
|
|
1382
|
-
`8${hex.slice(15, 18)}`,
|
|
1383
|
-
hex.slice(18, 30)
|
|
1384
|
-
].join("-");
|
|
1385
|
-
}
|
|
1386
1389
|
function extractFilePathFromArgs(args) {
|
|
1387
1390
|
const raw = args.filePath ?? args.file_path ?? args.path;
|
|
1388
1391
|
return raw ? cli.toRelativePath(raw) : undefined;
|
|
@@ -1482,80 +1485,22 @@ function createGitButlerPlugin(config = { ...DEFAULT_CONFIG }) {
|
|
|
1482
1485
|
const relativePath = cli.toRelativePath(filePath);
|
|
1483
1486
|
try {
|
|
1484
1487
|
const rootSessionID = state.resolveSessionRoot(input.sessionID);
|
|
1485
|
-
const
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
file: relativePath,
|
|
1492
|
-
sessionID: input.sessionID
|
|
1493
|
-
});
|
|
1494
|
-
return;
|
|
1495
|
-
}
|
|
1496
|
-
const branchInfo = cli.findFileBranch(relativePath, statusSnapshot);
|
|
1497
|
-
if (branchInfo.inBranch) {
|
|
1498
|
-
if (branchInfo.unassignedCliId && branchInfo.branchCliId) {
|
|
1499
|
-
if (cli.hasMultiBranchHunks(relativePath, statusSnapshot)) {
|
|
1500
|
-
log.warn("rub-skip-multi-branch", {
|
|
1501
|
-
file: relativePath,
|
|
1502
|
-
confidence: branchInfo.confidence
|
|
1503
|
-
});
|
|
1504
|
-
} else {
|
|
1505
|
-
log.info("rub-check", {
|
|
1506
|
-
file: relativePath,
|
|
1507
|
-
multiBranch: false,
|
|
1508
|
-
source: branchInfo.unassignedCliId,
|
|
1509
|
-
dest: branchInfo.branchCliId,
|
|
1510
|
-
confidence: branchInfo.confidence
|
|
1511
|
-
});
|
|
1512
|
-
const rubOk = cli.butRub(branchInfo.unassignedCliId, branchInfo.branchCliId);
|
|
1513
|
-
if (rubOk) {
|
|
1514
|
-
log.info("rub-ok", {
|
|
1515
|
-
source: branchInfo.unassignedCliId,
|
|
1516
|
-
dest: branchInfo.branchCliId,
|
|
1517
|
-
file: relativePath,
|
|
1518
|
-
confidence: branchInfo.confidence
|
|
1519
|
-
});
|
|
1520
|
-
} else {
|
|
1521
|
-
log.error("rub-failed", {
|
|
1522
|
-
source: branchInfo.unassignedCliId,
|
|
1523
|
-
dest: branchInfo.branchCliId,
|
|
1524
|
-
file: relativePath,
|
|
1525
|
-
confidence: branchInfo.confidence
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
} else if (!branchInfo.branchCliId) {
|
|
1530
|
-
log.warn("after-edit-ambiguous-assignment", {
|
|
1531
|
-
file: relativePath,
|
|
1532
|
-
sessionID: input.sessionID,
|
|
1533
|
-
confidence: branchInfo.confidence
|
|
1534
|
-
});
|
|
1535
|
-
} else {
|
|
1536
|
-
log.info("after-edit-already-assigned", {
|
|
1537
|
-
file: relativePath,
|
|
1538
|
-
sessionID: input.sessionID,
|
|
1539
|
-
branch: branchInfo.branchName ?? branchInfo.branchCliId,
|
|
1540
|
-
branchCliId: branchInfo.branchCliId,
|
|
1541
|
-
confidence: branchInfo.confidence ?? "high"
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
return;
|
|
1545
|
-
}
|
|
1546
|
-
} else {
|
|
1488
|
+
const branchSeed = config.branch_target ?? rootSessionID;
|
|
1489
|
+
const cacheKey = sessionCacheKey(rootSessionID, relativePath);
|
|
1490
|
+
const cached = assignmentCache.get(cacheKey);
|
|
1491
|
+
const cacheHit = cached && Date.now() - cached.timestamp < ASSIGNMENT_CACHE_TTL_MS;
|
|
1492
|
+
const conversationId = cacheHit ? cached.conversationId : await toUUID(branchSeed);
|
|
1493
|
+
if (cacheHit) {
|
|
1547
1494
|
log.info("assignment-cache-hit", {
|
|
1548
1495
|
file: relativePath,
|
|
1549
|
-
conversationId
|
|
1550
|
-
rootSessionID: cached.rootSessionID,
|
|
1496
|
+
conversationId,
|
|
1551
1497
|
ageMs: Date.now() - cached.timestamp
|
|
1552
1498
|
});
|
|
1553
1499
|
}
|
|
1554
|
-
const branchSeed = config.branch_target ?? rootSessionID;
|
|
1555
|
-
const conversationId = cacheHit ? cached.conversationId : await toUUID(branchSeed);
|
|
1556
1500
|
log.info("after-edit", {
|
|
1557
1501
|
file: relativePath,
|
|
1558
1502
|
sessionID: input.sessionID,
|
|
1503
|
+
rootSessionID,
|
|
1559
1504
|
conversationId
|
|
1560
1505
|
});
|
|
1561
1506
|
try {
|
|
@@ -1567,7 +1512,7 @@ function createGitButlerPlugin(config = { ...DEFAULT_CONFIG }) {
|
|
|
1567
1512
|
hook_event_name: "afterFileEdit",
|
|
1568
1513
|
workspace_roots: [cwd]
|
|
1569
1514
|
});
|
|
1570
|
-
assignmentCache.set(
|
|
1515
|
+
assignmentCache.set(cacheKey, {
|
|
1571
1516
|
conversationId,
|
|
1572
1517
|
rootSessionID,
|
|
1573
1518
|
timestamp: Date.now()
|
|
@@ -1575,6 +1520,7 @@ function createGitButlerPlugin(config = { ...DEFAULT_CONFIG }) {
|
|
|
1575
1520
|
} catch (err) {
|
|
1576
1521
|
log.error("cursor-after-edit-error", {
|
|
1577
1522
|
file: relativePath,
|
|
1523
|
+
conversationId,
|
|
1578
1524
|
error: err instanceof Error ? err.message : String(err)
|
|
1579
1525
|
});
|
|
1580
1526
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -17,5 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
19
19
|
import type { GitButlerPluginConfig } from "./config.js";
|
|
20
|
+
export declare function toUUID(input: string): Promise<string>;
|
|
21
|
+
export declare function sessionCacheKey(rootSessionID: string, filePath: string): string;
|
|
20
22
|
export declare function createGitButlerPlugin(config?: GitButlerPluginConfig): Plugin;
|
|
21
23
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAUzD,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,qBAA6C,GACpD,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAUzD,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa3D;AAED,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,qBAA6C,GACpD,MAAM,CAskBR"}
|