feat(nightshift): add automated codebase maintenance system#122
feat(nightshift): add automated codebase maintenance system#122Loa212 wants to merge 3 commits intocoollabsio:mainfrom
Conversation
23caf52 to
cf65998
Compare
|
Oh wow, nightshift sounds pretty good! Thanks I will take a look at it! |
|
@andrasbacsai sorry I have to make some changes. I will tag you later once I feel it is ready for review again. Thanks ! |
c2724c7 to
de3b00f
Compare
|
@andrasbacsai tested this with both Claude and Codex. It's marked as experimental, living in each project's settings under a "Nightshift" tab. You can hit Built-in checks (8 enabled by default, 2 opt-in):
-> Each check has its own cooldown, can be individually enabled/disabled, and you can override the prompt per-check. -> You can set a schedule time for automatic overnight runs, and choose what happens after: leave changes staged, commit, or commit & open a PR. Since Codex now has usage tracking we could hook this up to show nightshift costs, or we can wait for stable Claude usage support. Let me know what you'd prefer. Overall let me know what you think. I believe this can be a nice addition but you decide :) If you want it shaped differently I'm open to suggestions. |
Nightshift runs configurable maintenance checks (lint, dead code, security, tests, etc.) on a schedule or manually. Each check creates a timestamped session in a dedicated "nightshift" worktree and executes via Claude CLI. - Backend engine with sequential check execution and per-project guards - 10 built-in checks with customizable prompts and cooldowns - Scheduler (60s interval) with manual trigger support - Frontend event orchestration and settings UI (marked experimental) - Uses save_empty_index() and worktrees:changed from refactor PR
- Fix get_last_check_run_time() to use the run's started_at for the matching check result, not the max started_at across all runs - Fix Codex detached tail to treat process exit with content as completed rather than cancelled (yolo mode may not emit turn.completed)
…ream compat - Drop RunGuard before emitting run-completed event to prevent race where user clicks Run Now before RUNNING_PROJECTS is cleared - Use has_content (text + tool_calls + content_blocks) instead of just full_content for Codex error/fallback checks — prevents false chat:error when Codex works via tools with no text output - Add nightshift fields to new upstream Session constructor site
Summary
Adds Nightshift — an automated codebase maintenance system that runs configurable checks in the background using real Claude CLI sessions.
What's included
Rust backend (
src-tauri/src/nightshift/)RUNNING_PROJECTSguard prevents concurrent runs on the same projectFrontend (
src/)NightshiftPanein Project Settings with experimental banner, enable toggle, "Run Now" button, per-check configNightshiftRunsModalwith run history and collapsible check resultsuseNightshiftEventshook: listens fornightshift:execute-check, sends messages to CLI sessions, reports completion back to engineIntegration points
save_empty_index()andworktrees:changedevent from PR test(chat): add test for WorktreeIndex::new_empty() #120source,nightshift_check_id,nightshift_run_id(NICE-TO-HAVE) Token usage / cost tracking
Token usage tracking and budget limits are not yet implemented. Citing the inspiration (see below):
Inspiration
Inspired by marcus/nightshift