@newrelic/preflight 0.0.1-pre.1 → 1.0.0

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 (578) hide show
  1. package/LICENSE +183 -0
  2. package/README.md +498 -0
  3. package/dist/alerts/alert-log.d.ts +24 -0
  4. package/dist/alerts/alert-log.d.ts.map +1 -0
  5. package/dist/alerts/alert-log.js +159 -0
  6. package/dist/alerts/alert-log.js.map +1 -0
  7. package/dist/alerts/alert-snapshot-collector.d.ts +168 -0
  8. package/dist/alerts/alert-snapshot-collector.d.ts.map +1 -0
  9. package/dist/alerts/alert-snapshot-collector.js +243 -0
  10. package/dist/alerts/alert-snapshot-collector.js.map +1 -0
  11. package/dist/alerts/local-alert-engine.d.ts +86 -0
  12. package/dist/alerts/local-alert-engine.d.ts.map +1 -0
  13. package/dist/alerts/local-alert-engine.js +466 -0
  14. package/dist/alerts/local-alert-engine.js.map +1 -0
  15. package/dist/alerts/local-alert-rule.d.ts +439 -0
  16. package/dist/alerts/local-alert-rule.d.ts.map +1 -0
  17. package/dist/alerts/local-alert-rule.js +139 -0
  18. package/dist/alerts/local-alert-rule.js.map +1 -0
  19. package/dist/alerts/os-notifier.d.ts +39 -0
  20. package/dist/alerts/os-notifier.d.ts.map +1 -0
  21. package/dist/alerts/os-notifier.js +170 -0
  22. package/dist/alerts/os-notifier.js.map +1 -0
  23. package/dist/alerts/types.d.ts +35 -0
  24. package/dist/alerts/types.d.ts.map +1 -0
  25. package/dist/alerts/types.js +8 -0
  26. package/dist/alerts/types.js.map +1 -0
  27. package/dist/config.d.ts +169 -0
  28. package/dist/config.d.ts.map +1 -0
  29. package/dist/config.js +860 -0
  30. package/dist/config.js.map +1 -0
  31. package/dist/dashboard/dashboard-server.d.ts +38 -0
  32. package/dist/dashboard/dashboard-server.d.ts.map +1 -0
  33. package/dist/dashboard/dashboard-server.js +207 -0
  34. package/dist/dashboard/dashboard-server.js.map +1 -0
  35. package/dist/dashboard/index.d.ts +3 -0
  36. package/dist/dashboard/index.d.ts.map +1 -0
  37. package/dist/dashboard/index.js +2 -0
  38. package/dist/dashboard/index.js.map +1 -0
  39. package/dist/dashboard/live-event-bus.d.ts +99 -0
  40. package/dist/dashboard/live-event-bus.d.ts.map +1 -0
  41. package/dist/dashboard/live-event-bus.js +56 -0
  42. package/dist/dashboard/live-event-bus.js.map +1 -0
  43. package/dist/dashboard/routes/api-handler.d.ts +122 -0
  44. package/dist/dashboard/routes/api-handler.d.ts.map +1 -0
  45. package/dist/dashboard/routes/api-handler.js +1414 -0
  46. package/dist/dashboard/routes/api-handler.js.map +1 -0
  47. package/dist/dashboard/routes/replay-analyzer.d.ts +15 -0
  48. package/dist/dashboard/routes/replay-analyzer.d.ts.map +1 -0
  49. package/dist/dashboard/routes/replay-analyzer.js +227 -0
  50. package/dist/dashboard/routes/replay-analyzer.js.map +1 -0
  51. package/dist/dashboard/routes/sse-handler.d.ts +4 -0
  52. package/dist/dashboard/routes/sse-handler.d.ts.map +1 -0
  53. package/dist/dashboard/routes/sse-handler.js +122 -0
  54. package/dist/dashboard/routes/sse-handler.js.map +1 -0
  55. package/dist/dashboard/routes/static-handler.d.ts +3 -0
  56. package/dist/dashboard/routes/static-handler.d.ts.map +1 -0
  57. package/dist/dashboard/routes/static-handler.js +103 -0
  58. package/dist/dashboard/routes/static-handler.js.map +1 -0
  59. package/dist/data/alerts/conditions/01-daily-cost-spike.json +16 -0
  60. package/dist/data/alerts/conditions/02-low-efficiency-score.json +16 -0
  61. package/dist/data/alerts/conditions/03-stuck-loop-rate.json +16 -0
  62. package/dist/data/alerts/conditions/04-anti-pattern-rate.json +16 -0
  63. package/dist/data/alerts/conditions/05-session-cost-budget.json +16 -0
  64. package/dist/data/alerts/conditions-personal/01-personal-daily-cost.json +16 -0
  65. package/dist/data/alerts/conditions-personal/02-personal-session-cost.json +16 -0
  66. package/dist/data/alerts/conditions-personal/03-personal-low-efficiency.json +16 -0
  67. package/dist/data/alerts/conditions-personal/04-personal-anti-pattern-rate.json +16 -0
  68. package/dist/data/alerts/conditions-personal/05-personal-stuck-loop.json +16 -0
  69. package/dist/data/alerts/policy.json +4 -0
  70. package/dist/data/dashboards/ai-coding-assistant-manager-view.json +103 -0
  71. package/dist/data/dashboards/ai-coding-assistant-overview.json +239 -0
  72. package/dist/data/dashboards/ai-coding-assistant-personal.json +442 -0
  73. package/dist/data/dashboards/ai-coding-assistant-platform-comparison.json +320 -0
  74. package/dist/data/dashboards/ai-coding-assistant-security.json +275 -0
  75. package/dist/data/dashboards/ai-coding-assistant-session-detail.json +296 -0
  76. package/dist/data/dashboards/ai-coding-assistant-team-view.json +345 -0
  77. package/dist/deploy/data-paths.d.ts +22 -0
  78. package/dist/deploy/data-paths.d.ts.map +1 -0
  79. package/dist/deploy/data-paths.js +69 -0
  80. package/dist/deploy/data-paths.js.map +1 -0
  81. package/dist/deploy/deploy-alerts.d.ts +58 -0
  82. package/dist/deploy/deploy-alerts.d.ts.map +1 -0
  83. package/dist/deploy/deploy-alerts.js +371 -0
  84. package/dist/deploy/deploy-alerts.js.map +1 -0
  85. package/dist/deploy/deploy-dashboards.d.ts +92 -0
  86. package/dist/deploy/deploy-dashboards.d.ts.map +1 -0
  87. package/dist/deploy/deploy-dashboards.js +282 -0
  88. package/dist/deploy/deploy-dashboards.js.map +1 -0
  89. package/dist/digest/digest-formatter.d.ts +3 -0
  90. package/dist/digest/digest-formatter.d.ts.map +1 -0
  91. package/dist/digest/digest-formatter.js +37 -0
  92. package/dist/digest/digest-formatter.js.map +1 -0
  93. package/dist/digest/digest-sender.d.ts +2 -0
  94. package/dist/digest/digest-sender.d.ts.map +1 -0
  95. package/dist/digest/digest-sender.js +29 -0
  96. package/dist/digest/digest-sender.js.map +1 -0
  97. package/dist/hooks/bash-classifier.d.ts +26 -0
  98. package/dist/hooks/bash-classifier.d.ts.map +1 -0
  99. package/dist/hooks/bash-classifier.js +409 -0
  100. package/dist/hooks/bash-classifier.js.map +1 -0
  101. package/dist/hooks/collector-script.d.ts +47 -0
  102. package/dist/hooks/collector-script.d.ts.map +1 -0
  103. package/dist/hooks/collector-script.js +662 -0
  104. package/dist/hooks/collector-script.js.map +1 -0
  105. package/dist/hooks/event-processor.d.ts +65 -0
  106. package/dist/hooks/event-processor.d.ts.map +1 -0
  107. package/dist/hooks/event-processor.js +342 -0
  108. package/dist/hooks/event-processor.js.map +1 -0
  109. package/dist/hooks/index.d.ts +7 -0
  110. package/dist/hooks/index.d.ts.map +1 -0
  111. package/dist/hooks/index.js +5 -0
  112. package/dist/hooks/index.js.map +1 -0
  113. package/dist/hooks/session-resolver.d.ts +66 -0
  114. package/dist/hooks/session-resolver.d.ts.map +1 -0
  115. package/dist/hooks/session-resolver.js +196 -0
  116. package/dist/hooks/session-resolver.js.map +1 -0
  117. package/dist/hooks/tool-parsers.d.ts +19 -0
  118. package/dist/hooks/tool-parsers.d.ts.map +1 -0
  119. package/dist/hooks/tool-parsers.js +260 -0
  120. package/dist/hooks/tool-parsers.js.map +1 -0
  121. package/dist/index.d.ts +107 -0
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +1505 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/install/cli.d.ts +11 -0
  126. package/dist/install/cli.d.ts.map +1 -0
  127. package/dist/install/cli.js +365 -0
  128. package/dist/install/cli.js.map +1 -0
  129. package/dist/install/index.d.ts +4 -0
  130. package/dist/install/index.d.ts.map +1 -0
  131. package/dist/install/index.js +3 -0
  132. package/dist/install/index.js.map +1 -0
  133. package/dist/install/install-helper.d.ts +35 -0
  134. package/dist/install/install-helper.d.ts.map +1 -0
  135. package/dist/install/install-helper.js +227 -0
  136. package/dist/install/install-helper.js.map +1 -0
  137. package/dist/install/key-validator.d.ts +19 -0
  138. package/dist/install/key-validator.d.ts.map +1 -0
  139. package/dist/install/key-validator.js +122 -0
  140. package/dist/install/key-validator.js.map +1 -0
  141. package/dist/install/migrate.d.ts +12 -0
  142. package/dist/install/migrate.d.ts.map +1 -0
  143. package/dist/install/migrate.js +115 -0
  144. package/dist/install/migrate.js.map +1 -0
  145. package/dist/install/schedule.d.ts +11 -0
  146. package/dist/install/schedule.d.ts.map +1 -0
  147. package/dist/install/schedule.js +114 -0
  148. package/dist/install/schedule.js.map +1 -0
  149. package/dist/install/setup-wizard.d.ts +40 -0
  150. package/dist/install/setup-wizard.d.ts.map +1 -0
  151. package/dist/install/setup-wizard.js +489 -0
  152. package/dist/install/setup-wizard.js.map +1 -0
  153. package/dist/lib/date.d.ts +54 -0
  154. package/dist/lib/date.d.ts.map +1 -0
  155. package/dist/lib/date.js +85 -0
  156. package/dist/lib/date.js.map +1 -0
  157. package/dist/metrics/anti-patterns.d.ts +62 -0
  158. package/dist/metrics/anti-patterns.d.ts.map +1 -0
  159. package/dist/metrics/anti-patterns.js +301 -0
  160. package/dist/metrics/anti-patterns.js.map +1 -0
  161. package/dist/metrics/api-failure-tracker.d.ts +82 -0
  162. package/dist/metrics/api-failure-tracker.d.ts.map +1 -0
  163. package/dist/metrics/api-failure-tracker.js +202 -0
  164. package/dist/metrics/api-failure-tracker.js.map +1 -0
  165. package/dist/metrics/budget-tracker.d.ts +60 -0
  166. package/dist/metrics/budget-tracker.d.ts.map +1 -0
  167. package/dist/metrics/budget-tracker.js +130 -0
  168. package/dist/metrics/budget-tracker.js.map +1 -0
  169. package/dist/metrics/claudemd-tracker.d.ts +108 -0
  170. package/dist/metrics/claudemd-tracker.d.ts.map +1 -0
  171. package/dist/metrics/claudemd-tracker.js +337 -0
  172. package/dist/metrics/claudemd-tracker.js.map +1 -0
  173. package/dist/metrics/collaboration-profile.d.ts +65 -0
  174. package/dist/metrics/collaboration-profile.d.ts.map +1 -0
  175. package/dist/metrics/collaboration-profile.js +231 -0
  176. package/dist/metrics/collaboration-profile.js.map +1 -0
  177. package/dist/metrics/context-composition-tracker.d.ts +74 -0
  178. package/dist/metrics/context-composition-tracker.d.ts.map +1 -0
  179. package/dist/metrics/context-composition-tracker.js +202 -0
  180. package/dist/metrics/context-composition-tracker.js.map +1 -0
  181. package/dist/metrics/context-tracker.d.ts +78 -0
  182. package/dist/metrics/context-tracker.d.ts.map +1 -0
  183. package/dist/metrics/context-tracker.js +222 -0
  184. package/dist/metrics/context-tracker.js.map +1 -0
  185. package/dist/metrics/context-window-tracker.d.ts +18 -0
  186. package/dist/metrics/context-window-tracker.d.ts.map +1 -0
  187. package/dist/metrics/context-window-tracker.js +35 -0
  188. package/dist/metrics/context-window-tracker.js.map +1 -0
  189. package/dist/metrics/cost-forecast.d.ts +36 -0
  190. package/dist/metrics/cost-forecast.d.ts.map +1 -0
  191. package/dist/metrics/cost-forecast.js +91 -0
  192. package/dist/metrics/cost-forecast.js.map +1 -0
  193. package/dist/metrics/cost-per-outcome.d.ts +102 -0
  194. package/dist/metrics/cost-per-outcome.d.ts.map +1 -0
  195. package/dist/metrics/cost-per-outcome.js +266 -0
  196. package/dist/metrics/cost-per-outcome.js.map +1 -0
  197. package/dist/metrics/cost-tracker.d.ts +78 -0
  198. package/dist/metrics/cost-tracker.d.ts.map +1 -0
  199. package/dist/metrics/cost-tracker.js +169 -0
  200. package/dist/metrics/cost-tracker.js.map +1 -0
  201. package/dist/metrics/decision-tracker.d.ts +49 -0
  202. package/dist/metrics/decision-tracker.d.ts.map +1 -0
  203. package/dist/metrics/decision-tracker.js +161 -0
  204. package/dist/metrics/decision-tracker.js.map +1 -0
  205. package/dist/metrics/efficiency-score.d.ts +80 -0
  206. package/dist/metrics/efficiency-score.d.ts.map +1 -0
  207. package/dist/metrics/efficiency-score.js +219 -0
  208. package/dist/metrics/efficiency-score.js.map +1 -0
  209. package/dist/metrics/git-efficiency-tracker.d.ts +165 -0
  210. package/dist/metrics/git-efficiency-tracker.d.ts.map +1 -0
  211. package/dist/metrics/git-efficiency-tracker.js +1056 -0
  212. package/dist/metrics/git-efficiency-tracker.js.map +1 -0
  213. package/dist/metrics/index.d.ts +26 -0
  214. package/dist/metrics/index.d.ts.map +1 -0
  215. package/dist/metrics/index.js +14 -0
  216. package/dist/metrics/index.js.map +1 -0
  217. package/dist/metrics/instruction-drift-tracker.d.ts +69 -0
  218. package/dist/metrics/instruction-drift-tracker.d.ts.map +1 -0
  219. package/dist/metrics/instruction-drift-tracker.js +213 -0
  220. package/dist/metrics/instruction-drift-tracker.js.map +1 -0
  221. package/dist/metrics/latency-decomposition.d.ts +50 -0
  222. package/dist/metrics/latency-decomposition.d.ts.map +1 -0
  223. package/dist/metrics/latency-decomposition.js +112 -0
  224. package/dist/metrics/latency-decomposition.js.map +1 -0
  225. package/dist/metrics/latency-tracker.d.ts +33 -0
  226. package/dist/metrics/latency-tracker.d.ts.map +1 -0
  227. package/dist/metrics/latency-tracker.js +93 -0
  228. package/dist/metrics/latency-tracker.js.map +1 -0
  229. package/dist/metrics/live-session-registry.d.ts +29 -0
  230. package/dist/metrics/live-session-registry.d.ts.map +1 -0
  231. package/dist/metrics/live-session-registry.js +103 -0
  232. package/dist/metrics/live-session-registry.js.map +1 -0
  233. package/dist/metrics/model-usage-tracker.d.ts +21 -0
  234. package/dist/metrics/model-usage-tracker.d.ts.map +1 -0
  235. package/dist/metrics/model-usage-tracker.js +53 -0
  236. package/dist/metrics/model-usage-tracker.js.map +1 -0
  237. package/dist/metrics/percentile.d.ts +5 -0
  238. package/dist/metrics/percentile.d.ts.map +1 -0
  239. package/dist/metrics/percentile.js +10 -0
  240. package/dist/metrics/percentile.js.map +1 -0
  241. package/dist/metrics/personal-coach.d.ts +47 -0
  242. package/dist/metrics/personal-coach.d.ts.map +1 -0
  243. package/dist/metrics/personal-coach.js +241 -0
  244. package/dist/metrics/personal-coach.js.map +1 -0
  245. package/dist/metrics/prompt-feedback.d.ts +75 -0
  246. package/dist/metrics/prompt-feedback.d.ts.map +1 -0
  247. package/dist/metrics/prompt-feedback.js +286 -0
  248. package/dist/metrics/prompt-feedback.js.map +1 -0
  249. package/dist/metrics/proxy-metrics.d.ts +54 -0
  250. package/dist/metrics/proxy-metrics.d.ts.map +1 -0
  251. package/dist/metrics/proxy-metrics.js +228 -0
  252. package/dist/metrics/proxy-metrics.js.map +1 -0
  253. package/dist/metrics/quality-proxy-tracker.d.ts +51 -0
  254. package/dist/metrics/quality-proxy-tracker.d.ts.map +1 -0
  255. package/dist/metrics/quality-proxy-tracker.js +162 -0
  256. package/dist/metrics/quality-proxy-tracker.js.map +1 -0
  257. package/dist/metrics/recommendation-engine.d.ts +72 -0
  258. package/dist/metrics/recommendation-engine.d.ts.map +1 -0
  259. package/dist/metrics/recommendation-engine.js +207 -0
  260. package/dist/metrics/recommendation-engine.js.map +1 -0
  261. package/dist/metrics/retry-detector.d.ts +43 -0
  262. package/dist/metrics/retry-detector.d.ts.map +1 -0
  263. package/dist/metrics/retry-detector.js +179 -0
  264. package/dist/metrics/retry-detector.js.map +1 -0
  265. package/dist/metrics/session-tracker.d.ts +75 -0
  266. package/dist/metrics/session-tracker.d.ts.map +1 -0
  267. package/dist/metrics/session-tracker.js +249 -0
  268. package/dist/metrics/session-tracker.js.map +1 -0
  269. package/dist/metrics/task-completion-tracker.d.ts +15 -0
  270. package/dist/metrics/task-completion-tracker.d.ts.map +1 -0
  271. package/dist/metrics/task-completion-tracker.js +27 -0
  272. package/dist/metrics/task-completion-tracker.js.map +1 -0
  273. package/dist/metrics/task-detector.d.ts +84 -0
  274. package/dist/metrics/task-detector.d.ts.map +1 -0
  275. package/dist/metrics/task-detector.js +302 -0
  276. package/dist/metrics/task-detector.js.map +1 -0
  277. package/dist/metrics/tool-selection-scorer.d.ts +39 -0
  278. package/dist/metrics/tool-selection-scorer.d.ts.map +1 -0
  279. package/dist/metrics/tool-selection-scorer.js +193 -0
  280. package/dist/metrics/tool-selection-scorer.js.map +1 -0
  281. package/dist/metrics/trend-analyzer.d.ts +92 -0
  282. package/dist/metrics/trend-analyzer.d.ts.map +1 -0
  283. package/dist/metrics/trend-analyzer.js +293 -0
  284. package/dist/metrics/trend-analyzer.js.map +1 -0
  285. package/dist/metrics/turn-cost-attributor.d.ts +41 -0
  286. package/dist/metrics/turn-cost-attributor.d.ts.map +1 -0
  287. package/dist/metrics/turn-cost-attributor.js +118 -0
  288. package/dist/metrics/turn-cost-attributor.js.map +1 -0
  289. package/dist/metrics/turn-tracker.d.ts +49 -0
  290. package/dist/metrics/turn-tracker.d.ts.map +1 -0
  291. package/dist/metrics/turn-tracker.js +192 -0
  292. package/dist/metrics/turn-tracker.js.map +1 -0
  293. package/dist/platforms/amazon-q-adapter.d.ts +10 -0
  294. package/dist/platforms/amazon-q-adapter.d.ts.map +1 -0
  295. package/dist/platforms/amazon-q-adapter.js +75 -0
  296. package/dist/platforms/amazon-q-adapter.js.map +1 -0
  297. package/dist/platforms/claude-code-adapter.d.ts +10 -0
  298. package/dist/platforms/claude-code-adapter.d.ts.map +1 -0
  299. package/dist/platforms/claude-code-adapter.js +48 -0
  300. package/dist/platforms/claude-code-adapter.js.map +1 -0
  301. package/dist/platforms/continue-adapter.d.ts +10 -0
  302. package/dist/platforms/continue-adapter.d.ts.map +1 -0
  303. package/dist/platforms/continue-adapter.js +73 -0
  304. package/dist/platforms/continue-adapter.js.map +1 -0
  305. package/dist/platforms/copilot-adapter.d.ts +37 -0
  306. package/dist/platforms/copilot-adapter.d.ts.map +1 -0
  307. package/dist/platforms/copilot-adapter.js +66 -0
  308. package/dist/platforms/copilot-adapter.js.map +1 -0
  309. package/dist/platforms/cursor-adapter.d.ts +10 -0
  310. package/dist/platforms/cursor-adapter.d.ts.map +1 -0
  311. package/dist/platforms/cursor-adapter.js +60 -0
  312. package/dist/platforms/cursor-adapter.js.map +1 -0
  313. package/dist/platforms/generic-mcp-adapter.d.ts +113 -0
  314. package/dist/platforms/generic-mcp-adapter.d.ts.map +1 -0
  315. package/dist/platforms/generic-mcp-adapter.js +139 -0
  316. package/dist/platforms/generic-mcp-adapter.js.map +1 -0
  317. package/dist/platforms/index.d.ts +15 -0
  318. package/dist/platforms/index.d.ts.map +1 -0
  319. package/dist/platforms/index.js +12 -0
  320. package/dist/platforms/index.js.map +1 -0
  321. package/dist/platforms/platform-registry.d.ts +11 -0
  322. package/dist/platforms/platform-registry.d.ts.map +1 -0
  323. package/dist/platforms/platform-registry.js +54 -0
  324. package/dist/platforms/platform-registry.js.map +1 -0
  325. package/dist/platforms/types.d.ts +36 -0
  326. package/dist/platforms/types.d.ts.map +1 -0
  327. package/dist/platforms/types.js +2 -0
  328. package/dist/platforms/types.js.map +1 -0
  329. package/dist/platforms/windsurf-adapter.d.ts +10 -0
  330. package/dist/platforms/windsurf-adapter.d.ts.map +1 -0
  331. package/dist/platforms/windsurf-adapter.js +63 -0
  332. package/dist/platforms/windsurf-adapter.js.map +1 -0
  333. package/dist/platforms/zed-adapter.d.ts +10 -0
  334. package/dist/platforms/zed-adapter.d.ts.map +1 -0
  335. package/dist/platforms/zed-adapter.js +72 -0
  336. package/dist/platforms/zed-adapter.js.map +1 -0
  337. package/dist/proxy/index.d.ts +7 -0
  338. package/dist/proxy/index.d.ts.map +1 -0
  339. package/dist/proxy/index.js +5 -0
  340. package/dist/proxy/index.js.map +1 -0
  341. package/dist/proxy/otlp-receiver.d.ts +28 -0
  342. package/dist/proxy/otlp-receiver.d.ts.map +1 -0
  343. package/dist/proxy/otlp-receiver.js +319 -0
  344. package/dist/proxy/otlp-receiver.js.map +1 -0
  345. package/dist/proxy/proxy-manager.d.ts +47 -0
  346. package/dist/proxy/proxy-manager.d.ts.map +1 -0
  347. package/dist/proxy/proxy-manager.js +338 -0
  348. package/dist/proxy/proxy-manager.js.map +1 -0
  349. package/dist/proxy/types.d.ts +72 -0
  350. package/dist/proxy/types.d.ts.map +1 -0
  351. package/dist/proxy/types.js +33 -0
  352. package/dist/proxy/types.js.map +1 -0
  353. package/dist/proxy/upstream-http.d.ts +26 -0
  354. package/dist/proxy/upstream-http.d.ts.map +1 -0
  355. package/dist/proxy/upstream-http.js +209 -0
  356. package/dist/proxy/upstream-http.js.map +1 -0
  357. package/dist/proxy/upstream-stdio.d.ts +25 -0
  358. package/dist/proxy/upstream-stdio.d.ts.map +1 -0
  359. package/dist/proxy/upstream-stdio.js +256 -0
  360. package/dist/proxy/upstream-stdio.js.map +1 -0
  361. package/dist/security/audit-trail.d.ts +74 -0
  362. package/dist/security/audit-trail.d.ts.map +1 -0
  363. package/dist/security/audit-trail.js +338 -0
  364. package/dist/security/audit-trail.js.map +1 -0
  365. package/dist/security/index.d.ts +5 -0
  366. package/dist/security/index.d.ts.map +1 -0
  367. package/dist/security/index.js +4 -0
  368. package/dist/security/index.js.map +1 -0
  369. package/dist/security/ssrf.d.ts +2 -0
  370. package/dist/security/ssrf.d.ts.map +1 -0
  371. package/dist/security/ssrf.js +126 -0
  372. package/dist/security/ssrf.js.map +1 -0
  373. package/dist/server.d.ts +14 -0
  374. package/dist/server.d.ts.map +1 -0
  375. package/dist/server.js +117 -0
  376. package/dist/server.js.map +1 -0
  377. package/dist/shared/__test-utils__/log-output.d.ts +49 -0
  378. package/dist/shared/__test-utils__/log-output.d.ts.map +1 -0
  379. package/dist/shared/__test-utils__/log-output.js +38 -0
  380. package/dist/shared/__test-utils__/log-output.js.map +1 -0
  381. package/dist/shared/config.d.ts +56 -0
  382. package/dist/shared/config.d.ts.map +1 -0
  383. package/dist/shared/config.js +290 -0
  384. package/dist/shared/config.js.map +1 -0
  385. package/dist/shared/errors.d.ts +139 -0
  386. package/dist/shared/errors.d.ts.map +1 -0
  387. package/dist/shared/errors.js +406 -0
  388. package/dist/shared/errors.js.map +1 -0
  389. package/dist/shared/events/factory.d.ts +143 -0
  390. package/dist/shared/events/factory.d.ts.map +1 -0
  391. package/dist/shared/events/factory.js +351 -0
  392. package/dist/shared/events/factory.js.map +1 -0
  393. package/dist/shared/events/index.d.ts +6 -0
  394. package/dist/shared/events/index.d.ts.map +1 -0
  395. package/dist/shared/events/index.js +3 -0
  396. package/dist/shared/events/index.js.map +1 -0
  397. package/dist/shared/events/serialize.d.ts +87 -0
  398. package/dist/shared/events/serialize.d.ts.map +1 -0
  399. package/dist/shared/events/serialize.js +510 -0
  400. package/dist/shared/events/serialize.js.map +1 -0
  401. package/dist/shared/events/types.d.ts +139 -0
  402. package/dist/shared/events/types.d.ts.map +1 -0
  403. package/dist/shared/events/types.js +2 -0
  404. package/dist/shared/events/types.js.map +1 -0
  405. package/dist/shared/harvest/event-buffer.d.ts +59 -0
  406. package/dist/shared/harvest/event-buffer.d.ts.map +1 -0
  407. package/dist/shared/harvest/event-buffer.js +100 -0
  408. package/dist/shared/harvest/event-buffer.js.map +1 -0
  409. package/dist/shared/harvest/harvest-scheduler.d.ts +200 -0
  410. package/dist/shared/harvest/harvest-scheduler.d.ts.map +1 -0
  411. package/dist/shared/harvest/harvest-scheduler.js +647 -0
  412. package/dist/shared/harvest/harvest-scheduler.js.map +1 -0
  413. package/dist/shared/harvest/index.d.ts +7 -0
  414. package/dist/shared/harvest/index.d.ts.map +1 -0
  415. package/dist/shared/harvest/index.js +4 -0
  416. package/dist/shared/harvest/index.js.map +1 -0
  417. package/dist/shared/harvest/metric-aggregator.d.ts +115 -0
  418. package/dist/shared/harvest/metric-aggregator.d.ts.map +1 -0
  419. package/dist/shared/harvest/metric-aggregator.js +247 -0
  420. package/dist/shared/harvest/metric-aggregator.js.map +1 -0
  421. package/dist/shared/index.d.ts +22 -0
  422. package/dist/shared/index.d.ts.map +1 -0
  423. package/dist/shared/index.js +13 -0
  424. package/dist/shared/index.js.map +1 -0
  425. package/dist/shared/logger.d.ts +57 -0
  426. package/dist/shared/logger.d.ts.map +1 -0
  427. package/dist/shared/logger.js +166 -0
  428. package/dist/shared/logger.js.map +1 -0
  429. package/dist/shared/pricing-data.d.ts +4 -0
  430. package/dist/shared/pricing-data.d.ts.map +1 -0
  431. package/dist/shared/pricing-data.js +473 -0
  432. package/dist/shared/pricing-data.js.map +1 -0
  433. package/dist/shared/pricing.d.ts +148 -0
  434. package/dist/shared/pricing.d.ts.map +1 -0
  435. package/dist/shared/pricing.js +528 -0
  436. package/dist/shared/pricing.js.map +1 -0
  437. package/dist/shared/redact.d.ts +33 -0
  438. package/dist/shared/redact.d.ts.map +1 -0
  439. package/dist/shared/redact.js +110 -0
  440. package/dist/shared/redact.js.map +1 -0
  441. package/dist/shared/timing.d.ts +96 -0
  442. package/dist/shared/timing.d.ts.map +1 -0
  443. package/dist/shared/timing.js +173 -0
  444. package/dist/shared/timing.js.map +1 -0
  445. package/dist/shared/tokens.d.ts +145 -0
  446. package/dist/shared/tokens.d.ts.map +1 -0
  447. package/dist/shared/tokens.js +492 -0
  448. package/dist/shared/tokens.js.map +1 -0
  449. package/dist/shared/transport/events-api.d.ts +14 -0
  450. package/dist/shared/transport/events-api.d.ts.map +1 -0
  451. package/dist/shared/transport/events-api.js +29 -0
  452. package/dist/shared/transport/events-api.js.map +1 -0
  453. package/dist/shared/transport/http-client.d.ts +49 -0
  454. package/dist/shared/transport/http-client.d.ts.map +1 -0
  455. package/dist/shared/transport/http-client.js +381 -0
  456. package/dist/shared/transport/http-client.js.map +1 -0
  457. package/dist/shared/transport/index.d.ts +10 -0
  458. package/dist/shared/transport/index.d.ts.map +1 -0
  459. package/dist/shared/transport/index.js +6 -0
  460. package/dist/shared/transport/index.js.map +1 -0
  461. package/dist/shared/transport/logs-api.d.ts +29 -0
  462. package/dist/shared/transport/logs-api.d.ts.map +1 -0
  463. package/dist/shared/transport/logs-api.js +40 -0
  464. package/dist/shared/transport/logs-api.js.map +1 -0
  465. package/dist/shared/transport/metric-api.d.ts +9 -0
  466. package/dist/shared/transport/metric-api.d.ts.map +1 -0
  467. package/dist/shared/transport/metric-api.js +39 -0
  468. package/dist/shared/transport/metric-api.js.map +1 -0
  469. package/dist/shared/transport/otlp-event-bridge.d.ts +22 -0
  470. package/dist/shared/transport/otlp-event-bridge.d.ts.map +1 -0
  471. package/dist/shared/transport/otlp-event-bridge.js +50 -0
  472. package/dist/shared/transport/otlp-event-bridge.js.map +1 -0
  473. package/dist/shared/transport/otlp-shared.d.ts +14 -0
  474. package/dist/shared/transport/otlp-shared.d.ts.map +1 -0
  475. package/dist/shared/transport/otlp-shared.js +49 -0
  476. package/dist/shared/transport/otlp-shared.js.map +1 -0
  477. package/dist/shared/transport/otlp-transport.d.ts +58 -0
  478. package/dist/shared/transport/otlp-transport.d.ts.map +1 -0
  479. package/dist/shared/transport/otlp-transport.js +236 -0
  480. package/dist/shared/transport/otlp-transport.js.map +1 -0
  481. package/dist/shared/transport/types.d.ts +129 -0
  482. package/dist/shared/transport/types.d.ts.map +1 -0
  483. package/dist/shared/transport/types.js +2 -0
  484. package/dist/shared/transport/types.js.map +1 -0
  485. package/dist/shared/version.d.ts +2 -0
  486. package/dist/shared/version.d.ts.map +1 -0
  487. package/dist/shared/version.js +2 -0
  488. package/dist/shared/version.js.map +1 -0
  489. package/dist/storage/index.d.ts +7 -0
  490. package/dist/storage/index.d.ts.map +1 -0
  491. package/dist/storage/index.js +4 -0
  492. package/dist/storage/index.js.map +1 -0
  493. package/dist/storage/local-store.d.ts +153 -0
  494. package/dist/storage/local-store.d.ts.map +1 -0
  495. package/dist/storage/local-store.js +719 -0
  496. package/dist/storage/local-store.js.map +1 -0
  497. package/dist/storage/retention.d.ts +2 -0
  498. package/dist/storage/retention.d.ts.map +1 -0
  499. package/dist/storage/retention.js +53 -0
  500. package/dist/storage/retention.js.map +1 -0
  501. package/dist/storage/session-store.d.ts +97 -0
  502. package/dist/storage/session-store.d.ts.map +1 -0
  503. package/dist/storage/session-store.js +391 -0
  504. package/dist/storage/session-store.js.map +1 -0
  505. package/dist/storage/types.d.ts +64 -0
  506. package/dist/storage/types.d.ts.map +1 -0
  507. package/dist/storage/types.js +2 -0
  508. package/dist/storage/types.js.map +1 -0
  509. package/dist/storage/weekly-summary.d.ts +61 -0
  510. package/dist/storage/weekly-summary.d.ts.map +1 -0
  511. package/dist/storage/weekly-summary.js +243 -0
  512. package/dist/storage/weekly-summary.js.map +1 -0
  513. package/dist/tools/analytics-tools.d.ts +101 -0
  514. package/dist/tools/analytics-tools.d.ts.map +1 -0
  515. package/dist/tools/analytics-tools.js +71 -0
  516. package/dist/tools/analytics-tools.js.map +1 -0
  517. package/dist/tools/cost-tools.d.ts +121 -0
  518. package/dist/tools/cost-tools.d.ts.map +1 -0
  519. package/dist/tools/cost-tools.js +174 -0
  520. package/dist/tools/cost-tools.js.map +1 -0
  521. package/dist/tools/cross-session-tools.d.ts +376 -0
  522. package/dist/tools/cross-session-tools.d.ts.map +1 -0
  523. package/dist/tools/cross-session-tools.js +820 -0
  524. package/dist/tools/cross-session-tools.js.map +1 -0
  525. package/dist/tools/extended-analytics-tools.d.ts +164 -0
  526. package/dist/tools/extended-analytics-tools.d.ts.map +1 -0
  527. package/dist/tools/extended-analytics-tools.js +121 -0
  528. package/dist/tools/extended-analytics-tools.js.map +1 -0
  529. package/dist/tools/index.d.ts +7 -0
  530. package/dist/tools/index.d.ts.map +1 -0
  531. package/dist/tools/index.js +4 -0
  532. package/dist/tools/index.js.map +1 -0
  533. package/dist/tools/session-stats.d.ts +162 -0
  534. package/dist/tools/session-stats.d.ts.map +1 -0
  535. package/dist/tools/session-stats.js +1054 -0
  536. package/dist/tools/session-stats.js.map +1 -0
  537. package/dist/tools/workflow-tools.d.ts +126 -0
  538. package/dist/tools/workflow-tools.d.ts.map +1 -0
  539. package/dist/tools/workflow-tools.js +274 -0
  540. package/dist/tools/workflow-tools.js.map +1 -0
  541. package/dist/tracing/mcp-tracer.d.ts +4 -0
  542. package/dist/tracing/mcp-tracer.d.ts.map +1 -0
  543. package/dist/tracing/mcp-tracer.js +14 -0
  544. package/dist/tracing/mcp-tracer.js.map +1 -0
  545. package/dist/tracing/session-span.d.ts +14 -0
  546. package/dist/tracing/session-span.d.ts.map +1 -0
  547. package/dist/tracing/session-span.js +53 -0
  548. package/dist/tracing/session-span.js.map +1 -0
  549. package/dist/tracing/task-span-tracker.d.ts +11 -0
  550. package/dist/tracing/task-span-tracker.d.ts.map +1 -0
  551. package/dist/tracing/task-span-tracker.js +59 -0
  552. package/dist/tracing/task-span-tracker.js.map +1 -0
  553. package/dist/tracing/tool-call-span.d.ts +4 -0
  554. package/dist/tracing/tool-call-span.d.ts.map +1 -0
  555. package/dist/tracing/tool-call-span.js +60 -0
  556. package/dist/tracing/tool-call-span.js.map +1 -0
  557. package/dist/transport/index.d.ts +3 -0
  558. package/dist/transport/index.d.ts.map +1 -0
  559. package/dist/transport/index.js +2 -0
  560. package/dist/transport/index.js.map +1 -0
  561. package/dist/transport/log-ingest.d.ts +42 -0
  562. package/dist/transport/log-ingest.d.ts.map +1 -0
  563. package/dist/transport/log-ingest.js +151 -0
  564. package/dist/transport/log-ingest.js.map +1 -0
  565. package/dist/transport/nr-ingest.d.ts +171 -0
  566. package/dist/transport/nr-ingest.d.ts.map +1 -0
  567. package/dist/transport/nr-ingest.js +659 -0
  568. package/dist/transport/nr-ingest.js.map +1 -0
  569. package/dist/types.d.ts +45 -0
  570. package/dist/types.d.ts.map +1 -0
  571. package/dist/types.js +2 -0
  572. package/dist/types.js.map +1 -0
  573. package/dist/web/assets/index-BrL281N-.css +2 -0
  574. package/dist/web/assets/index-CcaYZzXm.js +42 -0
  575. package/dist/web/favicon.svg +15 -0
  576. package/dist/web/index.html +15 -0
  577. package/examples/local-alert-rules.json +106 -0
  578. package/package.json +125 -1
