@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,164 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join, posix } from 'node:path';
|
|
3
|
+
// ─── Sonar: questions asked of the graph ────
|
|
4
|
+
//
|
|
5
|
+
// Hubs (most importers), importers by depth, test files, folder rollups,
|
|
6
|
+
// entry points and islands (code nothing imports). Pure functions over a
|
|
7
|
+
// loaded index; only entry points read package.json and look for `artisan`.
|
|
8
|
+
const TEST_DIR = /(^|\/)(tests?|__tests__|spec)\//;
|
|
9
|
+
const TEST_FILE = /\.(test|spec)\.[a-z]+$|_test\.go$|(^|\/)test_[^/]+\.py$/;
|
|
10
|
+
export function isTestPath(path) {
|
|
11
|
+
return TEST_DIR.test(path) || TEST_FILE.test(path);
|
|
12
|
+
}
|
|
13
|
+
/** True when `path` is `scope` itself or inside it ('' is the whole repo). */
|
|
14
|
+
export function inScope(path, scope) {
|
|
15
|
+
return !scope || path === scope || path.startsWith(`${scope}/`);
|
|
16
|
+
}
|
|
17
|
+
export function filesIn(index, scope) {
|
|
18
|
+
return [...index.files.values()].filter(f => inScope(f.path, scope));
|
|
19
|
+
}
|
|
20
|
+
/** Files in scope with the most importers (from anywhere). */
|
|
21
|
+
export function topHubs(index, scope, limit) {
|
|
22
|
+
const hubs = [];
|
|
23
|
+
for (const [path, list] of index.importers)
|
|
24
|
+
if (inScope(path, scope))
|
|
25
|
+
hubs.push({ path, importers: list.length });
|
|
26
|
+
return hubs.sort((a, b) => b.importers - a.importers || a.path.localeCompare(b.path)).slice(0, limit);
|
|
27
|
+
}
|
|
28
|
+
/** Importers of a file, level by level: [direct, their importers, ...], each file once at its nearest level. */
|
|
29
|
+
export function importersByDepth(index, path, depth) {
|
|
30
|
+
const seen = new Set([path]);
|
|
31
|
+
const levels = [];
|
|
32
|
+
let frontier = [path];
|
|
33
|
+
for (let d = 0; d < depth && frontier.length > 0; d++) {
|
|
34
|
+
const next = [];
|
|
35
|
+
for (const p of frontier) {
|
|
36
|
+
for (const imp of index.importers.get(p) ?? []) {
|
|
37
|
+
if (seen.has(imp))
|
|
38
|
+
continue;
|
|
39
|
+
seen.add(imp);
|
|
40
|
+
next.push(imp);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (next.length === 0)
|
|
44
|
+
break;
|
|
45
|
+
levels.push(next.sort());
|
|
46
|
+
frontier = next;
|
|
47
|
+
}
|
|
48
|
+
return levels;
|
|
49
|
+
}
|
|
50
|
+
/** File, symbol and line counts per folder key. */
|
|
51
|
+
export function rollup(files, keyOf) {
|
|
52
|
+
const map = new Map();
|
|
53
|
+
for (const f of files) {
|
|
54
|
+
const dir = keyOf(f.path);
|
|
55
|
+
const r = map.get(dir) ?? { dir, files: 0, symbols: 0, lines: 0 };
|
|
56
|
+
r.files++;
|
|
57
|
+
r.symbols += f.symbols.length;
|
|
58
|
+
r.lines += f.lines;
|
|
59
|
+
map.set(dir, r);
|
|
60
|
+
}
|
|
61
|
+
return [...map.values()].sort((a, b) => b.files - a.files || a.dir.localeCompare(b.dir));
|
|
62
|
+
}
|
|
63
|
+
/** The folder one level below `scope` that holds `path` (or the file itself at that level). */
|
|
64
|
+
export function childKey(scope, path) {
|
|
65
|
+
const rest = scope ? path.slice(scope.length + 1) : path;
|
|
66
|
+
const seg = rest.split('/')[0];
|
|
67
|
+
const key = scope ? `${scope}/${seg}` : seg;
|
|
68
|
+
return rest.includes('/') ? `${key}/` : key;
|
|
69
|
+
}
|
|
70
|
+
function readManifest(abs) {
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(readFileSync(abs, 'utf-8'));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function leaves(v) {
|
|
79
|
+
if (typeof v === 'string')
|
|
80
|
+
return [v];
|
|
81
|
+
if (Array.isArray(v))
|
|
82
|
+
return v.flatMap(leaves);
|
|
83
|
+
return v && typeof v === 'object' ? Object.values(v).flatMap(leaves) : [];
|
|
84
|
+
}
|
|
85
|
+
function indexedTarget(index, dir, target) {
|
|
86
|
+
const base = posix.normalize(dir ? `${dir}/${target}` : target);
|
|
87
|
+
const tries = [base, base.replace(/(^|\/)dist\//, '$1src/').replace(/\.(m|c)?js$/, '.$1ts'), `${base}.ts`, `${base}/index.ts`];
|
|
88
|
+
return tries.find(t => index.files.has(t)) ?? null;
|
|
89
|
+
}
|
|
90
|
+
function packageEntries(index, manifestPath, out) {
|
|
91
|
+
const dir = manifestPath.includes('/') ? manifestPath.slice(0, manifestPath.lastIndexOf('/')) : '';
|
|
92
|
+
const m = readManifest(join(index.root, manifestPath));
|
|
93
|
+
if (!m)
|
|
94
|
+
return;
|
|
95
|
+
const add = (target, why) => {
|
|
96
|
+
if (target.endsWith('.json'))
|
|
97
|
+
return;
|
|
98
|
+
const hit = indexedTarget(index, dir, target);
|
|
99
|
+
if (hit && !out.has(hit))
|
|
100
|
+
out.set(hit, why);
|
|
101
|
+
};
|
|
102
|
+
for (const t of leaves(m.bin))
|
|
103
|
+
add(t, 'bin');
|
|
104
|
+
for (const t of [m.main, m.module].filter((x) => typeof x === 'string'))
|
|
105
|
+
add(t, 'main');
|
|
106
|
+
for (const t of leaves(m.exports))
|
|
107
|
+
add(t, 'exports');
|
|
108
|
+
const scripts = (m.scripts ?? {});
|
|
109
|
+
for (const name of ['dev', 'start']) {
|
|
110
|
+
const cmd = scripts[name];
|
|
111
|
+
if (typeof cmd !== 'string')
|
|
112
|
+
continue;
|
|
113
|
+
for (const tok of cmd.split(/\s+/))
|
|
114
|
+
if (/\.(m|c)?[jt]sx?$/.test(tok))
|
|
115
|
+
add(tok, `scripts.${name}`);
|
|
116
|
+
}
|
|
117
|
+
for (const e of ['index.ts', 'index.js', 'index.mjs', 'src/index.ts', 'src/index.js', 'src/main.ts'])
|
|
118
|
+
add(e, 'package index');
|
|
119
|
+
}
|
|
120
|
+
const ENTRY_FILES = [
|
|
121
|
+
[/(^|\/)nuxt\.config\.(ts|js|mjs)$/, 'nuxt.config'],
|
|
122
|
+
[/(^|\/)(vite|astro|next)\.config\.(ts|js|mjs)$/, 'build config'],
|
|
123
|
+
[/(^|\/)routes\/[^/]+\.php$/, 'laravel routes'],
|
|
124
|
+
[/(^|\/)src\/pages\/.+\.astro$/, 'astro page'],
|
|
125
|
+
[/(^|\/)main\.go$/, 'go main'],
|
|
126
|
+
[/(^|\/)__main__\.py$/, 'python main'],
|
|
127
|
+
[/(^|\/)manage\.py$/, 'django manage'],
|
|
128
|
+
];
|
|
129
|
+
/** Entry points in scope, plus how many server route files there are. */
|
|
130
|
+
export function entryPoints(index, scope) {
|
|
131
|
+
const found = new Map();
|
|
132
|
+
let routeFiles = 0;
|
|
133
|
+
for (const f of filesIn(index, scope)) {
|
|
134
|
+
if (f.path === 'package.json' || f.path.endsWith('/package.json'))
|
|
135
|
+
packageEntries(index, f.path, found);
|
|
136
|
+
if (/(^|\/)server\/(api|routes)\//.test(f.path))
|
|
137
|
+
routeFiles++;
|
|
138
|
+
for (const [re, why] of ENTRY_FILES)
|
|
139
|
+
if (re.test(f.path) && !found.has(f.path))
|
|
140
|
+
found.set(f.path, why);
|
|
141
|
+
if (f.path.endsWith('composer.json')) {
|
|
142
|
+
const dir = f.path.slice(0, -'composer.json'.length);
|
|
143
|
+
if (existsSync(join(index.root, dir, 'artisan')))
|
|
144
|
+
found.set(`${dir}artisan`, 'laravel artisan');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const entries = [...found].filter(([p]) => inScope(p, scope)).map(([path, why]) => ({ path, why }));
|
|
148
|
+
return { entries: entries.sort((a, b) => a.path.localeCompare(b.path)), routeFiles };
|
|
149
|
+
}
|
|
150
|
+
// ─── Islands ────────────────────────────────
|
|
151
|
+
const CODE_LANGS = new Set(['ts', 'js', 'vue', 'svelte', 'astro', 'blade', 'php', 'py', 'go']);
|
|
152
|
+
// Loaded by a framework convention, by a tool's config or run directly: no importer expected.
|
|
153
|
+
const CONVENTION = /(^|\/)(pages|layouts|middleware|plugins|server\/(api|routes|middleware|plugins|tasks)|database\/(migrations|seeders|factories)|config|routes|scripts|bin|migrations|public)\/|(^|\/)(app|error)\.vue$|\.config\.[a-z]+$|\.d\.ts$|(^|\/)(app\.config|eslint\.config|vitest\.workspace)\.|(^|\/)\.[^/]+$/;
|
|
154
|
+
/** True when a file is loaded by convention rather than an import. */
|
|
155
|
+
function isConventionLoaded(path) {
|
|
156
|
+
return CONVENTION.test(path);
|
|
157
|
+
}
|
|
158
|
+
/** Code files in scope nothing imports, that are no test, entry point or convention file. */
|
|
159
|
+
export function islands(index, scope, entries) {
|
|
160
|
+
return filesIn(index, scope)
|
|
161
|
+
.filter(f => CODE_LANGS.has(f.lang) && !index.importers.has(f.path) && !entries.has(f.path) && !isTestPath(f.path) && !isConventionLoaded(f.path))
|
|
162
|
+
.map(f => f.path)
|
|
163
|
+
.sort();
|
|
164
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ToolContext } from '../index.js';
|
|
2
|
+
import type { SonarIndex } from './types.js';
|
|
3
|
+
/** True when the agent of this call holds runner_sonar (ToolContext.hasTool). */
|
|
4
|
+
export declare function holdsSonar(context: ToolContext | undefined): boolean;
|
|
5
|
+
/** `hint` on its own line above `output`, or `output` as it is. */
|
|
6
|
+
export declare function withHint(hint: string | null, output: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The concrete identifiers a grep pattern looks for, in order, at most three:
|
|
9
|
+
* `saveTask`, `\bsaveTask\b`, `saveTask\(`, `function useOrganisation\b`,
|
|
10
|
+
* `export (async )?function loadTask`, `(type|interface) (ServiceItem|ServiceRef)`,
|
|
11
|
+
* `ServiceItem\s*=|export interface ServiceRef`. Declaration keywords and
|
|
12
|
+
* optional groups are left out; a word glued to more regex (`save\w*`,
|
|
13
|
+
* `[Ss]ave`, `save.*Task`) is not concrete and gives nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function namesOf(pattern: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* runner_grep `pattern`, searched in `at` (repo-relative; empty or undefined
|
|
18
|
+
* for the whole checkout): where the concrete names it looks for are defined
|
|
19
|
+
* and how to list their uses, or, for a declaration grep without a name in a
|
|
20
|
+
* file or folder, how to get its outline.
|
|
21
|
+
*/
|
|
22
|
+
export declare function grepHint(index: SonarIndex, pattern: string, at?: string): string | null;
|
|
23
|
+
/** A whole-file read of a big file with symbols: its outline, and how to read one part. */
|
|
24
|
+
export declare function readHint(index: SonarIndex, rel: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* A read of lines `from`-`to` (1-based, inclusive) of a big code file: the
|
|
27
|
+
* symbols in that range, so the next read can be by symbol instead of a guessed
|
|
28
|
+
* offset. Null for a small, symbol-less or non-code file, a range that covers
|
|
29
|
+
* the whole file, or a range with no symbol in it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function rangeHint(index: SonarIndex, rel: string, from: number, to: number): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* A grep inside one big indexed code file that names no definition: its
|
|
34
|
+
* outline answers where things are without another grep or a guessed read.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fileGrepHint(index: SonarIndex, at: string | undefined): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* runner_glob `pattern` whose file-name part is a concrete name (`**\/*sonar*`,
|
|
39
|
+
* `src/**\/useTasks.ts`): where a symbol of that name is defined, as the grep
|
|
40
|
+
* hint says it. A pattern of wildcards and extensions only gives nothing.
|
|
41
|
+
*/
|
|
42
|
+
export declare function globHint(index: SonarIndex, pattern: string): string | null;
|
|
43
|
+
/** A listing of a folder with many indexed code files: how to get its map at once. */
|
|
44
|
+
export declare function listHint(index: SonarIndex, rel: string): string | null;
|
|
45
|
+
/** runner_test without a filter: how to find the tests that cover a change. */
|
|
46
|
+
export declare const TEST_HINT = "sonar: runner_sonar { action: \"tests\", path: \"<changed file>\" } names the tests that cover a file and the runner_test { cwd, filter } that runs them; the full suite at most once, at the end.";
|
|
47
|
+
/** An edit of a file many others import: how to see what depends on it. */
|
|
48
|
+
export declare function editHint(index: SonarIndex, rel: string): string | null;
|
|
49
|
+
/** Outline rows a read outline lists at most. */
|
|
50
|
+
export declare const READ_OUTLINE_MAX_ROWS = 80;
|
|
51
|
+
/** Lines of the file a read outline shows under it (imports, header). */
|
|
52
|
+
export declare const READ_OUTLINE_HEAD_LINES = 60;
|
|
53
|
+
/**
|
|
54
|
+
* What the first whole read of a big code file shows instead of its text: a
|
|
55
|
+
* `sonar:` line on how to read on, then its symbols with their line ranges
|
|
56
|
+
* (at most READ_OUTLINE_MAX_ROWS). Null for a small, symbol-less or non-code
|
|
57
|
+
* file, or one the index does not have.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readOutline(index: SonarIndex, rel: string): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* A declaration grep for one name with one pointable definition: a `sonar:`
|
|
62
|
+
* line, then its code as runner_sonar find { read: true } shows it (with its
|
|
63
|
+
* doc comment, at most BODY_MAX_LINES), then a blank line for the grep result.
|
|
64
|
+
* `lineOf` reads a line of a repo-relative file. Null otherwise: a bare
|
|
65
|
+
* identifier is a question about uses, several definitions need a choice.
|
|
66
|
+
*/
|
|
67
|
+
export declare function grepDefinition(index: SonarIndex, pattern: string, lineOf: (path: string, line: number) => string): string | null;
|
|
68
|
+
/** The run a call belongs to: the dispatch's queue entry, else its conversation or task. */
|
|
69
|
+
export declare function runKeyOf(context: ToolContext | undefined): string;
|
|
70
|
+
/** True the first time a run asks for `key`, false after (until the memo expires). Exported for tests. */
|
|
71
|
+
export declare function firstInRun(context: ToolContext | undefined, key: string, now?: number): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* What goes on top of runner_grep `pattern` in the checkout of `context`,
|
|
74
|
+
* searched in `opts.path` (absolute) when given: the code of the one
|
|
75
|
+
* definition a declaration grep looks for, else the grep hint.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sonarGrepAnswer(pattern: string, context: ToolContext | undefined, opts?: {
|
|
78
|
+
cacheDir?: string;
|
|
79
|
+
path?: string;
|
|
80
|
+
}): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* What a whole-file runner_read_file of `abs` gets from sonar: the outline
|
|
83
|
+
* instead of the text (`outline: true`, the first whole read of a big code
|
|
84
|
+
* file in a run, while the index matches the file on disk), a hint above the
|
|
85
|
+
* text, or nothing (a repeat read is a deliberate one: the text alone).
|
|
86
|
+
*/
|
|
87
|
+
export declare function sonarReadView(abs: string, context: ToolContext | undefined, opts?: {
|
|
88
|
+
cacheDir?: string;
|
|
89
|
+
}): {
|
|
90
|
+
text: string;
|
|
91
|
+
outline: boolean;
|
|
92
|
+
} | null;
|
|
93
|
+
/**
|
|
94
|
+
* The hint for a runner_read_file of `abs` from line `from` to `to` (1-based,
|
|
95
|
+
* inclusive): the symbols in that range, once per file per run. Not for a file
|
|
96
|
+
* the index no longer matches: its line ranges would point at the wrong code.
|
|
97
|
+
*/
|
|
98
|
+
export declare function sonarRangeHint(abs: string, from: number, to: number, context: ToolContext | undefined, opts?: {
|
|
99
|
+
cacheDir?: string;
|
|
100
|
+
}): string | null;
|
|
101
|
+
/** The hint for runner_glob `pattern` in the checkout of `context`. */
|
|
102
|
+
export declare function sonarGlobHint(pattern: string, context: ToolContext | undefined, opts?: {
|
|
103
|
+
cacheDir?: string;
|
|
104
|
+
}): string | null;
|
|
105
|
+
/** The hint for runner_list_directory of the folder `abs`, once per folder per run. */
|
|
106
|
+
export declare function sonarListHint(abs: string, context: ToolContext | undefined, opts?: {
|
|
107
|
+
cacheDir?: string;
|
|
108
|
+
}): string | null;
|
|
109
|
+
/** The hint for runner_test without a filter in a checkout with an index, once per run. */
|
|
110
|
+
export declare function sonarTestHint(filter: string | undefined, context: ToolContext | undefined, opts?: {
|
|
111
|
+
cacheDir?: string;
|
|
112
|
+
}): string | null;
|
|
113
|
+
/** The hint for runner_edit_file / runner_write_file on the existing file `abs`, once per file per run. */
|
|
114
|
+
export declare function sonarEditHint(abs: string, context: ToolContext | undefined, opts?: {
|
|
115
|
+
cacheDir?: string;
|
|
116
|
+
}): string | null;
|