19ab3b5656
When .sisyphus/ is gitignored, task state written during worktree execution is lost when the worktree is removed. Fix: - add worktree-sync.ts: syncSisyphusStateFromWorktree() copies .sisyphus/ contents from worktree to main repo directory - update start-work.ts template: documents the sync step as CRITICAL when worktree_path is set in boulder.json - update work-with-pr/SKILL.md: adds explicit sync step before worktree removal - export from boulder-state index - test: 5 scenarios covering no-.sisyphus, nested dirs, overwrite stale state
35 lines
993 B
TypeScript
35 lines
993 B
TypeScript
import { existsSync, cpSync, mkdirSync } from "node:fs"
|
|
import { join } from "node:path"
|
|
import { BOULDER_DIR } from "./constants"
|
|
import { log } from "../../shared/logger"
|
|
|
|
export function syncSisyphusStateFromWorktree(worktreePath: string, mainRepoPath: string): boolean {
|
|
const srcDir = join(worktreePath, BOULDER_DIR)
|
|
const destDir = join(mainRepoPath, BOULDER_DIR)
|
|
|
|
if (!existsSync(srcDir)) {
|
|
log("[worktree-sync] No .sisyphus directory in worktree, nothing to sync", { worktreePath })
|
|
return true
|
|
}
|
|
|
|
try {
|
|
if (!existsSync(destDir)) {
|
|
mkdirSync(destDir, { recursive: true })
|
|
}
|
|
|
|
cpSync(srcDir, destDir, { recursive: true, force: true })
|
|
log("[worktree-sync] Synced .sisyphus state from worktree to main repo", {
|
|
worktreePath,
|
|
mainRepoPath,
|
|
})
|
|
return true
|
|
} catch (err) {
|
|
log("[worktree-sync] Failed to sync .sisyphus state", {
|
|
worktreePath,
|
|
mainRepoPath,
|
|
error: String(err),
|
|
})
|
|
return false
|
|
}
|
|
}
|