Merge claudedo/ccd650a8d2b04a7092e81ed07c16dbe0
This commit is contained in:
@@ -253,6 +253,79 @@ public sealed class InteractiveLaunchSpecService : IInteractiveLaunchSpecService
|
||||
return new LaunchSpec(repoDir, resolvedClaude, args, env);
|
||||
}
|
||||
|
||||
// Builds the LaunchSpec for the fresh session a merge-helper run hands off to once Phase 2
|
||||
// (enhance) is done -- SAME handler task id as the run that called handoff_list_handler, so
|
||||
// HandlerBaseCommit/HandlerHeadCommit and the review range stay untouched; this never creates
|
||||
// a task. Reuses the merge-helper system prompt unchanged (the phase 3-5 instructions already
|
||||
// live there) and only writes a fresh handoff kickoff file, in a NEW session dir -- the old
|
||||
// ConPTY tile keeps running against its own session-dir files untouched.
|
||||
public async Task<LaunchSpec> BuildForMergeHelperHandoffAsync(
|
||||
string taskId, IReadOnlyList<string> survivingTaskIds, CancellationToken ct)
|
||||
{
|
||||
if (survivingTaskIds.Count == 0)
|
||||
throw new InvalidOperationException("No surviving tasks to hand off.");
|
||||
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
|
||||
var taskRepo = new TaskRepository(ctx);
|
||||
var listRepo = new ListRepository(ctx);
|
||||
|
||||
var handlerTask = await taskRepo.GetByIdAsync(taskId, ct)
|
||||
?? throw new KeyNotFoundException($"Task not found: {taskId}");
|
||||
var list = await listRepo.GetByIdAsync(handlerTask.ListId, ct)
|
||||
?? throw new KeyNotFoundException($"List not found: {handlerTask.ListId}");
|
||||
|
||||
var repoDir = list.WorkingDir;
|
||||
if (string.IsNullOrEmpty(repoDir) || !Directory.Exists(repoDir))
|
||||
throw new InvalidOperationException($"list '{list.Name}' has no existing working directory");
|
||||
|
||||
var briefLines = new List<string>();
|
||||
foreach (var id in survivingTaskIds)
|
||||
{
|
||||
var task = await taskRepo.GetByIdAsync(id, ct)
|
||||
?? throw new KeyNotFoundException($"Task not found: {id}");
|
||||
briefLines.Add($"- [{task.Status}] {task.Title} (id: {task.Id})");
|
||||
}
|
||||
|
||||
var sessionDir = Path.Combine(Paths.AppDataRoot(), "merge-helper-sessions", Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(sessionDir);
|
||||
|
||||
var systemPromptPath = Path.Combine(sessionDir, "system-prompt.md");
|
||||
await File.WriteAllTextAsync(systemPromptPath, PromptFiles.ReadOrDefault(PromptKind.MergeHelper), ct);
|
||||
|
||||
var briefPath = Path.Combine(sessionDir, "handoff.md");
|
||||
await File.WriteAllTextAsync(briefPath, PromptFiles.Render(PromptKind.MergeHelperHandoff,
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
["scope"] = $"List: {list.Name}",
|
||||
["repo"] = repoDir,
|
||||
["tasks"] = string.Join("\n", briefLines),
|
||||
}), ct);
|
||||
|
||||
var resolvedClaude = WindowsTerminalLauncher.Resolve(_claudePath)
|
||||
?? throw new InvalidOperationException($"claude executable not found: {_claudePath}");
|
||||
|
||||
var listConfig = await listRepo.GetConfigAsync(handlerTask.ListId, ct);
|
||||
var settings = await new AppSettingsRepository(ctx).GetAsync(ct);
|
||||
|
||||
var args = new List<string>
|
||||
{
|
||||
"--effort", EffortFor(settings, listConfig?.Model),
|
||||
"--permission-mode", "auto",
|
||||
"--allowedTools", MergeHelperAllowedTools,
|
||||
"--add-dir", sessionDir, repoDir,
|
||||
"--append-system-prompt-file", systemPromptPath,
|
||||
$"Read the file {briefPath} first. It lists the surviving tasks and their status. " +
|
||||
"After reading it, begin at phase 3 as your instructions describe.",
|
||||
};
|
||||
|
||||
var env = new Dictionary<string, string>
|
||||
{
|
||||
["MCP_TOOL_TIMEOUT"] = "200000",
|
||||
};
|
||||
|
||||
return new LaunchSpec(repoDir, resolvedClaude, args, env);
|
||||
}
|
||||
|
||||
// Renders one task as a brief list item. A description can itself be arbitrary Markdown
|
||||
// (headings, lists, fenced code) — those must not merge into the brief's own task list, so
|
||||
// the description is placed in a fenced code block indented to the list item's continuation
|
||||
|
||||
@@ -42,4 +42,12 @@ public interface IInteractiveLaunchSpecService
|
||||
/// is empty or the list has no existing working directory.</summary>
|
||||
Task<string> CreateMergeHelperTaskAsync(
|
||||
IReadOnlyList<string> taskIds, string listId, string title, string descriptionHeader, CancellationToken ct);
|
||||
|
||||
/// <summary>Builds a LaunchSpec for the fresh ConPTY session a merge-helper run hands off to
|
||||
/// once Phase 2 (enhance) is done -- reuses the SAME handler task id (no new task, HandlerBaseCommit
|
||||
/// untouched) and the unmodified merge-helper system prompt, writing only a fresh handoff kickoff
|
||||
/// naming the surviving tasks. Throws KeyNotFoundException if the task/list doesn't exist;
|
||||
/// InvalidOperationException if survivingTaskIds is empty or the list has no working directory.</summary>
|
||||
Task<LaunchSpec> BuildForMergeHelperHandoffAsync(
|
||||
string taskId, IReadOnlyList<string> survivingTaskIds, CancellationToken ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user