@jonit-dev/night-watch-cli 1.7.43 → 1.7.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cli.js +2343 -2000
  2. package/dist/commands/audit.d.ts.map +1 -1
  3. package/dist/commands/audit.js +23 -9
  4. package/dist/commands/audit.js.map +1 -1
  5. package/dist/commands/dashboard/tab-actions.d.ts.map +1 -1
  6. package/dist/commands/dashboard/tab-actions.js +8 -6
  7. package/dist/commands/dashboard/tab-actions.js.map +1 -1
  8. package/dist/commands/dashboard/tab-schedules.d.ts.map +1 -1
  9. package/dist/commands/dashboard/tab-schedules.js +23 -16
  10. package/dist/commands/dashboard/tab-schedules.js.map +1 -1
  11. package/dist/commands/dashboard/types.d.ts +1 -1
  12. package/dist/commands/dashboard/types.d.ts.map +1 -1
  13. package/dist/commands/dashboard.d.ts.map +1 -1
  14. package/dist/commands/dashboard.js +11 -7
  15. package/dist/commands/dashboard.js.map +1 -1
  16. package/dist/commands/prs.js +1 -1
  17. package/dist/commands/prs.js.map +1 -1
  18. package/dist/commands/qa.d.ts.map +1 -1
  19. package/dist/commands/qa.js +10 -6
  20. package/dist/commands/qa.js.map +1 -1
  21. package/dist/commands/review.d.ts.map +1 -1
  22. package/dist/commands/review.js +12 -13
  23. package/dist/commands/review.js.map +1 -1
  24. package/dist/commands/run.d.ts +12 -0
  25. package/dist/commands/run.d.ts.map +1 -1
  26. package/dist/commands/run.js +141 -57
  27. package/dist/commands/run.js.map +1 -1
  28. package/dist/commands/slice.d.ts.map +1 -1
  29. package/dist/commands/slice.js +12 -8
  30. package/dist/commands/slice.js.map +1 -1
  31. package/dist/commands/status.js +1 -1
  32. package/dist/commands/status.js.map +1 -1
  33. package/dist/scripts/night-watch-cron.sh +15 -5
  34. package/dist/scripts/night-watch-pr-reviewer-cron.sh +10 -6
  35. package/dist/templates/night-watch-pr-reviewer.md +20 -9
  36. package/package.json +1 -1
@@ -74,6 +74,13 @@ if ! acquire_lock "${LOCK_FILE}"; then
74
74
  exit 0
75
75
  fi
76
76
 
77
+ # Ensure all repo-scoped gh/night-watch commands run against this project.
78
+ if ! cd "${PROJECT_DIR}"; then
79
+ log "ERROR: Cannot access project directory ${PROJECT_DIR}"
80
+ emit_result "failure" "reason=invalid_project_dir"
81
+ exit 1
82
+ fi
83
+
77
84
  cleanup_worktrees "${PROJECT_DIR}"
78
85
 
79
86
  ISSUE_NUMBER="" # board mode: GitHub issue number
@@ -286,8 +293,9 @@ MERGED_PR_COUNT=$(count_prs_for_branch merged "${BRANCH_NAME}")
286
293
  if [ "${MERGED_PR_COUNT}" -gt 0 ]; then
287
294
  log "INFO: Found merged PR for ${BRANCH_NAME}; skipping provider run"
288
295
  if [ -n "${ISSUE_NUMBER}" ]; then
289
- # Board mode: move issue to Done
290
- "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Done" 2>>"${LOG_FILE}" || true
296
+ # Board mode: close issue and move to Done
297
+ "${NW_CLI}" board close-issue "${ISSUE_NUMBER}" 2>>"${LOG_FILE}" || \
298
+ "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Done" 2>>"${LOG_FILE}" || true
291
299
  emit_result "success_already_merged" "prd=${ELIGIBLE_PRD}|branch=${BRANCH_NAME}"
292
300
  exit 0
