@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,248 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { basename } from 'node:path';
3
+ import { runRipgrep } from '../_ripgrep.js';
4
+ import { inScope, isTestPath } from './graph.js';
5
+ import { Budget } from './render.js';
6
+ // ─── Sonar: env and config keys ─────────────
7
+ //
8
+ // `refs { query: "env:NAME" }` and `refs { query: "config:a.b" }`: where a
9
+ // key is set and where it is read, sorted, instead of a grep whose hits the
10
+ // agent sorts itself. An env key: `.env*` files (the value is never shown),
11
+ // config, CI and deploy files (Dockerfile, compose, workflows), the code that
12
+ // reads it, the docs that name it; a `NUXT_*` key also names the
13
+ // runtimeConfig key Nuxt maps it onto. A config key: Laravel's
14
+ // `config/<file>.php` (the line that defines it, and the env it reads) and
15
+ // every `config('a.b')` / `Config::get('a.b')`; without such a file, Nuxt's
16
+ // runtimeConfig (nuxt.config and the files that call useRuntimeConfig) and
17
+ // app config (app.config and the files that call useAppConfig).
18
+ const LINES_PER_FILE = 6;
19
+ const FILES_PER_SECTION = 25;
20
+ const RG_MAX_RECORDS = 1500;
21
+ const CODE_GLOB = '*.{ts,tsx,js,jsx,mjs,cjs,mts,cts,vue,svelte,astro}';
22
+ const SECTION_TITLES = {
23
+ defined: 'set in env files (values hidden)',
24
+ deploy: 'set in config, CI or deploy files',
25
+ read: 'read in code',
26
+ docs: 'named in docs',
27
+ };
28
+ const isEnvFile = (path) => {
29
+ const b = basename(path);
30
+ return b.startsWith('.env') || b.endsWith('.env');
31
+ };
32
+ function whereOf(index, path) {
33
+ if (isEnvFile(path))
34
+ return 'defined';
35
+ if (/\.(md|mdx|txt|rst)$/i.test(path))
36
+ return 'docs';
37
+ if (index.files.has(path) && !/\.(json|ya?ml|toml|ini|neon|xml)$/i.test(path))
38
+ return 'read';
39
+ return 'deploy';
40
+ }
41
+ /** A line as shown: an env file's value is cut off, every line trimmed and capped. */
42
+ function shown(path, text) {
43
+ const t = isEnvFile(path) ? text.replace(/=.*$/, '=<hidden>') : text;
44
+ return t.trim().slice(0, 140);
45
+ }
46
+ async function search(index, pattern, glob) {
47
+ const rg = await runRipgrep({ pattern, cwd: index.root, ignoreCase: false, mode: 'content', context: 0, maxFileBytes: 512 * 1024, maxRecords: RG_MAX_RECORDS, glob });
48
+ if (rg && rg.kind === 'content')
49
+ return { hits: rg.lines.filter((l) => l.match), truncated: rg.truncated };
50
+ // No ripgrep: the indexed files only (env and deploy files are missed, and the answer says so).
51
+ const re = new RegExp(pattern);
52
+ const hits = [];
53
+ for (const p of index.files.keys()) {
54
+ let src;
55
+ try {
56
+ src = readFileSync(`${index.root}/${p}`, 'utf-8');
57
+ }
58
+ catch {
59
+ continue;
60
+ }
61
+ src.split('\n').forEach((text, i) => { if (re.test(text))
62
+ hits.push({ path: p, line: i + 1, text }); });
63
+ }
64
+ return { hits, truncated: false };
65
+ }
66
+ function byFile(hits) {
67
+ const out = new Map();
68
+ for (const h of hits)
69
+ out.set(h.path, [...(out.get(h.path) ?? []), h]);
70
+ return out;
71
+ }
72
+ function pushSection(out, title, files) {
73
+ if (files.size === 0)
74
+ return;
75
+ const paths = [...files.keys()].sort((a, b) => Number(isTestPath(a)) - Number(isTestPath(b)) || a.localeCompare(b));
76
+ out.push(`${title} (${paths.length} file(s)):`);
77
+ for (const p of paths.slice(0, FILES_PER_SECTION)) {
78
+ const lines = files.get(p);
79
+ if (lines.length === 1) {
80
+ out.push(` ${p}:${lines[0].line}: ${shown(p, lines[0].text)}`);
81
+ continue;
82
+ }
83
+ out.push(` ${p} (${lines.length})`);
84
+ for (const l of lines.slice(0, LINES_PER_FILE))
85
+ out.push(` ${l.line}: ${shown(p, l.text)}`);
86
+ if (lines.length > LINES_PER_FILE)
87
+ out.push(` +${lines.length - LINES_PER_FILE} more lines`);
88
+ }
89
+ if (paths.length > FILES_PER_SECTION)
90
+ out.push(` +${paths.length - FILES_PER_SECTION} more files`);
91
+ }
92
+ /** `NUXT_PUBLIC_API_BASE` -> `public.apiBase`; null for a key Nuxt does not map. */
93
+ export function nuxtKeyOf(env) {
94
+ const m = /^NUXT_(PUBLIC_)?([A-Z0-9_]+)$/.exec(env);
95
+ if (!m)
96
+ return null;
97
+ const camel = m[2].toLowerCase().replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
98
+ return m[1] ? `public.${camel}` : camel;
99
+ }
100
+ /** `public.apiBase` -> `NUXT_PUBLIC_API_BASE`. */
101
+ function nuxtEnvOf(key) {
102
+ return `NUXT_${key.split('.').map(p => p.replace(/([a-z0-9])([A-Z])/g, '$1_$2')).join('_').toUpperCase()}`;
103
+ }
104
+ async function renderEnv(index, name, within) {
105
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
106
+ return `Error: "${name}" is not an env name (letters, digits, _).`;
107
+ const { hits, truncated } = await search(index, `\\b${name}\\b`);
108
+ const inside = hits.filter(h => inScope(h.path, within));
109
+ const out = new Budget();
110
+ const under = within ? ` under ${within}` : '';
111
+ const files = byFile(inside);
112
+ out.push(`env ${name}${under}: ${files.size} file(s), ${inside.length} line(s)${truncated ? ' (stopped at the search cap: narrow with `path`)' : ''}.`);
113
+ const sections = { defined: new Map(), deploy: new Map(), read: new Map(), docs: new Map() };
114
+ for (const [p, lines] of files)
115
+ sections[whereOf(index, p)].set(p, lines);
116
+ for (const w of ['defined', 'deploy', 'read', 'docs'])
117
+ pushSection(out, SECTION_TITLES[w], sections[w]);
118
+ if (files.size === 0)
119
+ out.push('Not found. A gitignored file (.env) is not searched: its keys are not in the repo.');
120
+ else if (sections.defined.size === 0)
121
+ out.push('Not in a tracked env file (.env.example or the like); a gitignored .env is not searched.');
122
+ const nuxt = nuxtKeyOf(name);
123
+ if (nuxt)
124
+ out.push(`Nuxt maps it onto runtimeConfig.${nuxt}: refs { query: "config:${nuxt}" } for its uses.`);
125
+ return out.text('pass `path` to narrow');
126
+ }
127
+ /** Laravel config files named `<file>.php` in a `config/` folder of the index. */
128
+ function laravelConfigFiles(index, file) {
129
+ return [...index.files.keys()].filter(p => p === `config/${file}.php` || p.endsWith(`/config/${file}.php`));
130
+ }
131
+ /** The line in a Laravel config file that defines `keys` (nested arrays followed in order). */
132
+ function definitionLine(root, path, keys) {
133
+ let lines;
134
+ try {
135
+ lines = readFileSync(`${root}/${path}`, 'utf-8').split('\n');
136
+ }
137
+ catch {
138
+ return null;
139
+ }
140
+ let from = 0;
141
+ let hit = null;
142
+ for (const key of keys) {
143
+ const re = new RegExp(`(['"])${key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\1\\s*=>`);
144
+ const at = lines.findIndex((l, i) => i >= from && re.test(l));
145
+ if (at === -1)
146
+ return hit;
147
+ hit = { path, line: at + 1, text: lines[at] };
148
+ from = at + 1;
149
+ }
150
+ return hit;
151
+ }
152
+ async function renderLaravelConfig(index, key, defs, within) {
153
+ const keys = key.split('.').slice(1);
154
+ const out = new Budget();
155
+ out.push(`config ${key} (Laravel):`);
156
+ for (const d of defs) {
157
+ const line = keys.length > 0 ? definitionLine(index.root, d, keys) : null;
158
+ if (line) {
159
+ const env = /\benv\(\s*['"](\w+)['"]/.exec(line.text)?.[1];
160
+ out.push(` defined ${d}:${line.line}: ${line.text.trim().slice(0, 140)}${env ? ` (env ${env}: refs { query: "env:${env}" })` : ''}`);
161
+ }
162
+ else {
163
+ out.push(` file ${d}${keys.length > 0 ? ` (key "${keys.join('.')}" not found as a literal array key)` : ''}`);
164
+ }
165
+ }
166
+ const esc = key.replace(/\./g, '\\.');
167
+ const pattern = `(?:\\bconfig\\s*\\(\\s*\\[?\\s*|\\bconfig\\s*\\(\\s*\\)\\s*->\\s*\\w+\\s*\\(\\s*|\\bConfig::\\w+\\s*\\(\\s*)['"]${esc}(?:\\.[\\w.-]+)?['"]`;
168
+ const { hits, truncated } = await search(index, pattern, '*.php');
169
+ const files = byFile(hits.filter(h => inScope(h.path, within)));
170
+ if (files.size === 0)
171
+ out.push(`No config('${key}...') reads found${within ? ` under ${within}` : ''} (a key built from variables is not seen).`);
172
+ pushSection(out, `read${truncated ? ' (search cap reached)' : ''}`, files);
173
+ return out.text('pass `path` to narrow');
174
+ }
175
+ /** The lines of `paths` that set `last` (`last:`), by file. */
176
+ function keyLines(index, paths, last) {
177
+ const defRe = new RegExp(`\\b${last}\\s*:`);
178
+ const defs = new Map();
179
+ for (const p of paths) {
180
+ let lines;
181
+ try {
182
+ lines = readFileSync(`${index.root}/${p}`, 'utf-8').split('\n');
183
+ }
184
+ catch {
185
+ continue;
186
+ }
187
+ const at = lines.map((text, i) => ({ path: p, line: i + 1, text })).filter(l => defRe.test(l.text));
188
+ if (at.length > 0)
189
+ defs.set(p, at);
190
+ }
191
+ return defs;
192
+ }
193
+ async function renderNuxtConfig(index, key, within) {
194
+ const last = key.split('.').pop();
195
+ if (!/^[A-Za-z_$][\w$]*$/.test(last))
196
+ return `Error: "${key}" is not a config key (a.b.c).`;
197
+ const out = new Budget();
198
+ const env = nuxtEnvOf(key);
199
+ const runtimeDefs = keyLines(index, nuxtConfigs(index).filter(p => inScope(p, within)), last);
200
+ const appDefs = keyLines(index, appConfigs(index).filter(p => inScope(p, within)), last);
201
+ // app.config is build-time only: no env override. Shown when it defines the key, or when nothing does.
202
+ const kinds = [
203
+ ...(runtimeDefs.size > 0 || appDefs.size === 0 ? [{ label: 'runtimeConfig', file: 'nuxt.config', reader: 'useRuntimeConfig', defs: runtimeDefs }] : []),
204
+ ...(appDefs.size > 0 ? [{ label: 'app config', file: 'app.config', reader: 'useAppConfig', defs: appDefs }] : []),
205
+ ];
206
+ const envNote = runtimeDefs.size > 0 || appDefs.size === 0 ? ` Env override (runtimeConfig only): ${env} (refs { query: "env:${env}" }).` : '';
207
+ out.push(`config ${key} (Nuxt ${kinds.map(k => k.label).join(' + ')}; not a key of a Laravel config/${key.split('.')[0]}.php in the index).${envNote}`);
208
+ if (runtimeDefs.size === 0 && appDefs.size === 0)
209
+ out.push(`"${last}:" is in no nuxt.config or app.config${within ? ` under ${within}` : ''}: a typo, a Laravel config file outside the index, or set only through ${env}.`);
210
+ // A read is `.key` or a destructure (`{ key } =`); `key: value` is a literal that sets something else.
211
+ const [uses, ...callers] = await Promise.all([
212
+ search(index, `\\.${last}\\b|\\{[^}]*\\b${last}\\b[^}]*\\}\\s*=`, CODE_GLOB),
213
+ ...kinds.map(k => search(index, k.reader, CODE_GLOB)),
214
+ ]);
215
+ kinds.forEach((k, i) => {
216
+ pushSection(out, `defined in ${k.file}`, k.defs);
217
+ const reading = new Set(callers[i].hits.map(h => h.path));
218
+ const files = byFile(uses.hits.filter(h => reading.has(h.path) && !k.defs.has(h.path) && inScope(h.path, within)));
219
+ if (files.size === 0)
220
+ out.push(`No file that calls ${k.reader} names "${last}"${within ? ` under ${within}` : ''}.`);
221
+ pushSection(out, `read (files that call ${k.reader} and name it)`, files);
222
+ });
223
+ return out.text('pass `path` to narrow');
224
+ }
225
+ /** `refs` of `env:NAME` or `config:a.b`. */
226
+ export async function renderKeyRefs(index, query, within) {
227
+ const m = /^(env|config):\s*(.+)$/i.exec(query.trim());
228
+ if (!m)
229
+ return 'Error: a key query is "env:NAME" or "config:a.b".';
230
+ const key = m[2].trim();
231
+ if (m[1].toLowerCase() === 'env')
232
+ return renderEnv(index, key, within);
233
+ if (!/^[\w-]+(\.[\w-]+)*$/.test(key))
234
+ return `Error: "${key}" is not a config key (a.b.c).`;
235
+ const defs = laravelConfigFiles(index, key.split('.')[0]);
236
+ if (defs.length === 0)
237
+ return renderNuxtConfig(index, key, within);
238
+ // A monorepo with Laravel and Nuxt: a key that is in no Laravel config file is the Nuxt one.
239
+ const keys = key.split('.').slice(1);
240
+ const found = keys.length === 0 || defs.some(d => definitionLine(index.root, d, keys)?.text.includes(keys[keys.length - 1]));
241
+ return !found && (nuxtConfigs(index).length > 0 || appConfigs(index).length > 0) ? renderNuxtConfig(index, key, within) : renderLaravelConfig(index, key, defs, within);
242
+ }
243
+ function nuxtConfigs(index) {
244
+ return [...index.files.keys()].filter(p => /(^|\/)nuxt\.config\.[mc]?[jt]s$/.test(p));
245
+ }
246
+ function appConfigs(index) {
247
+ return [...index.files.keys()].filter(p => /(^|\/)app\.config\.[mc]?[jt]s$/.test(p));
248
+ }
@@ -0,0 +1,15 @@
1
+ export interface LaravelRoute {
2
+ /** Upper case; `GET|HEAD`-style for several, `ANY` for any. */
3
+ method: string;
4
+ /** Leading slash, Laravel placeholders as written (`{photo}`). */
5
+ uri: string;
6
+ /** 1-based line of the `Route::` that defines it. */
7
+ line: number;
8
+ /** Controller class short name (no namespace). */
9
+ controller?: string;
10
+ /** Controller method, or `closure`, `view <name>`, `redirect <to>`, `inertia <Page>`. */
11
+ action?: string;
12
+ name?: string;
13
+ }
14
+ /** Every route a Laravel route file defines, in source order. `file` is its name (`api.php` gets the `api` prefix). */
15
+ export declare function parseLaravelRoutes(src: string, file: string): LaravelRoute[];
@@ -0,0 +1,263 @@
1
+ import { blankComments } from './imports.js';
2
+ import { callArgs, phpString, phpStrings } from './laravel.js';
3
+ const VERBS = new Set(['get', 'post', 'put', 'patch', 'delete', 'options', 'any']);
4
+ /** [action, method, uri suffix ({p} is the resource parameter)]. */
5
+ const RESOURCE = [
6
+ ['index', 'GET', ''],
7
+ ['create', 'GET', '/create'],
8
+ ['store', 'POST', ''],
9
+ ['show', 'GET', '/{p}'],
10
+ ['edit', 'GET', '/{p}/edit'],
11
+ ['update', 'PUT|PATCH', '/{p}'],
12
+ ['destroy', 'DELETE', '/{p}'],
13
+ ];
14
+ const API_SKIPS = new Set(['create', 'edit']);
15
+ /** Index of the closing quote of the PHP string opening at `i`. */
16
+ function stringEnd(src, i, quote) {
17
+ let j = i + 1;
18
+ while (j < src.length && src[j] !== quote)
19
+ j += src[j] === '\\' ? 2 : 1;
20
+ return j;
21
+ }
22
+ /** Index of the `}` closing the brace at `open` (strings skipped); the end of the source when unclosed. */
23
+ function braceEnd(src, open) {
24
+ let depth = 0;
25
+ for (let i = open; i < src.length; i++) {
26
+ const c = src[i];
27
+ if (c === '"' || c === '\'') {
28
+ i = stringEnd(src, i, c);
29
+ continue;
30
+ }
31
+ if (c === '{')
32
+ depth++;
33
+ else if (c === '}' && --depth === 0)
34
+ return i;
35
+ }
36
+ return src.length;
37
+ }
38
+ const GROUP_CALL = /(?:->|::)\s*group\s*\(/;
39
+ /**
40
+ * One `Route::...` statement from `start`: where it ends (its `;`, or the `{`
41
+ * of a group's closure) and, for a group, the closure body. A route's own
42
+ * closure (`Route::get('/', function () { ... })`) is skipped over.
43
+ */
44
+ function statementAt(code, start) {
45
+ let depth = 0;
46
+ for (let i = start; i < code.length; i++) {
47
+ const c = code[i];
48
+ if (c === '"' || c === '\'') {
49
+ i = stringEnd(code, i, c);
50
+ continue;
51
+ }
52
+ if (c === '(' || c === '[') {
53
+ depth++;
54
+ continue;
55
+ }
56
+ if (c === ')' || c === ']') {
57
+ depth--;
58
+ continue;
59
+ }
60
+ if (c === '{') {
61
+ const close = braceEnd(code, i);
62
+ if (depth > 0 && GROUP_CALL.test(code.slice(start, i)))
63
+ return { end: i, body: [i, close] };
64
+ i = close;
65
+ continue;
66
+ }
67
+ if (c === ';' && depth <= 0)
68
+ return { end: i };
69
+ }
70
+ return { end: code.length };
71
+ }
72
+ /** The calls of a statement at its top level: `Route::get(...)`, `->name(...)`; not the ones inside a closure. */
73
+ function topLevelCalls(stmt) {
74
+ const calls = [];
75
+ let depth = 0;
76
+ for (let i = 0; i < stmt.length; i++) {
77
+ const c = stmt[i];
78
+ if (c === '"' || c === '\'') {
79
+ i = stringEnd(stmt, i, c);
80
+ continue;
81
+ }
82
+ if ('([{'.includes(c)) {
83
+ depth++;
84
+ continue;
85
+ }
86
+ if (')]}'.includes(c)) {
87
+ depth--;
88
+ continue;
89
+ }
90
+ if (depth !== 0)
91
+ continue;
92
+ const m = /^(?:Route\s*::|->)\s*(\w+)\s*\(/.exec(stmt.slice(i, i + 80));
93
+ if (!m)
94
+ continue;
95
+ const open = i + m[0].length - 1;
96
+ calls.push({ name: m[1], args: callArgs(stmt, open) });
97
+ i = open - 1;
98
+ }
99
+ return calls;
100
+ }
101
+ const join = (...parts) => {
102
+ const path = parts.map(p => p.replace(/^\/+|\/+$/g, '')).filter(Boolean).join('/');
103
+ return `/${path}`;
104
+ };
105
+ /** `X::class` / `\App\X::class` -> `X`. */
106
+ function classOf(arg) {
107
+ return /^\\?(?:[\w]+\\)*(\w+)::class$/.exec(arg?.trim() ?? '')?.[1];
108
+ }
109
+ /** A route's handler argument: `[X::class, 'm']`, `'X@m'`, `X::class`, `'m'` under a controller group, or a closure. */
110
+ function handlerOf(arg, frame) {
111
+ const a = arg?.trim() ?? '';
112
+ const pair = /^\[\s*\\?(?:[\w]+\\)*(\w+)::class\s*,\s*['"](\w+)['"]\s*\]$/.exec(a);
113
+ if (pair)
114
+ return { controller: pair[1], action: pair[2] };
115
+ const invokable = classOf(a);
116
+ if (invokable)
117
+ return { controller: invokable, action: '__invoke' };
118
+ const str = phpString(a);
119
+ if (str !== null) {
120
+ const at = str.split('@');
121
+ if (at.length === 2)
122
+ return { controller: at[0].split('\\').pop(), action: at[1] };
123
+ if (frame?.controller && /^\w+$/.test(str))
124
+ return { controller: frame.controller, action: str };
125
+ }
126
+ if (/^(?:static\s+)?(?:function|fn)\b/.test(a))
127
+ return { action: 'closure' };
128
+ return {};
129
+ }
130
+ /** `photos` -> `photo`, `categories` -> `category`: Laravel's resource parameter. */
131
+ function singular(word) {
132
+ const w = word.replace(/-/g, '_');
133
+ if (w.endsWith('ies'))
134
+ return `${w.slice(0, -3)}y`;
135
+ if (/(ss|us)$/.test(w))
136
+ return w;
137
+ return w.endsWith('s') ? w.slice(0, -1) : w;
138
+ }
139
+ function resourceRoutes(calls, frame, api, line) {
140
+ const head = calls[0];
141
+ const name = phpString(head.args[0]);
142
+ if (!name)
143
+ return [];
144
+ const parts = name.split('.');
145
+ // Nested: `photos.comments` -> photos/{photo}/comments/{comment}.
146
+ const base = parts.map((p, i) => (i < parts.length - 1 ? `${p}/{${singular(p)}}` : p)).join('/');
147
+ const param = singular(parts[parts.length - 1]);
148
+ const controller = classOf(head.args[1]);
149
+ const only = calls.find(c => c.name === 'only');
150
+ const except = calls.find(c => c.name === 'except');
151
+ const keep = only ? new Set(phpStrings(only.args[0])) : null;
152
+ const drop = new Set(except ? phpStrings(except.args[0]) : []);
153
+ return RESOURCE
154
+ .filter(([action]) => !(api && API_SKIPS.has(action)) && (!keep || keep.has(action)) && !drop.has(action))
155
+ .map(([action, method, suffix]) => ({
156
+ method,
157
+ uri: join(frame?.prefix ?? '', base + suffix.replace('{p}', `{${param}}`)),
158
+ line,
159
+ controller,
160
+ action,
161
+ name: `${frame?.name ?? ''}${name}.${action}`,
162
+ }));
163
+ }
164
+ const shortcut = (method, kind) => (c) => [method, phpString(c.args[0]), { action: `${kind} ${phpString(c.args[1]) ?? '?'}` }];
165
+ /** Method, URI and handler per `Route::` call that is not a plain verb or a resource. */
166
+ const OTHER_CALLS = {
167
+ match: (c, frame) => [phpStrings(c.args[0]).map(m => m.toUpperCase()).join('|') || 'ANY', phpString(c.args[1]), handlerOf(c.args[2], frame)],
168
+ view: shortcut('GET', 'view'),
169
+ inertia: shortcut('GET', 'inertia'),
170
+ redirect: shortcut('ANY', 'redirect'),
171
+ permanentredirect: shortcut('ANY', 'redirect'),
172
+ fallback: (c, frame) => ['ANY', '{fallback}', handlerOf(c.args[0], frame)],
173
+ };
174
+ /** The route(s) one statement defines. */
175
+ function routesOf(calls, frame, line) {
176
+ const head = calls[0];
177
+ if (!head)
178
+ return [];
179
+ const verb = head.name.toLowerCase();
180
+ if (verb === 'resource' || verb === 'apiresource')
181
+ return resourceRoutes(calls, frame, verb === 'apiresource', line);
182
+ const spec = VERBS.has(verb)
183
+ ? [verb === 'any' ? 'ANY' : verb.toUpperCase(), phpString(head.args[0]), handlerOf(head.args[1], frame)]
184
+ : OTHER_CALLS[verb]?.(head, frame);
185
+ if (!spec || spec[1] === null)
186
+ return [];
187
+ const named = calls.find(c => c.name === 'name');
188
+ const name = named ? `${frame?.name ?? ''}${phpString(named.args[0]) ?? ''}` : undefined;
189
+ return [{ method: spec[0], uri: join(frame?.prefix ?? '', spec[1]), line, name, ...spec[2] }];
190
+ }
191
+ /** One chained call of a group statement (`prefix()`, `name()`, `controller()`, or `group([...])` options). */
192
+ function applyGroupCall(o, c) {
193
+ const arg = c.args[0];
194
+ if (c.name === 'prefix')
195
+ o.prefix = phpString(arg) ?? o.prefix;
196
+ else if (c.name === 'name' || c.name === 'as')
197
+ o.name = phpString(arg) ?? o.name;
198
+ else if (c.name === 'controller')
199
+ o.controller = classOf(arg) ?? o.controller;
200
+ else if (c.name === 'group' && arg?.trim().startsWith('[')) {
201
+ o.prefix = /['"]prefix['"]\s*=>\s*(['"])(.*?)\1/.exec(arg)?.[2] ?? o.prefix;
202
+ o.name = /['"]as['"]\s*=>\s*(['"])(.*?)\1/.exec(arg)?.[2] ?? o.name;
203
+ }
204
+ }
205
+ /** The group a statement opens: its prefix, name prefix and controller on top of the enclosing one. */
206
+ function frameOf(calls, parent, body) {
207
+ const o = { prefix: '', name: '' };
208
+ for (const c of calls)
209
+ applyGroupCall(o, c);
210
+ const { prefix, name, controller } = o;
211
+ return {
212
+ prefix: join(parent?.prefix ?? '', prefix),
213
+ name: `${parent?.name ?? ''}${name}`,
214
+ controller: controller ?? parent?.controller,
215
+ open: body[0],
216
+ end: body[1],
217
+ };
218
+ }
219
+ function lineStarts(src) {
220
+ const starts = [0];
221
+ for (let i = 0; i < src.length; i++)
222
+ if (src[i] === '\n')
223
+ starts.push(i + 1);
224
+ return starts;
225
+ }
226
+ function lineAt(starts, pos) {
227
+ let lo = 0;
228
+ let hi = starts.length - 1;
229
+ while (lo < hi) {
230
+ const mid = (lo + hi + 1) >> 1;
231
+ if (starts[mid] <= pos)
232
+ lo = mid;
233
+ else
234
+ hi = mid - 1;
235
+ }
236
+ return lo + 1;
237
+ }
238
+ /** Every route a Laravel route file defines, in source order. `file` is its name (`api.php` gets the `api` prefix). */
239
+ export function parseLaravelRoutes(src, file) {
240
+ const code = blankComments(src, 'php');
241
+ const starts = lineStarts(code);
242
+ const root = /(^|\/)api\.php$/.test(file) ? { prefix: '/api', name: '', open: -1, end: code.length } : undefined;
243
+ const stack = root ? [root] : [];
244
+ const out = [];
245
+ let skipUntil = -1;
246
+ for (const m of code.matchAll(/\bRoute\s*::/g)) {
247
+ const at = m.index;
248
+ if (at < skipUntil)
249
+ continue;
250
+ while (stack.length > 0 && at > stack[stack.length - 1].end)
251
+ stack.pop();
252
+ const frame = stack[stack.length - 1];
253
+ const stmt = statementAt(code, at);
254
+ const calls = topLevelCalls(code.slice(at, stmt.end));
255
+ if (stmt.body) {
256
+ stack.push(frameOf(calls, frame, stmt.body));
257
+ continue;
258
+ }
259
+ skipUntil = stmt.end;
260
+ out.push(...routesOf(calls, frame, lineAt(starts, at)));
261
+ }
262
+ return out;
263
+ }
@@ -0,0 +1,64 @@
1
+ import type { Resolution } from './resolve.js';
2
+ import type { RawImport } from './types.js';
3
+ export type LaravelKind = 'view' | 'x' | 'livewire' | 'config' | 'lang' | 'asset' | 'inertia';
4
+ /** The top-level arguments of the call (or array) whose opening bracket is at `open`, trimmed. */
5
+ export declare function callArgs(src: string, open: number): string[];
6
+ /** The value of a plain PHP string literal, or null (a variable, an interpolated string, an expression). */
7
+ export declare function phpString(arg: string | undefined): string | null;
8
+ /** The string literals of `'a'` or `['a', 'b']`. */
9
+ export declare function phpStrings(arg: string | undefined): string[];
10
+ /** A string literal turned into the specifier of `kind`, or null when it is not a plain name. */
11
+ export declare function laravelSpec(kind: LaravelKind, value: string): RawImport | null;
12
+ interface CallRule {
13
+ re: RegExp;
14
+ kind: LaravelKind;
15
+ /** Which argument holds the name(s); arrays of names are read too. */
16
+ args: number[];
17
+ }
18
+ /** Blade directives that name a view, a Livewire component, a lang file or a Vite entry. */
19
+ export declare const BLADE_CALLS: CallRule[];
20
+ /** The specifiers a set of call rules finds in `code`. */
21
+ export declare function scanCalls(code: string, rules: CallRule[]): RawImport[];
22
+ export interface ClassUseScope {
23
+ namespace?: string;
24
+ /** Short names `use` statements bind (their alias or last segment). */
25
+ imported: Set<string>;
26
+ /** Classes the file declares itself. */
27
+ declared: string[];
28
+ blade: boolean;
29
+ }
30
+ /**
31
+ * Classes used by their short name without a `use`: in a namespace they are
32
+ * the namespace's own (`App\Models\Foo`), outside one (routes, Blade) a
33
+ * global class or a config/app.php alias (`Foo`). Weak: a miss is a PHP or
34
+ * vendor class, nothing to report.
35
+ */
36
+ export declare function scanClassUses(code: string, scope: ClassUseScope): RawImport[];
37
+ /** Laravel's by-name references in PHP code: `code` has comments blanked, `raw` is the source. */
38
+ export declare function scanLaravelPhp(code: string, raw: string, path: string, blade?: boolean): RawImport[];
39
+ /** Laravel's prefixed specifiers -> the files of the app the importing file belongs to. */
40
+ export declare class LaravelLinks {
41
+ private readonly root;
42
+ private readonly fileSet;
43
+ /** Folders holding a composer.json, longest first: the app a file belongs to. */
44
+ private readonly appRoots;
45
+ private readonly appOf;
46
+ /** `<lang dir>\0<file>` -> that file in every locale. */
47
+ private readonly langFiles;
48
+ /** config/app.php `aliases`: short name -> FQCN. */
49
+ readonly aliases: Map<string, string>;
50
+ constructor(root: string, fileSet: Set<string>);
51
+ private loadAliases;
52
+ /** The Laravel app folder of a repo file ('' for the repo root). */
53
+ appRootOf(path: string): string;
54
+ private at;
55
+ private existing;
56
+ /** A Laravel specifier resolved, or null when `spec` is none (a plain PHP class name). */
57
+ resolve(fromPath: string, spec: string): Resolution | null;
58
+ private resolveKind;
59
+ /** `<x-foo.bar>`: the anonymous Blade file and the class, whichever exist. */
60
+ private resolveComponent;
61
+ /** `<livewire:admin.user-list>`: the class (Livewire 3 and 2 folders) and its conventional view. */
62
+ private resolveLivewire;
63
+ }
64
+ export {};