Fix #3629: resolve boulder progress from worktree plan
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
getPlanName,
|
||||
getPlanProgress,
|
||||
readBoulderState,
|
||||
resolveBoulderPlanPath,
|
||||
writeBoulderState,
|
||||
} from "../../features/boulder-state"
|
||||
import { log } from "../../shared/logger"
|
||||
@@ -150,7 +151,8 @@ function buildExistingSessionContext(params: {
|
||||
directory: string
|
||||
}): string {
|
||||
const { existingState, sessionId, activeAgent, worktreePath, worktreeBlock, directory } = params
|
||||
const progress = getPlanProgress(existingState.active_plan)
|
||||
const planPath = resolveBoulderPlanPath(directory, existingState)
|
||||
const progress = getPlanProgress(planPath)
|
||||
if (progress.isComplete) {
|
||||
return `
|
||||
## Previous Work Complete
|
||||
@@ -186,7 +188,7 @@ Looking for new plans...`
|
||||
|
||||
**Status**: RESUMING existing work
|
||||
**Plan**: ${existingState.plan_name}
|
||||
**Path**: ${existingState.active_plan}
|
||||
**Path**: ${planPath}
|
||||
**Progress**: ${progress.completed}/${progress.total} tasks completed
|
||||
**Sessions**: ${existingState.session_ids.length + 1} (current session appended)
|
||||
**Started**: ${existingState.started_at}
|
||||
@@ -197,11 +199,16 @@ Read the plan file and continue from the first unchecked task.`
|
||||
}
|
||||
|
||||
function shouldDiscoverPlans(
|
||||
directory: string,
|
||||
existingState: ReturnType<typeof readBoulderState>,
|
||||
explicitPlanName: string | null,
|
||||
): boolean {
|
||||
return (!existingState && !explicitPlanName)
|
||||
|| (existingState !== null && !explicitPlanName && getPlanProgress(existingState.active_plan).isComplete)
|
||||
|| (
|
||||
existingState !== null
|
||||
&& !explicitPlanName
|
||||
&& getPlanProgress(resolveBoulderPlanPath(directory, existingState)).isComplete
|
||||
)
|
||||
}
|
||||
|
||||
function buildPlanDiscoveryContext(params: {
|
||||
@@ -303,7 +310,7 @@ export function buildStartWorkContextInfo(params: {
|
||||
})
|
||||
}
|
||||
|
||||
if (shouldDiscoverPlans(existingState, explicitPlanName)) {
|
||||
if (shouldDiscoverPlans(ctx.directory, existingState, explicitPlanName)) {
|
||||
return buildPlanDiscoveryContext({
|
||||
contextInfo,
|
||||
sessionId,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { describe, expect, test, beforeEach, afterEach, spyOn } from "bun:test"
|
||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { dirname, join } from "node:path"
|
||||
import { tmpdir } from "node:os"
|
||||
import { randomUUID } from "node:crypto"
|
||||
import { createStartWorkHook } from "./index"
|
||||
@@ -1013,5 +1013,39 @@ You are starting a Sisyphus work session.
|
||||
expect(output.parts[0].text).toContain("subagent")
|
||||
expect(output.parts[0].text).not.toContain("Worktree Setup Required")
|
||||
})
|
||||
|
||||
test("should show worktree plan progress and path when the mirrored plan exists", async () => {
|
||||
// given
|
||||
const mainPlanPath = join(testDir, ".sisyphus", "plans", "resume-worktree-plan.md")
|
||||
const worktreeDir = join(testDir, "..", `resume-worktree-${randomUUID()}`)
|
||||
const worktreePlanPath = join(worktreeDir, ".sisyphus", "plans", "resume-worktree-plan.md")
|
||||
mkdirSync(dirname(mainPlanPath), { recursive: true })
|
||||
mkdirSync(dirname(worktreePlanPath), { recursive: true })
|
||||
writeFileSync(mainPlanPath, "# Plan\n- [ ] Main repo task\n")
|
||||
writeFileSync(worktreePlanPath, "# Plan\n- [x] Worktree task 1\n- [ ] Worktree task 2\n")
|
||||
writeBoulderState(testDir, {
|
||||
active_plan: mainPlanPath,
|
||||
started_at: "2026-01-01T00:00:00Z",
|
||||
session_ids: ["old-session"],
|
||||
plan_name: "resume-worktree-plan",
|
||||
worktree_path: worktreeDir,
|
||||
})
|
||||
|
||||
const hook = createStartWorkHook(createMockPluginInput())
|
||||
const output = {
|
||||
parts: [{ type: "text", text: createStartWorkPrompt() }],
|
||||
}
|
||||
|
||||
try {
|
||||
// when
|
||||
await hook["chat.message"]({ sessionID: "session-worktree-progress" }, output)
|
||||
|
||||
// then
|
||||
expect(output.parts[0].text).toContain(worktreePlanPath)
|
||||
expect(output.parts[0].text).toContain("1/2 tasks completed")
|
||||
} finally {
|
||||
rmSync(worktreeDir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user