feat: AI-powered merge via pi agent

This commit is contained in:
Dustin Byrne
2026-03-25 18:43:49 -04:00
parent 22d806d436
commit 16e9043aee
7 changed files with 308 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import { exec } from "node:child_process";
import { TaskStore } from "@hai/core";
import { createServer } from "@hai/dashboard";
import { TriageProcessor, TaskExecutor, Scheduler } from "@hai/engine";
import { TriageProcessor, TaskExecutor, Scheduler, aiMergeTask } from "@hai/engine";
function openBrowser(url: string): void {
const cmd =
@@ -16,8 +16,15 @@ export async function runDashboard(port: number, opts: { engine?: boolean; open?
const store = new TaskStore(cwd);
await store.init();
// Start the web server
const app = createServer(store);
// AI-powered merge handler
const onMerge = (taskId: string) =>
aiMergeTask(store, cwd, taskId, {
onAgentText: (delta) => process.stdout.write(delta),
onAgentTool: (name) => console.log(`[merger] tool: ${name}`),
});
// Start the web server with AI merge wired in
const app = createServer(store, { onMerge });
// Optionally start the AI engine
if (opts.engine) {
@@ -56,6 +63,7 @@ export async function runDashboard(port: number, opts: { engine?: boolean; open?
console.log(` → http://localhost:${port}`);
console.log();
console.log(` Tasks stored in .hai/tasks/`);
console.log(` Merge: AI-assisted (conflict resolution + commit messages)`);
if (opts.engine) {
console.log(` AI engine: ✓ active`);
console.log(` • triage: auto-specifying tasks`);

View File

@@ -1,4 +1,5 @@
import { TaskStore, COLUMNS, COLUMN_LABELS, type Column, type MergeResult } from "@hai/core";
import { aiMergeTask } from "@hai/engine";
import { createInterface } from "node:readline/promises";
async function getStore(): Promise<TaskStore> {
@@ -63,10 +64,16 @@ export async function runTaskList() {
}
export async function runTaskMerge(id: string) {
const cwd = process.cwd();
const store = await getStore();
console.log(`\n Merging ${id} with AI...\n`);
try {
const result = await store.mergeTask(id);
const result = await aiMergeTask(store, cwd, id, {
onAgentText: (delta) => process.stdout.write(delta),
onAgentTool: (name) => console.log(` [merge] tool: ${name}`),
});
console.log();
if (result.merged) {