@jonit-dev/night-watch-cli 1.7.10 → 1.7.11

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 (315) hide show
  1. package/LICENSE +1 -1
  2. package/dist/commands/dashboard/tab-config.d.ts.map +1 -1
  3. package/dist/commands/dashboard/tab-config.js +8 -1
  4. package/dist/commands/dashboard/tab-config.js.map +1 -1
  5. package/dist/commands/doctor.d.ts.map +1 -1
  6. package/dist/commands/doctor.js +3 -0
  7. package/dist/commands/doctor.js.map +1 -1
  8. package/dist/commands/review.d.ts +4 -0
  9. package/dist/commands/review.d.ts.map +1 -1
  10. package/dist/commands/review.js +30 -0
  11. package/dist/commands/review.js.map +1 -1
  12. package/dist/commands/run.d.ts +11 -0
  13. package/dist/commands/run.d.ts.map +1 -1
  14. package/dist/commands/run.js +47 -7
  15. package/dist/commands/run.js.map +1 -1
  16. package/dist/server/index.d.ts.map +1 -1
  17. package/dist/server/index.js +43 -3
  18. package/dist/server/index.js.map +1 -1
  19. package/dist/shared/types.d.ts +223 -0
  20. package/dist/shared/types.d.ts.map +1 -0
  21. package/dist/shared/types.js +7 -0
  22. package/dist/shared/types.js.map +1 -0
  23. package/dist/src/agents/soul-compiler.d.ts +11 -0
  24. package/dist/src/agents/soul-compiler.d.ts.map +1 -0
  25. package/dist/src/agents/soul-compiler.js +103 -0
  26. package/dist/src/agents/soul-compiler.js.map +1 -0
  27. package/dist/src/board/factory.d.ts +3 -0
  28. package/dist/src/board/factory.d.ts.map +1 -0
  29. package/dist/src/board/factory.js +10 -0
  30. package/dist/src/board/factory.js.map +1 -0
  31. package/dist/src/board/providers/github-graphql.d.ts +16 -0
  32. package/dist/src/board/providers/github-graphql.d.ts.map +1 -0
  33. package/dist/src/board/providers/github-graphql.js +43 -0
  34. package/dist/src/board/providers/github-graphql.js.map +1 -0
  35. package/dist/src/board/providers/github-projects.d.ts +51 -0
  36. package/dist/src/board/providers/github-projects.d.ts.map +1 -0
  37. package/dist/src/board/providers/github-projects.js +672 -0
  38. package/dist/src/board/providers/github-projects.js.map +1 -0
  39. package/dist/src/board/types.d.ts +60 -0
  40. package/dist/src/board/types.d.ts.map +1 -0
  41. package/dist/src/board/types.js +4 -0
  42. package/dist/src/board/types.js.map +1 -0
  43. package/dist/src/cli.d.ts +3 -0
  44. package/dist/src/cli.d.ts.map +1 -0
  45. package/dist/src/cli.js +80 -0
  46. package/dist/src/cli.js.map +1 -0
  47. package/dist/src/commands/board.d.ts +9 -0
  48. package/dist/src/commands/board.d.ts.map +1 -0
  49. package/dist/src/commands/board.js +294 -0
  50. package/dist/src/commands/board.js.map +1 -0
  51. package/dist/src/commands/cancel.d.ts +46 -0
  52. package/dist/src/commands/cancel.d.ts.map +1 -0
  53. package/dist/src/commands/cancel.js +241 -0
  54. package/dist/src/commands/cancel.js.map +1 -0
  55. package/dist/src/commands/dashboard/tab-actions.d.ts +10 -0
  56. package/dist/src/commands/dashboard/tab-actions.d.ts.map +1 -0
  57. package/dist/src/commands/dashboard/tab-actions.js +245 -0
  58. package/dist/src/commands/dashboard/tab-actions.js.map +1 -0
  59. package/dist/src/commands/dashboard/tab-config.d.ts +21 -0
  60. package/dist/src/commands/dashboard/tab-config.d.ts.map +1 -0
  61. package/dist/src/commands/dashboard/tab-config.js +829 -0
  62. package/dist/src/commands/dashboard/tab-config.js.map +1 -0
  63. package/dist/src/commands/dashboard/tab-logs.d.ts +10 -0
  64. package/dist/src/commands/dashboard/tab-logs.d.ts.map +1 -0
  65. package/dist/src/commands/dashboard/tab-logs.js +178 -0
  66. package/dist/src/commands/dashboard/tab-logs.js.map +1 -0
  67. package/dist/src/commands/dashboard/tab-schedules.d.ts +21 -0
  68. package/dist/src/commands/dashboard/tab-schedules.d.ts.map +1 -0
  69. package/dist/src/commands/dashboard/tab-schedules.js +304 -0
  70. package/dist/src/commands/dashboard/tab-schedules.js.map +1 -0
  71. package/dist/src/commands/dashboard/tab-status.d.ts +32 -0
  72. package/dist/src/commands/dashboard/tab-status.d.ts.map +1 -0
  73. package/dist/src/commands/dashboard/tab-status.js +421 -0
  74. package/dist/src/commands/dashboard/tab-status.js.map +1 -0
  75. package/dist/src/commands/dashboard/types.d.ts +43 -0
  76. package/dist/src/commands/dashboard/types.d.ts.map +1 -0
  77. package/dist/src/commands/dashboard/types.js +5 -0
  78. package/dist/src/commands/dashboard/types.js.map +1 -0
  79. package/dist/src/commands/dashboard.d.ts +11 -0
  80. package/dist/src/commands/dashboard.d.ts.map +1 -0
  81. package/dist/src/commands/dashboard.js +239 -0
  82. package/dist/src/commands/dashboard.js.map +1 -0
  83. package/dist/src/commands/doctor.d.ts +16 -0
  84. package/dist/src/commands/doctor.d.ts.map +1 -0
  85. package/dist/src/commands/doctor.js +202 -0
  86. package/dist/src/commands/doctor.js.map +1 -0
  87. package/dist/src/commands/history.d.ts +7 -0
  88. package/dist/src/commands/history.d.ts.map +1 -0
  89. package/dist/src/commands/history.js +56 -0
  90. package/dist/src/commands/history.js.map +1 -0
  91. package/dist/src/commands/init.d.ts +25 -0
  92. package/dist/src/commands/init.d.ts.map +1 -0
  93. package/dist/src/commands/init.js +543 -0
  94. package/dist/src/commands/init.js.map +1 -0
  95. package/dist/src/commands/install.d.ts +48 -0
  96. package/dist/src/commands/install.d.ts.map +1 -0
  97. package/dist/src/commands/install.js +303 -0
  98. package/dist/src/commands/install.js.map +1 -0
  99. package/dist/src/commands/logs.d.ts +15 -0
  100. package/dist/src/commands/logs.d.ts.map +1 -0
  101. package/dist/src/commands/logs.js +104 -0
  102. package/dist/src/commands/logs.js.map +1 -0
  103. package/dist/src/commands/prd-state.d.ts +12 -0
  104. package/dist/src/commands/prd-state.d.ts.map +1 -0
  105. package/dist/src/commands/prd-state.js +47 -0
  106. package/dist/src/commands/prd-state.js.map +1 -0
  107. package/dist/src/commands/prd.d.ts +24 -0
  108. package/dist/src/commands/prd.d.ts.map +1 -0
  109. package/dist/src/commands/prd.js +283 -0
  110. package/dist/src/commands/prd.js.map +1 -0
  111. package/dist/src/commands/prds.d.ts +13 -0
  112. package/dist/src/commands/prds.d.ts.map +1 -0
  113. package/dist/src/commands/prds.js +196 -0
  114. package/dist/src/commands/prds.js.map +1 -0
  115. package/dist/src/commands/prs.d.ts +14 -0
  116. package/dist/src/commands/prs.d.ts.map +1 -0
  117. package/dist/src/commands/prs.js +106 -0
  118. package/dist/src/commands/prs.js.map +1 -0
  119. package/dist/src/commands/qa.d.ts +30 -0
  120. package/dist/src/commands/qa.d.ts.map +1 -0
  121. package/dist/src/commands/qa.js +159 -0
  122. package/dist/src/commands/qa.js.map +1 -0
  123. package/dist/src/commands/retry.d.ts +9 -0
  124. package/dist/src/commands/retry.d.ts.map +1 -0
  125. package/dist/src/commands/retry.js +72 -0
  126. package/dist/src/commands/retry.js.map +1 -0
  127. package/dist/src/commands/review.d.ts +35 -0
  128. package/dist/src/commands/review.d.ts.map +1 -0
  129. package/dist/src/commands/review.js +252 -0
  130. package/dist/src/commands/review.js.map +1 -0
  131. package/dist/src/commands/run.d.ts +61 -0
  132. package/dist/src/commands/run.d.ts.map +1 -0
  133. package/dist/src/commands/run.js +364 -0
  134. package/dist/src/commands/run.js.map +1 -0
  135. package/dist/src/commands/serve.d.ts +7 -0
  136. package/dist/src/commands/serve.d.ts.map +1 -0
  137. package/dist/src/commands/serve.js +27 -0
  138. package/dist/src/commands/serve.js.map +1 -0
  139. package/dist/src/commands/slice.d.ts +26 -0
  140. package/dist/src/commands/slice.d.ts.map +1 -0
  141. package/dist/src/commands/slice.js +175 -0
  142. package/dist/src/commands/slice.js.map +1 -0
  143. package/dist/src/commands/state.d.ts +8 -0
  144. package/dist/src/commands/state.d.ts.map +1 -0
  145. package/dist/src/commands/state.js +56 -0
  146. package/dist/src/commands/state.js.map +1 -0
  147. package/dist/src/commands/status.d.ts +14 -0
  148. package/dist/src/commands/status.d.ts.map +1 -0
  149. package/dist/src/commands/status.js +147 -0
  150. package/dist/src/commands/status.js.map +1 -0
  151. package/dist/src/commands/uninstall.d.ts +25 -0
  152. package/dist/src/commands/uninstall.d.ts.map +1 -0
  153. package/dist/src/commands/uninstall.js +141 -0
  154. package/dist/src/commands/uninstall.js.map +1 -0
  155. package/dist/src/commands/update.d.ts +21 -0
  156. package/dist/src/commands/update.d.ts.map +1 -0
  157. package/dist/src/commands/update.js +87 -0
  158. package/dist/src/commands/update.js.map +1 -0
  159. package/dist/src/config.d.ts +23 -0
  160. package/dist/src/config.d.ts.map +1 -0
  161. package/dist/src/config.js +629 -0
  162. package/dist/src/config.js.map +1 -0
  163. package/dist/src/constants.d.ts +60 -0
  164. package/dist/src/constants.d.ts.map +1 -0
  165. package/dist/src/constants.js +118 -0
  166. package/dist/src/constants.js.map +1 -0
  167. package/dist/src/server/index.d.ts +23 -0
  168. package/dist/src/server/index.d.ts.map +1 -0
  169. package/dist/src/server/index.js +1642 -0
  170. package/dist/src/server/index.js.map +1 -0
  171. package/dist/src/slack/channel-manager.d.ts +32 -0
  172. package/dist/src/slack/channel-manager.d.ts.map +1 -0
  173. package/dist/src/slack/channel-manager.js +128 -0
  174. package/dist/src/slack/channel-manager.js.map +1 -0
  175. package/dist/src/slack/client.d.ts +63 -0
  176. package/dist/src/slack/client.d.ts.map +1 -0
  177. package/dist/src/slack/client.js +151 -0
  178. package/dist/src/slack/client.js.map +1 -0
  179. package/dist/src/slack/deliberation.d.ts +45 -0
  180. package/dist/src/slack/deliberation.d.ts.map +1 -0
  181. package/dist/src/slack/deliberation.js +539 -0
  182. package/dist/src/slack/deliberation.js.map +1 -0
  183. package/dist/src/slack/index.d.ts +6 -0
  184. package/dist/src/slack/index.d.ts.map +1 -0
  185. package/dist/src/slack/index.js +5 -0
  186. package/dist/src/slack/index.js.map +1 -0
  187. package/dist/src/slack/interaction-listener.d.ts +47 -0
  188. package/dist/src/slack/interaction-listener.d.ts.map +1 -0
  189. package/dist/src/slack/interaction-listener.js +216 -0
  190. package/dist/src/slack/interaction-listener.js.map +1 -0
  191. package/dist/src/storage/json-state-migrator.d.ts +24 -0
  192. package/dist/src/storage/json-state-migrator.d.ts.map +1 -0
  193. package/dist/src/storage/json-state-migrator.js +197 -0
  194. package/dist/src/storage/json-state-migrator.js.map +1 -0
  195. package/dist/src/storage/repositories/index.d.ts +25 -0
  196. package/dist/src/storage/repositories/index.d.ts.map +1 -0
  197. package/dist/src/storage/repositories/index.js +43 -0
  198. package/dist/src/storage/repositories/index.js.map +1 -0
  199. package/dist/src/storage/repositories/interfaces.d.ts +59 -0
  200. package/dist/src/storage/repositories/interfaces.d.ts.map +1 -0
  201. package/dist/src/storage/repositories/interfaces.js +6 -0
  202. package/dist/src/storage/repositories/interfaces.js.map +1 -0
  203. package/dist/src/storage/repositories/sqlite/agent-persona-repository.d.ts +27 -0
  204. package/dist/src/storage/repositories/sqlite/agent-persona-repository.d.ts.map +1 -0
  205. package/dist/src/storage/repositories/sqlite/agent-persona-repository.js +569 -0
  206. package/dist/src/storage/repositories/sqlite/agent-persona-repository.js.map +1 -0
  207. package/dist/src/storage/repositories/sqlite/execution-history-repository.d.ts +21 -0
  208. package/dist/src/storage/repositories/sqlite/execution-history-repository.d.ts.map +1 -0
  209. package/dist/src/storage/repositories/sqlite/execution-history-repository.js +94 -0
  210. package/dist/src/storage/repositories/sqlite/execution-history-repository.js.map +1 -0
  211. package/dist/src/storage/repositories/sqlite/prd-state-repository.d.ts +17 -0
  212. package/dist/src/storage/repositories/sqlite/prd-state-repository.d.ts.map +1 -0
  213. package/dist/src/storage/repositories/sqlite/prd-state-repository.js +74 -0
  214. package/dist/src/storage/repositories/sqlite/prd-state-repository.js.map +1 -0
  215. package/dist/src/storage/repositories/sqlite/project-registry-repository.d.ts +17 -0
  216. package/dist/src/storage/repositories/sqlite/project-registry-repository.d.ts.map +1 -0
  217. package/dist/src/storage/repositories/sqlite/project-registry-repository.js +43 -0
  218. package/dist/src/storage/repositories/sqlite/project-registry-repository.js.map +1 -0
  219. package/dist/src/storage/repositories/sqlite/roadmap-state-repository.d.ts +14 -0
  220. package/dist/src/storage/repositories/sqlite/roadmap-state-repository.d.ts.map +1 -0
  221. package/dist/src/storage/repositories/sqlite/roadmap-state-repository.js +47 -0
  222. package/dist/src/storage/repositories/sqlite/roadmap-state-repository.js.map +1 -0
  223. package/dist/src/storage/repositories/sqlite/slack-discussion-repository.d.ts +20 -0
  224. package/dist/src/storage/repositories/sqlite/slack-discussion-repository.d.ts.map +1 -0
  225. package/dist/src/storage/repositories/sqlite/slack-discussion-repository.js +88 -0
  226. package/dist/src/storage/repositories/sqlite/slack-discussion-repository.js.map +1 -0
  227. package/dist/src/storage/sqlite/client.d.ts +23 -0
  228. package/dist/src/storage/sqlite/client.d.ts.map +1 -0
  229. package/dist/src/storage/sqlite/client.js +47 -0
  230. package/dist/src/storage/sqlite/client.js.map +1 -0
  231. package/dist/src/storage/sqlite/migrations.d.ts +11 -0
  232. package/dist/src/storage/sqlite/migrations.d.ts.map +1 -0
  233. package/dist/src/storage/sqlite/migrations.js +94 -0
  234. package/dist/src/storage/sqlite/migrations.js.map +1 -0
  235. package/dist/src/templates/prd-template.d.ts +11 -0
  236. package/dist/src/templates/prd-template.d.ts.map +1 -0
  237. package/dist/src/templates/prd-template.js +166 -0
  238. package/dist/src/templates/prd-template.js.map +1 -0
  239. package/dist/src/templates/slicer-prompt.d.ts +54 -0
  240. package/dist/src/templates/slicer-prompt.d.ts.map +1 -0
  241. package/dist/src/templates/slicer-prompt.js +163 -0
  242. package/dist/src/templates/slicer-prompt.js.map +1 -0
  243. package/dist/src/types.d.ts +127 -0
  244. package/dist/src/types.d.ts.map +1 -0
  245. package/dist/src/types.js +5 -0
  246. package/dist/src/types.js.map +1 -0
  247. package/dist/src/utils/checks.d.ts +55 -0
  248. package/dist/src/utils/checks.d.ts.map +1 -0
  249. package/dist/src/utils/checks.js +246 -0
  250. package/dist/src/utils/checks.js.map +1 -0
  251. package/dist/src/utils/config-writer.d.ts +16 -0
  252. package/dist/src/utils/config-writer.d.ts.map +1 -0
  253. package/dist/src/utils/config-writer.js +45 -0
  254. package/dist/src/utils/config-writer.js.map +1 -0
  255. package/dist/src/utils/crontab.d.ts +62 -0
  256. package/dist/src/utils/crontab.d.ts.map +1 -0
  257. package/dist/src/utils/crontab.js +168 -0
  258. package/dist/src/utils/crontab.js.map +1 -0
  259. package/dist/src/utils/execution-history.d.ts +54 -0
  260. package/dist/src/utils/execution-history.d.ts.map +1 -0
  261. package/dist/src/utils/execution-history.js +80 -0
  262. package/dist/src/utils/execution-history.js.map +1 -0
  263. package/dist/src/utils/github.d.ts +40 -0
  264. package/dist/src/utils/github.d.ts.map +1 -0
  265. package/dist/src/utils/github.js +126 -0
  266. package/dist/src/utils/github.js.map +1 -0
  267. package/dist/src/utils/notify.d.ts +63 -0
  268. package/dist/src/utils/notify.d.ts.map +1 -0
  269. package/dist/src/utils/notify.js +389 -0
  270. package/dist/src/utils/notify.js.map +1 -0
  271. package/dist/src/utils/prd-states.d.ts +16 -0
  272. package/dist/src/utils/prd-states.d.ts.map +1 -0
  273. package/dist/src/utils/prd-states.js +28 -0
  274. package/dist/src/utils/prd-states.js.map +1 -0
  275. package/dist/src/utils/registry.d.ts +45 -0
  276. package/dist/src/utils/registry.d.ts.map +1 -0
  277. package/dist/src/utils/registry.js +86 -0
  278. package/dist/src/utils/registry.js.map +1 -0
  279. package/dist/src/utils/roadmap-parser.d.ts +45 -0
  280. package/dist/src/utils/roadmap-parser.d.ts.map +1 -0
  281. package/dist/src/utils/roadmap-parser.js +136 -0
  282. package/dist/src/utils/roadmap-parser.js.map +1 -0
  283. package/dist/src/utils/roadmap-scanner.d.ts +92 -0
  284. package/dist/src/utils/roadmap-scanner.d.ts.map +1 -0
  285. package/dist/src/utils/roadmap-scanner.js +349 -0
  286. package/dist/src/utils/roadmap-scanner.js.map +1 -0
  287. package/dist/src/utils/roadmap-state.d.ts +90 -0
  288. package/dist/src/utils/roadmap-state.d.ts.map +1 -0
  289. package/dist/src/utils/roadmap-state.js +154 -0
  290. package/dist/src/utils/roadmap-state.js.map +1 -0
  291. package/dist/src/utils/script-result.d.ts +12 -0
  292. package/dist/src/utils/script-result.d.ts.map +1 -0
  293. package/dist/src/utils/script-result.js +46 -0
  294. package/dist/src/utils/script-result.js.map +1 -0
  295. package/dist/src/utils/shell.d.ts +27 -0
  296. package/dist/src/utils/shell.d.ts.map +1 -0
  297. package/dist/src/utils/shell.js +64 -0
  298. package/dist/src/utils/shell.js.map +1 -0
  299. package/dist/src/utils/status-data.d.ts +148 -0
  300. package/dist/src/utils/status-data.d.ts.map +1 -0
  301. package/dist/src/utils/status-data.js +593 -0
  302. package/dist/src/utils/status-data.js.map +1 -0
  303. package/dist/src/utils/ui.d.ts +55 -0
  304. package/dist/src/utils/ui.d.ts.map +1 -0
  305. package/dist/src/utils/ui.js +121 -0
  306. package/dist/src/utils/ui.js.map +1 -0
  307. package/package.json +3 -1
  308. package/scripts/night-watch-cron.sh +7 -0
  309. package/scripts/night-watch-helpers.sh +33 -4
  310. package/scripts/night-watch-pr-reviewer-cron.sh +11 -3
  311. package/web/dist/assets/index-BtxQU4oX.css +1 -0
  312. package/web/dist/assets/index-CsNIryJz.js +473 -0
  313. package/web/dist/index.html +2 -2
  314. package/web/dist/assets/index-BPW-7_1C.js +0 -380
  315. package/web/dist/assets/index-DVqjjJEO.css +0 -1
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Execution history ledger for Night Watch CLI
3
+ * Stores PRD execution records in the SQLite repository layer.
4
+ * Decoupled from PRD file paths — keyed by project directory + PRD filename.
5
+ */
6
+ import { resetRepositories } from "../storage/repositories/index.js";
7
+ import { closeDb } from "../storage/sqlite/client.js";
8
+ export type ExecutionOutcome = "success" | "failure" | "timeout" | "rate_limited";
9
+ export interface IExecutionRecord {
10
+ timestamp: number;
11
+ outcome: ExecutionOutcome;
12
+ exitCode: number;
13
+ attempt: number;
14
+ }
15
+ interface IPrdHistory {
16
+ records: IExecutionRecord[];
17
+ }
18
+ /**
19
+ * Full history structure: projectDir -> prdFile -> records
20
+ */
21
+ export type IExecutionHistory = Record<string, Record<string, IPrdHistory>>;
22
+ /**
23
+ * Get the path to the history file.
24
+ * Kept for backward compatibility.
25
+ */
26
+ export declare function getHistoryPath(): string;
27
+ /**
28
+ * Load execution history from the SQLite repository.
29
+ * Returns the full IExecutionHistory structure reconstructed from the DB.
30
+ */
31
+ export declare function loadHistory(): IExecutionHistory;
32
+ /**
33
+ * Save execution history to the repository.
34
+ * Full replace: clears all existing records then inserts all records from the
35
+ * provided IExecutionHistory structure in a single transaction.
36
+ */
37
+ export declare function saveHistory(history: IExecutionHistory): void;
38
+ /**
39
+ * Record a PRD execution result.
40
+ * Appends a record and trims to MAX_HISTORY_RECORDS_PER_PRD.
41
+ */
42
+ export declare function recordExecution(projectDir: string, prdFile: string, outcome: ExecutionOutcome, exitCode: number, attempt?: number): void;
43
+ /**
44
+ * Get the most recent execution record for a PRD.
45
+ * Returns null if no history exists.
46
+ */
47
+ export declare function getLastExecution(projectDir: string, prdFile: string): IExecutionRecord | null;
48
+ /**
49
+ * Check if a PRD is in cooldown after a recent non-success execution.
50
+ * Returns true if the PRD should be skipped.
51
+ */
52
+ export declare function isInCooldown(projectDir: string, prdFile: string, cooldownPeriod: number): boolean;
53
+ export { closeDb, resetRepositories };
54
+ //# sourceMappingURL=execution-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-history.d.ts","sourceRoot":"","sources":["../../../src/utils/execution-history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAmB,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;AAElF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,WAAW;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAG/C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAG5D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAU,GAClB,IAAI,CAaN;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,gBAAgB,GAAG,IAAI,CAKzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GACrB,OAAO,CAYT;AAED,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Execution history ledger for Night Watch CLI
3
+ * Stores PRD execution records in the SQLite repository layer.
4
+ * Decoupled from PRD file paths — keyed by project directory + PRD filename.
5
+ */
6
+ import * as os from "os";
7
+ import * as path from "path";
8
+ import { GLOBAL_CONFIG_DIR, HISTORY_FILE_NAME, MAX_HISTORY_RECORDS_PER_PRD, } from "../constants.js";
9
+ import { getRepositories, resetRepositories } from "../storage/repositories/index.js";
10
+ import { closeDb } from "../storage/sqlite/client.js";
11
+ /**
12
+ * Get the path to the history file.
13
+ * Kept for backward compatibility.
14
+ */
15
+ export function getHistoryPath() {
16
+ const base = process.env.NIGHT_WATCH_HOME || path.join(os.homedir(), GLOBAL_CONFIG_DIR);
17
+ return path.join(base, HISTORY_FILE_NAME);
18
+ }
19
+ /**
20
+ * Load execution history from the SQLite repository.
21
+ * Returns the full IExecutionHistory structure reconstructed from the DB.
22
+ */
23
+ export function loadHistory() {
24
+ const { executionHistory } = getRepositories();
25
+ return executionHistory.getAllHistory();
26
+ }
27
+ /**
28
+ * Save execution history to the repository.
29
+ * Full replace: clears all existing records then inserts all records from the
30
+ * provided IExecutionHistory structure in a single transaction.
31
+ */
32
+ export function saveHistory(history) {
33
+ const { executionHistory } = getRepositories();
34
+ executionHistory.replaceAll(history);
35
+ }
36
+ /**
37
+ * Record a PRD execution result.
38
+ * Appends a record and trims to MAX_HISTORY_RECORDS_PER_PRD.
39
+ */
40
+ export function recordExecution(projectDir, prdFile, outcome, exitCode, attempt = 1) {
41
+ const resolved = path.resolve(projectDir);
42
+ const { executionHistory } = getRepositories();
43
+ const record = {
44
+ timestamp: Math.floor(Date.now() / 1000),
45
+ outcome,
46
+ exitCode,
47
+ attempt,
48
+ };
49
+ executionHistory.addRecord(resolved, prdFile, record);
50
+ executionHistory.trimRecords(resolved, prdFile, MAX_HISTORY_RECORDS_PER_PRD);
51
+ }
52
+ /**
53
+ * Get the most recent execution record for a PRD.
54
+ * Returns null if no history exists.
55
+ */
56
+ export function getLastExecution(projectDir, prdFile) {
57
+ const resolved = path.resolve(projectDir);
58
+ const { executionHistory } = getRepositories();
59
+ const records = executionHistory.getRecords(resolved, prdFile);
60
+ return records.length > 0 ? records[0] : null;
61
+ }
62
+ /**
63
+ * Check if a PRD is in cooldown after a recent non-success execution.
64
+ * Returns true if the PRD should be skipped.
65
+ */
66
+ export function isInCooldown(projectDir, prdFile, cooldownPeriod) {
67
+ const last = getLastExecution(projectDir, prdFile);
68
+ if (!last) {
69
+ return false;
70
+ }
71
+ // Success records don't trigger cooldown
72
+ if (last.outcome === "success") {
73
+ return false;
74
+ }
75
+ const now = Math.floor(Date.now() / 1000);
76
+ const age = now - last.timestamp;
77
+ return age < cooldownPeriod;
78
+ }
79
+ export { closeDb, resetRepositories };
80
+ //# sourceMappingURL=execution-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-history.js","sourceRoot":"","sources":["../../../src/utils/execution-history.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAoBtD;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,IAAI,GACR,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,EAAE,gBAAgB,EAAE,GAAG,eAAe,EAAE,CAAC;IAC/C,OAAO,gBAAgB,CAAC,aAAa,EAAE,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAA0B;IACpD,MAAM,EAAE,gBAAgB,EAAE,GAAG,eAAe,EAAE,CAAC;IAC/C,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAkB,EAClB,OAAe,EACf,OAAyB,EACzB,QAAgB,EAChB,UAAkB,CAAC;IAEnB,MAAM,QAAQ,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CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,OAAO,GAAG,GAAG,cAAc,CAAC;AAC9B,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * GitHub utilities for Night Watch CLI
3
+ * Fetches PR details using the gh CLI
4
+ */
5
+ export interface IPrDetails {
6
+ number: number;
7
+ title: string;
8
+ url: string;
9
+ body: string;
10
+ additions: number;
11
+ deletions: number;
12
+ changedFiles: number;
13
+ }
14
+ /**
15
+ * Fetch PR details by exact branch name selector.
16
+ * Returns null on any failure.
17
+ */
18
+ export declare function fetchPrDetailsForBranch(branchName: string, cwd: string): IPrDetails | null;
19
+ /**
20
+ * Fetch PR details by PR number selector.
21
+ * Returns null on any failure.
22
+ */
23
+ export declare function fetchPrDetailsByNumber(prNumber: number, cwd: string): IPrDetails | null;
24
+ /**
25
+ * Fetch PR details for the most recently created PR matching a branch prefix.
26
+ * Returns null if gh is unavailable, not authenticated, or no PR found.
27
+ */
28
+ export declare function fetchPrDetails(branchPrefix: string, cwd: string): IPrDetails | null;
29
+ /**
30
+ * Fetch PR details for the most recently updated PR matching any of the given branch patterns.
31
+ * Used by the review command to find the PR that was just reviewed.
32
+ * Returns null on any failure.
33
+ */
34
+ export declare function fetchReviewedPrDetails(branchPatterns: string[], cwd: string): IPrDetails | null;
35
+ /**
36
+ * Extract a summary from a PR body.
37
+ * Takes the first meaningful paragraph, strips markdown headers, truncates to maxLength.
38
+ */
39
+ export declare function extractSummary(body: string, maxLength?: number): string;
40
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/utils/github.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAmCD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAE1F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEvF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAyBnF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAyB/F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,CAgC5E"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * GitHub utilities for Night Watch CLI
3
+ * Fetches PR details using the gh CLI
4
+ */
5
+ import { execFileSync } from "child_process";
6
+ function parsePrDetails(raw) {
7
+ try {
8
+ const details = JSON.parse(raw);
9
+ if (typeof details.number !== "number") {
10
+ return null;
11
+ }
12
+ return {
13
+ number: details.number,
14
+ title: details.title ?? "",
15
+ url: details.url ?? "",
16
+ body: details.body ?? "",
17
+ additions: details.additions ?? 0,
18
+ deletions: details.deletions ?? 0,
19
+ changedFiles: details.changedFiles ?? 0,
20
+ };
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ function fetchPrBySelector(selector, cwd) {
27
+ try {
28
+ const output = execFileSync("gh", ["pr", "view", selector, "--json", "number,title,url,body,additions,deletions,changedFiles"], { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
29
+ return parsePrDetails(output);
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ /**
36
+ * Fetch PR details by exact branch name selector.
37
+ * Returns null on any failure.
38
+ */
39
+ export function fetchPrDetailsForBranch(branchName, cwd) {
40
+ return fetchPrBySelector(branchName, cwd);
41
+ }
42
+ /**
43
+ * Fetch PR details by PR number selector.
44
+ * Returns null on any failure.
45
+ */
46
+ export function fetchPrDetailsByNumber(prNumber, cwd) {
47
+ return fetchPrBySelector(String(prNumber), cwd);
48
+ }
49
+ /**
50
+ * Fetch PR details for the most recently created PR matching a branch prefix.
51
+ * Returns null if gh is unavailable, not authenticated, or no PR found.
52
+ */
53
+ export function fetchPrDetails(branchPrefix, cwd) {
54
+ try {
55
+ // Find the most recently created open PR on a matching branch
56
+ const listOutput = execFileSync("gh", ["pr", "list", "--state", "open", "--json", "number,headRefName", "--limit", "20"], { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
57
+ const prs = JSON.parse(listOutput);
58
+ // Filter PRs matching the branch prefix
59
+ const matching = prs.filter((pr) => pr.headRefName.startsWith(branchPrefix + "/"));
60
+ if (matching.length === 0) {
61
+ return null;
62
+ }
63
+ // Use the first match (most recent)
64
+ const prNumber = matching[0].number;
65
+ return fetchPrDetailsByNumber(prNumber, cwd);
66
+ }
67
+ catch {
68
+ // gh CLI not available, not authenticated, or command failed
69
+ return null;
70
+ }
71
+ }
72
+ /**
73
+ * Fetch PR details for the most recently updated PR matching any of the given branch patterns.
74
+ * Used by the review command to find the PR that was just reviewed.
75
+ * Returns null on any failure.
76
+ */
77
+ export function fetchReviewedPrDetails(branchPatterns, cwd) {
78
+ try {
79
+ const listOutput = execFileSync("gh", ["pr", "list", "--state", "open", "--json", "number,headRefName", "--limit", "20"], { cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
80
+ const prs = JSON.parse(listOutput);
81
+ // Filter PRs matching any branch pattern
82
+ const matching = prs.filter((pr) => branchPatterns.some((pattern) => pr.headRefName.startsWith(pattern)));
83
+ if (matching.length === 0) {
84
+ return null;
85
+ }
86
+ // Use the first match
87
+ const prNumber = matching[0].number;
88
+ return fetchPrDetailsByNumber(prNumber, cwd);
89
+ }
90
+ catch {
91
+ return null;
92
+ }
93
+ }
94
+ /**
95
+ * Extract a summary from a PR body.
96
+ * Takes the first meaningful paragraph, strips markdown headers, truncates to maxLength.
97
+ */
98
+ export function extractSummary(body, maxLength = 500) {
99
+ if (!body || body.trim().length === 0) {
100
+ return "";
101
+ }
102
+ // Split into lines and filter out markdown headers and empty lines
103
+ const lines = body.split("\n");
104
+ const contentLines = [];
105
+ for (const line of lines) {
106
+ const trimmed = line.trim();
107
+ // Skip empty lines, markdown headers, and horizontal rules
108
+ if (trimmed === "" || trimmed.startsWith("#") || trimmed === "---" || trimmed === "***") {
109
+ // If we already have content, a blank line means end of first paragraph
110
+ if (contentLines.length > 0 && trimmed === "") {
111
+ break;
112
+ }
113
+ continue;
114
+ }
115
+ contentLines.push(trimmed);
116
+ }
117
+ const summary = contentLines.join("\n");
118
+ if (summary.length <= maxLength) {
119
+ return summary;
120
+ }
121
+ // Truncate at word boundary
122
+ const truncated = summary.slice(0, maxLength);
123
+ const lastSpace = truncated.lastIndexOf(" ");
124
+ return (lastSpace > 0 ? truncated.slice(0, lastSpace) : truncated) + "...";
125
+ }
126
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/utils/github.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAY7C,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAwB,CAAC;QACvD,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,IAAI,C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R,CAAC;YACD,SAAS;QACX,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,OAAO,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,4BAA4B;IAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Notification utilities for Night Watch CLI
3
+ * Sends webhook notifications to Slack, Discord, and Telegram
4
+ */
5
+ import { INightWatchConfig, IWebhookConfig, NotificationEvent } from "../types.js";
6
+ export interface INotificationContext {
7
+ event: NotificationEvent;
8
+ projectName: string;
9
+ prdName?: string;
10
+ branchName?: string;
11
+ prNumber?: number;
12
+ exitCode: number;
13
+ duration?: number;
14
+ provider: string;
15
+ prUrl?: string;
16
+ prTitle?: string;
17
+ prBody?: string;
18
+ filesChanged?: number;
19
+ additions?: number;
20
+ deletions?: number;
21
+ }
22
+ /**
23
+ * Get the emoji for a notification event
24
+ */
25
+ export declare function getEventEmoji(event: NotificationEvent): string;
26
+ /**
27
+ * Get a human-readable title for a notification event
28
+ */
29
+ export declare function getEventTitle(event: NotificationEvent): string;
30
+ /**
31
+ * Get the Discord embed color for a notification event
32
+ */
33
+ export declare function getEventColor(event: NotificationEvent): number;
34
+ /**
35
+ * Build a description string from notification context
36
+ */
37
+ export declare function buildDescription(ctx: INotificationContext): string;
38
+ /**
39
+ * Format a notification payload for Slack incoming webhooks
40
+ */
41
+ export declare function formatSlackPayload(ctx: INotificationContext): object;
42
+ /**
43
+ * Format a notification payload for Discord webhooks
44
+ */
45
+ export declare function formatDiscordPayload(ctx: INotificationContext): object;
46
+ /**
47
+ * Build a structured Telegram message when PR details are available.
48
+ * Falls back to the basic format when they are not.
49
+ */
50
+ export declare function formatTelegramPayload(ctx: INotificationContext): {
51
+ text: string;
52
+ parse_mode: string;
53
+ };
54
+ /**
55
+ * Send a notification to a single webhook endpoint
56
+ * Silently catches errors — never throws
57
+ */
58
+ export declare function sendWebhook(webhook: IWebhookConfig, ctx: INotificationContext): Promise<void>;
59
+ /**
60
+ * Send notifications to all configured webhooks and (if configured) to Slack via Bot API.
61
+ */
62
+ export declare function sendNotifications(config: INightWatchConfig, ctx: INotificationContext): Promise<void>;
63
+ //# sourceMappingURL=notify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.d.ts","sourceRoot":"","sources":["../../../src/utils/notify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAmB,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQpG,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,iBAAiB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,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