kantban-cli 0.1.10 → 0.1.11
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
CHANGED
|
@@ -163,10 +163,10 @@ async function main() {
|
|
|
163
163
|
}
|
|
164
164
|
case "pipeline": {
|
|
165
165
|
if (args[0] === "stop") {
|
|
166
|
-
const { stopPipeline } = await import("./pipeline-
|
|
166
|
+
const { stopPipeline } = await import("./pipeline-7LG74YA2.js");
|
|
167
167
|
await stopPipeline(args.slice(1));
|
|
168
168
|
} else {
|
|
169
|
-
const { runPipeline } = await import("./pipeline-
|
|
169
|
+
const { runPipeline } = await import("./pipeline-7LG74YA2.js");
|
|
170
170
|
await runPipeline(client, args);
|
|
171
171
|
}
|
|
172
172
|
break;
|
|
@@ -53,6 +53,43 @@ async function cleanupWorktree(worktreeName, exec = defaultExecFile) {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
+
function execPromise(exec, cmd, args) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
exec(cmd, args, (err, stdout, stderr) => {
|
|
59
|
+
if (err) reject(Object.assign(err, { stdout, stderr }));
|
|
60
|
+
else resolve({ stdout, stderr });
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function mergeWorktreeBranch(worktreeName, integrationBranch, exec = defaultExecFile) {
|
|
65
|
+
try {
|
|
66
|
+
await execPromise(exec, "git", ["branch", integrationBranch, "HEAD"]).catch(() => {
|
|
67
|
+
});
|
|
68
|
+
const { stdout: baseOut } = await execPromise(exec, "git", ["merge-base", integrationBranch, worktreeName]);
|
|
69
|
+
const mergeBase = baseOut.trim();
|
|
70
|
+
const { stdout: integrationSha } = await execPromise(exec, "git", ["rev-parse", integrationBranch]);
|
|
71
|
+
if (integrationSha.trim() === mergeBase) {
|
|
72
|
+
const { stdout: worktreeSha } = await execPromise(exec, "git", ["rev-parse", worktreeName]);
|
|
73
|
+
await execPromise(exec, "git", ["update-ref", `refs/heads/${integrationBranch}`, worktreeSha.trim()]);
|
|
74
|
+
console.error(`[worktree] fast-forward merged ${worktreeName} \u2192 ${integrationBranch}`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const tmpWorktree = `merge-tmp-${Date.now()}`;
|
|
78
|
+
try {
|
|
79
|
+
await execPromise(exec, "git", ["worktree", "add", tmpWorktree, integrationBranch]);
|
|
80
|
+
await execPromise(exec, "git", ["-C", tmpWorktree, "merge", "--no-edit", worktreeName]);
|
|
81
|
+
console.error(`[worktree] merged ${worktreeName} \u2192 ${integrationBranch}`);
|
|
82
|
+
} finally {
|
|
83
|
+
await execPromise(exec, "git", ["worktree", "remove", "--force", tmpWorktree]).catch(() => {
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
} catch (err) {
|
|
88
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
89
|
+
console.error(`[worktree] merge failed for ${worktreeName} \u2192 ${integrationBranch}: ${msg}`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
56
93
|
|
|
57
94
|
// src/lib/constraint-evaluator.ts
|
|
58
95
|
function resolveColumn(board, columnId, subjectRef) {
|
|
@@ -457,6 +494,7 @@ var PipelineOrchestrator = class {
|
|
|
457
494
|
worktreeEnabled: cfg?.worktree?.enabled,
|
|
458
495
|
worktreeOnMove: cfg?.worktree?.on_move,
|
|
459
496
|
worktreeOnDone: cfg?.worktree?.on_done,
|
|
497
|
+
worktreeIntegrationBranch: cfg?.worktree?.integration_branch,
|
|
460
498
|
invocationTier: cfg?.invocation_tier,
|
|
461
499
|
lookaheadColumnId: cfg?.lookahead_column_id,
|
|
462
500
|
runMemory: cfg?.run_memory,
|
|
@@ -1597,18 +1635,28 @@ ${findingsText}`)
|
|
|
1597
1635
|
);
|
|
1598
1636
|
}
|
|
1599
1637
|
const isTerminal = result.reason === "moved" || result.reason === "max_iterations" || result.reason === "error" || result.reason === "stalled" || result.reason === "stopped" || result.reason === "deleted";
|
|
1600
|
-
if (isTerminal && colConfig
|
|
1638
|
+
if (isTerminal && colConfig) {
|
|
1601
1639
|
const colScope2 = this.columnScopes.get(columnId);
|
|
1602
1640
|
const ticket2 = colScope2?.tickets.find((t) => t.id === ticketId);
|
|
1603
1641
|
if (ticket2) {
|
|
1604
1642
|
const worktreeName = generateWorktreeName(ticket2.ticket_number, colConfig.name);
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1643
|
+
if (colConfig.worktreeOnDone === "merge" && colConfig.worktreeIntegrationBranch && this.deps.mergeWorktree) {
|
|
1644
|
+
void this.deps.mergeWorktree(worktreeName, colConfig.worktreeIntegrationBranch).then((success) => {
|
|
1645
|
+
if (!success) {
|
|
1646
|
+
console.error(` [warn] Worktree merge failed for ${worktreeName} \u2192 ${colConfig.worktreeIntegrationBranch} \u2014 may need manual resolution`);
|
|
1647
|
+
}
|
|
1648
|
+
}).catch((err) => {
|
|
1649
|
+
console.error(` [warn] Worktree merge error for ${worktreeName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1650
|
+
});
|
|
1651
|
+
} else if (colConfig.worktreeOnDone === "cleanup" && this.deps.cleanupWorktree) {
|
|
1652
|
+
void this.deps.cleanupWorktree(worktreeName).then((success) => {
|
|
1653
|
+
if (!success) {
|
|
1654
|
+
console.error(` [warn] Worktree cleanup failed for ${worktreeName} \u2014 may need manual removal`);
|
|
1655
|
+
}
|
|
1656
|
+
}).catch((err) => {
|
|
1657
|
+
console.error(` [warn] Worktree cleanup error for ${worktreeName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1612
1660
|
}
|
|
1613
1661
|
}
|
|
1614
1662
|
this.deps.gateSnapshotStore?.clear(ticketId);
|
|
@@ -3663,6 +3711,7 @@ async function runPipeline(client, args) {
|
|
|
3663
3711
|
// Run memory append — closure captures runMemory by reference (set after initialization)
|
|
3664
3712
|
appendRunMemory: (section, content) => runMemory ? runMemory.append(section, content) : Promise.resolve(),
|
|
3665
3713
|
cleanupWorktree: (name) => cleanupWorktree(name),
|
|
3714
|
+
mergeWorktree: (name, integrationBranch) => mergeWorktreeBranch(name, integrationBranch),
|
|
3666
3715
|
// Pipeline event emission — wsClient captured by reference (set later before any loops run)
|
|
3667
3716
|
emitPipelineEvent: (event) => {
|
|
3668
3717
|
wsClient?.send(event);
|
|
@@ -4046,4 +4095,4 @@ export {
|
|
|
4046
4095
|
runPipeline,
|
|
4047
4096
|
stopPipeline
|
|
4048
4097
|
};
|
|
4049
|
-
//# sourceMappingURL=pipeline-
|
|
4098
|
+
//# sourceMappingURL=pipeline-7LG74YA2.js.map
|