feat(hooks): make start-work hook respect worktree config
This commit is contained in:
@@ -64,7 +64,7 @@ function resolveWorktreeContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createStartWorkHook(ctx: PluginInput) {
|
export function createStartWorkHook(ctx: PluginInput, options?: { worktreeEnabled?: boolean }) {
|
||||||
return {
|
return {
|
||||||
"chat.message": async (input: StartWorkHookInput, output: StartWorkHookOutput): Promise<void> => {
|
"chat.message": async (input: StartWorkHookInput, output: StartWorkHookOutput): Promise<void> => {
|
||||||
const parts = output.parts
|
const parts = output.parts
|
||||||
@@ -85,7 +85,10 @@ export function createStartWorkHook(ctx: PluginInput) {
|
|||||||
const timestamp = new Date().toISOString()
|
const timestamp = new Date().toISOString()
|
||||||
|
|
||||||
const { planName: explicitPlanName, explicitWorktreePath } = parseUserRequest(promptText)
|
const { planName: explicitPlanName, explicitWorktreePath } = parseUserRequest(promptText)
|
||||||
const { worktreePath, block: worktreeBlock } = resolveWorktreeContext(explicitWorktreePath)
|
const worktreeDisabled = options?.worktreeEnabled === false
|
||||||
|
const { worktreePath, block: worktreeBlock } = worktreeDisabled
|
||||||
|
? { worktreePath: undefined, block: "" }
|
||||||
|
: resolveWorktreeContext(explicitWorktreePath)
|
||||||
|
|
||||||
let contextInfo = ""
|
let contextInfo = ""
|
||||||
|
|
||||||
@@ -106,7 +109,7 @@ The requested plan "${getPlanName(matchedPlan)}" has been completed.
|
|||||||
All ${progress.total} tasks are done. Create a new plan with: /plan "your task"`
|
All ${progress.total} tasks are done. Create a new plan with: /plan "your task"`
|
||||||
} else {
|
} else {
|
||||||
if (existingState) clearBoulderState(ctx.directory)
|
if (existingState) clearBoulderState(ctx.directory)
|
||||||
const newState = createBoulderState(matchedPlan, sessionId, "atlas", worktreePath)
|
const newState = createBoulderState(matchedPlan, sessionId, "atlas", worktreeDisabled ? undefined : worktreePath)
|
||||||
writeBoulderState(ctx.directory, newState)
|
writeBoulderState(ctx.directory, newState)
|
||||||
|
|
||||||
contextInfo = `
|
contextInfo = `
|
||||||
@@ -152,9 +155,9 @@ No incomplete plans available. Create a new plan with: /plan "your task"`
|
|||||||
const progress = getPlanProgress(existingState.active_plan)
|
const progress = getPlanProgress(existingState.active_plan)
|
||||||
|
|
||||||
if (!progress.isComplete) {
|
if (!progress.isComplete) {
|
||||||
const effectiveWorktree = worktreePath ?? existingState.worktree_path
|
const effectiveWorktree = worktreeDisabled ? undefined : (worktreePath ?? existingState.worktree_path)
|
||||||
|
|
||||||
if (worktreePath !== undefined) {
|
if (!worktreeDisabled && worktreePath !== undefined) {
|
||||||
const updatedSessions = existingState.session_ids.includes(sessionId)
|
const updatedSessions = existingState.session_ids.includes(sessionId)
|
||||||
? existingState.session_ids
|
? existingState.session_ids
|
||||||
: [...existingState.session_ids, sessionId]
|
: [...existingState.session_ids, sessionId]
|
||||||
@@ -213,7 +216,7 @@ All ${plans.length} plan(s) are complete. Create a new plan with: /plan "your ta
|
|||||||
} else if (incompletePlans.length === 1) {
|
} else if (incompletePlans.length === 1) {
|
||||||
const planPath = incompletePlans[0]
|
const planPath = incompletePlans[0]
|
||||||
const progress = getPlanProgress(planPath)
|
const progress = getPlanProgress(planPath)
|
||||||
const newState = createBoulderState(planPath, sessionId, "atlas", worktreePath)
|
const newState = createBoulderState(planPath, sessionId, "atlas", worktreeDisabled ? undefined : worktreePath)
|
||||||
writeBoulderState(ctx.directory, newState)
|
writeBoulderState(ctx.directory, newState)
|
||||||
|
|
||||||
contextInfo += `
|
contextInfo += `
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ export function createSessionHooks(args: {
|
|||||||
: null
|
: null
|
||||||
|
|
||||||
const startWork = isHookEnabled("start-work")
|
const startWork = isHookEnabled("start-work")
|
||||||
? safeHook("start-work", () => createStartWorkHook(ctx))
|
? safeHook("start-work", () => createStartWorkHook(ctx, { worktreeEnabled: pluginConfig.start_work?.worktree }))
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const prometheusMdOnly = isHookEnabled("prometheus-md-only")
|
const prometheusMdOnly = isHookEnabled("prometheus-md-only")
|
||||||
|
|||||||
Reference in New Issue
Block a user