feat(FN-692): add setupScript setting for automatic worktree initialization

- Add `setupScript` property to ProjectSettings to reference a named script
- Execute the referenced setup script after worktreeInitCommand on fresh worktrees
- Log success/failure of setup script execution; warn and skip if script name not found
- Skip setup script for pooled/recycled worktrees (fresh only)
- Add changeset (minor) for the new setting
This commit is contained in:
gsxdsm
2026-04-01 09:26:20 -07:00
parent 5e949ff4aa
commit 57d996fb9b
3 changed files with 33 additions and 0 deletions

View File

@@ -448,6 +448,26 @@ export class TaskExecutor {
await this.store.logEntry(task.id, `Worktree init command failed: ${message}`);
}
}
// Run setup script for fresh worktrees (after worktreeInitCommand)
if (settings.setupScript) {
const scriptCommand = settings.scripts?.[settings.setupScript];
if (scriptCommand) {
try {
execSync(scriptCommand, {
cwd: worktreePath,
stdio: "pipe",
timeout: 120_000,
});
await this.store.logEntry(task.id, `Setup script '${settings.setupScript}' completed`, scriptCommand);
} catch (err: any) {
const message = err.stderr?.toString() || err.message || "Unknown error";
await this.store.logEntry(task.id, `Setup script '${settings.setupScript}' failed: ${message}`);
}
} else {
await this.store.logEntry(task.id, `Setup script '${settings.setupScript}' not found in scripts map — skipping`);
}
}
}
} else if (task.worktree) {
// Task already had a worktree assigned and it exists on disk — reuse it