feat: migrate bash cron utilities to TypeScript#62
Conversation
- Add git-utils.ts with getBranchTipTimestamp, detectDefaultBranch - Add worktree-manager.ts with prepareBranchWorktree, prepareDetachedWorktree - Add claim-manager.ts with claimPrd, releaseClaim, isClaimed, readClaimInfo - Add log-utils.ts with rotateLog, checkRateLimited - Add prd-discovery.ts with findEligiblePrd, findEligibleBoardIssue - Extend prd-utils.ts with markPrdDone - Extend status-data.ts with acquireLock, releaseLock - Add cron CLI command group with all subcommands - Add comprehensive tests for all new modules Part of #57 - migrate bash business logic to typescript 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The else-if branch at line 211 was a duplicate of line 200's condition,
causing the no-dupe-else-if lint error. Added hour.includes(',') to the
first branch to distinguish comma-separated hours from single hours.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Night Watch PR FixPrevious review score: N/A (review CI failed to run) Changes made:
CI Failures Fixed:
Night Watch PR Reviewer |
DiffGuard AI AnalysisAI Review Summary🏆 Overall Score: 82/100 This PR implements a comprehensive CLI interface for cron script integration, replacing bash functions with well-structured TypeScript modules. The implementation is thorough with good test coverage, though there are a few concerns worth addressing. ✅ Key Strengths
🐛 Bugs Found
🔧 Issues Found
🔚 Conclusion Analyzed using z-ai/glm-5 |
…mmands - Add 6 test cases for findEligibleBoardIssue (empty output, gh failure, unclaimed issue returned, claimed issue skipped, all claimed returns null, malformed JSON skipped) - Add CLI integration tests for all cron subcommands: exit-code signaling, invalid argument validation, stdout output paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Additional Tests AddedNew test coverage:
Night Watch PR Reviewer |
Two bugs in the beforeEach setup: 1. git(['init', '--bare', remoteDir]) used default cwd=projectDir which didn't exist yet, causing ENOENT on CI; fixed by passing tmpDir as cwd 2. wt2 was named 'project-nw-scope2' so both wt1 and wt2 matched the 'scope' token in cleanupWorktrees; renamed wt2 to 'project-nw-feature1' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract HORIZON_SHORT_TERM, HORIZON_MEDIUM_TERM, HORIZON_LONG_TERM in roadmap-mapping.ts - Extract ERROR_BOARD_NOT_CONFIGURED constant in board.routes.ts Reduces lint warnings from 33 to 30. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DiffGuard AI AnalysisAI Review Summary🏆 Overall Score: 88/100 This PR successfully implements CLI cron commands and supporting utilities to replace bash helper functions. The code is well-structured with comprehensive test coverage and clear separation of concerns. ✅ Key Strengths
🐛 Bugs Found
📋 Issues Found
🔚 Conclusion Analyzed using z-ai/glm-5 |
…e test timeout The test was hanging past the 30s limit because the worker stagger delay defaulted to 60s (production value) when not explicitly set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…test.ts Kept new board timeout comment test from master alongside existing rate_limit_fallback test from this branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
This PR implements Phases 1-6 of the PRD to migrate bash business logic from
scripts/night-watch-helpers.shto TypeScript modules. This makes the code testable with vitest and provides a cleaner CLI interface for cron scripts.Changes
New Modules (packages/core/src/utils/)
getBranchTipTimestamp,detectDefaultBranch,resolveWorktreeBaseRefprepareBranchWorktree,prepareDetachedWorktree,cleanupWorktreesclaimPrd,releaseClaim,isClaimed,readClaimInforotateLog,checkRateLimitedfindEligiblePrd,findEligibleBoardIssue,sortPrdsByPriorityExtended Modules
acquireLock,releaseLockfunctionsmarkPrdDonefunctionCLI Command
night-watch croncommand group with subcommands:detect-branch- Detect default branchacquire-lock/release-lock- Lock file managementfind-eligible- Find eligible PRD for executionclaim/release-claim/is-claimed- PRD claim managementmark-done- Mark PRD as doneprepare-worktree/cleanup-worktrees- Worktree managementcheck-rate-limit/rotate-log- Log utilitiesTests
Remaining Work (Future PRs)
Test Results
yarn verifypassesCloses #57
🤖 Generated with Claude Code