fix(start-work): preserve existing works when starting an explicit new plan

This commit is contained in:
YeonGyu-Kim
2026-05-11 14:25:52 +09:00
parent dd5f77562a
commit 079a2cd65a
2 changed files with 73 additions and 12 deletions
+25 -12
View File
@@ -48,19 +48,14 @@ function findPlanByName(plans: string[], requestedName: string): string | null {
return normalizedPartialMatch || null
}
function buildAutoSelectedPlanContext(params: {
function buildAutoSelectedPlanContextInfoOnly(params: {
planPath: string
sessionId: string
timestamp: string
activeAgent: string
worktreePath: string | undefined
worktreeBlock: string
directory: string
}): string {
const { planPath, sessionId, timestamp, activeAgent, worktreePath, worktreeBlock, directory } = params
const { planPath, sessionId, timestamp, worktreeBlock } = params
const progress = getPlanProgress(planPath)
const newState = createBoulderState(planPath, sessionId, activeAgent, worktreePath)
writeBoulderState(directory, newState)
return `
## Auto-Selected Plan
@@ -75,6 +70,27 @@ ${worktreeBlock}
boulder.json has been created. Read the plan and begin execution.`
}
function buildAutoSelectedPlanContextWithStateInit(params: {
planPath: string
sessionId: string
timestamp: string
activeAgent: string
worktreePath: string | undefined
worktreeBlock: string
directory: string
}): string {
const { planPath, sessionId, timestamp, activeAgent, worktreePath, worktreeBlock, directory } = params
const newState = createBoulderState(planPath, sessionId, activeAgent, worktreePath)
writeBoulderState(directory, newState)
return buildAutoSelectedPlanContextInfoOnly({
planPath,
sessionId,
timestamp,
worktreeBlock,
})
}
function buildMissingPlanContext(explicitPlanName: string, allPlans: string[]): string {
const incompletePlans = allPlans.filter((p) => !getPlanProgress(p).isComplete)
if (incompletePlans.length > 0) {
@@ -218,14 +234,11 @@ function buildExplicitPlanContext(params: {
worktreePath,
})
return buildAutoSelectedPlanContext({
return buildAutoSelectedPlanContextInfoOnly({
planPath: matchedPlan,
sessionId,
timestamp,
activeAgent,
worktreePath,
worktreeBlock,
directory,
})
}
@@ -328,7 +341,7 @@ function buildPlanDiscoveryContext(params: {
}
if (incompletePlans.length === 1) {
return contextInfo + buildAutoSelectedPlanContext({
return contextInfo + buildAutoSelectedPlanContextWithStateInit({
planPath: incompletePlans[0],
sessionId,
timestamp,