@nordhavnhq/runner 0.0.0-stage → 0.95.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 (338) hide show
  1. package/bin/cliclick +0 -0
  2. package/dist/brand.d.ts +5 -0
  3. package/dist/brand.js +18 -0
  4. package/dist/cli/agent.d.ts +9 -0
  5. package/dist/cli/agent.js +80 -0
  6. package/dist/cli/folder.d.ts +2 -0
  7. package/dist/cli/folder.js +103 -0
  8. package/dist/cli/init.d.ts +2 -0
  9. package/dist/cli/init.js +67 -0
  10. package/dist/cli/lifecycle.d.ts +3 -0
  11. package/dist/cli/lifecycle.js +149 -0
  12. package/dist/cli/link.d.ts +42 -0
  13. package/dist/cli/link.js +314 -0
  14. package/dist/cli/logs.d.ts +2 -0
  15. package/dist/cli/logs.js +147 -0
  16. package/dist/cli/prompts.d.ts +7 -0
  17. package/dist/cli/prompts.js +13 -0
  18. package/dist/cli/ps.d.ts +2 -0
  19. package/dist/cli/ps.js +81 -0
  20. package/dist/cli/relay.d.ts +4 -0
  21. package/dist/cli/relay.js +29 -0
  22. package/dist/cli/update.d.ts +6 -0
  23. package/dist/cli/update.js +131 -0
  24. package/dist/config.d.ts +166 -0
  25. package/dist/config.js +383 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +145 -0
  28. package/dist/legacy-env.d.ts +4 -0
  29. package/dist/legacy-env.js +32 -0
  30. package/dist/paths.d.ts +37 -0
  31. package/dist/paths.js +92 -0
  32. package/dist/runtime/daemon.d.ts +57 -0
  33. package/dist/runtime/daemon.js +159 -0
  34. package/dist/runtime/dev-start.d.ts +31 -0
  35. package/dist/runtime/dev-start.js +110 -0
  36. package/dist/runtime/file-claims.d.ts +58 -0
  37. package/dist/runtime/file-claims.js +174 -0
  38. package/dist/runtime/fs-browse.d.ts +18 -0
  39. package/dist/runtime/fs-browse.js +104 -0
  40. package/dist/runtime/fs-checkout.d.ts +154 -0
  41. package/dist/runtime/fs-checkout.js +1049 -0
  42. package/dist/runtime/fs-git-index.d.ts +22 -0
  43. package/dist/runtime/fs-git-index.js +133 -0
  44. package/dist/runtime/fs-git.d.ts +16 -0
  45. package/dist/runtime/fs-git.js +424 -0
  46. package/dist/runtime/git-relay.d.ts +46 -0
  47. package/dist/runtime/git-relay.js +259 -0
  48. package/dist/runtime/git-unpushed.d.ts +36 -0
  49. package/dist/runtime/git-unpushed.js +93 -0
  50. package/dist/runtime/node-version.d.ts +12 -0
  51. package/dist/runtime/node-version.js +39 -0
  52. package/dist/runtime/preview-tunnel.d.ts +16 -0
  53. package/dist/runtime/preview-tunnel.js +135 -0
  54. package/dist/runtime/processes.d.ts +61 -0
  55. package/dist/runtime/processes.js +408 -0
  56. package/dist/runtime/project-node-download.d.ts +17 -0
  57. package/dist/runtime/project-node-download.js +137 -0
  58. package/dist/runtime/project-node.d.ts +65 -0
  59. package/dist/runtime/project-node.js +223 -0
  60. package/dist/runtime/reap-scratch.d.ts +22 -0
  61. package/dist/runtime/reap-scratch.js +112 -0
  62. package/dist/runtime/spill-tool-output.d.ts +14 -0
  63. package/dist/runtime/spill-tool-output.js +84 -0
  64. package/dist/runtime/up.d.ts +6 -0
  65. package/dist/runtime/up.js +1325 -0
  66. package/dist/tools/_coerce.d.ts +2 -0
  67. package/dist/tools/_coerce.js +26 -0
  68. package/dist/tools/_commit-scope.d.ts +14 -0
  69. package/dist/tools/_commit-scope.js +70 -0
  70. package/dist/tools/_jail.d.ts +68 -0
  71. package/dist/tools/_jail.js +209 -0
  72. package/dist/tools/_output.d.ts +24 -0
  73. package/dist/tools/_output.js +48 -0
  74. package/dist/tools/_ripgrep.d.ts +46 -0
  75. package/dist/tools/_ripgrep.js +148 -0
  76. package/dist/tools/_run-worktree.d.ts +10 -0
  77. package/dist/tools/_run-worktree.js +27 -0
  78. package/dist/tools/_shell-words.d.ts +15 -0
  79. package/dist/tools/_shell-words.js +43 -0
  80. package/dist/tools/_sonar/astro.d.ts +6 -0
  81. package/dist/tools/_sonar/astro.js +45 -0
  82. package/dist/tools/_sonar/blade.d.ts +3 -0
  83. package/dist/tools/_sonar/blade.js +53 -0
  84. package/dist/tools/_sonar/build.d.ts +44 -0
  85. package/dist/tools/_sonar/build.js +147 -0
  86. package/dist/tools/_sonar/changed.d.ts +21 -0
  87. package/dist/tools/_sonar/changed.js +230 -0
  88. package/dist/tools/_sonar/diagnose/delta.d.ts +27 -0
  89. package/dist/tools/_sonar/diagnose/delta.js +64 -0
  90. package/dist/tools/_sonar/diagnose/detect.d.ts +39 -0
  91. package/dist/tools/_sonar/diagnose/detect.js +117 -0
  92. package/dist/tools/_sonar/diagnose/index.d.ts +13 -0
  93. package/dist/tools/_sonar/diagnose/index.js +217 -0
  94. package/dist/tools/_sonar/diagnose/lint-worker.d.ts +1 -0
  95. package/dist/tools/_sonar/diagnose/lint-worker.js +48 -0
  96. package/dist/tools/_sonar/diagnose/pool.d.ts +22 -0
  97. package/dist/tools/_sonar/diagnose/pool.js +149 -0
  98. package/dist/tools/_sonar/diagnose/rules.d.ts +23 -0
  99. package/dist/tools/_sonar/diagnose/rules.js +131 -0
  100. package/dist/tools/_sonar/diagnose/types-worker.d.ts +1 -0
  101. package/dist/tools/_sonar/diagnose/types-worker.js +183 -0
  102. package/dist/tools/_sonar/files.d.ts +14 -0
  103. package/dist/tools/_sonar/files.js +121 -0
  104. package/dist/tools/_sonar/graph.d.ts +34 -0
  105. package/dist/tools/_sonar/graph.js +164 -0
  106. package/dist/tools/_sonar/hints.d.ts +116 -0
  107. package/dist/tools/_sonar/hints.js +545 -0
  108. package/dist/tools/_sonar/imports.d.ts +38 -0
  109. package/dist/tools/_sonar/imports.js +275 -0
  110. package/dist/tools/_sonar/index.d.ts +79 -0
  111. package/dist/tools/_sonar/index.js +462 -0
  112. package/dist/tools/_sonar/keys.d.ts +5 -0
  113. package/dist/tools/_sonar/keys.js +248 -0
  114. package/dist/tools/_sonar/laravel-routes.d.ts +15 -0
  115. package/dist/tools/_sonar/laravel-routes.js +263 -0
  116. package/dist/tools/_sonar/laravel.d.ts +64 -0
  117. package/dist/tools/_sonar/laravel.js +326 -0
  118. package/dist/tools/_sonar/location.d.ts +33 -0
  119. package/dist/tools/_sonar/location.js +137 -0
  120. package/dist/tools/_sonar/map.d.ts +43 -0
  121. package/dist/tools/_sonar/map.js +212 -0
  122. package/dist/tools/_sonar/parse.d.ts +3 -0
  123. package/dist/tools/_sonar/parse.js +76 -0
  124. package/dist/tools/_sonar/prewarm.d.ts +9 -0
  125. package/dist/tools/_sonar/prewarm.js +96 -0
  126. package/dist/tools/_sonar/prisma.d.ts +9 -0
  127. package/dist/tools/_sonar/prisma.js +51 -0
  128. package/dist/tools/_sonar/refs.d.ts +7 -0
  129. package/dist/tools/_sonar/refs.js +273 -0
  130. package/dist/tools/_sonar/render.d.ts +66 -0
  131. package/dist/tools/_sonar/render.js +498 -0
  132. package/dist/tools/_sonar/resolve.d.ts +63 -0
  133. package/dist/tools/_sonar/resolve.js +402 -0
  134. package/dist/tools/_sonar/roots.d.ts +4 -0
  135. package/dist/tools/_sonar/roots.js +42 -0
  136. package/dist/tools/_sonar/routes.d.ts +5 -0
  137. package/dist/tools/_sonar/routes.js +247 -0
  138. package/dist/tools/_sonar/serve.d.ts +12 -0
  139. package/dist/tools/_sonar/serve.js +104 -0
  140. package/dist/tools/_sonar/suggest.d.ts +23 -0
  141. package/dist/tools/_sonar/suggest.js +114 -0
  142. package/dist/tools/_sonar/tests.d.ts +21 -0
  143. package/dist/tools/_sonar/tests.js +134 -0
  144. package/dist/tools/_sonar/tsconfig.d.ts +34 -0
  145. package/dist/tools/_sonar/tsconfig.js +188 -0
  146. package/dist/tools/_sonar/types.d.ts +81 -0
  147. package/dist/tools/_sonar/types.js +6 -0
  148. package/dist/tools/_symbols.d.ts +27 -0
  149. package/dist/tools/_symbols.js +461 -0
  150. package/dist/tools/_test-report.d.ts +47 -0
  151. package/dist/tools/_test-report.js +203 -0
  152. package/dist/tools/_touched.d.ts +44 -0
  153. package/dist/tools/_touched.js +195 -0
  154. package/dist/tools/_upload.d.ts +26 -0
  155. package/dist/tools/_upload.js +132 -0
  156. package/dist/tools/_worktree-setup.d.ts +29 -0
  157. package/dist/tools/_worktree-setup.js +204 -0
  158. package/dist/tools/browser.d.ts +2 -0
  159. package/dist/tools/browser.js +8 -0
  160. package/dist/tools/commit-guard.d.ts +44 -0
  161. package/dist/tools/commit-guard.js +165 -0
  162. package/dist/tools/computer.d.ts +13 -0
  163. package/dist/tools/computer.js +952 -0
  164. package/dist/tools/console.d.ts +44 -0
  165. package/dist/tools/console.js +739 -0
  166. package/dist/tools/database.d.ts +28 -0
  167. package/dist/tools/database.js +152 -0
  168. package/dist/tools/filesystem.d.ts +36 -0
  169. package/dist/tools/filesystem.js +506 -0
  170. package/dist/tools/git-tag.d.ts +10 -0
  171. package/dist/tools/git-tag.js +164 -0
  172. package/dist/tools/git.d.ts +52 -0
  173. package/dist/tools/git.js +1272 -0
  174. package/dist/tools/http.d.ts +12 -0
  175. package/dist/tools/http.js +119 -0
  176. package/dist/tools/image.d.ts +8 -0
  177. package/dist/tools/image.js +551 -0
  178. package/dist/tools/index.d.ts +13 -0
  179. package/dist/tools/index.js +58 -0
  180. package/dist/tools/outline.d.ts +20 -0
  181. package/dist/tools/outline.js +98 -0
  182. package/dist/tools/search.d.ts +17 -0
  183. package/dist/tools/search.js +391 -0
  184. package/dist/tools/sonar.d.ts +17 -0
  185. package/dist/tools/sonar.js +231 -0
  186. package/dist/tools/testing.d.ts +36 -0
  187. package/dist/tools/testing.js +273 -0
  188. package/dist/tools/upload.d.ts +8 -0
  189. package/dist/tools/upload.js +106 -0
  190. package/dist/tools/webcam.d.ts +28 -0
  191. package/dist/tools/webcam.js +967 -0
  192. package/dist/update/install-kind.d.ts +35 -0
  193. package/dist/update/install-kind.js +109 -0
  194. package/dist/update/install.d.ts +32 -0
  195. package/dist/update/install.js +187 -0
  196. package/dist/update/manifest.d.ts +18 -0
  197. package/dist/update/manifest.js +73 -0
  198. package/dist/update/peers.d.ts +18 -0
  199. package/dist/update/peers.js +43 -0
  200. package/dist/update/policy.d.ts +20 -0
  201. package/dist/update/policy.js +49 -0
  202. package/dist/update/supervisor.d.ts +25 -0
  203. package/dist/update/supervisor.js +83 -0
  204. package/dist/update/updater.d.ts +44 -0
  205. package/dist/update/updater.js +116 -0
  206. package/dist/utils/format.d.ts +50 -0
  207. package/dist/utils/format.js +190 -0
  208. package/dist/version.d.ts +17 -0
  209. package/dist/version.js +63 -0
  210. package/dist/version.json +5 -0
  211. package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.d.ts +15 -0
  212. package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.js +541 -0
  213. package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.d.ts +25 -0
  214. package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.js +137 -0
  215. package/node_modules/@nordhavnhq/runner-browser/dist/guard.d.ts +21 -0
  216. package/node_modules/@nordhavnhq/runner-browser/dist/guard.js +104 -0
  217. package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.d.ts +47 -0
  218. package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.js +41 -0
  219. package/node_modules/@nordhavnhq/runner-browser/dist/host.d.ts +18 -0
  220. package/node_modules/@nordhavnhq/runner-browser/dist/host.js +15 -0
  221. package/node_modules/@nordhavnhq/runner-browser/dist/index.d.ts +13 -0
  222. package/node_modules/@nordhavnhq/runner-browser/dist/index.js +28 -0
  223. package/node_modules/@nordhavnhq/runner-browser/dist/live-input.d.ts +74 -0
  224. package/node_modules/@nordhavnhq/runner-browser/dist/live-input.js +93 -0
  225. package/node_modules/@nordhavnhq/runner-browser/dist/live-open.d.ts +4 -0
  226. package/node_modules/@nordhavnhq/runner-browser/dist/live-open.js +57 -0
  227. package/node_modules/@nordhavnhq/runner-browser/dist/live.d.ts +148 -0
  228. package/node_modules/@nordhavnhq/runner-browser/dist/live.js +179 -0
  229. package/node_modules/@nordhavnhq/runner-browser/dist/local-live.d.ts +31 -0
  230. package/node_modules/@nordhavnhq/runner-browser/dist/local-live.js +262 -0
  231. package/node_modules/@nordhavnhq/runner-browser/dist/marks.d.ts +36 -0
  232. package/node_modules/@nordhavnhq/runner-browser/dist/marks.js +173 -0
  233. package/node_modules/@nordhavnhq/runner-browser/dist/page-events.d.ts +27 -0
  234. package/node_modules/@nordhavnhq/runner-browser/dist/page-events.js +82 -0
  235. package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.d.ts +13 -0
  236. package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.js +526 -0
  237. package/node_modules/@nordhavnhq/runner-browser/dist/params.d.ts +12 -0
  238. package/node_modules/@nordhavnhq/runner-browser/dist/params.js +32 -0
  239. package/node_modules/@nordhavnhq/runner-browser/dist/pick.d.ts +24 -0
  240. package/node_modules/@nordhavnhq/runner-browser/dist/pick.js +76 -0
  241. package/node_modules/@nordhavnhq/runner-browser/dist/session.d.ts +225 -0
  242. package/node_modules/@nordhavnhq/runner-browser/dist/session.js +507 -0
  243. package/node_modules/@nordhavnhq/runner-browser/dist/shots.d.ts +11 -0
  244. package/node_modules/@nordhavnhq/runner-browser/dist/shots.js +103 -0
  245. package/node_modules/@nordhavnhq/runner-browser/dist/show.d.ts +10 -0
  246. package/node_modules/@nordhavnhq/runner-browser/dist/show.js +190 -0
  247. package/node_modules/@nordhavnhq/runner-browser/dist/target.d.ts +37 -0
  248. package/node_modules/@nordhavnhq/runner-browser/dist/target.js +82 -0
  249. package/node_modules/@nordhavnhq/runner-browser/dist/tour.d.ts +19 -0
  250. package/node_modules/@nordhavnhq/runner-browser/dist/tour.js +178 -0
  251. package/node_modules/@nordhavnhq/runner-browser/package.json +18 -0
  252. package/node_modules/@nordhavnhq/runner-runtime/dist/config.d.ts +96 -0
  253. package/node_modules/@nordhavnhq/runner-runtime/dist/config.js +25 -0
  254. package/node_modules/@nordhavnhq/runner-runtime/dist/connection.d.ts +276 -0
  255. package/node_modules/@nordhavnhq/runner-runtime/dist/connection.js +507 -0
  256. package/node_modules/@nordhavnhq/runner-runtime/dist/constants.d.ts +48 -0
  257. package/node_modules/@nordhavnhq/runner-runtime/dist/constants.js +95 -0
  258. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.d.ts +94 -0
  259. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.js +219 -0
  260. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.d.ts +136 -0
  261. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.js +214 -0
  262. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.d.ts +735 -0
  263. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.js +40 -0
  264. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.d.ts +362 -0
  265. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.js +703 -0
  266. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.d.ts +105 -0
  267. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.js +202 -0
  268. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.d.ts +204 -0
  269. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.js +497 -0
  270. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.d.ts +45 -0
  271. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.js +176 -0
  272. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.d.ts +74 -0
  273. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.js +72 -0
  274. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.d.ts +59 -0
  275. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.js +117 -0
  276. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.d.ts +62 -0
  277. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.js +84 -0
  278. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.d.ts +27 -0
  279. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.js +80 -0
  280. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.d.ts +22 -0
  281. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.js +22 -0
  282. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.d.ts +595 -0
  283. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.js +85 -0
  284. package/node_modules/@nordhavnhq/runner-runtime/dist/index.d.ts +43 -0
  285. package/node_modules/@nordhavnhq/runner-runtime/dist/index.js +50 -0
  286. package/node_modules/@nordhavnhq/runner-runtime/dist/inference.d.ts +135 -0
  287. package/node_modules/@nordhavnhq/runner-runtime/dist/inference.js +945 -0
  288. package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.d.ts +67 -0
  289. package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.js +47 -0
  290. package/node_modules/@nordhavnhq/runner-runtime/dist/platform.d.ts +21 -0
  291. package/node_modules/@nordhavnhq/runner-runtime/dist/platform.js +25 -0
  292. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.d.ts +39 -0
  293. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.js +67 -0
  294. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.d.ts +61 -0
  295. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.js +58 -0
  296. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.d.ts +23 -0
  297. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.js +42 -0
  298. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.d.ts +6 -0
  299. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.js +12 -0
  300. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.d.ts +150 -0
  301. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.js +36 -0
  302. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.d.ts +14 -0
  303. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.js +49 -0
  304. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.d.ts +109 -0
  305. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.js +894 -0
  306. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.d.ts +73 -0
  307. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.js +765 -0
  308. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.d.ts +246 -0
  309. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.js +621 -0
  310. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.d.ts +88 -0
  311. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.js +188 -0
  312. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.d.ts +15 -0
  313. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.js +10 -0
  314. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.d.ts +16 -0
  315. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.js +97 -0
  316. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.d.ts +22 -0
  317. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.js +47 -0
  318. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.d.ts +26 -0
  319. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.js +48 -0
  320. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.d.ts +8 -0
  321. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.js +19 -0
  322. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.d.ts +76 -0
  323. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.js +155 -0
  324. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.d.ts +43 -0
  325. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.js +37 -0
  326. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.d.ts +49 -0
  327. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.js +104 -0
  328. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.d.ts +16 -0
  329. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.js +6 -0
  330. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.d.ts +86 -0
  331. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.js +141 -0
  332. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.d.ts +179 -0
  333. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.js +35 -0
  334. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.d.ts +21 -0
  335. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.js +179 -0
  336. package/node_modules/@nordhavnhq/runner-runtime/package.json +18 -0
  337. package/package.json +33 -4
  338. package/README.md +0 -3