293
301
  elif finalize_prd_done "already merged on ${BRANCH_NAME}"; then
@@ -420,13 +428,14 @@ if [ ${EXIT_CODE} -eq 0 ]; then
420
428
  OPEN_PR_COUNT=$(count_prs_for_branch open "${BRANCH_NAME}")
421
429
  if [ "${OPEN_PR_COUNT}" -gt 0 ]; then
422
430
  if [ -n "${ISSUE_NUMBER}" ]; then
423
- # Board mode: move to Review and comment with PR URL
431
+ # Board mode: comment with PR URL, then close issue and move to Done
424
432
  PR_URL=$(gh pr list --state open --json headRefName,url \
425
433
  --jq ".[] | select(.headRefName == \"${BRANCH_NAME}\") | .url" 2>/dev/null || true)
426
- "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Review" 2>>"${LOG_FILE}" || true
427
434
  if [ -n "${PR_URL}" ]; then
428
435
  "${NW_CLI}" board comment "${ISSUE_NUMBER}" --body "PR opened: ${PR_URL}" 2>>"${LOG_FILE}" || true
429
436
  fi
437
+ "${NW_CLI}" board close-issue "${ISSUE_NUMBER}" 2>>"${LOG_FILE}" || \
438
+ "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Done" 2>>"${LOG_FILE}" || true
430
439
  emit_result "success_open_pr" "prd=${ELIGIBLE_PRD}|branch=${BRANCH_NAME}"
431
440
  elif finalize_prd_done "implemented, PR opened on ${BRANCH_NAME}"; then
432
441
  emit_result "success_open_pr" "prd=${ELIGIBLE_PRD}|branch=${BRANCH_NAME}"
@@ -439,7 +448,8 @@ if [ ${EXIT_CODE} -eq 0 ]; then
439
448
  MERGED_PR_COUNT=$(count_prs_for_branch merged "${BRANCH_NAME}")
440
449
  if [ "${MERGED_PR_COUNT}" -gt 0 ]; then
441
450
  if [ -n "${ISSUE_NUMBER}" ]; then
442
- "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Done" 2>>"${LOG_FILE}" || true
451
+ "${NW_CLI}" board close-issue "${ISSUE_NUMBER}" 2>>"${LOG_FILE}" || \
452
+ "${NW_CLI}" board move-issue "${ISSUE_NUMBER}" --column "Done" 2>>"${LOG_FILE}" || true
443
453
  emit_result "success_already_merged" "prd=${ELIGIBLE_PRD}|branch=${BRANCH_NAME}"
444
454
  elif finalize_prd_done "already merged on ${BRANCH_NAME}"; then
445
455
  emit_result "success_already_merged" "prd=${ELIGIBLE_PRD}|branch=${BRANCH_NAME}"
@@ -210,9 +210,12 @@ if [ "${NEEDS_WORK}" -eq 0 ]; then
210
210
  [ -z "${pr_number}" ] || [ -z "${pr_branch}" ] && continue
211
211
  printf '%s\n' "${pr_branch}" | grep -Eq "${BRANCH_REGEX}" || continue
212
212
 
213
- # Check CI status
214
- FAILED_CHECKS=$(gh pr checks "${pr_number}" 2>/dev/null | grep -ci 'fail' || true)
215
- [ "${FAILED_CHECKS}" -gt 0 ] && continue
213
+ # Check CI status - must have ALL checks passing (not just "no failures")
214
+ # gh pr checks exits 0 if all pass, 8 if pending, non-zero otherwise
215
+ if ! gh pr checks "${pr_number}" --required >/dev/null 2>&1; then
216
+ log "AUTO-MERGE: PR #${pr_number} has pending or failed CI checks"
217
+ continue
218
+ fi
216
219
 
217
220
  # Check review score