package/README.md ADDED
@@ -0,0 +1,498 @@
1
+ # NR AI Coding Observability: Preflight
2
+
3
+ **Observability for AI coding assistants.** Captures every action your AI coding tool takes — file reads, edits, commands, searches — and sends the data to New Relic so you can see exactly what's happening, how much it costs, and where it's wasting time.
4
+
5
+ Think of it like Google Analytics for your AI pair programmer.
6
+
7
+ ## What It Does
8
+
9
+ - **Tracks every action** — sees every file the AI reads, every command it runs, every edit it makes
10
+ - **Tracks costs** — calculates USD spend per session, day, and week, broken down by model
11
+ - **Detects waste** — catches inefficiencies like re-reading the same file repeatedly, making edits without reading first, or running the same failing command in a loop
12
+ - **Measures efficiency** — computes a 0-100 score per task based on how directly the AI worked toward the goal
13
+ - **Sends to New Relic** — all data lands in your NR account as queryable events and metrics, ready for dashboards and alerts
14
+
15
+ ---
16
+
17
+ ## Before You Start
18
+
19
+ Two things are always required. A New Relic account is optional — the tool works in [local mode](#local-mode) without one.
20
+
21
+ ### 1. An AI coding tool
22
+
23
+ This works with **Claude Code**, Cursor, Windsurf, GitHub Copilot, Zed, Continue.dev, or Amazon Q Developer. The examples below use Claude Code, which has the deepest integration.
24
+
25
+ ### 2. Node.js v22 or higher (v24 recommended)
26
+
27
+ Open a terminal and run:
28
+
29
+ ```bash
30
+ node --version
31
+ ```
32
+
33
+ If it shows `v22.x.x` or higher, you're set. v24 is recommended (and what the project uses for development). If you need to upgrade, install it from [nodejs.org](https://nodejs.org) or via nvm:
34
+
35
+ ```bash
36
+ nvm install 24 && nvm use 24
37
+ ```
38
+
39
+ ### 3. A New Relic account (optional)
40
+
41
+ > Skip this section if you plan to use [local mode](#local-mode) — no NR account needed.
42
+
43
+ To send telemetry to New Relic, you need two keys:
44
+
45
+ | Key | What it does | Where to find it |
46
+ | ---------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
47
+ | **License key** | Sends telemetry data _into_ NR (ingest) | NR One → top-right menu → API keys → create a key of type **License**. Long hex string ending in `NRAL`. Not `NRAK-`. |
48
+ | **User API key** | Deploys dashboards and alerts _into_ NR | NR One → top-right menu → API keys → create a key of type **User**. Starts with `NRAK-`. Only needed for the deploy commands. |
49
+
50
+ You'll also need your **Account ID** — a number visible in the URL when you're logged into NR One: `https://one.newrelic.com/nr1-core?account=`**`12345`**.
51
+
52
+ **Data ingest:** this tool is free and open source, but the telemetry it sends counts against your NR data ingest. Standard ingest rates apply on paid plans. Monitor your usage in **NR One → Data Management → Data Ingestion**.
53
+
54
+ ---
55
+
56
+ ## Quick Start
57
+
58
+ **Step 1 — Install**
59
+
60
+ ```bash
61
+ npm install -g @newrelic/preflight
62
+ ```
63
+
64
+ **Step 2 — Run the interactive setup wizard**
65
+
66
+ ```bash
67
+ preflight setup
68
+ ```
69
+
70
+ The wizard first asks for a mode: choose **cloud** to send telemetry to New Relic, or **local** for offline dashboard-only use. In cloud mode it then asks for your license key, account ID, region (US, EU, FedRAMP), and optionally a user API key. It validates keys live before continuing and pre-fills your developer name from the email on the API key. Most people are running in under 5 minutes.
71
+
72
+ If `NEW_RELIC_LICENSE_KEY`, `NEW_RELIC_ACCOUNT_ID`, or `NEW_RELIC_API_KEY` are already set in your shell environment, the wizard detects them and lets you press Enter to accept — no copy-paste needed.
73
+
74
+ Prefer non-interactive? Skip the wizard and run:
75
+
76
+ ```bash
77
+ preflight install \
78
+ --license-key YOUR_LICENSE_KEY \
79
+ --account-id YOUR_ACCOUNT_ID
80
+ ```
81
+
82
+ This installs the hook scripts in your Claude Code settings and registers the MCP server in `~/.mcp.json`, so every tool call is captured and the `nr_observe_*` tools are available in Claude Code. You only run this once.
83
+
84
+ **Step 3 — Deploy dashboards** _(optional but recommended)_
85
+
86
+ Replace `NRAK-...` with your user API key and `12345` with your account ID:
87
+
88
+ ```bash
89
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
90
+ preflight deploy-dashboards --all
91
+ ```
92
+
93
+ This creates 7 dashboards in your NR account. Find them under **Dashboards** → search "AI Coding". The deploy commands ship with the package — both `preflight deploy-dashboards` and `preflight deploy-alerts` are available immediately after `npm install -g`.
94
+
95
+ > **Region:** Use your account's license key and account ID for your environment. Add `--eu` for EU region accounts or `--gov` for FedRAMP accounts. Omit both flags for standard production (`one.newrelic.com`).
96
+
97
+ **Step 4 — Restart Claude Code and verify**
98
+
99
+ Restart Claude Code, then verify the MCP server connected:
100
+
101
+ > _Can you call the `nr_observe_health` tool and show me the result?_
102
+
103
+ You should see `"status": "ok"` with a version and uptime. Then make any request to Claude Code (triggering at least one tool call), and check session tracking:
104
+
105
+ > _Can you call the `nr_observe_get_session_stats` tool and show me the result?_
106
+
107
+ If you get back tool call counts and timing data, it's working.
108
+
109
+ ---
110
+
111
+ ## From source / contributing
112
+
113
+ This is also the current install path until the npm package is published. Use it to develop the project, deploy dashboards/alerts, or stay on the latest unreleased changes:
114
+
115
+ ```bash
116
+ git clone https://github.com/newrelic-experimental/preflight
117
+ cd preflight
118
+ nvm use # Switch to the right Node version (24+)
119
+ npm install # Install all dependencies
120
+ npm run build # Compile TypeScript
121
+ npm link # Register preflight binary on PATH (required for hooks)
122
+ ```
123
+
124
+ Then run `preflight setup` exactly as in the Quick Start.
125
+
126
+ > **`npm link` permission error?** If you see `EACCES: permission denied` pointing at `/usr/local/lib/node_modules`, your system Node.js is installed in a root-owned directory. Pick one fix:
127
+ >
128
+ > _Quick fix — set a user-writable npm prefix (keeps your existing Node.js):_
129
+ >
130
+ > ```bash
131
+ > npm config set prefix ~/.npm-global
132
+ > export PATH="$HOME/.npm-global/bin:$PATH" # also add to ~/.zshrc or ~/.bash_profile
133
+ > npm link
134
+ > ```
135
+ >
136
+ > _Recommended — use nvm (better if you switch Node versions):_
137
+ >
138
+ > ```bash
139
+ > curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
140
+ > # restart your shell, then:
141
+ > nvm install 24 && nvm use 24
142
+ > npm install && npm run build && npm link
143
+ > ```
144
+ >
145
+ > Do not use `sudo npm link` — it creates root-owned files that break future `npm install` runs.
146
+
147
+ ---
148
+
149
+ ## Talking to Preflight
150
+
151
+ Once installed, Claude Code can query live session data on your behalf. Just ask it in plain English — or use the tool names directly:
152
+
153
+ | What to ask | What you get back |
154
+ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
155
+ | _"Show me my session stats"_ → `nr_observe_get_session_stats` | Tool call counts, success rate, total duration |
156
+ | _"What's my efficiency score?"_ → `nr_observe_get_efficiency_score` | A 0-100 score with a breakdown of where points were lost |
157
+ | _"How much has this session cost?"_ → `nr_observe_get_cost_breakdown` | USD cost broken down by tool type and AI model |
158
+ | _"Any budget warnings?"_ → `nr_observe_get_budget_status` | Current spend vs. your configured caps (if set) |
159
+ | _"Any wasteful patterns?"_ → `nr_observe_get_anti_patterns` | Detected inefficiencies — repeated reads, blind edits, stuck loops |
160
+ | _"Any recommendations?"_ → `nr_observe_get_recommendations` | Personalized suggestions for this session |
161
+ | _"How am I doing this week?"_ → `nr_observe_get_personal_insights` | A narrative coaching report vs. your own historical baseline (requires 2+ weeks of history) |
162
+
163
+ Everything also flows into your New Relic dashboards automatically — you don't have to ask Claude to see it there.
164
+
165
+ ---
166
+
167
+ ## Dashboards
168
+
169
+ After deploying, you'll have seven dashboards in NR One:
170
+
171
+ | Dashboard | What it shows |
172
+ | ----------------------- | --------------------------------------------------------------- |
173
+ | **Overview** | Session stats, efficiency score, cost summary, top tools |
174
+ | **Session Detail** | Every tool call in a specific session, in order |
175
+ | **Personal** | 30-day self-reflection view scoped to one developer |
176
+ | **Team View** | Aggregated cost and efficiency across multiple developers |
177
+ | **Manager View** | Team-level cost by developer with no tool-call content visible |
178
+ | **Platform Comparison** | Side-by-side metrics across Claude Code, Cursor, Windsurf, etc. |
179
+ | **Security Audit** | Audit trail of sensitive file access and destructive commands |
180
+
181
+ ### Personal dashboard
182
+
183
+ Deploy a dashboard pre-filtered to your name (it opens already showing your data):
184
+
185
+ ```bash
186
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
187
+ preflight deploy-dashboards \
188
+ ai-coding-assistant-personal.json --developer your-name
189
+ ```
190
+
191
+ ### Updating or removing dashboards
192
+
193
+ To replace existing dashboards in place after pulling new fixes (preserves the dashboard's GUID and URL), add `--update`:
194
+
195
+ ```bash
196
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
197
+ preflight deploy-dashboards --all --update
198
+ ```
199
+
200
+ To delete the deployed dashboards, add `--teardown`. Dashboards are matched by name; missing ones are skipped:
201
+
202
+ ```bash
203
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
204
+ preflight deploy-dashboards --all --teardown
205
+ ```
206
+
207
+ ### Terraform (IaC alternative)
208
+
209
+ A Terraform module in `terraform/` deploys all 7 dashboards and the full alert policy as an alternative to the deploy scripts — useful for GitOps workflows or when you want state tracking. See [ADVANCED.md — Terraform Deployment](./docs/ADVANCED.md#terraform-deployment) for usage.
210
+
211
+ ---
212
+
213
+ ## Alert Conditions
214
+
215
+ Optional: get notified in NR when something goes wrong.
216
+
217
+ ```bash
218
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
219
+ preflight deploy-alerts
220
+ ```
221
+
222
+ Add `--eu` for EU region accounts or `--gov` for FedRAMP accounts. This creates five alert conditions: daily cost spike, low efficiency score, stuck loop rate, anti-pattern rate, and session cost budget. To remove them, add `--teardown`.
223
+
224
+ To apply changes to alert JSONs without losing the existing policy, add `--update`. This syncs conditions in place (matched by name): updates existing ones, creates new ones, and deletes any that have been removed locally:
225
+
226
+ ```bash
227
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
228
+ preflight deploy-alerts --update
229
+ ```
230
+
231
+ For personal alerts scoped to your developer name:
232
+
233
+ ```bash
234
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
235
+ preflight deploy-alerts --developer your-name
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Configuration
241
+
242
+ The easiest way to configure is through the setup wizard (`preflight setup`). To edit manually, open `~/.newrelic-preflight/config.json`:
243
+
244
+ ```json
245
+ {
246
+ "licenseKey": "aabbccdd...",
247
+ "accountId": "12345",
248
+ "developer": "your-name",
249
+ "sessionBudgetUsd": 1.0,
250
+ "dailyBudgetUsd": 5.0,
251
+ "weeklyBudgetUsd": 20.0
252
+ }
253
+ ```
254
+
255
+ ### Key settings
256
+
257
+ | Setting | What it does | Default |
258
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
259
+ | `developer` | Your identifier on all NR events. Automatically normalized to lowercase with underscores — e.g., "John Doe" → "john_doe". Falls back to `$USER` or your git name if not set. | Inferred |
260
+ | `collectorHost` | Region override: `null` = US (default), `'eu'` = EU, `'gov'` = FedRAMP/GovCloud. The wizard auto-detects from your license key prefix and lets you confirm. | `null` (US) |
261
+ | `nrApiKey` | User API key (`NRAK-...`) for NerdGraph queries (team summaries, dashboard/alert deploy). The wizard prompts for it and validates it live. | Not set |
262
+ | `sessionBudgetUsd` | Emits a warning event at 50%, 80%, 100% of this amount per session | No limit |
263
+ | `dailyBudgetUsd` | Emits a warning event at 50%, 80%, 100% of this amount per day | No limit |
264
+ | `weeklyBudgetUsd` | Emits a warning event at 50%, 80%, 100% of this amount per week | No limit |
265
+ | `retainSessionsDays` | Auto-deletes local session files older than N days | Keep forever |
266
+ | `teamId` | A label **you define** (e.g. `"platform-eng"`, `"my-team"`) stamped on all NR events as `team_id`, enabling cross-developer queries like `WHERE team_id = 'platform-eng'`. This is **not** your NR account ID — it's a free-form slug you choose to identify your team. | Not set |
267
+ | `projectId` | Tags all events with a project name (auto-derived from your git remote URL if not set) | Auto-derived |
268
+ | `digestWebhookUrl` | Slack webhook URL for weekly cost and efficiency summaries | Not set |
269
+
270
+ All settings can also be set via environment variables — see [example.config.js](./example.config.js) for the full annotated reference.
271
+
272
+ ### Validating your config
273
+
274
+ If the MCP server fails to connect, run:
275
+
276
+ ```bash
277
+ preflight validate
278
+ ```
279
+
280
+ This checks your config file for JSON syntax errors, invalid field types, and misspelled or unknown keys — and suggests corrections:
281
+
282
+ ```
283
+ ✗ Error: mode: Invalid enum value. Expected 'cloud' | 'local' | 'both', received 'clod'
284
+ ⚠ Warning: Unknown key "licensekey" — did you mean "licenseKey"?
285
+ ```
286
+
287
+ Pass `--config <path>` to check a file at a non-default location.
288
+
289
+ ### OTLP Transport
290
+
291
+ To export telemetry to other OpenTelemetry-compatible backends (Datadog, Grafana Cloud, Honeycomb, or New Relic's OTLP endpoint), or to enable an inbound OTLP receiver in proxy mode, see [ADVANCED.md](./docs/ADVANCED.md#otlp-transport).
292
+
293
+ ---
294
+
295
+ ## Updating
296
+
297
+ To pull the latest changes and rebuild in one step:
298
+
299
+ ```bash
300
+ preflight update
301
+ ```
302
+
303
+ This runs `git pull` followed by `npm run build` in the repo directory. Restart Claude Code afterwards to pick up the new version.
304
+
305
+ ---
306
+
307
+ ## Uninstalling
308
+
309
+ To remove the Preflight hooks and MCP server from Claude Code:
310
+
311
+ ```bash
312
+ preflight uninstall
313
+ ```
314
+
315
+ This removes the hooks from your user-level Claude Code settings and deregisters the MCP server. A timestamped backup of your settings is saved automatically before any changes are made.
316
+
317
+ If you installed at the project level, add `--project`:
318
+
319
+ ```bash
320
+ preflight uninstall --project
321
+ ```
322
+
323
+ Restart Claude Code after uninstalling for the changes to take effect.
324
+
325
+ ### Removing dashboards and alerts
326
+
327
+ If you deployed dashboards or alerts, tear them down separately:
328
+
329
+ ```bash
330
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
331
+ preflight deploy-dashboards --all --teardown
332
+
333
+ NEW_RELIC_API_KEY=NRAK-... NEW_RELIC_ACCOUNT_ID=12345 \
334
+ preflight deploy-alerts --teardown
335
+ ```
336
+
337
+ ### Removing local data
338
+
339
+ Session history and configuration are stored in `~/.newrelic-preflight/`. To remove everything:
340
+
341
+ ```bash
342
+ rm -rf ~/.newrelic-preflight
343
+ ```
344
+
345
+ ### Unlinking the binary
346
+
347
+ If you registered the CLI globally via `npm link`, remove it with:
348
+
349
+ ```bash
350
+ npm unlink -g @newrelic/preflight
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Local mode
356
+
357
+ If you'd rather not ship telemetry to New Relic, set `mode: 'local'` in your config:
358
+
359
+ ```json
360
+ {
361
+ "mode": "local"
362
+ }
363
+ ```
364
+
365
+ In local mode:
366
+
367
+ - The MCP server does **not** construct `NrIngestManager` and never makes outbound HTTP calls to NR.
368
+ - An embedded dashboard boots at **http://127.0.0.1:7777** (configurable via `dashboard.port` or `NR_AI_DASHBOARD_PORT`).
369
+ - All telemetry stays in `~/.newrelic-preflight/` on your machine.
370
+ - `licenseKey` and `accountId` are not required.
371
+
372
+ **With Claude Code** (default): the server runs via the MCP connection (`--stdio`). You don't launch it manually — Claude Code starts it automatically when you open a session, because `preflight install` registered it as an MCP server. The dashboard stays alive as long as your Claude Code session is open.
373
+
374
+ **Standalone** (no Claude Code required): pass `--local` to run the dashboard server directly, without an MCP transport. Use this to browse the dashboard when Claude Code isn't running, or to observe non-Claude-Code sources that hit the hooks (e.g. scripts using the Anthropic SDK). If the per-session MCP is also installed, only one process owns the dashboard at a time — whichever started first — and the other runs headless.
375
+
376
+ ```bash
377
+ npm run build # build once
378
+ node dist/index.js --local
379
+ # or:
380
+ npm run dev # shortcut: assumes dist/ already built
381
+ npm run dev:all # build + start in one step
382
+ npm run start:local # alias for npm run dev
383
+ ```
384
+
385
+ Open `http://127.0.0.1:7777` in your browser. The process stays alive until you press Ctrl+C.
386
+
387
+ The dashboard has six views:
388
+
389
+ - **Today** — live KPIs, sparkline of tool latencies, recent calls, anti-pattern alerts.
390
+ - **Sessions** — list of past sessions with a per-session timeline of every tool call.
391
+ - **History** — weekly efficiency and daily spend trends.
392
+ - **Audit** — every classified tool call (sensitive file access, destructive commands, external network), with a JSONL export button.
393
+ - **Settings** — edit developer name, team ID, budget caps, and session retention from the browser (no config file editing required).
394
+ - **Alerts** — live budget spend vs. caps, editable personal alert thresholds, and Slack digest configuration.
395
+
396
+ Run `preflight setup` to choose a mode interactively.
397
+
398
+ ---
399
+
400
+ ## Local Alerts
401
+
402
+ Local-mode users get threshold alerting evaluated in-process — no New Relic dependency. Rules live at `~/.newrelic-preflight/alerts/rules.json`; a starter set is copied into place by the setup wizard.
403
+
404
+ For the full list of rule types, channel options, alert log configuration, and live reload behavior, see [ADVANCED.md](./docs/ADVANCED.md#local-alerts).
405
+
406
+ ---
407
+
408
+ ## Weekly Digest
409
+
410
+ Register a Slack webhook to receive a weekly summary every Monday morning:
411
+
412
+ In Claude Code, ask: _"Call `nr_observe_subscribe_digest` with this webhook URL: `https://hooks.slack.com/services/...`"_
413
+
414
+ Or set it in your config file as `digestWebhookUrl`, or configure it directly from the **Alerts** tab in the local dashboard.
415
+
416
+ ---
417
+
418
+ ## Supported Platforms
419
+
420
+ | Platform | How to enable |
421
+ | ------------------ | ------------------------------------------------------ |
422
+ | Claude Code | `preflight install` (automatic) |
423
+ | Cursor | Set `NEW_RELIC_AI_PLATFORM=cursor` in your environment |
424
+ | Windsurf | Set `NEW_RELIC_AI_PLATFORM=windsurf` |
425
+ | GitHub Copilot | Set `NEW_RELIC_AI_PLATFORM=copilot` |
426
+ | Zed | Set `NEW_RELIC_AI_PLATFORM=zed` |
427
+ | Continue.dev | Set `NEW_RELIC_AI_PLATFORM=continue` |
428
+ | Amazon Q Developer | Set `NEW_RELIC_AI_PLATFORM=amazonq` |
429
+
430
+ ---
431
+
432
+ ## Glossary
433
+
434
+ **MCP (Model Context Protocol)** — A standard that lets AI assistants like Claude Code discover and call external tools. Preflight registers itself as an MCP server so Claude Code can call it directly.
435
+
436
+ **License key** — A NR credential for _sending_ data into New Relic. Looks like a long hex string ending in `NRAL`. Found under API Keys in NR One.
437
+
438
+ **User API key** — A NR credential for _reading_ data and managing resources (dashboards, alerts). Starts with `NRAK-`. Create one under API Keys in NR One.
439
+
440
+ **Anti-pattern** — A detected waste pattern. Examples: re-reading the same file multiple times without making changes between reads (the AI lost context and is reloading it), making edits to a file without reading it first (blind edit), running the same failing command in a loop (stuck loop).
441
+
442
+ **Efficiency score** — A 0-100 number per task. High means the AI worked directly toward the goal. Low means wasted tool calls — repeated reads, blind edits, unnecessary backtracking.
443
+
444
+ **Token** — The unit AI models use to measure text length for billing. Roughly 3-4 characters per token. One page of text ≈ 500 tokens.
445
+
446
+ **Hook** — A script that Claude Code calls automatically before and after every tool call. Preflight uses this to capture tool call data without interrupting your workflow.
447
+
448
+ ---
449
+
450
+ ## Requirements
451
+
452
+ - **Node.js**: v22 or higher (`.nvmrc` pins v24 for development)
453
+ - **New Relic account**: free tier works; you need a license key (a user API key is optional — only needed for deploying dashboards and alerts)
454
+ - **An AI coding tool**: Claude Code, Cursor, Windsurf, GitHub Copilot, Zed, Continue.dev, or Amazon Q
455
+
456
+ ---
457
+
458
+ ## Documentation
459
+
460
+ - **[CONTRIBUTING.md](./CONTRIBUTING.md)** — Development setup, architecture, conventions, testing, and end-to-end verification
461
+ - **[ADVANCED.md](./docs/ADVANCED.md)** — OTLP export, local alerts, per-developer alerts, session backfill, Terraform deployment
462
+ - **[COMMANDS_TABLE.md](./docs/COMMANDS_TABLE.md)** — All MCP tools with parameters and return values
463
+ - **[METRICS_TABLE.md](./docs/METRICS_TABLE.md)** — Every event and metric sent to New Relic
464
+ - **[SECURITY.md](./docs/SECURITY.md)** — Security practices and audit trail
465
+
466
+ ---
467
+
468
+ ## For Contributors
469
+
470
+ ### Development setup
471
+
472
+ ```bash
473
+ nvm install && nvm use
474
+ npm install
475
+ npm run build
476
+ npm test
477
+ ```
478
+
479
+ ### Common tasks
480
+
481
+ | Command | Purpose |
482
+ | ---------------------- | ---------------------------------------------------------- |
483
+ | `npm run build` | Build TypeScript server + Vite web dashboard |
484
+ | `npm run build:server` | Build only the TypeScript server (`tsc --build`) |
485
+ | `npm run build:web` | Build only the Vite web dashboard (output: `dist/web/`) |
486
+ | `npm test` | Run all tests |
487
+ | `npm run lint` | Check code style |
488
+ | `npm run format` | Auto-format code |
489
+ | `npm run dev` | Start local dashboard (assumes pre-built `dist/`) |
490
+ | `npm run dev:all` | Build then start local dashboard |
491
+ | `npm run dev:full` | Build backend, then run backend + Vite dev server together |
492
+ | `npm run start:local` | Alias for `npm run dev` |
493
+
494
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full development guide, conventions, and architecture.
495
+
496
+ ---
497
+
498
+ **Questions?** Start with [CONTRIBUTING.md](./CONTRIBUTING.md) or [open an issue](https://github.com/newrelic-experimental/preflight/issues).
@@ -0,0 +1,24 @@
1
+ import type { AlertEvent } from '../dashboard/live-event-bus.js';
2
+ export interface AlertLogOptions {
3
+ readonly path: string;
4
+ readonly maxBytes?: number;
5
+ }
6
+ /**
7
+ * Append-only JSONL log for alert events. One file with one rotation
8
+ * (`<path>.1`). All filesystem I/O is deferred to first append() so the
9
+ * constructor stays cheap and side-effect-free for testing.
10
+ */
11
+ export declare class AlertLog {
12
+ private readonly path;
13
+ private readonly maxBytes;
14
+ private initialized;
15
+ private pending;
16
+ constructor(opts: AlertLogOptions);
17
+ append(event: AlertEvent): Promise<void>;
18
+ readRecent(limit: number): Promise<AlertEvent[]>;
19
+ private doReadRecent;
20
+ rotateIfNeeded(): Promise<void>;
21
+ close(): Promise<void>;
22
+ private ensureInitialized;
23
+ }
24
+ //# sourceMappingURL=alert-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-log.d.ts","sourceRoot":"","sources":["../../src/alerts/alert-log.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAoBjE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAoC;gBAEvC,IAAI,EAAE,eAAe;IAK3B,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBxC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YAexC,YAAY;IA4CpB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAKd,iBAAiB;CAahC"}