@@ -0,0 +1,326 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join, posix } from 'node:path';
3
+ const KINDS = new Set(['view', 'x', 'livewire', 'config', 'lang', 'asset', 'inertia']);
4
+ /** Longest stretch one call's arguments are read over (an unclosed call stops there). */
5
+ const MAX_CALL_CHARS = 2000;
6
+ // ─── Call arguments ─────────────────────────
7
+ /** Index after the PHP string starting at `i` (its quote); strings may span lines. */
8
+ function skipString(src, i, quote, end) {
9
+ let j = i + 1;
10
+ while (j < end && src[j] !== quote)
11
+ j += src[j] === '\\' ? 2 : 1;
12
+ return j + 1;
13
+ }
14
+ /** The top-level arguments of the call (or array) whose opening bracket is at `open`, trimmed. */
15
+ export function callArgs(src, open) {
16
+ const args = [];
17
+ const end = Math.min(src.length, open + MAX_CALL_CHARS);
18
+ let depth = 0;
19
+ let start = open + 1;
20
+ for (let i = open; i < end; i++) {
21
+ const c = src[i];
22
+ if (c === '"' || c === '\'') {
23
+ i = skipString(src, i, c, end) - 1;
24
+ continue;
25
+ }
26
+ if ('([{'.includes(c)) {
27
+ depth++;
28
+ continue;
29
+ }
30
+ if (')]}'.includes(c)) {
31
+ if (--depth === 0) {
32
+ args.push(src.slice(start, i).trim());
33
+ break;
34
+ }
35
+ continue;
36
+ }
37
+ if (c === ',' && depth === 1) {
38
+ args.push(src.slice(start, i).trim());
39
+ start = i + 1;
40
+ }
41
+ }
42
+ while (args.length > 0 && !args[args.length - 1])
43
+ args.pop();
44
+ return args;
45
+ }
46
+ /** The value of a plain PHP string literal, or null (a variable, an interpolated string, an expression). */
47
+ export function phpString(arg) {
48
+ const m = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/s.exec(arg?.trim() ?? '');
49
+ if (!m || (m[1] === '"' && m[2].includes('$')))
50
+ return null;
51
+ return m[2].replace(/\\\\/g, '\\').replace(/\\'/g, '\'');
52
+ }
53
+ /** The string literals of `'a'` or `['a', 'b']`. */
54
+ export function phpStrings(arg) {
55
+ const one = phpString(arg);
56
+ if (one !== null)
57
+ return [one];
58
+ const t = arg?.trim() ?? '';
59
+ if (!t.startsWith('[') || !t.endsWith(']'))
60
+ return [];
61
+ return callArgs(t, 0).map(phpString).filter((s) => s !== null);
62
+ }
63
+ // ─── Specifiers ─────────────────────────────
64
+ /** A string literal turned into the specifier of `kind`, or null when it is not a plain name. */
65
+ export function laravelSpec(kind, value) {
66
+ const v = value.trim();
67
+ if (kind === 'config') {
68
+ const file = /^([\w-]+)(?:\.|$)/.exec(v)?.[1];
69
+ return file ? { spec: `config:${file}`, weak: true } : null;
70
+ }
71
+ if (kind === 'lang') {
72
+ const file = /^([\w/-]+)\.\w/.exec(v)?.[1];
73
+ return file && !v.includes('::') ? { spec: `lang:${file}`, weak: true } : null;
74
+ }
75
+ if (kind === 'asset')
76
+ return /^[\w./@-]+$/.test(v) ? { spec: `asset:${v}` } : null;
77
+ if (!/^[\w.:/-]+$/.test(v))
78
+ return null;
79
+ // Package components (icon sets and the like) carry no prefix: a miss is not worth reporting.
80
+ return kind === 'x' ? { spec: `x:${v}`, weak: true } : { spec: `${kind}:${v}` };
81
+ }
82
+ /** Calls PHP code (and Blade's inline PHP) names a view, config or lang file, or an Inertia page with. */
83
+ const PHP_CALLS = [
84
+ { re: /(?:(?<![\w$])view|\bView::(?:make|first)|->(?:markdown|layout|extends))\s*\(/g, kind: 'view', args: [0] },
85
+ { re: /\bRoute::view\s*\(/g, kind: 'view', args: [1] },
86
+ { re: /(?:\bInertia::render|(?<![\w$>:])inertia)\s*\(/g, kind: 'inertia', args: [0] },
87
+ { re: /\bRoute::inertia\s*\(/g, kind: 'inertia', args: [1] },
88
+ { re: /(?:(?<![\w$>:])config(?:\s*\(\s*\)\s*->\s*\w+)?|\bConfig::\w+)\s*\(/g, kind: 'config', args: [0] },
89
+ { re: /(?:(?<![\w$>:])(?:__|trans|trans_choice)|\bLang::(?:get|choice|has))\s*\(/g, kind: 'lang', args: [0] },
90
+ ];
91
+ /** Blade directives that name a view, a Livewire component, a lang file or a Vite entry. */
92
+ export const BLADE_CALLS = [
93
+ { re: /(?<![@\w])@(?:extends|include|includeIf|includeIsolated|includeFirst|component)\s*\(/g, kind: 'view', args: [0] },
94
+ { re: /(?<![@\w])@(?:includeWhen|includeUnless)\s*\(/g, kind: 'view', args: [1] },
95
+ { re: /(?<![@\w])@each\s*\(/g, kind: 'view', args: [0, 3] },
96
+ { re: /(?<![@\w])@livewire\s*\(/g, kind: 'livewire', args: [0] },
97
+ { re: /(?<![@\w])@(?:lang|choice)\s*\(/g, kind: 'lang', args: [0] },
98
+ { re: /(?<![@\w])@vite\s*\(/g, kind: 'asset', args: [0] },
99
+ ];
100
+ /** The specifiers a set of call rules finds in `code`. */
101
+ export function scanCalls(code, rules) {
102
+ const out = [];
103
+ for (const rule of rules) {
104
+ for (const m of code.matchAll(rule.re)) {
105
+ const args = callArgs(code, m.index + m[0].length - 1);
106
+ for (const at of rule.args) {
107
+ for (const value of phpStrings(args[at])) {
108
+ const imp = laravelSpec(rule.kind, value);
109
+ if (imp)
110
+ out.push(imp);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return out;
116
+ }
117
+ // ─── PHP files ──────────────────────────────
118
+ const NOT_CLASSES = new Set(['self', 'static', 'parent', 'Closure', 'Exception', 'Throwable', 'Error', 'Generator', 'Traversable', 'Iterator', 'Stringable']);
119
+ /** Short class names used inline: `new Foo`, `Foo::x`, `instanceof Foo`, return types. */
120
+ const NAME_USES = [
121
+ /\bnew\s+([A-Z]\w*)(?![\w\\])/g,
122
+ /(?<![\w\\$>:])([A-Z]\w*)\s*::/g,
123
+ /\binstanceof\s+([A-Z]\w*)(?![\w\\])/g,
124
+ /\)\s*:\s*\??([A-Z]\w*)(?![\w\\])/g,
125
+ ];
126
+ /** `Foo $x` parameter, property and promoted-constructor types. */
127
+ const TYPE_HINT = /(?<![\w\\$>:])([A-Z]\w*)(?=\s+&?\s*(?:\.\.\.)?\$\w)/g;
128
+ const CLASS_LISTS = /\b(?:extends|implements)\s+([\w\\,\s]+?)(?=\s*(?:\{|\bimplements\b))/g;
129
+ const CATCHES = /\bcatch\s*\(([^)$]+)/g;
130
+ function namesUsed(code, blade) {
131
+ const names = new Set();
132
+ // Blade is mostly HTML: only the forms that cannot be prose.
133
+ const rules = blade ? NAME_USES.slice(0, 2) : [...NAME_USES, TYPE_HINT];
134
+ for (const re of rules)
135
+ for (const m of code.matchAll(re))
136
+ names.add(m[1]);
137
+ if (blade)
138
+ return names;
139
+ for (const re of [CLASS_LISTS, CATCHES]) {
140
+ for (const m of code.matchAll(re)) {
141
+ for (const part of m[1].split(/[,|]/)) {
142
+ const name = part.trim();
143
+ if (/^[A-Z]\w*$/.test(name))
144
+ names.add(name);
145
+ }
146
+ }
147
+ }
148
+ return names;
149
+ }
150
+ /**
151
+ * Classes used by their short name without a `use`: in a namespace they are
152
+ * the namespace's own (`App\Models\Foo`), outside one (routes, Blade) a
153
+ * global class or a config/app.php alias (`Foo`). Weak: a miss is a PHP or
154
+ * vendor class, nothing to report.
155
+ */
156
+ export function scanClassUses(code, scope) {
157
+ const out = [];
158
+ for (const name of namesUsed(code, scope.blade)) {
159
+ if (NOT_CLASSES.has(name) || scope.imported.has(name) || scope.declared.includes(name))
160
+ continue;
161
+ out.push({ spec: scope.namespace ? `${scope.namespace}\\${name}` : name, weak: true });
162
+ }
163
+ // `\Foo` in a namespace: a global class or an alias.
164
+ if (scope.namespace)
165
+ for (const m of code.matchAll(/(?<![\w\\$])\\([A-Z]\w*)(?![\w\\])/g))
166
+ out.push({ spec: m[1], weak: true });
167
+ return out;
168
+ }
169
+ /** `'FooController@index'` / `'Admin\\UserController'` in a route file: the default controller namespace. */
170
+ function scanRouteStrings(code) {
171
+ const out = [];
172
+ for (const m of code.matchAll(/(['"])((?:[A-Z]\w*\\{1,2})*[A-Z]\w*Controller)(?:@\w+)?\1/g)) {
173
+ out.push({ spec: `App\\Http\\Controllers\\${m[2].replace(/\\\\/g, '\\')}`, weak: true });
174
+ }
175
+ return out;
176
+ }
177
+ /** Laravel's by-name references in PHP code: `code` has comments blanked, `raw` is the source. */
178
+ export function scanLaravelPhp(code, raw, path, blade = false) {
179
+ const out = scanCalls(code, PHP_CALLS);
180
+ // In Blade, `view: 'grid'` is far more likely an Alpine object than a named argument.
181
+ if (blade)
182
+ return out;
183
+ // Mailable `new Content(view: 'emails.x')` and notification named arguments.
184
+ for (const m of code.matchAll(/(?<![\w$])(?:view|markdown)\s*:\s*(['"])([\w.:/-]+)\1/g))
185
+ out.push({ spec: `view:${m[2]}` });
186
+ // Livewire `#[Layout('layouts.app')]` (the comment blanker eats attributes).
187
+ for (const m of raw.matchAll(/#\[\s*(?:\\?Livewire\\Attributes\\)?Layout\s*\(\s*(['"])([\w.:/-]+)\1/g))
188
+ out.push({ spec: `view:${m[2]}` });
189
+ if (/(^|\/)routes\/[^/]+\.php$/.test(path))
190
+ out.push(...scanRouteStrings(code));
191
+ return out;
192
+ }
193
+ // ─── Linking ────────────────────────────────
194
+ function dirOf(path) {
195
+ const at = path.lastIndexOf('/');
196
+ return at === -1 ? '' : path.slice(0, at);
197
+ }
198
+ /** `user-profile` / `user_profile` -> `UserProfile`. */
199
+ function studly(segment) {
200
+ return segment.split(/[-_]/).map(p => p.charAt(0).toUpperCase() + p.slice(1)).join('');
201
+ }
202
+ const UNRESOLVED = { kind: 'unresolved' };
203
+ const INERTIA_EXTS = ['.vue', '.tsx', '.jsx', '.ts', '.js', '.svelte'];
204
+ /** Laravel's prefixed specifiers -> the files of the app the importing file belongs to. */
205
+ export class LaravelLinks {
206
+ root;
207
+ fileSet;
208
+ /** Folders holding a composer.json, longest first: the app a file belongs to. */
209
+ appRoots;
210
+ appOf = new Map();
211
+ /** `<lang dir>\0<file>` -> that file in every locale. */
212
+ langFiles = new Map();
213
+ /** config/app.php `aliases`: short name -> FQCN. */
214
+ aliases = new Map();
215
+ constructor(root, fileSet) {
216
+ this.root = root;
217
+ this.fileSet = fileSet;
218
+ const roots = [];
219
+ for (const p of fileSet) {
220
+ if (p === 'composer.json' || p.endsWith('/composer.json'))
221
+ roots.push(dirOf(p));
222
+ const lang = /^((?:.*\/)?lang)\/[^/]+\/(.+)\.php$/.exec(p);
223
+ if (lang && !p.endsWith('.blade.php')) {
224
+ const key = `${lang[1]}\0${lang[2]}`;
225
+ this.langFiles.set(key, [...(this.langFiles.get(key) ?? []), p]);
226
+ }
227
+ }
228
+ this.appRoots = roots.sort((a, b) => b.length - a.length);
229
+ for (const r of this.appRoots)
230
+ this.loadAliases(r);
231
+ }
232
+ loadAliases(appRoot) {
233
+ const rel = this.at(appRoot, 'config/app.php');
234
+ if (!this.fileSet.has(rel))
235
+ return;
236
+ let src;
237
+ try {
238
+ src = readFileSync(join(this.root, rel), 'utf-8');
239
+ }
240
+ catch {
241
+ return;
242
+ }
243
+ const start = src.search(/['"]aliases['"]\s*=>/);
244
+ if (start === -1)
245
+ return;
246
+ const end = src.indexOf(']', start);
247
+ const block = src.slice(start, end === -1 ? undefined : end);
248
+ for (const m of block.matchAll(/['"](\w+)['"]\s*=>\s*\\?([\w\\]+)::class/g))
249
+ this.aliases.set(m[1], m[2]);
250
+ }
251
+ /** The Laravel app folder of a repo file ('' for the repo root). */
252
+ appRootOf(path) {
253
+ const dir = dirOf(path);
254
+ let hit = this.appOf.get(dir);
255
+ if (hit === undefined) {
256
+ hit = this.appRoots.find(r => !r || dir === r || dir.startsWith(`${r}/`)) ?? '';
257
+ this.appOf.set(dir, hit);
258
+ }
259
+ return hit;
260
+ }
261
+ at(appRoot, rel) {
262
+ return posix.normalize(appRoot ? `${appRoot}/${rel}` : rel);
263
+ }
264
+ existing(candidates) {
265
+ const hits = [...new Set(candidates.filter(c => this.fileSet.has(c)))];
266
+ return hits.length > 0 ? { kind: 'files', paths: hits } : UNRESOLVED;
267
+ }
268
+ /** A Laravel specifier resolved, or null when `spec` is none (a plain PHP class name). */
269
+ resolve(fromPath, spec) {
270
+ const colon = spec.indexOf(':');
271
+ const kind = colon > 0 ? spec.slice(0, colon) : '';
272
+ if (!KINDS.has(kind))
273
+ return null;
274
+ const value = spec.slice(colon + 1);
275
+ const ns = value.indexOf('::');
276
+ // A package's namespaced view or component (`mail::message`): known, not ours.
277
+ if (ns > 0 && kind !== 'config' && kind !== 'lang')
278
+ return { kind: 'external', name: `${value.slice(0, ns)}::` };
279
+ const app = this.appRootOf(fromPath);
280
+ return this.resolveKind(kind, value, app);
281
+ }
282
+ resolveKind(kind, value, app) {
283
+ const views = this.at(app, 'resources/views');
284
+ const path = value.replace(/\./g, '/');
285
+ if (kind === 'view')
286
+ return this.existing([`${views}/${path}.blade.php`, `${views}/${path}.php`]);
287
+ if (kind === 'x')
288
+ return this.resolveComponent(value, app, views);
289
+ if (kind === 'livewire')
290
+ return this.resolveLivewire(value, app, views);
291
+ if (kind === 'config')
292
+ return this.existing([this.at(app, `config/${value}.php`)]);
293
+ if (kind === 'lang')
294
+ return this.existing([...this.langFiles.get(`${this.at(app, 'lang')}\0${value}`) ?? [], ...this.langFiles.get(`${this.at(app, 'resources/lang')}\0${value}`) ?? []]);
295
+ if (kind === 'inertia') {
296
+ const bases = ['resources/js/Pages', 'resources/js/pages'].map(b => this.at(app, `${b}/${value}`));
297
+ return this.existing(bases.flatMap(b => INERTIA_EXTS.map(e => b + e)));
298
+ }
299
+ const asset = this.at(app, value);
300
+ if (this.fileSet.has(asset))
301
+ return { kind: 'files', paths: [asset] };
302
+ return existsSync(join(this.root, asset)) ? { kind: 'outside', path: asset } : UNRESOLVED;
303
+ }
304
+ /** `<x-foo.bar>`: the anonymous Blade file and the class, whichever exist. */
305
+ resolveComponent(name, app, views) {
306
+ const segs = name.split('.');
307
+ const path = segs.join('/');
308
+ const last = segs[segs.length - 1];
309
+ return this.existing([
310
+ `${views}/components/${path}.blade.php`,
311
+ `${views}/components/${path}/index.blade.php`,
312
+ `${views}/components/${path}/${last}.blade.php`,
313
+ this.at(app, `app/View/Components/${segs.map(studly).join('/')}.php`),
314
+ ]);
315
+ }
316
+ /** `<livewire:admin.user-list>`: the class (Livewire 3 and 2 folders) and its conventional view. */
317
+ resolveLivewire(name, app, views) {
318
+ const segs = name.split('.');
319
+ const cls = segs.map(studly).join('/');
320
+ return this.existing([
321
+ this.at(app, `app/Livewire/${cls}.php`),
322
+ this.at(app, `app/Http/Livewire/${cls}.php`),
323
+ `${views}/livewire/${segs.join('/')}.blade.php`,
324
+ ]);
325
+ }
326
+ }
@@ -0,0 +1,33 @@
1
+ /** True for a repo-relative path that is an index file (or a write in flight), at any level. */
2
+ export declare function isSonarFilePath(rel: string): boolean;
3
+ /**
4
+ * The index file of a root. `cacheDir` (tests) keeps every index in that
5
+ * folder instead, named after the root, so a test never writes into a checkout.
6
+ */
7
+ export declare function sonarCachePath(root: string, cacheDir?: string): string;
8
+ /** Where the index of a root lived before it moved into the checkout. */
9
+ export declare function legacySonarCachePath(root: string): string;
10
+ /** A temporary file next to `path`, renamed onto it once written. */
11
+ export declare function sonarTmpPath(path: string): string;
12
+ /**
13
+ * Make sure git leaves the root's index file out: its lines in
14
+ * `<git common dir>/info/exclude`, each added once. Outside git it does
15
+ * nothing. Checked once per root in a process. Throws when the exclude file
16
+ * cannot be read or written.
17
+ */
18
+ export declare function ensureSonarExcluded(root: string): void;
19
+ /** Forget which roots were checked (tests). */
20
+ export declare function clearSonarExcludeMemo(): void;
21
+ /**
22
+ * Move an index from its old place into the checkout, once: only when the
23
+ * checkout has none yet and the old file exists. A move across devices
24
+ * copies and removes. True when a file was moved.
25
+ */
26
+ export declare function migrateLegacySonarCache(root: string, target: string, legacy?: string): boolean;
27
+ /**
28
+ * The checkout root a path belongs to, for a tool that wants the index of
29
+ * the file it touches: walking up from `path`, the first folder that holds a
30
+ * `.sonar`, never past the top of the git work tree (the folder holding
31
+ * `.git`). Null when there is none. Never throws.
32
+ */
33
+ export declare function findSonarRootOnDisk(path: string): string | null;
@@ -0,0 +1,137 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync } from 'node:fs';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { nordhavnDir } from '../../paths.js';
6
+ // ─── Sonar: where the index lives ───────────
7
+ //
8
+ // The index of a checkout is one file in the checkout itself, `<root>/.sonar`
9
+ // (JSON, no extension), so it travels with the folder and every process that
10
+ // works there finds it. Git never sees it: the first write adds `/.sonar` to
11
+ // the repo's `info/exclude` (shared by every worktree), never to .gitignore.
12
+ // The index used to live in `<nordhavn dir>/sonar/<sha1(root)>.json`; such a
13
+ // file is moved into the checkout once, so nothing is rebuilt.
14
+ /** The index file's name, at the root of the checkout. */
15
+ const SONAR_FILE = '.sonar';
16
+ /** Prefix of the temporary file a write renames into place. */
17
+ const SONAR_TMP_PREFIX = '.sonar.tmp-';
18
+ /** True for a repo-relative path that is an index file (or a write in flight), at any level. */
19
+ export function isSonarFilePath(rel) {
20
+ const base = rel.slice(rel.lastIndexOf('/') + 1);
21
+ return base === SONAR_FILE || base.startsWith(SONAR_TMP_PREFIX);
22
+ }
23
+ /**
24
+ * The index file of a root. `cacheDir` (tests) keeps every index in that
25
+ * folder instead, named after the root, so a test never writes into a checkout.
26
+ */
27
+ export function sonarCachePath(root, cacheDir) {
28
+ if (cacheDir)
29
+ return join(cacheDir, `${createHash('sha1').update(root).digest('hex')}.json`);
30
+ return join(root, SONAR_FILE);
31
+ }
32
+ /** Where the index of a root lived before it moved into the checkout. */
33
+ export function legacySonarCachePath(root) {
34
+ return join(nordhavnDir(), 'sonar', `${createHash('sha1').update(root).digest('hex')}.json`);
35
+ }
36
+ /** A temporary file next to `path`, renamed onto it once written. */
37
+ export function sonarTmpPath(path) {
38
+ return join(dirname(path), `${SONAR_TMP_PREFIX}${process.pid}-${Date.now()}`);
39
+ }
40
+ /** Roots whose exclude lines are known to be in place, in this process. */
41
+ const excluded = new Set();
42
+ /** The git dir and the root's place in the work tree, or null outside git (or without git). */
43
+ function gitPlaceOf(root) {
44
+ const run = spawnSync('git', ['rev-parse', '--git-common-dir', '--show-prefix'], { cwd: root, encoding: 'utf8', timeout: 5000 });
45
+ if (run.error || run.status !== 0) {
46
+ if (run.error && run.error.code !== 'ENOENT')
47
+ throw run.error;
48
+ // Not a repo (or no git binary): nothing to keep out of git.
49
+ return null;
50
+ }
51
+ const [commonDir = '', prefix = ''] = run.stdout.split('\n');
52
+ if (!commonDir)
53
+ return null;
54
+ return { commonDir: resolve(root, commonDir.trim()), prefix: prefix.trim() };
55
+ }
56
+ /** The exclude lines of a root: the index file and a write in flight. */
57
+ function sonarExcludeLines(prefix) {
58
+ return [`/${prefix}${SONAR_FILE}`, `/${prefix}${SONAR_TMP_PREFIX}*`];
59
+ }
60
+ /**
61
+ * Make sure git leaves the root's index file out: its lines in
62
+ * `<git common dir>/info/exclude`, each added once. Outside git it does
63
+ * nothing. Checked once per root in a process. Throws when the exclude file
64
+ * cannot be read or written.
65
+ */
66
+ export function ensureSonarExcluded(root) {
67
+ if (excluded.has(root))
68
+ return;
69
+ const place = gitPlaceOf(root);
70
+ if (place) {
71
+ const file = join(place.commonDir, 'info', 'exclude');
72
+ const current = existsSync(file) ? readFileSync(file, 'utf-8') : '';
73
+ const have = new Set(current.split('\n').map(l => l.trim()));
74
+ const missing = sonarExcludeLines(place.prefix).filter(l => !have.has(l));
75
+ if (missing.length > 0) {
76
+ mkdirSync(dirname(file), { recursive: true });
77
+ const lead = current && !current.endsWith('\n') ? '\n' : '';
78
+ appendFileSync(file, `${lead}${missing.join('\n')}\n`);
79
+ }
80
+ }
81
+ excluded.add(root);
82
+ }
83
+ /** Forget which roots were checked (tests). */
84
+ export function clearSonarExcludeMemo() {
85
+ excluded.clear();
86
+ }
87
+ /**
88
+ * Move an index from its old place into the checkout, once: only when the
89
+ * checkout has none yet and the old file exists. A move across devices
90
+ * copies and removes. True when a file was moved.
91
+ */
92
+ export function migrateLegacySonarCache(root, target, legacy = legacySonarCachePath(root)) {
93
+ if (existsSync(target) || !existsSync(legacy))
94
+ return false;
95
+ ensureSonarExcluded(root);
96
+ try {
97
+ renameSync(legacy, target);
98
+ }
99
+ catch (err) {
100
+ if (err.code !== 'EXDEV')
101
+ throw err;
102
+ copyFileSync(legacy, target);
103
+ unlinkSync(legacy);
104
+ }
105
+ return true;
106
+ }
107
+ /**
108
+ * The checkout root a path belongs to, for a tool that wants the index of
109
+ * the file it touches: walking up from `path`, the first folder that holds a
110
+ * `.sonar`, never past the top of the git work tree (the folder holding
111
+ * `.git`). Null when there is none. Never throws.
112
+ */
113
+ export function findSonarRootOnDisk(path) {
114
+ try {
115
+ let dir = resolve(path);
116
+ try {
117
+ if (!statSync(dir).isDirectory())
118
+ dir = dirname(dir);
119
+ }
120
+ catch {
121
+ dir = dirname(dir);
122
+ }
123
+ for (;;) {
124
+ if (existsSync(join(dir, SONAR_FILE)))
125
+ return dir;
126
+ if (existsSync(join(dir, '.git')))
127
+ return null;
128
+ const up = dirname(dir);
129
+ if (up === dir)
130
+ return null;
131
+ dir = up;
132
+ }
133
+ }
134
+ catch {
135
+ return null;
136
+ }
137
+ }
@@ -0,0 +1,43 @@
1
+ import { type FsSonarEdge, type FsSonarGraph, type FsSonarNode } from '@nordhavnhq/runner-runtime';
2
+ import type { SonarIndex, SonarWorkspace } from './types.js';
3
+ export interface SonarGraphLimits {
4
+ nodes: number;
5
+ edges: number;
6
+ }
7
+ /** The folder node a file falls in at `depth`: its first `depth` folder segments, its own folder when it sits shallower. */
8
+ export declare function folderAt(path: string, depth: number): string;
9
+ /** A folder graph's depth: 1 to FS_SONAR_MAX_DEPTH, 1 when it is no number. */
10
+ export declare function clampSonarDepth(depth: unknown): number;
11
+ /**
12
+ * The workspace a node belongs to, by name: the deepest workspace whose
13
+ * folder holds it. A folder that itself holds another workspace (`apps`,
14
+ * the root of a monorepo) belongs to none.
15
+ */
16
+ export declare function workspaceOfNode(id: string, kind: 'folder' | 'file', workspaces: SonarWorkspace[]): string | null;
17
+ /** Cut to the limits: the smallest nodes by lines first, then the lightest edges; edges of a cut node go with it. */
18
+ export declare function limitSonarGraph(nodes: FsSonarNode[], edges: FsSonarEdge[], limits?: SonarGraphLimits): {
19
+ nodes: FsSonarNode[];
20
+ edges: FsSonarEdge[];
21
+ truncated: boolean;
22
+ };
23
+ /**
24
+ * The index as folders `depth` segments deep (clamped to 1 to
25
+ * FS_SONAR_MAX_DEPTH), a file shallower than that in its own folder, a file
26
+ * at the root in node ''. Edges sum the file links between two folders (a
27
+ * component tag counts as one); `importers` counts the files outside a
28
+ * folder that import into it.
29
+ */
30
+ export declare function buildSonarFolderGraph(index: SonarIndex, depth: number, limits?: SonarGraphLimits, path?: string): FsSonarGraph;
31
+ /** A folder path as the graph names it: relative, no leading or trailing slash, '' for the root. */
32
+ export declare function normalizeSonarFolder(path: string): string;
33
+ /**
34
+ * The files directly in folder `path`, plus, as external folder nodes, the
35
+ * folders they import from or are imported by: a sub-folder of `path` by its
36
+ * first segment below it, anything else by its first `segments(path)`
37
+ * segments (the siblings' level; a file sitting shallower in its own
38
+ * folder). Edges run between those files, and between a file and an
39
+ * external folder, never between two external folders.
40
+ */
41
+ export declare function buildSonarFileGraph(index: SonarIndex, path: string, limits?: SonarGraphLimits): FsSonarGraph;
42
+ /** Text cut to `max` characters at a line boundary. */
43
+ export declare function cutAtLine(text: string, max: number): string;