218
221
  PR_COMMENTS=$(
@@ -474,9 +477,10 @@ if [ "${AUTO_MERGE}" = "1" ] && [ ${EXIT_CODE} -eq 0 ]; then
474
477
  continue
475
478
  fi
476
479
 
477
- # Check CI status - must have no failures
478
- FAILED_CHECKS=$(gh pr checks "${pr_number}" 2>/dev/null | grep -ci 'fail' || true)
479
- if [ "${FAILED_CHECKS}" -gt 0 ]; then
480
+ # Check CI status - must have ALL checks passing (not just "no failures")
481
+ # gh pr checks exits 0 if all pass, 8 if pending, non-zero otherwise
482
+ if ! gh pr checks "${pr_number}" --required >/dev/null 2>&1; then
483
+ log "AUTO-MERGE: PR #${pr_number} has pending or failed CI checks"
480
484
  continue
481
485
  fi
482
486
 
@@ -105,22 +105,30 @@ A PR needs attention if **any** of the following: merge conflicts present, revie
105
105
  - Push the clean branch: `git push --force-with-lease origin <branch-name>`
106
106
  - **Do NOT leave any conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) in any file.**
107
107
 
108
- d. **Address CI failures** (if any):
109
- - Read the failed job logs carefully to understand the root cause.
110
- - **typecheck failures**: Fix TypeScript type errors.
111
- - **lint failures**: Fix ESLint violations.
112
- - **test failures**: Fix broken tests or update tests to match code changes.
113
- - **build failures**: Fix compilation/bundling errors.
114
- - **verify failures**: This runs after all others -- usually means one of the above needs fixing.
115
-
116
- e. **Address review feedback** (if score < 80):
108
+ d. **Address review feedback** (if score < 80):
117
109
  - Read the review comments carefully. Extract areas for improvement, bugs found, issues found, and specific file/line suggestions.
110
+ - For each review suggestion:
111
+ - If you agree, implement the change.
112
+ - If you do not agree, do not implement it blindly. Capture a short technical reason and include that reason in the PR comment.
118
113
  - Fix bugs identified.
119
114
  - Improve error handling if flagged.
120
115
  - Add missing tests if coverage was noted.
121
116
  - Refactor code if structure was criticized.
122
117
  - Follow all project conventions from AI assistant documentation files (e.g., CLAUDE.md, AGENTS.md, or similar).
123
118
 
119
+ e. **Address CI failures** (if any):
120
+ - Check CI status and identify non-passing checks:
121
+ ```
122
+ gh pr checks <number> --json name,state,conclusion
123
+ ```
124
+ - Read the failed job logs carefully to understand the root cause.
125
+ - **typecheck failures**: Fix TypeScript type errors.
126
+ - **lint failures**: Fix ESLint violations.
127
+ - **test failures**: Fix broken tests or update tests to match code changes.
128
+ - **build failures**: Fix compilation/bundling errors.
129
+ - **verify failures**: This runs after all others -- usually means one of the above needs fixing.
130
+ - Re-run local equivalents of the failing jobs before pushing to confirm the CI issues are fixed.
131
+
124
132
  f. **Run verification**: Run the project's test/lint commands (e.g., `npm test`, `npm run lint`, `npm run verify` or equivalent). Fix until it passes.
125
133
 
126
134
  g. **Commit and push** the fixes (only if there are staged changes beyond the rebase):
@@ -157,6 +165,9 @@ A PR needs attention if **any** of the following: merge conflicts present, revie
157
165
  - <fix 1>
158
166
  - <fix 2>
159
167
 
168
+ <If any review suggestions were not applied>### Review Feedback Not Applied:
169
+ - <suggestion>: <short technical reason><end>
170
+
160
171
  <If CI was fixed>### CI Failures Fixed:
161
172
  - <job>: <what was wrong and how it was fixed><end>
162
173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jonit-dev/night-watch-cli",
3
- "version": "1.7.43",
3
+ "version": "1.7.46",
4
4
  "description": "Autonomous PRD execution using AI Provider CLIs + cron",
5
5
  "type": "module",
6
6
  "bin": {