@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,461 @@
|
|
|
1
|
+
import { scanPrisma } from './_sonar/prisma.js';
|
|
2
|
+
const EXTENSIONS = {
|
|
3
|
+
ts: 'js', tsx: 'js', mts: 'js', cts: 'js', js: 'js', jsx: 'js', mjs: 'js', cjs: 'js', vue: 'js', svelte: 'js',
|
|
4
|
+
php: 'php',
|
|
5
|
+
py: 'py', pyi: 'py',
|
|
6
|
+
go: 'go',
|
|
7
|
+
rs: 'rust',
|
|
8
|
+
java: 'clike', kt: 'clike', kts: 'clike', cs: 'clike', swift: 'clike', scala: 'clike', dart: 'clike',
|
|
9
|
+
c: 'clike', h: 'clike', cc: 'clike', cpp: 'clike', hpp: 'clike', cxx: 'clike', m: 'clike',
|
|
10
|
+
md: 'md', mdx: 'md', markdown: 'md',
|
|
11
|
+
prisma: 'prisma',
|
|
12
|
+
};
|
|
13
|
+
/** The scanner a path gets, or null when there is none for its language. */
|
|
14
|
+
function symbolLanguageOf(path) {
|
|
15
|
+
const lower = path.toLowerCase();
|
|
16
|
+
if (lower.endsWith('.blade.php'))
|
|
17
|
+
return null; // a template: mostly HTML
|
|
18
|
+
const ext = lower.slice(lower.lastIndexOf('.') + 1);
|
|
19
|
+
return EXTENSIONS[ext] ?? null;
|
|
20
|
+
}
|
|
21
|
+
/** Every symbol of a file in line order, or null for an unknown language. */
|
|
22
|
+
export function scanSymbols(path, content) {
|
|
23
|
+
const lang = symbolLanguageOf(path);
|
|
24
|
+
if (!lang)
|
|
25
|
+
return null;
|
|
26
|
+
const lines = content.split('\n');
|
|
27
|
+
if (lang === 'md')
|
|
28
|
+
return scanMarkdown(lines);
|
|
29
|
+
if (lang === 'prisma')
|
|
30
|
+
return scanPrisma(lines).map(s => ({ ...s, level: 0 }));
|
|
31
|
+
if (lang === 'py')
|
|
32
|
+
return scanPython(lines);
|
|
33
|
+
const ext = path.toLowerCase().slice(path.lastIndexOf('.') + 1);
|
|
34
|
+
return scanBraced(ext === 'vue' || ext === 'svelte' ? onlyScriptBlocks(lines) : lines, lang);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The first line a reader of `symbol` wants: its doc comment, decorators or
|
|
38
|
+
* attributes directly above it. 1-based in, 1-based out.
|
|
39
|
+
*/
|
|
40
|
+
export function symbolDocStart(content, symbol) {
|
|
41
|
+
const lines = content.split('\n');
|
|
42
|
+
let s = symbol.start;
|
|
43
|
+
while (s > 1) {
|
|
44
|
+
const t = lines[s - 2].trim();
|
|
45
|
+
if (!t || !/^(?:\/\/|\/\*|\*|#|@)/.test(t))
|
|
46
|
+
break;
|
|
47
|
+
s--;
|
|
48
|
+
}
|
|
49
|
+
return s;
|
|
50
|
+
}
|
|
51
|
+
/** "Class.method" for a symbol inside something, else its own name. */
|
|
52
|
+
export function qualifiedName(s) {
|
|
53
|
+
return s.parent ? `${s.parent}.${s.name}` : s.name;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The symbols a `symbol` argument names: "saveTask", "TaskStore.save",
|
|
57
|
+
* "TaskStore::save" or "TaskStore#save". An exact (case-sensitive) match wins
|
|
58
|
+
* over a case-insensitive one.
|
|
59
|
+
*/
|
|
60
|
+
export function findSymbols(symbols, query) {
|
|
61
|
+
const raw = query.trim().replace(/\(\)$/, '');
|
|
62
|
+
// A heading or a name that contains dots itself ("Node 22.22.0") first.
|
|
63
|
+
const whole = symbols.filter(s => s.name === raw);
|
|
64
|
+
if (whole.length > 0)
|
|
65
|
+
return whole;
|
|
66
|
+
const q = raw.replace(/::|->|(\w)#/g, (m, w) => (w ? `${w}.` : '.'));
|
|
67
|
+
const dot = q.lastIndexOf('.');
|
|
68
|
+
const name = dot === -1 ? q : q.slice(dot + 1);
|
|
69
|
+
const parent = dot === -1 ? null : q.slice(0, dot).split('.').pop();
|
|
70
|
+
const matches = (s, fold) => fold(s.name) === fold(name) && (parent === null || fold(s.parent ?? '') === fold(parent));
|
|
71
|
+
const exact = symbols.filter(s => matches(s, v => v));
|
|
72
|
+
if (exact.length > 0)
|
|
73
|
+
return exact;
|
|
74
|
+
const folded = symbols.filter(s => matches(s, v => v.toLowerCase()));
|
|
75
|
+
if (folded.length > 0)
|
|
76
|
+
return folded;
|
|
77
|
+
// Last: part of a name ("lean task" finds the heading "Lean task runs").
|
|
78
|
+
const part = raw.toLowerCase();
|
|
79
|
+
return symbols.filter(s => s.name.toLowerCase().includes(part));
|
|
80
|
+
}
|
|
81
|
+
const OPEN = new Set(['{', '(', '[']);
|
|
82
|
+
const CLOSE = new Set(['}', ')', ']']);
|
|
83
|
+
/** A JavaScript `/` that starts a regex literal rather than dividing. */
|
|
84
|
+
function startsRegex(code) {
|
|
85
|
+
const before = code.trimEnd();
|
|
86
|
+
return before === '' || /[(,=:[!&|?{};+\-*%<>~^]$/.test(before) || /\b(?:return|typeof|case|in|of|delete|void|throw|new)$/.test(before);
|
|
87
|
+
}
|
|
88
|
+
function lex(lines, lang) {
|
|
89
|
+
const info = { depthStart: [], depthEnd: [], startsInCode: [], codeEnd: [] };
|
|
90
|
+
let depth = 0;
|
|
91
|
+
let mode = 'code';
|
|
92
|
+
let quote = '';
|
|
93
|
+
const tmplStack = [];
|
|
94
|
+
// A '/" string ends at the end of its line in these languages: a stray quote
|
|
95
|
+
// (an apostrophe in a regex the lexer did not see as one) costs one line.
|
|
96
|
+
const strEndsAtEol = lang === 'js' || lang === 'clike' || lang === 'go';
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
info.depthStart.push(depth);
|
|
99
|
+
info.startsInCode.push(mode === 'code');
|
|
100
|
+
let codeEnd = line.length;
|
|
101
|
+
for (let i = 0; i < line.length; i++) {
|
|
102
|
+
const c = line[i];
|
|
103
|
+
const next = line[i + 1];
|
|
104
|
+
if (mode === 'block') {
|
|
105
|
+
if (c === '*' && next === '/') {
|
|
106
|
+
mode = 'code';
|
|
107
|
+
i++;
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (mode === 'str') {
|
|
112
|
+
if (c === '\\') {
|
|
113
|
+
i++;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (c === quote)
|
|
117
|
+
mode = 'code';
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (mode === 'tmpl') {
|
|
121
|
+
if (c === '\\') {
|
|
122
|
+
i++;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (c === '`') {
|
|
126
|
+
mode = 'code';
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (c === '$' && next === '{') {
|
|
130
|
+
tmplStack.push(depth);
|
|
131
|
+
depth++;
|
|
132
|
+
i++;
|
|
133
|
+
mode = 'code';
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
// code
|
|
138
|
+
if (c === '/' && next === '/') {
|
|
139
|
+
codeEnd = i;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (c === '#' && lang === 'php' && next !== '[') {
|
|
143
|
+
codeEnd = i;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (c === '/' && next === '*') {
|
|
147
|
+
mode = 'block';
|
|
148
|
+
i++;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (c === '"') {
|
|
152
|
+
mode = 'str';
|
|
153
|
+
quote = '"';
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (c === '\'') {
|
|
157
|
+
if (lang === 'rust' && !/^'(?:\\.[^']*|[^'\\])'/.test(line.slice(i)))
|
|
158
|
+
continue; // a lifetime
|
|
159
|
+
mode = 'str';
|
|
160
|
+
quote = '\'';
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (c === '`') {
|
|
164
|
+
if (lang === 'js') {
|
|
165
|
+
mode = 'tmpl';
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (lang === 'go') {
|
|
169
|
+
mode = 'str';
|
|
170
|
+
quote = '`';
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (c === '/' && lang === 'js' && startsRegex(line.slice(0, i))) {
|
|
175
|
+
// Skip to the closing slash, honouring escapes and a character class.
|
|
176
|
+
let inClass = false;
|
|
177
|
+
let j = i + 1;
|
|
178
|
+
for (; j < line.length; j++) {
|
|
179
|
+
const r = line[j];
|
|
180
|
+
if (r === '\\') {
|
|
181
|
+
j++;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (r === '[')
|
|
185
|
+
inClass = true;
|
|
186
|
+
else if (r === ']')
|
|
187
|
+
inClass = false;
|
|
188
|
+
else if (r === '/' && !inClass)
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
i = j;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (OPEN.has(c))
|
|
195
|
+
depth++;
|
|
196
|
+
else if (CLOSE.has(c)) {
|
|
197
|
+
depth = Math.max(0, depth - 1);
|
|
198
|
+
if (c === '}' && tmplStack.length > 0 && tmplStack[tmplStack.length - 1] === depth) {
|
|
199
|
+
tmplStack.pop();
|
|
200
|
+
mode = 'tmpl';
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (mode === 'str' && strEndsAtEol && quote !== '`')
|
|
205
|
+
mode = 'code';
|
|
206
|
+
info.depthEnd.push(depth);
|
|
207
|
+
info.codeEnd.push(codeEnd);
|
|
208
|
+
}
|
|
209
|
+
return info;
|
|
210
|
+
}
|
|
211
|
+
const IDENT = '[A-Za-z_$][\\w$]*';
|
|
212
|
+
const CONTROL = new Set(['if', 'for', 'while', 'switch', 'catch', 'return', 'else', 'do', 'try', 'new', 'throw', 'super', 'function', 'typeof', 'await', 'foreach', 'using', 'lock', 'sizeof', 'when', 'match', 'elif', 'with']);
|
|
213
|
+
const JS_TOP = [
|
|
214
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${IDENT})`), kind: 'class', container: true },
|
|
215
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?function\\s*\\*?\\s*(${IDENT})`), kind: 'function' },
|
|
216
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?interface\\s+(${IDENT})`), kind: 'interface' },
|
|
217
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?type\\s+(${IDENT})\\s*(?:<.*>)?\\s*=`), kind: 'type' },
|
|
218
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?(?:const\\s+)?enum\\s+(${IDENT})`), kind: 'enum' },
|
|
219
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?(?:namespace|module)\\s+(${IDENT})`), kind: 'namespace', container: true },
|
|
220
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${IDENT})\\s*(?::[^=]*)?=\\s*(?:async\\s+)?(?:function\\b|(?:<[^>]*>\\s*)?\\([^)]*\\)?\\s*(?::[^=]*)?=>|${IDENT}\\s*=>)`), kind: 'function' },
|
|
221
|
+
{ re: new RegExp(`^\\s*(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${IDENT})`), kind: 'const' },
|
|
222
|
+
{ re: /^\s*export\s+(default)\b/, kind: 'export' },
|
|
223
|
+
];
|
|
224
|
+
const JS_MEMBER = [
|
|
225
|
+
{ re: new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|declare|override|accessor)\\s+)*(#?${IDENT})\\s*[?!]?\\s*(?::[^=]*)?=\\s*(?:async\\s+)?(?:function\\b|(?:<[^>]*>\\s*)?\\([^)]*\\)?\\s*(?::[^=]*)?=>|${IDENT}\\s*=>)`), kind: 'method' },
|
|
226
|
+
{ re: new RegExp(`^\\s*(?:(?:public|private|protected|static|readonly|async|abstract|override|declare|accessor)\\s+)*(?:(get|set)\\s+)?\\*?\\s*(#?${IDENT})\\s*[?!]?\\s*(?:<[^>]*>)?\\s*\\(`), kind: 'method', group: 2 },
|
|
227
|
+
];
|
|
228
|
+
const PHP_TOP = [
|
|
229
|
+
{ re: /^\s*(?:(?:abstract|final|readonly)\s+)*(?:class|interface|trait|enum)\s+(\w+)/, kind: 'class', container: true },
|
|
230
|
+
{ re: /^\s*function\s+&?\s*(\w+)/, kind: 'function' },
|
|
231
|
+
];
|
|
232
|
+
const PHP_MEMBER = [
|
|
233
|
+
{ re: /^\s*(?:(?:public|private|protected|static|abstract|final|readonly)\s+)*function\s+&?\s*(\w+)/, kind: 'method' },
|
|
234
|
+
];
|
|
235
|
+
const GO_TOP = [
|
|
236
|
+
{ re: /^func\s+\(\s*\w*\s*\*?\s*(\w+)[^)]*\)\s*(\w+)/, kind: 'method', group: 2, parentGroup: 1 },
|
|
237
|
+
{ re: /^func\s+(\w+)/, kind: 'function' },
|
|
238
|
+
{ re: /^type\s+(\w+)\s+(?:struct|interface)\b/, kind: 'type' },
|
|
239
|
+
{ re: /^type\s+(\w+)/, kind: 'type' },
|
|
240
|
+
{ re: /^(?:var|const)\s+(\w+)/, kind: 'const' },
|
|
241
|
+
];
|
|
242
|
+
const RUST_FN = /^\s*(?:pub(?:\([^)]*\))?\s+)?(?:default\s+)?(?:const\s+)?(?:async\s+)?(?:unsafe\s+)?(?:extern\s+"[^"]*"\s+)?fn\s+(\w+)/;
|
|
243
|
+
const RUST_TOP = [
|
|
244
|
+
{ re: /^\s*(?:pub(?:\([^)]*\))?\s+)?(?:unsafe\s+)?impl(?:<.*?>)?\s+(?:[\w:<>, &']+\s+for\s+)?&?([\w:]+)/, kind: 'impl', container: true },
|
|
245
|
+
{ re: /^\s*(?:pub(?:\([^)]*\))?\s+)?(?:unsafe\s+)?trait\s+(\w+)/, kind: 'trait', container: true },
|
|
246
|
+
{ re: /^\s*(?:pub(?:\([^)]*\))?\s+)?mod\s+(\w+)\s*\{/, kind: 'mod', container: true },
|
|
247
|
+
{ re: /^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|enum|union)\s+(\w+)/, kind: 'struct' },
|
|
248
|
+
{ re: /^\s*(?:pub(?:\([^)]*\))?\s+)?type\s+(\w+)/, kind: 'type' },
|
|
249
|
+
{ re: RUST_FN, kind: 'function' },
|
|
250
|
+
];
|
|
251
|
+
const RUST_MEMBER = [{ re: RUST_FN, kind: 'method' }];
|
|
252
|
+
const CLIKE_CONTAINER = {
|
|
253
|
+
re: /^\s*(?:@\w+(?:\([^)]*\))?\s+)*(?:(?:public|private|protected|internal|static|final|abstract|sealed|partial|open|data|inner|export|readonly|ref|unsafe|enum|annotation|companion)\s+)*(?:class|interface|enum|struct|record|object|trait|namespace|extension|protocol)\s+(\w+)/,
|
|
254
|
+
kind: 'class',
|
|
255
|
+
container: true,
|
|
256
|
+
};
|
|
257
|
+
const CLIKE_FN = {
|
|
258
|
+
re: /^\s*(?:@\w+(?:\([^)]*\))?\s+)*(?:(?:public|private|protected|internal|static|final|abstract|override|virtual|async|open|suspend|inline|synchronized|native|sealed|extern|unsafe|partial|mutating|const|constexpr|fun|func|def)\s+)*(?:[\w<>[\],.?*&:]+\s+)?[*&]?(\w+)\s*(?:<[^>]*>)?\s*\([^;]*$/,
|
|
259
|
+
kind: 'function',
|
|
260
|
+
};
|
|
261
|
+
const CLIKE_TOP = [CLIKE_CONTAINER, CLIKE_FN];
|
|
262
|
+
const CLIKE_MEMBER = [CLIKE_CONTAINER, { ...CLIKE_FN, kind: 'method' }];
|
|
263
|
+
const PATTERNS = {
|
|
264
|
+
js: { top: JS_TOP, member: JS_MEMBER },
|
|
265
|
+
php: { top: PHP_TOP, member: PHP_MEMBER },
|
|
266
|
+
go: { top: GO_TOP, member: [] },
|
|
267
|
+
rust: { top: RUST_TOP, member: RUST_MEMBER },
|
|
268
|
+
clike: { top: CLIKE_TOP, member: CLIKE_MEMBER },
|
|
269
|
+
};
|
|
270
|
+
/** A line ending like this goes on on the next line. */
|
|
271
|
+
const CONTINUES_AFTER = /(?:[=,(|&+\-*?:<[]|=>|->|\bextends|\bimplements|\bas)$/;
|
|
272
|
+
/** A next line starting like this belongs to the statement above. */
|
|
273
|
+
const CONTINUES_BEFORE = /^(?:[.?|&:{]|=>|->|extends\b|implements\b|where\b|throws\b)/;
|
|
274
|
+
function match(patterns, text) {
|
|
275
|
+
for (const p of patterns) {
|
|
276
|
+
const m = p.re.exec(text);
|
|
277
|
+
const name = m?.[p.group ?? 1];
|
|
278
|
+
if (!name || CONTROL.has(name))
|
|
279
|
+
continue;
|
|
280
|
+
return { name, kind: p.kind, container: p.container === true, parent: p.parentGroup ? m?.[p.parentGroup] : undefined };
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
function scanBraced(lines, lang) {
|
|
285
|
+
const info = lex(lines, lang);
|
|
286
|
+
const { top, member } = PATTERNS[lang];
|
|
287
|
+
const code = (l) => lines[l].slice(0, info.codeEnd[l]);
|
|
288
|
+
// Where the declaration starting on line `i` ends: back at its own depth on
|
|
289
|
+
// a line that does not carry on into the next one.
|
|
290
|
+
const statementEnd = (i) => {
|
|
291
|
+
const base = info.depthStart[i];
|
|
292
|
+
for (let l = i; l < lines.length; l++) {
|
|
293
|
+
if (info.depthEnd[l] > base)
|
|
294
|
+
continue;
|
|
295
|
+
if (info.depthEnd[l] < base)
|
|
296
|
+
return l;
|
|
297
|
+
if (CONTINUES_AFTER.test(code(l).trimEnd()))
|
|
298
|
+
continue;
|
|
299
|
+
let n = l + 1;
|
|
300
|
+
while (n < lines.length && !code(n).trim())
|
|
301
|
+
n++;
|
|
302
|
+
if (n < lines.length && info.depthStart[n] === base && CONTINUES_BEFORE.test(code(n).trimStart()))
|
|
303
|
+
continue;
|
|
304
|
+
return l;
|
|
305
|
+
}
|
|
306
|
+
return lines.length - 1;
|
|
307
|
+
};
|
|
308
|
+
const out = [];
|
|
309
|
+
const containers = [];
|
|
310
|
+
for (let i = 0; i < lines.length; i++) {
|
|
311
|
+
while (containers.length > 0 && containers[containers.length - 1].end < i + 1)
|
|
312
|
+
containers.pop();
|
|
313
|
+
if (!info.startsInCode[i])
|
|
314
|
+
continue;
|
|
315
|
+
const text = code(i);
|
|
316
|
+
if (!text.trim())
|
|
317
|
+
continue;
|
|
318
|
+
const parent = containers[containers.length - 1];
|
|
319
|
+
let hit = null;
|
|
320
|
+
if (!parent) {
|
|
321
|
+
if (info.depthStart[i] === 0)
|
|
322
|
+
hit = match(top, text);
|
|
323
|
+
}
|
|
324
|
+
else if (info.depthStart[i] === info.depthStart[parent.start - 1] + 1) {
|
|
325
|
+
// Inside a namespace or module the top-level forms count; inside a class its members.
|
|
326
|
+
hit = parent.kind === 'namespace' || parent.kind === 'mod'
|
|
327
|
+
? match(top, text)
|
|
328
|
+
: match(member, text) ?? match(top.filter(p => p.container), text);
|
|
329
|
+
}
|
|
330
|
+
if (!hit)
|
|
331
|
+
continue;
|
|
332
|
+
const end = statementEnd(i) + 1;
|
|
333
|
+
const sym = { name: hit.name, kind: hit.kind, start: i + 1, end, level: containers.length };
|
|
334
|
+
if (parent ?? hit.parent)
|
|
335
|
+
sym.parent = parent?.name ?? hit.parent;
|
|
336
|
+
out.push(sym);
|
|
337
|
+
if (hit.container && end > i + 1)
|
|
338
|
+
containers.push(sym);
|
|
339
|
+
}
|
|
340
|
+
return out;
|
|
341
|
+
}
|
|
342
|
+
/** A .vue or .svelte file with everything outside its <script> blocks blanked,
|
|
343
|
+
* so the template's quotes and braces never reach the lexer. */
|
|
344
|
+
function onlyScriptBlocks(lines) {
|
|
345
|
+
let inScript = false;
|
|
346
|
+
return lines.map((line) => {
|
|
347
|
+
if (!inScript && /^\s*<script\b/i.test(line)) {
|
|
348
|
+
inScript = !/<\/script>/i.test(line);
|
|
349
|
+
return '';
|
|
350
|
+
}
|
|
351
|
+
if (inScript && /^\s*<\/script>/i.test(line)) {
|
|
352
|
+
inScript = false;
|
|
353
|
+
return '';
|
|
354
|
+
}
|
|
355
|
+
return inScript ? line : '';
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
// ─── Python ─────────────────────────────────
|
|
359
|
+
function scanPython(lines) {
|
|
360
|
+
// Lines inside a triple-quoted string never end a block.
|
|
361
|
+
const inString = [];
|
|
362
|
+
let triple = null;
|
|
363
|
+
for (const line of lines) {
|
|
364
|
+
inString.push(triple !== null);
|
|
365
|
+
const re = /"""|'''/g;
|
|
366
|
+
let m;
|
|
367
|
+
while ((m = re.exec(line)) !== null) {
|
|
368
|
+
if (triple === null)
|
|
369
|
+
triple = m[0];
|
|
370
|
+
else if (triple === m[0])
|
|
371
|
+
triple = null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const indentOf = (l) => l.length - l.trimStart().length;
|
|
375
|
+
const isCode = (l) => !inString[l] && lines[l].trim() !== '' && !lines[l].trim().startsWith('#');
|
|
376
|
+
const out = [];
|
|
377
|
+
const stack = [];
|
|
378
|
+
for (let i = 0; i < lines.length; i++) {
|
|
379
|
+
if (!isCode(i))
|
|
380
|
+
continue;
|
|
381
|
+
const m = /^(\s*)(?:async\s+)?(def|class)\s+(\w+)/.exec(lines[i]);
|
|
382
|
+
const indent = indentOf(lines[i]);
|
|
383
|
+
while (stack.length > 0 && stack[stack.length - 1].indent >= indent)
|
|
384
|
+
stack.pop();
|
|
385
|
+
if (!m)
|
|
386
|
+
continue;
|
|
387
|
+
// Only top-level symbols and members of classes: a helper nested in a
|
|
388
|
+
// function is part of that function.
|
|
389
|
+
if (stack.some(s => s.sym.kind !== 'class'))
|
|
390
|
+
continue;
|
|
391
|
+
// The signature may span lines: its body starts after the bracket closes.
|
|
392
|
+
let header = i;
|
|
393
|
+
let depth = 0;
|
|
394
|
+
for (let l = i; l < lines.length; l++) {
|
|
395
|
+
for (const c of lines[l].replace(/#.*$/, '')) {
|
|
396
|
+
if (c === '(' || c === '[' || c === '{')
|
|
397
|
+
depth++;
|
|
398
|
+
else if (c === ')' || c === ']' || c === '}')
|
|
399
|
+
depth--;
|
|
400
|
+
}
|
|
401
|
+
header = l;
|
|
402
|
+
if (depth <= 0)
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
let end = header;
|
|
406
|
+
for (let l = header + 1; l < lines.length; l++) {
|
|
407
|
+
if (!isCode(l))
|
|
408
|
+
continue;
|
|
409
|
+
if (indentOf(lines[l]) <= indent)
|
|
410
|
+
break;
|
|
411
|
+
end = l;
|
|
412
|
+
}
|
|
413
|
+
const kind = m[2] === 'class' ? 'class' : stack.length > 0 ? 'method' : 'function';
|
|
414
|
+
const sym = { name: m[3], kind, start: i + 1, end: end + 1, level: stack.length };
|
|
415
|
+
if (stack.length > 0)
|
|
416
|
+
sym.parent = stack[stack.length - 1].sym.name;
|
|
417
|
+
out.push(sym);
|
|
418
|
+
stack.push({ sym, indent });
|
|
419
|
+
}
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
// ─── Markdown ───────────────────────────────
|
|
423
|
+
function scanMarkdown(lines) {
|
|
424
|
+
const heads = [];
|
|
425
|
+
let fence = null;
|
|
426
|
+
lines.forEach((line, i) => {
|
|
427
|
+
const f = /^\s*(```|~~~)/.exec(line);
|
|
428
|
+
if (f) {
|
|
429
|
+
fence = fence === null ? f[1] : (fence === f[1] ? null : fence);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (fence !== null)
|
|
433
|
+
return;
|
|
434
|
+
const h = /^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(line);
|
|
435
|
+
if (h)
|
|
436
|
+
heads.push({ level: h[1].length, name: h[2], line: i });
|
|
437
|
+
});
|
|
438
|
+
const minLevel = Math.min(...heads.map(h => h.level));
|
|
439
|
+
return heads.map((h, idx) => {
|
|
440
|
+
let end = lines.length - 1;
|
|
441
|
+
for (let j = idx + 1; j < heads.length; j++) {
|
|
442
|
+
if (heads[j].level <= h.level) {
|
|
443
|
+
end = heads[j].line - 1;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
while (end > h.line && !lines[end].trim())
|
|
448
|
+
end--;
|
|
449
|
+
let parent;
|
|
450
|
+
for (let j = idx - 1; j >= 0; j--) {
|
|
451
|
+
if (heads[j].level < h.level) {
|
|
452
|
+
parent = heads[j].name;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const sym = { name: h.name, kind: `h${h.level}`, start: h.line + 1, end: end + 1, level: h.level - minLevel };
|
|
457
|
+
if (parent)
|
|
458
|
+
sym.parent = parent;
|
|
459
|
+
return sym;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Most chars the summary may take. */
|
|
2
|
+
export declare const TEST_SUMMARY_MAX_CHARS = 3000;
|
|
3
|
+
interface TestFailure {
|
|
4
|
+
name: string;
|
|
5
|
+
/** The test's own title, without its suites (to find it in console output). */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** file:line, relative to the run's folder, when known. */
|
|
8
|
+
where?: string;
|
|
9
|
+
message: string;
|
|
10
|
+
diff?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TestReport {
|
|
13
|
+
passed: number;
|
|
14
|
+
failed: number;
|
|
15
|
+
skipped: number;
|
|
16
|
+
files: number;
|
|
17
|
+
failures: TestFailure[];
|
|
18
|
+
/** Errors outside any test: a file that would not load, a crashed suite. */
|
|
19
|
+
errors: string[];
|
|
20
|
+
}
|
|
21
|
+
/** The message and the expected/received diff out of an assertion's text. */
|
|
22
|
+
export declare function splitFailureText(raw: string): {
|
|
23
|
+
message: string;
|
|
24
|
+
diff?: string;
|
|
25
|
+
};
|
|
26
|
+
/** A Jest-shaped JSON report (jest --json, vitest's json reporter). */
|
|
27
|
+
export declare function parseJestJson(text: string, cwd: string): TestReport | null;
|
|
28
|
+
/**
|
|
29
|
+
* Vitest's JSON report carries a failure's message and stack but not its
|
|
30
|
+
* expected/received diff, which its console output does print, under a
|
|
31
|
+
* ` FAIL <file> > <suite> > <title>` header. Fill the missing diffs from there.
|
|
32
|
+
*/
|
|
33
|
+
export declare function addConsoleDiffs(report: TestReport, consoleText: string): void;
|
|
34
|
+
/** A JUnit XML report (phpunit and pest --log-junit). */
|
|
35
|
+
export declare function parseJunitXml(text: string, cwd: string): TestReport | null;
|
|
36
|
+
/**
|
|
37
|
+
* The summary an agent reads: one status line, then each failure with where
|
|
38
|
+
* it is, why, and a short diff, within {@link TEST_SUMMARY_MAX_CHARS}; the
|
|
39
|
+
* failures that do not fit are named, and the rest counted.
|
|
40
|
+
*/
|
|
41
|
+
export declare function renderTestSummary(report: TestReport, opts: {
|
|
42
|
+
exitCode: number | null;
|
|
43
|
+
label: string;
|
|
44
|
+
seconds: number;
|
|
45
|
+
fullOutputAt?: string;
|
|
46
|
+
}): string;
|
|
47
|
+
export {};
|