@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.
- package/bin/cliclick +0 -0
- package/dist/brand.d.ts +5 -0
- package/dist/brand.js +18 -0
- package/dist/cli/agent.d.ts +9 -0
- package/dist/cli/agent.js +80 -0
- package/dist/cli/folder.d.ts +2 -0
- package/dist/cli/folder.js +103 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +67 -0
- package/dist/cli/lifecycle.d.ts +3 -0
- package/dist/cli/lifecycle.js +149 -0
- package/dist/cli/link.d.ts +42 -0
- package/dist/cli/link.js +314 -0
- package/dist/cli/logs.d.ts +2 -0
- package/dist/cli/logs.js +147 -0
- package/dist/cli/prompts.d.ts +7 -0
- package/dist/cli/prompts.js +13 -0
- package/dist/cli/ps.d.ts +2 -0
- package/dist/cli/ps.js +81 -0
- package/dist/cli/relay.d.ts +4 -0
- package/dist/cli/relay.js +29 -0
- package/dist/cli/update.d.ts +6 -0
- package/dist/cli/update.js +131 -0
- package/dist/config.d.ts +166 -0
- package/dist/config.js +383 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +145 -0
- package/dist/legacy-env.d.ts +4 -0
- package/dist/legacy-env.js +32 -0
- package/dist/paths.d.ts +37 -0
- package/dist/paths.js +92 -0
- package/dist/runtime/daemon.d.ts +57 -0
- package/dist/runtime/daemon.js +159 -0
- package/dist/runtime/dev-start.d.ts +31 -0
- package/dist/runtime/dev-start.js +110 -0
- package/dist/runtime/file-claims.d.ts +58 -0
- package/dist/runtime/file-claims.js +174 -0
- package/dist/runtime/fs-browse.d.ts +18 -0
- package/dist/runtime/fs-browse.js +104 -0
- package/dist/runtime/fs-checkout.d.ts +154 -0
- package/dist/runtime/fs-checkout.js +1049 -0
- package/dist/runtime/fs-git-index.d.ts +22 -0
- package/dist/runtime/fs-git-index.js +133 -0
- package/dist/runtime/fs-git.d.ts +16 -0
- package/dist/runtime/fs-git.js +424 -0
- package/dist/runtime/git-relay.d.ts +46 -0
- package/dist/runtime/git-relay.js +259 -0
- package/dist/runtime/git-unpushed.d.ts +36 -0
- package/dist/runtime/git-unpushed.js +93 -0
- package/dist/runtime/node-version.d.ts +12 -0
- package/dist/runtime/node-version.js +39 -0
- package/dist/runtime/preview-tunnel.d.ts +16 -0
- package/dist/runtime/preview-tunnel.js +135 -0
- package/dist/runtime/processes.d.ts +61 -0
- package/dist/runtime/processes.js +408 -0
- package/dist/runtime/project-node-download.d.ts +17 -0
- package/dist/runtime/project-node-download.js +137 -0
- package/dist/runtime/project-node.d.ts +65 -0
- package/dist/runtime/project-node.js +223 -0
- package/dist/runtime/reap-scratch.d.ts +22 -0
- package/dist/runtime/reap-scratch.js +112 -0
- package/dist/runtime/spill-tool-output.d.ts +14 -0
- package/dist/runtime/spill-tool-output.js +84 -0
- package/dist/runtime/up.d.ts +6 -0
- package/dist/runtime/up.js +1325 -0
- package/dist/tools/_coerce.d.ts +2 -0
- package/dist/tools/_coerce.js +26 -0
- package/dist/tools/_commit-scope.d.ts +14 -0
- package/dist/tools/_commit-scope.js +70 -0
- package/dist/tools/_jail.d.ts +68 -0
- package/dist/tools/_jail.js +209 -0
- package/dist/tools/_output.d.ts +24 -0
- package/dist/tools/_output.js +48 -0
- package/dist/tools/_ripgrep.d.ts +46 -0
- package/dist/tools/_ripgrep.js +148 -0
- package/dist/tools/_run-worktree.d.ts +10 -0
- package/dist/tools/_run-worktree.js +27 -0
- package/dist/tools/_shell-words.d.ts +15 -0
- package/dist/tools/_shell-words.js +43 -0
- package/dist/tools/_sonar/astro.d.ts +6 -0
- package/dist/tools/_sonar/astro.js +45 -0
- package/dist/tools/_sonar/blade.d.ts +3 -0
- package/dist/tools/_sonar/blade.js +53 -0
- package/dist/tools/_sonar/build.d.ts +44 -0
- package/dist/tools/_sonar/build.js +147 -0
- package/dist/tools/_sonar/changed.d.ts +21 -0
- package/dist/tools/_sonar/changed.js +230 -0
- package/dist/tools/_sonar/diagnose/delta.d.ts +27 -0
- package/dist/tools/_sonar/diagnose/delta.js +64 -0
- package/dist/tools/_sonar/diagnose/detect.d.ts +39 -0
- package/dist/tools/_sonar/diagnose/detect.js +117 -0
- package/dist/tools/_sonar/diagnose/index.d.ts +13 -0
- package/dist/tools/_sonar/diagnose/index.js +217 -0
- package/dist/tools/_sonar/diagnose/lint-worker.d.ts +1 -0
- package/dist/tools/_sonar/diagnose/lint-worker.js +48 -0
- package/dist/tools/_sonar/diagnose/pool.d.ts +22 -0
- package/dist/tools/_sonar/diagnose/pool.js +149 -0
- package/dist/tools/_sonar/diagnose/rules.d.ts +23 -0
- package/dist/tools/_sonar/diagnose/rules.js +131 -0
- package/dist/tools/_sonar/diagnose/types-worker.d.ts +1 -0
- package/dist/tools/_sonar/diagnose/types-worker.js +183 -0
- package/dist/tools/_sonar/files.d.ts +14 -0
- package/dist/tools/_sonar/files.js +121 -0
- package/dist/tools/_sonar/graph.d.ts +34 -0
- package/dist/tools/_sonar/graph.js +164 -0
- package/dist/tools/_sonar/hints.d.ts +116 -0
- package/dist/tools/_sonar/hints.js +545 -0
- package/dist/tools/_sonar/imports.d.ts +38 -0
- package/dist/tools/_sonar/imports.js +275 -0
- package/dist/tools/_sonar/index.d.ts +79 -0
- package/dist/tools/_sonar/index.js +462 -0
- package/dist/tools/_sonar/keys.d.ts +5 -0
- package/dist/tools/_sonar/keys.js +248 -0
- package/dist/tools/_sonar/laravel-routes.d.ts +15 -0
- package/dist/tools/_sonar/laravel-routes.js +263 -0
- package/dist/tools/_sonar/laravel.d.ts +64 -0
- package/dist/tools/_sonar/laravel.js +326 -0
- package/dist/tools/_sonar/location.d.ts +33 -0
- package/dist/tools/_sonar/location.js +137 -0
- package/dist/tools/_sonar/map.d.ts +43 -0
- package/dist/tools/_sonar/map.js +212 -0
- package/dist/tools/_sonar/parse.d.ts +3 -0
- package/dist/tools/_sonar/parse.js +76 -0
- package/dist/tools/_sonar/prewarm.d.ts +9 -0
- package/dist/tools/_sonar/prewarm.js +96 -0
- package/dist/tools/_sonar/prisma.d.ts +9 -0
- package/dist/tools/_sonar/prisma.js +51 -0
- package/dist/tools/_sonar/refs.d.ts +7 -0
- package/dist/tools/_sonar/refs.js +273 -0
- package/dist/tools/_sonar/render.d.ts +66 -0
- package/dist/tools/_sonar/render.js +498 -0
- package/dist/tools/_sonar/resolve.d.ts +63 -0
- package/dist/tools/_sonar/resolve.js +402 -0
- package/dist/tools/_sonar/roots.d.ts +4 -0
- package/dist/tools/_sonar/roots.js +42 -0
- package/dist/tools/_sonar/routes.d.ts +5 -0
- package/dist/tools/_sonar/routes.js +247 -0
- package/dist/tools/_sonar/serve.d.ts +12 -0
- package/dist/tools/_sonar/serve.js +104 -0
- package/dist/tools/_sonar/suggest.d.ts +23 -0
- package/dist/tools/_sonar/suggest.js +114 -0
- package/dist/tools/_sonar/tests.d.ts +21 -0
- package/dist/tools/_sonar/tests.js +134 -0
- package/dist/tools/_sonar/tsconfig.d.ts +34 -0
- package/dist/tools/_sonar/tsconfig.js +188 -0
- package/dist/tools/_sonar/types.d.ts +81 -0
- package/dist/tools/_sonar/types.js +6 -0
- package/dist/tools/_symbols.d.ts +27 -0
- package/dist/tools/_symbols.js +461 -0
- package/dist/tools/_test-report.d.ts +47 -0
- package/dist/tools/_test-report.js +203 -0
- package/dist/tools/_touched.d.ts +44 -0
- package/dist/tools/_touched.js +195 -0
- package/dist/tools/_upload.d.ts +26 -0
- package/dist/tools/_upload.js +132 -0
- package/dist/tools/_worktree-setup.d.ts +29 -0
- package/dist/tools/_worktree-setup.js +204 -0
- package/dist/tools/browser.d.ts +2 -0
- package/dist/tools/browser.js +8 -0
- package/dist/tools/commit-guard.d.ts +44 -0
- package/dist/tools/commit-guard.js +165 -0
- package/dist/tools/computer.d.ts +13 -0
- package/dist/tools/computer.js +952 -0
- package/dist/tools/console.d.ts +44 -0
- package/dist/tools/console.js +739 -0
- package/dist/tools/database.d.ts +28 -0
- package/dist/tools/database.js +152 -0
- package/dist/tools/filesystem.d.ts +36 -0
- package/dist/tools/filesystem.js +506 -0
- package/dist/tools/git-tag.d.ts +10 -0
- package/dist/tools/git-tag.js +164 -0
- package/dist/tools/git.d.ts +52 -0
- package/dist/tools/git.js +1272 -0
- package/dist/tools/http.d.ts +12 -0
- package/dist/tools/http.js +119 -0
- package/dist/tools/image.d.ts +8 -0
- package/dist/tools/image.js +551 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +58 -0
- package/dist/tools/outline.d.ts +20 -0
- package/dist/tools/outline.js +98 -0
- package/dist/tools/search.d.ts +17 -0
- package/dist/tools/search.js +391 -0
- package/dist/tools/sonar.d.ts +17 -0
- package/dist/tools/sonar.js +231 -0
- package/dist/tools/testing.d.ts +36 -0
- package/dist/tools/testing.js +273 -0
- package/dist/tools/upload.d.ts +8 -0
- package/dist/tools/upload.js +106 -0
- package/dist/tools/webcam.d.ts +28 -0
- package/dist/tools/webcam.js +967 -0
- package/dist/update/install-kind.d.ts +35 -0
- package/dist/update/install-kind.js +109 -0
- package/dist/update/install.d.ts +32 -0
- package/dist/update/install.js +187 -0
- package/dist/update/manifest.d.ts +18 -0
- package/dist/update/manifest.js +73 -0
- package/dist/update/peers.d.ts +18 -0
- package/dist/update/peers.js +43 -0
- package/dist/update/policy.d.ts +20 -0
- package/dist/update/policy.js +49 -0
- package/dist/update/supervisor.d.ts +25 -0
- package/dist/update/supervisor.js +83 -0
- package/dist/update/updater.d.ts +44 -0
- package/dist/update/updater.js +116 -0
- package/dist/utils/format.d.ts +50 -0
- package/dist/utils/format.js +190 -0
- package/dist/version.d.ts +17 -0
- package/dist/version.js +63 -0
- package/dist/version.json +5 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.d.ts +15 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.js +541 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.d.ts +25 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.js +137 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/guard.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/guard.js +104 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.d.ts +47 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.js +41 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host.d.ts +18 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host.js +15 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/index.d.ts +13 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/index.js +28 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-input.d.ts +74 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-input.js +93 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-open.d.ts +4 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-open.js +57 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live.d.ts +148 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live.js +179 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/local-live.d.ts +31 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/local-live.js +262 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/marks.d.ts +36 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/marks.js +173 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-events.d.ts +27 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-events.js +82 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.d.ts +13 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.js +526 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/params.d.ts +12 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/params.js +32 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/pick.d.ts +24 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/pick.js +76 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/session.d.ts +225 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/session.js +507 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/shots.d.ts +11 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/shots.js +103 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/show.d.ts +10 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/show.js +190 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/target.d.ts +37 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/target.js +82 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/tour.d.ts +19 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/tour.js +178 -0
- package/node_modules/@nordhavnhq/runner-browser/package.json +18 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/config.d.ts +96 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/config.js +25 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/connection.d.ts +276 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/connection.js +507 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/constants.d.ts +48 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/constants.js +95 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.d.ts +94 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.js +219 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.d.ts +136 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.js +214 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.d.ts +735 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.js +40 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.d.ts +362 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.js +703 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.d.ts +105 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.js +202 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.d.ts +204 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.js +497 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.d.ts +45 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.js +176 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.d.ts +74 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.js +72 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.d.ts +59 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.js +117 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.d.ts +62 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.js +84 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.d.ts +27 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.js +80 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.d.ts +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.js +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.d.ts +595 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.js +85 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.d.ts +43 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.js +50 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/inference.d.ts +135 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/inference.js +945 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.d.ts +67 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.js +47 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/platform.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/platform.js +25 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.d.ts +39 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.js +67 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.d.ts +61 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.js +58 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.d.ts +23 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.js +42 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.d.ts +6 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.js +12 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.d.ts +150 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.js +36 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.d.ts +14 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.js +49 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.d.ts +109 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.js +894 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.d.ts +73 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.js +765 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.d.ts +246 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.js +621 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.d.ts +88 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.js +188 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.d.ts +15 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.js +10 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.d.ts +16 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.js +97 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.d.ts +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.js +47 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.d.ts +26 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.js +48 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.d.ts +8 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.js +19 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.d.ts +76 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.js +155 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.d.ts +43 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.js +37 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.d.ts +49 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.js +104 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.d.ts +16 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.js +6 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.d.ts +86 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.js +141 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.d.ts +179 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.js +35 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.js +179 -0
- package/node_modules/@nordhavnhq/runner-runtime/package.json +18 -0
- package/package.json +33 -4
- package/README.md +0 -3
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { FS_SONAR_GRAPH_EDGES, FS_SONAR_GRAPH_NODES, FS_SONAR_MAX_DEPTH } from '@nordhavnhq/runner-runtime';
|
|
2
|
+
const LIMITS = { nodes: FS_SONAR_GRAPH_NODES, edges: FS_SONAR_GRAPH_EDGES };
|
|
3
|
+
/** The folder of a repo-relative path ('' at the root). */
|
|
4
|
+
function dirOf(path) {
|
|
5
|
+
const i = path.lastIndexOf('/');
|
|
6
|
+
return i < 0 ? '' : path.slice(0, i);
|
|
7
|
+
}
|
|
8
|
+
const segmentsOf = (dir) => (dir ? dir.split('/') : []);
|
|
9
|
+
/** True when `path` is `folder` or lies inside it ('' holds everything). */
|
|
10
|
+
function contains(folder, path) {
|
|
11
|
+
return folder === '' || path === folder || path.startsWith(`${folder}/`);
|
|
12
|
+
}
|
|
13
|
+
/** The folder node a file falls in at `depth`: its first `depth` folder segments, its own folder when it sits shallower. */
|
|
14
|
+
export function folderAt(path, depth) {
|
|
15
|
+
return segmentsOf(dirOf(path)).slice(0, depth).join('/');
|
|
16
|
+
}
|
|
17
|
+
/** A folder graph's depth: 1 to FS_SONAR_MAX_DEPTH, 1 when it is no number. */
|
|
18
|
+
export function clampSonarDepth(depth) {
|
|
19
|
+
const n = typeof depth === 'number' && Number.isFinite(depth) ? Math.round(depth) : 1;
|
|
20
|
+
return Math.min(FS_SONAR_MAX_DEPTH, Math.max(1, n));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The workspace a node belongs to, by name: the deepest workspace whose
|
|
24
|
+
* folder holds it. A folder that itself holds another workspace (`apps`,
|
|
25
|
+
* the root of a monorepo) belongs to none.
|
|
26
|
+
*/
|
|
27
|
+
export function workspaceOfNode(id, kind, workspaces) {
|
|
28
|
+
let best = null;
|
|
29
|
+
for (const w of workspaces)
|
|
30
|
+
if (contains(w.dir, id) && (!best || w.dir.length > best.dir.length))
|
|
31
|
+
best = w;
|
|
32
|
+
if (!best)
|
|
33
|
+
return null;
|
|
34
|
+
if (kind === 'folder' && workspaces.some(w => w.dir !== id && w.dir !== best.dir && contains(id, w.dir)))
|
|
35
|
+
return null;
|
|
36
|
+
return best.name;
|
|
37
|
+
}
|
|
38
|
+
const linksOf = (f) => (f.componentEdges.length > 0 ? [...f.edges, ...f.componentEdges] : f.edges);
|
|
39
|
+
/** Every file folded into its group by `keyOf`, with the files outside a group that import into it. */
|
|
40
|
+
function groupFiles(index, keyOf) {
|
|
41
|
+
const groups = new Map();
|
|
42
|
+
for (const f of index.files.values()) {
|
|
43
|
+
const key = keyOf(f.path);
|
|
44
|
+
const g = groups.get(key) ?? { files: 0, lines: 0, symbols: 0, importers: new Set() };
|
|
45
|
+
g.files++;
|
|
46
|
+
g.lines += f.lines;
|
|
47
|
+
g.symbols += f.symbols.length;
|
|
48
|
+
groups.set(key, g);
|
|
49
|
+
}
|
|
50
|
+
for (const f of index.files.values()) {
|
|
51
|
+
const from = keyOf(f.path);
|
|
52
|
+
for (const t of linksOf(f)) {
|
|
53
|
+
if (!index.files.has(t))
|
|
54
|
+
continue;
|
|
55
|
+
const to = keyOf(t);
|
|
56
|
+
if (to !== from)
|
|
57
|
+
groups.get(to)?.importers.add(f.path);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return groups;
|
|
61
|
+
}
|
|
62
|
+
/** The links between groups, summed (`from\0to` -> weight); `keep` decides which pairs count. */
|
|
63
|
+
function sumEdges(index, keyOf, keep) {
|
|
64
|
+
const edges = new Map();
|
|
65
|
+
for (const f of index.files.values()) {
|
|
66
|
+
const from = keyOf(f.path);
|
|
67
|
+
for (const t of linksOf(f)) {
|
|
68
|
+
if (!index.files.has(t))
|
|
69
|
+
continue;
|
|
70
|
+
const to = keyOf(t);
|
|
71
|
+
if (to === from || !keep(from, to))
|
|
72
|
+
continue;
|
|
73
|
+
const k = `${from}\0${to}`;
|
|
74
|
+
edges.set(k, (edges.get(k) ?? 0) + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return edges;
|
|
78
|
+
}
|
|
79
|
+
/** Cut to the limits: the smallest nodes by lines first, then the lightest edges; edges of a cut node go with it. */
|
|
80
|
+
export function limitSonarGraph(nodes, edges, limits = LIMITS) {
|
|
81
|
+
let truncated = false;
|
|
82
|
+
let keptNodes = nodes;
|
|
83
|
+
let keptEdges = edges;
|
|
84
|
+
if (keptNodes.length > limits.nodes) {
|
|
85
|
+
truncated = true;
|
|
86
|
+
keptNodes = [...keptNodes].sort((a, b) => b.lines - a.lines || a.id.localeCompare(b.id)).slice(0, limits.nodes);
|
|
87
|
+
const ids = new Set(keptNodes.map(n => n.id));
|
|
88
|
+
keptEdges = keptEdges.filter(e => ids.has(e.from) && ids.has(e.to));
|
|
89
|
+
}
|
|
90
|
+
if (keptEdges.length > limits.edges) {
|
|
91
|
+
truncated = true;
|
|
92
|
+
keptEdges = [...keptEdges].sort((a, b) => b.weight - a.weight).slice(0, limits.edges);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
nodes: [...keptNodes].sort((a, b) => a.id.localeCompare(b.id)),
|
|
96
|
+
edges: [...keptEdges].sort((a, b) => b.weight - a.weight || a.from.localeCompare(b.from) || a.to.localeCompare(b.to)),
|
|
97
|
+
truncated,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function toEdges(sums) {
|
|
101
|
+
return [...sums].map(([k, weight]) => {
|
|
102
|
+
const [from = '', to = ''] = k.split('\0');
|
|
103
|
+
return { from, to, weight };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function folderNode(id, g, workspaces, external) {
|
|
107
|
+
return {
|
|
108
|
+
id,
|
|
109
|
+
kind: 'folder',
|
|
110
|
+
...(external ? { external: true } : {}),
|
|
111
|
+
files: g.files,
|
|
112
|
+
lines: g.lines,
|
|
113
|
+
symbols: g.symbols,
|
|
114
|
+
workspace: workspaceOfNode(id, 'folder', workspaces),
|
|
115
|
+
importers: g.importers.size,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The index as folders `depth` segments deep (clamped to 1 to
|
|
120
|
+
* FS_SONAR_MAX_DEPTH), a file shallower than that in its own folder, a file
|
|
121
|
+
* at the root in node ''. Edges sum the file links between two folders (a
|
|
122
|
+
* component tag counts as one); `importers` counts the files outside a
|
|
123
|
+
* folder that import into it.
|
|
124
|
+
*/
|
|
125
|
+
export function buildSonarFolderGraph(index, depth, limits = LIMITS, path = '') {
|
|
126
|
+
const d = clampSonarDepth(depth);
|
|
127
|
+
const root = normalizeSonarFolder(path);
|
|
128
|
+
if (root)
|
|
129
|
+
return buildScopedFolderGraph(index, root, d, limits);
|
|
130
|
+
const keyOf = (p) => folderAt(p, d);
|
|
131
|
+
const groups = groupFiles(index, keyOf);
|
|
132
|
+
const nodes = [...groups].map(([id, g]) => folderNode(id, g, index.workspaces, false));
|
|
133
|
+
const cut = limitSonarGraph(nodes, toEdges(sumEdges(index, keyOf, () => true)), limits);
|
|
134
|
+
return { level: 'folder', path: null, depth: d, ...cut };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The folder graph under `root` (the code app's tree root): its folders
|
|
138
|
+
* `depth` segments below it (a file shallower in its own folder), plus, as
|
|
139
|
+
* external nodes, the folders outside it they link with, by `root`'s
|
|
140
|
+
* siblings' level. Edges with at least one end inside `root`.
|
|
141
|
+
*/
|
|
142
|
+
function buildScopedFolderGraph(index, root, depth, limits) {
|
|
143
|
+
const level = segmentsOf(root).length;
|
|
144
|
+
const inside = (id) => contains(root, id);
|
|
145
|
+
const keyOf = (file) => {
|
|
146
|
+
const dir = dirOf(file);
|
|
147
|
+
if (contains(root, dir))
|
|
148
|
+
return segmentsOf(dir).slice(0, level + depth).join('/');
|
|
149
|
+
return segmentsOf(dir).slice(0, level).join('/');
|
|
150
|
+
};
|
|
151
|
+
const groups = groupFiles(index, keyOf);
|
|
152
|
+
const edges = toEdges(sumEdges(index, keyOf, (from, to) => inside(from) || inside(to)));
|
|
153
|
+
const linked = new Set(edges.flatMap(e => [e.from, e.to]));
|
|
154
|
+
const nodes = [];
|
|
155
|
+
for (const [id, g] of groups) {
|
|
156
|
+
if (inside(id))
|
|
157
|
+
nodes.push(folderNode(id, g, index.workspaces, false));
|
|
158
|
+
else if (linked.has(id))
|
|
159
|
+
nodes.push(folderNode(id, g, index.workspaces, true));
|
|
160
|
+
}
|
|
161
|
+
const cut = limitSonarGraph(nodes, edges, limits);
|
|
162
|
+
return { level: 'folder', path: root, depth, ...cut };
|
|
163
|
+
}
|
|
164
|
+
/** A folder path as the graph names it: relative, no leading or trailing slash, '' for the root. */
|
|
165
|
+
export function normalizeSonarFolder(path) {
|
|
166
|
+
const p = path.replace(/\\/g, '/').replace(/^\.?\/+/, '').replace(/\/+$/, '');
|
|
167
|
+
return p === '.' ? '' : p;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The files directly in folder `path`, plus, as external folder nodes, the
|
|
171
|
+
* folders they import from or are imported by: a sub-folder of `path` by its
|
|
172
|
+
* first segment below it, anything else by its first `segments(path)`
|
|
173
|
+
* segments (the siblings' level; a file sitting shallower in its own
|
|
174
|
+
* folder). Edges run between those files, and between a file and an
|
|
175
|
+
* external folder, never between two external folders.
|
|
176
|
+
*/
|
|
177
|
+
export function buildSonarFileGraph(index, path, limits = LIMITS) {
|
|
178
|
+
const p = normalizeSonarFolder(path);
|
|
179
|
+
const level = segmentsOf(p).length;
|
|
180
|
+
// A node id is shown as a file when it is an indexed file right in `path` (a sub-folder's id sits there too).
|
|
181
|
+
const isShown = (id) => dirOf(id) === p && index.files.has(id);
|
|
182
|
+
const keyOf = (file) => {
|
|
183
|
+
const dir = dirOf(file);
|
|
184
|
+
if (dir === p)
|
|
185
|
+
return file;
|
|
186
|
+
if (contains(p, dir))
|
|
187
|
+
return segmentsOf(dir).slice(0, level + 1).join('/');
|
|
188
|
+
return segmentsOf(dir).slice(0, level).join('/');
|
|
189
|
+
};
|
|
190
|
+
const groups = groupFiles(index, keyOf);
|
|
191
|
+
const edges = toEdges(sumEdges(index, keyOf, (from, to) => isShown(from) || isShown(to)));
|
|
192
|
+
const linked = new Set(edges.flatMap(e => [e.from, e.to]));
|
|
193
|
+
const nodes = [];
|
|
194
|
+
for (const [id, g] of groups) {
|
|
195
|
+
const f = isShown(id) ? index.files.get(id) : undefined;
|
|
196
|
+
if (f) {
|
|
197
|
+
nodes.push({ id, kind: 'file', files: 1, lines: f.lines, symbols: f.symbols.length, workspace: workspaceOfNode(id, 'file', index.workspaces), lang: f.lang, importers: g.importers.size });
|
|
198
|
+
}
|
|
199
|
+
else if (linked.has(id)) {
|
|
200
|
+
nodes.push(folderNode(id, g, index.workspaces, true));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const cut = limitSonarGraph(nodes, edges, limits);
|
|
204
|
+
return { level: 'file', path: p, depth: null, ...cut };
|
|
205
|
+
}
|
|
206
|
+
/** Text cut to `max` characters at a line boundary. */
|
|
207
|
+
export function cutAtLine(text, max) {
|
|
208
|
+
if (text.length <= max)
|
|
209
|
+
return text;
|
|
210
|
+
const cut = text.lastIndexOf('\n', max);
|
|
211
|
+
return cut > 0 ? text.slice(0, cut) : text.slice(0, max);
|
|
212
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { scanSymbols } from '../_symbols.js';
|
|
2
|
+
import { astroSymbols, scanAstroImports } from './astro.js';
|
|
3
|
+
import { scanBladeImports } from './blade.js';
|
|
4
|
+
import { sonarLangOf } from './files.js';
|
|
5
|
+
import { scanGoImports, scanJsImports, scanPhpImports, scanPyImports, scanTemplateTags, splitSfc } from './imports.js';
|
|
6
|
+
// ─── Sonar: one file in, one ParsedFile out ─
|
|
7
|
+
//
|
|
8
|
+
// Everything here depends on the file's content only, so it is what the
|
|
9
|
+
// cache keeps: a file whose mtime and size did not change is not read again.
|
|
10
|
+
/** Most symbols one file keeps (a generated file can have thousands). */
|
|
11
|
+
const MAX_SYMBOLS_PER_FILE = 2000;
|
|
12
|
+
function symbolsOf(path, content, lang, lines) {
|
|
13
|
+
if (lang === 'json' || lang === 'other' || lang === 'blade')
|
|
14
|
+
return [];
|
|
15
|
+
if (lang === 'astro')
|
|
16
|
+
return astroSymbols(path, content, lines).slice(0, MAX_SYMBOLS_PER_FILE);
|
|
17
|
+
const found = scanSymbols(path, content) ?? [];
|
|
18
|
+
return found.slice(0, MAX_SYMBOLS_PER_FILE).map(s => (s.parent
|
|
19
|
+
? { name: s.name, kind: s.kind, start: s.start, end: s.end, parent: s.parent }
|
|
20
|
+
: { name: s.name, kind: s.kind, start: s.start, end: s.end }));
|
|
21
|
+
}
|
|
22
|
+
function scanImports(path, content, lang) {
|
|
23
|
+
if (lang === 'ts' || lang === 'js')
|
|
24
|
+
return { ...scanJsImports(content), components: [] };
|
|
25
|
+
if (lang === 'vue' || lang === 'svelte') {
|
|
26
|
+
const { script, template } = splitSfc(content);
|
|
27
|
+
const scan = scanJsImports(script);
|
|
28
|
+
return { ...scan, components: lang === 'vue' ? scanTemplateTags(template, scan.importedNames) : [] };
|
|
29
|
+
}
|
|
30
|
+
if (lang === 'astro')
|
|
31
|
+
return { ...scanAstroImports(content), components: [] };
|
|
32
|
+
if (lang === 'php')
|
|
33
|
+
return { ...scanPhpImports(content, { path }), components: [] };
|
|
34
|
+
if (lang === 'blade')
|
|
35
|
+
return { ...scanBladeImports(content), components: [] };
|
|
36
|
+
if (lang === 'py')
|
|
37
|
+
return { ...scanPyImports(content), components: [] };
|
|
38
|
+
if (lang === 'go')
|
|
39
|
+
return { ...scanGoImports(content), components: [] };
|
|
40
|
+
return { imports: [], exportsNamed: [], components: [] };
|
|
41
|
+
}
|
|
42
|
+
/** Exported names a language marks by convention rather than a keyword. */
|
|
43
|
+
function conventionExports(lang, symbols) {
|
|
44
|
+
const top = symbols.filter(s => !s.parent);
|
|
45
|
+
if (lang === 'py')
|
|
46
|
+
return top.filter(s => !s.name.startsWith('_')).map(s => s.name);
|
|
47
|
+
if (lang === 'go')
|
|
48
|
+
return top.filter(s => /^[A-Z]/.test(s.name)).map(s => s.name);
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
/** Parse one file's content. */
|
|
52
|
+
export function parseSonarFile(path, content, size, mtimeMs) {
|
|
53
|
+
const lang = sonarLangOf(path);
|
|
54
|
+
const lines = content.length === 0 ? 0 : content.split('\n').length - (content.endsWith('\n') ? 1 : 0);
|
|
55
|
+
const symbols = symbolsOf(path, content, lang, lines);
|
|
56
|
+
const scan = scanImports(path, content, lang);
|
|
57
|
+
const parsed = {
|
|
58
|
+
path,
|
|
59
|
+
size,
|
|
60
|
+
mtimeMs,
|
|
61
|
+
lines,
|
|
62
|
+
lang,
|
|
63
|
+
symbols,
|
|
64
|
+
imports: scan.imports,
|
|
65
|
+
exportsNamed: [...new Set([...scan.exportsNamed, ...conventionExports(lang, symbols)])],
|
|
66
|
+
components: scan.components,
|
|
67
|
+
};
|
|
68
|
+
if (scan.namespace)
|
|
69
|
+
parsed.namespace = scan.namespace;
|
|
70
|
+
if (path.endsWith('go.mod')) {
|
|
71
|
+
const mod = /^module\s+(\S+)/m.exec(content)?.[1];
|
|
72
|
+
if (mod)
|
|
73
|
+
parsed.goModule = mod;
|
|
74
|
+
}
|
|
75
|
+
return parsed;
|
|
76
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolProvider } from '@nordhavnhq/runner-runtime';
|
|
2
|
+
/** A dispatch for a coupled checkout: its index brought up to date, or built when it has none that can be used. */
|
|
3
|
+
export declare function prewarmSonarForDispatch(root: string): void;
|
|
4
|
+
/** Warm `root` only when it was indexed before (it has a `.sonar`): git moving files elsewhere is no reason to index. */
|
|
5
|
+
export declare function prewarmSonarIfIndexed(root: string, why: string): void;
|
|
6
|
+
/** When the runner comes up: the checkouts it indexed before, one after the other, after `delayMs`. */
|
|
7
|
+
export declare function prewarmKnownSonarRoots(delayMs?: number): void;
|
|
8
|
+
/** A tool provider that warms the run's checkout after a git tool moved its files. */
|
|
9
|
+
export declare function withSonarPrewarm(provider: ToolProvider): ToolProvider;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { log } from '../../utils/format.js';
|
|
4
|
+
import { catchUpSonar, ensureSonarBuilt } from './build.js';
|
|
5
|
+
import { loadSonarIndex, SonarNotBuiltError } from './index.js';
|
|
6
|
+
import { sonarCachePath } from './location.js';
|
|
7
|
+
import { knownSonarRoots, rememberSonarRoot } from './roots.js';
|
|
8
|
+
// ─── Sonar: kept warm ───────────────────────
|
|
9
|
+
//
|
|
10
|
+
// An index that is there is brought up to date in the background, so the
|
|
11
|
+
// first runner_sonar of a run (or the code app's map) finds it in memory:
|
|
12
|
+
// when a dispatch arrives for a coupled checkout, when the runner comes up
|
|
13
|
+
// (the checkouts it indexed before, from a short list it keeps), and after
|
|
14
|
+
// git moved the files under it (a pull, a switch, a merge, by an agent or
|
|
15
|
+
// from the code app). A dispatch for a coupled checkout without a usable index
|
|
16
|
+
// (no `.sonar`, an outdated or damaged one) builds it (ensureSonarBuilt);
|
|
17
|
+
// startup and git leave a checkout without a `.sonar` alone. One that is too
|
|
18
|
+
// far behind catches up (catchUpSonar). Never awaited by who triggers it; a
|
|
19
|
+
// failure is logged. Overlapping loads of one root share one (loadSonarIndex).
|
|
20
|
+
/** A dispatch warms a root at most this often; git always does. */
|
|
21
|
+
const DISPATCH_EVERY_MS = 30_000;
|
|
22
|
+
const lastWarmed = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Bring the index of `root` up to date in the background. `why` is what
|
|
25
|
+
* asked ('dispatch' is throttled per root and builds a missing or unusable
|
|
26
|
+
* index, anything else only loads). Never throws; the promise settles when
|
|
27
|
+
* the load is done, for whoever wants to wait.
|
|
28
|
+
*/
|
|
29
|
+
function prewarmSonar(root, why) {
|
|
30
|
+
let real;
|
|
31
|
+
try {
|
|
32
|
+
real = realpathSync(root);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
}
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
if (why === 'dispatch' && now - (lastWarmed.get(real) ?? 0) < DISPATCH_EVERY_MS)
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
lastWarmed.set(real, now);
|
|
41
|
+
rememberSonarRoot(real);
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
loadSonarIndex(real).then((index) => {
|
|
45
|
+
catchUpSonar(index);
|
|
46
|
+
resolve();
|
|
47
|
+
}, (err) => {
|
|
48
|
+
if (!(err instanceof SonarNotBuiltError))
|
|
49
|
+
log('✗', 'sonar', `${real}: index not brought up to date (${why}): ${err.message}`);
|
|
50
|
+
else if (why === 'dispatch')
|
|
51
|
+
void ensureSonarBuilt(real);
|
|
52
|
+
resolve();
|
|
53
|
+
});
|
|
54
|
+
}, 0);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** A dispatch for a coupled checkout: its index brought up to date, or built when it has none that can be used. */
|
|
58
|
+
export function prewarmSonarForDispatch(root) {
|
|
59
|
+
void prewarmSonar(root, 'dispatch');
|
|
60
|
+
}
|
|
61
|
+
/** Warm `root` only when it was indexed before (it has a `.sonar`): git moving files elsewhere is no reason to index. */
|
|
62
|
+
export function prewarmSonarIfIndexed(root, why) {
|
|
63
|
+
try {
|
|
64
|
+
if (existsSync(sonarCachePath(realpathSync(root))))
|
|
65
|
+
void prewarmSonar(root, why);
|
|
66
|
+
}
|
|
67
|
+
catch { /* a root that is gone has nothing to warm */ }
|
|
68
|
+
}
|
|
69
|
+
/** When the runner comes up: the checkouts it indexed before, one after the other, after `delayMs`. */
|
|
70
|
+
export function prewarmKnownSonarRoots(delayMs = 5000) {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
void (async () => {
|
|
73
|
+
for (const root of knownSonarRoots()) {
|
|
74
|
+
if (!existsSync(join(root, '.sonar')))
|
|
75
|
+
continue;
|
|
76
|
+
await prewarmSonar(root, 'startup');
|
|
77
|
+
}
|
|
78
|
+
})();
|
|
79
|
+
}, delayMs).unref();
|
|
80
|
+
}
|
|
81
|
+
/** The git tools after which the files of a checkout moved. */
|
|
82
|
+
function movesFiles(name, params) {
|
|
83
|
+
return name === 'runner_git_pull' || name === 'runner_git_merge' || (name === 'runner_git_branch' && params.action === 'switch');
|
|
84
|
+
}
|
|
85
|
+
/** A tool provider that warms the run's checkout after a git tool moved its files. */
|
|
86
|
+
export function withSonarPrewarm(provider) {
|
|
87
|
+
return {
|
|
88
|
+
...provider,
|
|
89
|
+
async executeLocalTool(name, params, context) {
|
|
90
|
+
const result = await provider.executeLocalTool(name, params, context);
|
|
91
|
+
if (context?.projectRoot && movesFiles(name, params) && !result.startsWith('Error'))
|
|
92
|
+
prewarmSonarIfIndexed(context.projectRoot, name);
|
|
93
|
+
return result;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** One block of a Prisma schema: 1-based, inclusive line range. */
|
|
2
|
+
export interface PrismaSymbol {
|
|
3
|
+
name: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/** Every top-level block of a Prisma schema, in line order. */
|
|
9
|
+
export declare function scanPrisma(lines: string[]): PrismaSymbol[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// ─── Sonar: Prisma schemas ──────────────────
|
|
2
|
+
//
|
|
3
|
+
// A .prisma file is a list of top-level blocks: `model X { ... }`,
|
|
4
|
+
// `enum X { ... }`, composite `type X { ... }`, `view X { ... }`, plus
|
|
5
|
+
// `datasource` and `generator`. Each block is one symbol with its line
|
|
6
|
+
// range; fields are not listed. A schema imports nothing.
|
|
7
|
+
const KIND_BY_KEYWORD = {
|
|
8
|
+
model: 'model',
|
|
9
|
+
view: 'model',
|
|
10
|
+
enum: 'enum',
|
|
11
|
+
type: 'type',
|
|
12
|
+
datasource: 'datasource',
|
|
13
|
+
generator: 'generator',
|
|
14
|
+
};
|
|
15
|
+
const BLOCK_START = /^\s*(model|view|enum|type|datasource|generator)\s+([A-Za-z_]\w*)\s*\{/;
|
|
16
|
+
/** A line without its `//` comment and string literals, so braces in them do not count. */
|
|
17
|
+
function codeOf(line) {
|
|
18
|
+
return line.replace(/"(?:[^"\\]|\\.)*"/g, '""').replace(/\/\/.*$/, '');
|
|
19
|
+
}
|
|
20
|
+
/** Every top-level block of a Prisma schema, in line order. */
|
|
21
|
+
export function scanPrisma(lines) {
|
|
22
|
+
const out = [];
|
|
23
|
+
let open = null;
|
|
24
|
+
let depth = 0;
|
|
25
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26
|
+
const line = codeOf(lines[i]);
|
|
27
|
+
if (!open) {
|
|
28
|
+
const m = BLOCK_START.exec(line);
|
|
29
|
+
if (!m)
|
|
30
|
+
continue;
|
|
31
|
+
open = { name: m[2], kind: KIND_BY_KEYWORD[m[1]], start: i + 1, end: i + 1 };
|
|
32
|
+
depth = 0;
|
|
33
|
+
}
|
|
34
|
+
for (const ch of line) {
|
|
35
|
+
if (ch === '{')
|
|
36
|
+
depth++;
|
|
37
|
+
else if (ch === '}')
|
|
38
|
+
depth--;
|
|
39
|
+
}
|
|
40
|
+
if (depth <= 0) {
|
|
41
|
+
open.end = i + 1;
|
|
42
|
+
out.push(open);
|
|
43
|
+
open = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (open) {
|
|
47
|
+
open.end = Math.max(open.start, lines.length);
|
|
48
|
+
out.push(open);
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SonarIndex } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Uses of a symbol, read from the files the import graph points at. `path`
|
|
4
|
+
* is a file that defines it (picks that definition), or a folder or file to
|
|
5
|
+
* show the uses in (every definition).
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderRefs(index: SonarIndex, query: string, path?: string): Promise<string>;
|