@jonit-dev/night-watch-cli 1.7.18 → 1.7.20

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 (274) hide show
  1. package/bin/night-watch.mjs +1 -1
  2. package/dist/src/cli.js +13 -4
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/server/index.d.ts.map +1 -1
  5. package/dist/src/server/index.js +14 -22
  6. package/dist/src/server/index.js.map +1 -1
  7. package/dist/src/slack/client.d.ts +4 -0
  8. package/dist/src/slack/client.d.ts.map +1 -1
  9. package/dist/src/slack/client.js +6 -0
  10. package/dist/src/slack/client.js.map +1 -1
  11. package/dist/src/slack/interaction-listener.d.ts +2 -3
  12. package/dist/src/slack/interaction-listener.d.ts.map +1 -1
  13. package/dist/src/slack/interaction-listener.js +30 -14
  14. package/dist/src/slack/interaction-listener.js.map +1 -1
  15. package/dist/src/storage/repositories/sqlite/agent-persona-repository.js +1 -1
  16. package/dist/src/storage/repositories/sqlite/agent-persona-repository.js.map +1 -1
  17. package/package.json +1 -1
  18. package/web/dist/assets/index-DOzZY27d.js +473 -0
  19. package/web/dist/assets/index-w6Q6gxCS.css +1 -0
  20. package/web/dist/index.html +2 -2
  21. package/dist/board/factory.d.ts +0 -3
  22. package/dist/board/factory.d.ts.map +0 -1
  23. package/dist/board/factory.js +0 -10
  24. package/dist/board/factory.js.map +0 -1
  25. package/dist/board/providers/github-graphql.d.ts +0 -16
  26. package/dist/board/providers/github-graphql.d.ts.map +0 -1
  27. package/dist/board/providers/github-graphql.js +0 -43
  28. package/dist/board/providers/github-graphql.js.map +0 -1
  29. package/dist/board/providers/github-projects.d.ts +0 -51
  30. package/dist/board/providers/github-projects.d.ts.map +0 -1
  31. package/dist/board/providers/github-projects.js +0 -672
  32. package/dist/board/providers/github-projects.js.map +0 -1
  33. package/dist/board/types.d.ts +0 -60
  34. package/dist/board/types.d.ts.map +0 -1
  35. package/dist/board/types.js +0 -4
  36. package/dist/board/types.js.map +0 -1
  37. package/dist/cli.d.ts +0 -3
  38. package/dist/cli.d.ts.map +0 -1
  39. package/dist/cli.js +0 -80
  40. package/dist/cli.js.map +0 -1
  41. package/dist/commands/board.d.ts +0 -9
  42. package/dist/commands/board.d.ts.map +0 -1
  43. package/dist/commands/board.js +0 -294
  44. package/dist/commands/board.js.map +0 -1
  45. package/dist/commands/cancel.d.ts +0 -46
  46. package/dist/commands/cancel.d.ts.map +0 -1
  47. package/dist/commands/cancel.js +0 -241
  48. package/dist/commands/cancel.js.map +0 -1
  49. package/dist/commands/dashboard/tab-actions.d.ts +0 -10
  50. package/dist/commands/dashboard/tab-actions.d.ts.map +0 -1
  51. package/dist/commands/dashboard/tab-actions.js +0 -245
  52. package/dist/commands/dashboard/tab-actions.js.map +0 -1
  53. package/dist/commands/dashboard/tab-config.d.ts +0 -21
  54. package/dist/commands/dashboard/tab-config.d.ts.map +0 -1
  55. package/dist/commands/dashboard/tab-config.js +0 -829
  56. package/dist/commands/dashboard/tab-config.js.map +0 -1
  57. package/dist/commands/dashboard/tab-logs.d.ts +0 -10
  58. package/dist/commands/dashboard/tab-logs.d.ts.map +0 -1
  59. package/dist/commands/dashboard/tab-logs.js +0 -178
  60. package/dist/commands/dashboard/tab-logs.js.map +0 -1
  61. package/dist/commands/dashboard/tab-schedules.d.ts +0 -21
  62. package/dist/commands/dashboard/tab-schedules.d.ts.map +0 -1
  63. package/dist/commands/dashboard/tab-schedules.js +0 -304
  64. package/dist/commands/dashboard/tab-schedules.js.map +0 -1
  65. package/dist/commands/dashboard/tab-status.d.ts +0 -32
  66. package/dist/commands/dashboard/tab-status.d.ts.map +0 -1
  67. package/dist/commands/dashboard/tab-status.js +0 -421
  68. package/dist/commands/dashboard/tab-status.js.map +0 -1
  69. package/dist/commands/dashboard/types.d.ts +0 -43
  70. package/dist/commands/dashboard/types.d.ts.map +0 -1
  71. package/dist/commands/dashboard/types.js +0 -5
  72. package/dist/commands/dashboard/types.js.map +0 -1
  73. package/dist/commands/dashboard.d.ts +0 -11
  74. package/dist/commands/dashboard.d.ts.map +0 -1
  75. package/dist/commands/dashboard.js +0 -239
  76. package/dist/commands/dashboard.js.map +0 -1
  77. package/dist/commands/doctor.d.ts +0 -16
  78. package/dist/commands/doctor.d.ts.map +0 -1
  79. package/dist/commands/doctor.js +0 -202
  80. package/dist/commands/doctor.js.map +0 -1
  81. package/dist/commands/history.d.ts +0 -7
  82. package/dist/commands/history.d.ts.map +0 -1
  83. package/dist/commands/history.js +0 -56
  84. package/dist/commands/history.js.map +0 -1
  85. package/dist/commands/init.d.ts +0 -25
  86. package/dist/commands/init.d.ts.map +0 -1
  87. package/dist/commands/init.js +0 -534
  88. package/dist/commands/init.js.map +0 -1
  89. package/dist/commands/install.d.ts +0 -48
  90. package/dist/commands/install.d.ts.map +0 -1
  91. package/dist/commands/install.js +0 -303
  92. package/dist/commands/install.js.map +0 -1
  93. package/dist/commands/logs.d.ts +0 -15
  94. package/dist/commands/logs.d.ts.map +0 -1
  95. package/dist/commands/logs.js +0 -104
  96. package/dist/commands/logs.js.map +0 -1
  97. package/dist/commands/prd-state.d.ts +0 -12
  98. package/dist/commands/prd-state.d.ts.map +0 -1
  99. package/dist/commands/prd-state.js +0 -47
  100. package/dist/commands/prd-state.js.map +0 -1
  101. package/dist/commands/prd.d.ts +0 -24
  102. package/dist/commands/prd.d.ts.map +0 -1
  103. package/dist/commands/prd.js +0 -283
  104. package/dist/commands/prd.js.map +0 -1
  105. package/dist/commands/prds.d.ts +0 -13
  106. package/dist/commands/prds.d.ts.map +0 -1
  107. package/dist/commands/prds.js +0 -196
  108. package/dist/commands/prds.js.map +0 -1
  109. package/dist/commands/prs.d.ts +0 -14
  110. package/dist/commands/prs.d.ts.map +0 -1
  111. package/dist/commands/prs.js +0 -106
  112. package/dist/commands/prs.js.map +0 -1
  113. package/dist/commands/qa.d.ts +0 -30
  114. package/dist/commands/qa.d.ts.map +0 -1
  115. package/dist/commands/qa.js +0 -159
  116. package/dist/commands/qa.js.map +0 -1
  117. package/dist/commands/retry.d.ts +0 -9
  118. package/dist/commands/retry.d.ts.map +0 -1
  119. package/dist/commands/retry.js +0 -72
  120. package/dist/commands/retry.js.map +0 -1
  121. package/dist/commands/review.d.ts +0 -35
  122. package/dist/commands/review.d.ts.map +0 -1
  123. package/dist/commands/review.js +0 -252
  124. package/dist/commands/review.js.map +0 -1
  125. package/dist/commands/run.d.ts +0 -61
  126. package/dist/commands/run.d.ts.map +0 -1
  127. package/dist/commands/run.js +0 -364
  128. package/dist/commands/run.js.map +0 -1
  129. package/dist/commands/serve.d.ts +0 -7
  130. package/dist/commands/serve.d.ts.map +0 -1
  131. package/dist/commands/serve.js +0 -27
  132. package/dist/commands/serve.js.map +0 -1
  133. package/dist/commands/slice.d.ts +0 -26
  134. package/dist/commands/slice.d.ts.map +0 -1
  135. package/dist/commands/slice.js +0 -175
  136. package/dist/commands/slice.js.map +0 -1
  137. package/dist/commands/state.d.ts +0 -8
  138. package/dist/commands/state.d.ts.map +0 -1
  139. package/dist/commands/state.js +0 -56
  140. package/dist/commands/state.js.map +0 -1
  141. package/dist/commands/status.d.ts +0 -14
  142. package/dist/commands/status.d.ts.map +0 -1
  143. package/dist/commands/status.js +0 -147
  144. package/dist/commands/status.js.map +0 -1
  145. package/dist/commands/uninstall.d.ts +0 -25
  146. package/dist/commands/uninstall.d.ts.map +0 -1
  147. package/dist/commands/uninstall.js +0 -141
  148. package/dist/commands/uninstall.js.map +0 -1
  149. package/dist/commands/update.d.ts +0 -21
  150. package/dist/commands/update.d.ts.map +0 -1
  151. package/dist/commands/update.js +0 -87
  152. package/dist/commands/update.js.map +0 -1
  153. package/dist/config.d.ts +0 -23
  154. package/dist/config.d.ts.map +0 -1
  155. package/dist/config.js +0 -601
  156. package/dist/config.js.map +0 -1
  157. package/dist/constants.d.ts +0 -59
  158. package/dist/constants.d.ts.map +0 -1
  159. package/dist/constants.js +0 -110
  160. package/dist/constants.js.map +0 -1
  161. package/dist/server/index.d.ts +0 -23
  162. package/dist/server/index.d.ts.map +0 -1
  163. package/dist/server/index.js +0 -1074
  164. package/dist/server/index.js.map +0 -1
  165. package/dist/storage/json-state-migrator.d.ts +0 -24
  166. package/dist/storage/json-state-migrator.d.ts.map +0 -1
  167. package/dist/storage/json-state-migrator.js +0 -197
  168. package/dist/storage/json-state-migrator.js.map +0 -1
  169. package/dist/storage/repositories/index.d.ts +0 -23
  170. package/dist/storage/repositories/index.d.ts.map +0 -1
  171. package/dist/storage/repositories/index.js +0 -37
  172. package/dist/storage/repositories/index.js.map +0 -1
  173. package/dist/storage/repositories/interfaces.d.ts +0 -37
  174. package/dist/storage/repositories/interfaces.d.ts.map +0 -1
  175. package/dist/storage/repositories/interfaces.js +0 -6
  176. package/dist/storage/repositories/interfaces.js.map +0 -1
  177. package/dist/storage/repositories/sqlite/execution-history-repository.d.ts +0 -21
  178. package/dist/storage/repositories/sqlite/execution-history-repository.d.ts.map +0 -1
  179. package/dist/storage/repositories/sqlite/execution-history-repository.js +0 -94
  180. package/dist/storage/repositories/sqlite/execution-history-repository.js.map +0 -1
  181. package/dist/storage/repositories/sqlite/prd-state-repository.d.ts +0 -17
  182. package/dist/storage/repositories/sqlite/prd-state-repository.d.ts.map +0 -1
  183. package/dist/storage/repositories/sqlite/prd-state-repository.js +0 -74
  184. package/dist/storage/repositories/sqlite/prd-state-repository.js.map +0 -1
  185. package/dist/storage/repositories/sqlite/project-registry-repository.d.ts +0 -16
  186. package/dist/storage/repositories/sqlite/project-registry-repository.d.ts.map +0 -1
  187. package/dist/storage/repositories/sqlite/project-registry-repository.js +0 -34
  188. package/dist/storage/repositories/sqlite/project-registry-repository.js.map +0 -1
  189. package/dist/storage/repositories/sqlite/roadmap-state-repository.d.ts +0 -14
  190. package/dist/storage/repositories/sqlite/roadmap-state-repository.d.ts.map +0 -1
  191. package/dist/storage/repositories/sqlite/roadmap-state-repository.js +0 -47
  192. package/dist/storage/repositories/sqlite/roadmap-state-repository.js.map +0 -1
  193. package/dist/storage/sqlite/client.d.ts +0 -23
  194. package/dist/storage/sqlite/client.d.ts.map +0 -1
  195. package/dist/storage/sqlite/client.js +0 -47
  196. package/dist/storage/sqlite/client.js.map +0 -1
  197. package/dist/storage/sqlite/migrations.d.ts +0 -11
  198. package/dist/storage/sqlite/migrations.d.ts.map +0 -1
  199. package/dist/storage/sqlite/migrations.js +0 -57
  200. package/dist/storage/sqlite/migrations.js.map +0 -1
  201. package/dist/templates/prd-template.d.ts +0 -11
  202. package/dist/templates/prd-template.d.ts.map +0 -1
  203. package/dist/templates/prd-template.js +0 -166
  204. package/dist/templates/prd-template.js.map +0 -1
  205. package/dist/templates/slicer-prompt.d.ts +0 -54
  206. package/dist/templates/slicer-prompt.d.ts.map +0 -1
  207. package/dist/templates/slicer-prompt.js +0 -163
  208. package/dist/templates/slicer-prompt.js.map +0 -1
  209. package/dist/types.d.ts +0 -123
  210. package/dist/types.d.ts.map +0 -1
  211. package/dist/types.js +0 -5
  212. package/dist/types.js.map +0 -1
  213. package/dist/utils/checks.d.ts +0 -55
  214. package/dist/utils/checks.d.ts.map +0 -1
  215. package/dist/utils/checks.js +0 -246
  216. package/dist/utils/checks.js.map +0 -1
  217. package/dist/utils/config-writer.d.ts +0 -16
  218. package/dist/utils/config-writer.d.ts.map +0 -1
  219. package/dist/utils/config-writer.js +0 -45
  220. package/dist/utils/config-writer.js.map +0 -1
  221. package/dist/utils/crontab.d.ts +0 -62
  222. package/dist/utils/crontab.d.ts.map +0 -1
  223. package/dist/utils/crontab.js +0 -168
  224. package/dist/utils/crontab.js.map +0 -1
  225. package/dist/utils/execution-history.d.ts +0 -54
  226. package/dist/utils/execution-history.d.ts.map +0 -1
  227. package/dist/utils/execution-history.js +0 -80
  228. package/dist/utils/execution-history.js.map +0 -1
  229. package/dist/utils/github.d.ts +0 -40
  230. package/dist/utils/github.d.ts.map +0 -1
  231. package/dist/utils/github.js +0 -126
  232. package/dist/utils/github.js.map +0 -1
  233. package/dist/utils/notify.d.ts +0 -63
  234. package/dist/utils/notify.d.ts.map +0 -1
  235. package/dist/utils/notify.js +0 -264
  236. package/dist/utils/notify.js.map +0 -1
  237. package/dist/utils/prd-states.d.ts +0 -16
  238. package/dist/utils/prd-states.d.ts.map +0 -1
  239. package/dist/utils/prd-states.js +0 -28
  240. package/dist/utils/prd-states.js.map +0 -1
  241. package/dist/utils/registry.d.ts +0 -44
  242. package/dist/utils/registry.d.ts.map +0 -1
  243. package/dist/utils/registry.js +0 -86
  244. package/dist/utils/registry.js.map +0 -1
  245. package/dist/utils/roadmap-parser.d.ts +0 -45
  246. package/dist/utils/roadmap-parser.d.ts.map +0 -1
  247. package/dist/utils/roadmap-parser.js +0 -136
  248. package/dist/utils/roadmap-parser.js.map +0 -1
  249. package/dist/utils/roadmap-scanner.d.ts +0 -92
  250. package/dist/utils/roadmap-scanner.d.ts.map +0 -1
  251. package/dist/utils/roadmap-scanner.js +0 -349
  252. package/dist/utils/roadmap-scanner.js.map +0 -1
  253. package/dist/utils/roadmap-state.d.ts +0 -90
  254. package/dist/utils/roadmap-state.d.ts.map +0 -1
  255. package/dist/utils/roadmap-state.js +0 -154
  256. package/dist/utils/roadmap-state.js.map +0 -1
  257. package/dist/utils/script-result.d.ts +0 -12
  258. package/dist/utils/script-result.d.ts.map +0 -1
  259. package/dist/utils/script-result.js +0 -46
  260. package/dist/utils/script-result.js.map +0 -1
  261. package/dist/utils/shell.d.ts +0 -27
  262. package/dist/utils/shell.d.ts.map +0 -1
  263. package/dist/utils/shell.js +0 -64
  264. package/dist/utils/shell.js.map +0 -1
  265. package/dist/utils/status-data.d.ts +0 -148
  266. package/dist/utils/status-data.d.ts.map +0 -1
  267. package/dist/utils/status-data.js +0 -593
  268. package/dist/utils/status-data.js.map +0 -1
  269. package/dist/utils/ui.d.ts +0 -55
  270. package/dist/utils/ui.d.ts.map +0 -1
  271. package/dist/utils/ui.js +0 -121
  272. package/dist/utils/ui.js.map +0 -1
  273. package/web/dist/assets/index-BtxQU4oX.css +0 -1
  274. package/web/dist/assets/index-D3awZ0gS.js +0 -473
@@ -1,45 +0,0 @@
1
- /**
2
- * Config writer utility for Night Watch CLI
3
- * Saves partial config changes to night-watch.config.json while preserving unknown keys
4
- */
5
- import * as fs from "fs";
6
- import * as path from "path";
7
- import { CONFIG_FILE_NAME } from "../constants.js";
8
- /**
9
- * Save partial config changes to the night-watch.config.json file.
10
- * Reads the existing file, merges changes, and writes back.
11
- * Preserves unknown keys (like $schema, projectName).
12
- */
13
- export function saveConfig(projectDir, changes) {
14
- const configPath = path.join(projectDir, CONFIG_FILE_NAME);
15
- try {
16
- // Read existing file
17
- let existing = {};
18
- if (fs.existsSync(configPath)) {
19
- const content = fs.readFileSync(configPath, "utf-8");
20
- existing = JSON.parse(content);
21
- }
22
- // Merge changes (shallow merge for top-level keys, deep merge for notifications)
23
- const merged = { ...existing };
24
- for (const [key, value] of Object.entries(changes)) {
25
- if (value !== undefined) {
26
- if (key === "notifications" && existing.notifications && typeof existing.notifications === "object") {
27
- merged.notifications = { ...existing.notifications, ...value };
28
- }
29
- else {
30
- merged[key] = value;
31
- }
32
- }
33
- }
34
- // Write back with consistent formatting
35
- fs.writeFileSync(configPath, JSON.stringify(merged, null, 2) + "\n");
36
- return { success: true };
37
- }
38
- catch (err) {
39
- return {
40
- success: false,
41
- error: err instanceof Error ? err.message : String(err),
42
- };
43
- }
44
- }
45
- //# sourceMappingURL=config-writer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-writer.js","sourceRoot":"","sources":["../../src/utils/config-writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAQnD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,UAAkB,EAClB,OAAmC;IAEnC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,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AC;IACJ,CAAC;AACH,CAAC"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Crontab utility functions for Night Watch CLI
3
- * Provides safe read/write operations for user crontab
4
- */
5
- /**
6
- * Marker prefix used to identify Night Watch entries
7
- */
8
- export declare const CRONTAB_MARKER_PREFIX = "# night-watch-cli:";
9
- /**
10
- * Read current crontab entries
11
- * Returns empty array if user has no crontab
12
- */
13
- export declare function readCrontab(): string[];
14
- /**
15
- * Write crontab entries
16
- * @param lines - Array of crontab lines to write
17
- * @throws Error if crontab write fails
18
- */
19
- export declare function writeCrontab(lines: string[]): void;
20
- /**
21
- * Generate a marker comment for identifying entries
22
- * @param projectName - Name of the project
23
- */
24
- export declare function generateMarker(projectName: string): string;
25
- /**
26
- * Add a crontab entry if it doesn't already exist
27
- * @param entry - The crontab entry to add
28
- * @param marker - The marker to use for deduplication
29
- * @returns true if entry was added, false if it already existed
30
- */
31
- export declare function addEntry(entry: string, marker: string): boolean;
32
- /**
33
- * Remove all crontab entries containing the marker
34
- * @param marker - The marker to search for
35
- * @returns Number of entries removed
36
- */
37
- export declare function removeEntries(marker: string): number;
38
- /**
39
- * Check if an entry with the marker exists
40
- * @param marker - The marker to search for
41
- * @returns true if entry exists
42
- */
43
- export declare function hasEntry(marker: string): boolean;
44
- /**
45
- * Get all entries containing the marker
46
- * @param marker - The marker to search for
47
- * @returns Array of matching entries
48
- */
49
- export declare function getEntries(marker: string): string[];
50
- /**
51
- * Get all Night Watch entries for a project directory (independent of marker text)
52
- * @param projectDir - Absolute project directory
53
- */
54
- export declare function getProjectEntries(projectDir: string): string[];
55
- /**
56
- * Remove Night Watch entries for a project directory and/or marker
57
- * @param projectDir - Absolute project directory
58
- * @param marker - Optional marker for backward compatibility
59
- * @returns Number of entries removed
60
- */
61
- export declare function removeEntriesForProject(projectDir: string, marker?: string): number;
62
- //# sourceMappingURL=crontab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crontab.d.ts","sourceRoot":"","sources":["../../src/utils/crontab.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;GAEG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAqB1D;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAYtC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAkClD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAiB/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAGnD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAG9D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAYnF"}
@@ -1,168 +0,0 @@
1
- /**
2
- * Crontab utility functions for Night Watch CLI
3
- * Provides safe read/write operations for user crontab
4
- */
5
- import { execSync } from "child_process";
6
- import * as fs from "fs";
7
- import * as os from "os";
8
- import * as path from "path";
9
- /**
10
- * Marker prefix used to identify Night Watch entries
11
- */
12
- export const CRONTAB_MARKER_PREFIX = "# night-watch-cli:";
13
- /**
14
- * Check whether a crontab line belongs to the given project directory.
15
- * Supports unquoted, single-quoted, and double-quoted cd paths.
16
- */
17
- function isEntryForProject(line, projectDir) {
18
- if (!line.includes(CRONTAB_MARKER_PREFIX)) {
19
- return false;
20
- }
21
- const normalized = projectDir.replace(/\/+$/, "");
22
- const candidates = [
23
- `cd ${normalized}`,
24
- `cd '${normalized}'`,
25
- `cd "${normalized}"`,
26
- ];
27
- return candidates.some((candidate) => line.includes(candidate));
28
- }
29
- /**
30
- * Read current crontab entries
31
- * Returns empty array if user has no crontab
32
- */
33
- export function readCrontab() {
34
- try {
35
- const output = execSync("crontab -l 2>/dev/null", {
36
- encoding: "utf-8",
37
- stdio: ["pipe", "pipe", "pipe"],
38
- });
39
- return output.trim().split("\n").filter((line) => line.length > 0);
40
- }
41
- catch {
42
- // crontab -l returns error if no crontab exists
43
- // This is expected and should return empty array
44
- return [];
45
- }
46
- }
47
- /**
48
- * Write crontab entries
49
- * @param lines - Array of crontab lines to write
50
- * @throws Error if crontab write fails
51
- */
52
- export function writeCrontab(lines) {
53
- if (process.env.NW_EXECUTION_CONTEXT === "agent") {
54
- throw new Error("Crontab writes are blocked during agent execution (NW_EXECUTION_CONTEXT=agent). " +
55
- "This prevents the running agent from accidentally modifying its own scheduling.");
56
- }
57
- const content = lines.join("\n");
58
- // Create a backup first
59
- try {
60
- const currentCrontab = readCrontab();
61
- if (currentCrontab.length > 0) {
62
- execSync(`crontab -l > /tmp/night-watch-crontab-backup-$(date +%s).txt`, {
63
- encoding: "utf-8",
64
- });
65
- }
66
- }
67
- catch {
68
- // Ignore backup errors
69
- }
70
- // Write new crontab via temp file to avoid shell line length limits
71
- const tmpFile = path.join(os.tmpdir(), `night-watch-crontab-${Date.now()}.txt`);
72
- try {
73
- fs.writeFileSync(tmpFile, content + "\n");
74
- execSync(`crontab ${tmpFile}`, { encoding: "utf-8" });
75
- }
76
- catch (error) {
77
- throw new Error(`Failed to write crontab: ${error instanceof Error ? error.message : String(error)}`);
78
- }
79
- finally {
80
- try {
81
- fs.unlinkSync(tmpFile);
82
- }
83
- catch { /* ignore cleanup errors */ }
84
- }
85
- }
86
- /**
87
- * Generate a marker comment for identifying entries
88
- * @param projectName - Name of the project
89
- */
90
- export function generateMarker(projectName) {
91
- return `${CRONTAB_MARKER_PREFIX} ${projectName}`;
92
- }
93
- /**
94
- * Add a crontab entry if it doesn't already exist
95
- * @param entry - The crontab entry to add
96
- * @param marker - The marker to use for deduplication
97
- * @returns true if entry was added, false if it already existed
98
- */
99
- export function addEntry(entry, marker) {
100
- // Check if entry already exists
101
- if (hasEntry(marker)) {
102
- return false;
103
- }
104
- const lines = readCrontab();
105
- // Add the entry with marker comment on the same line
106
- const entryWithMarker = entry.endsWith(marker)
107
- ? entry
108
- : `${entry} ${marker}`;
109
- lines.push(entryWithMarker);
110
- writeCrontab(lines);
111
- return true;
112
- }
113
- /**
114
- * Remove all crontab entries containing the marker
115
- * @param marker - The marker to search for
116
- * @returns Number of entries removed
117
- */
118
- export function removeEntries(marker) {
119
- const lines = readCrontab();
120
- const filtered = lines.filter((line) => !line.includes(marker));
121
- const removedCount = lines.length - filtered.length;
122
- if (removedCount > 0) {
123
- writeCrontab(filtered);
124
- }
125
- return removedCount;
126
- }
127
- /**
128
- * Check if an entry with the marker exists
129
- * @param marker - The marker to search for
130
- * @returns true if entry exists
131
- */
132
- export function hasEntry(marker) {
133
- const lines = readCrontab();
134
- return lines.some((line) => line.includes(marker));
135
- }
136
- /**
137
- * Get all entries containing the marker
138
- * @param marker - The marker to search for
139
- * @returns Array of matching entries
140
- */
141
- export function getEntries(marker) {
142
- const lines = readCrontab();
143
- return lines.filter((line) => line.includes(marker));
144
- }
145
- /**
146
- * Get all Night Watch entries for a project directory (independent of marker text)
147
- * @param projectDir - Absolute project directory
148
- */
149
- export function getProjectEntries(projectDir) {
150
- const lines = readCrontab();
151
- return lines.filter((line) => isEntryForProject(line, projectDir));
152
- }
153
- /**
154
- * Remove Night Watch entries for a project directory and/or marker
155
- * @param projectDir - Absolute project directory
156
- * @param marker - Optional marker for backward compatibility
157
- * @returns Number of entries removed
158
- */
159
- export function removeEntriesForProject(projectDir, marker) {
160
- const lines = readCrontab();
161
- const filtered = lines.filter((line) => !isEntryForProject(line, projectDir) && !(marker && line.includes(marker)));
162
- const removedCount = lines.length - filtered.length;
163
- if (removedCount > 0) {
164
- writeCrontab(filtered);
165
- }
166
- return removedCount;
167
- }
168
- //# sourceMappingURL=crontab.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crontab.js","sourceRoot":"","sources":["../../src/utils/crontab.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAE1D;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAY,EAAE,UAAkB;IACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG;QACjB,MAAM,UAAU,EAAE;QAClB,OAAO,UAAU,GAAG;QACpB,OAAO,UAAU,GAAG;KACrB,CAAC;IAEF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,wBAAwB,EAAE;YAChD,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,C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ite 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
@@ -1 +0,0 @@
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"}
@@ -1,80 +0,0 @@
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
@@ -1 +0,0 @@
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,EAA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C;IACf,CAAC;IACD,yCAAyC;IACzC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,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"}
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,126 +0,0 @@
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
@@ -1 +0,0 @@
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,CAAC;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