mergestory 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +48 -2
- package/assets/kokoro-plugin/package-lock.json +1139 -0
- package/dist/analyzer/analyze.d.ts +8 -0
- package/dist/analyzer/analyze.js +328 -0
- package/dist/analyzer/components.d.ts +18 -0
- package/dist/analyzer/components.js +266 -0
- package/dist/analyzer/dependencies.d.ts +13 -0
- package/dist/analyzer/dependencies.js +349 -0
- package/dist/analyzer/evidence.d.ts +15 -0
- package/dist/analyzer/evidence.js +73 -0
- package/dist/analyzer/hunks.d.ts +21 -0
- package/dist/analyzer/hunks.js +88 -0
- package/dist/analyzer/imports.d.ts +46 -0
- package/dist/analyzer/imports.js +87 -0
- package/dist/analyzer/index.d.ts +14 -0
- package/dist/analyzer/index.js +16 -0
- package/dist/analyzer/languages/go.d.ts +2 -0
- package/dist/analyzer/languages/go.js +76 -0
- package/dist/analyzer/languages/index.d.ts +18 -0
- package/dist/analyzer/languages/index.js +72 -0
- package/dist/analyzer/languages/javascript.d.ts +2 -0
- package/dist/analyzer/languages/javascript.js +336 -0
- package/dist/analyzer/languages/jvm.d.ts +2 -0
- package/dist/analyzer/languages/jvm.js +157 -0
- package/dist/analyzer/languages/others.d.ts +2 -0
- package/dist/analyzer/languages/others.js +40 -0
- package/dist/analyzer/languages/php.d.ts +2 -0
- package/dist/analyzer/languages/php.js +81 -0
- package/dist/analyzer/languages/python.d.ts +2 -0
- package/dist/analyzer/languages/python.js +180 -0
- package/dist/analyzer/languages/ruby.d.ts +2 -0
- package/dist/analyzer/languages/ruby.js +99 -0
- package/dist/analyzer/languages/rust.d.ts +2 -0
- package/dist/analyzer/languages/rust.js +164 -0
- package/dist/analyzer/languages/shared.d.ts +35 -0
- package/dist/analyzer/languages/shared.js +43 -0
- package/dist/analyzer/languages/types.d.ts +78 -0
- package/dist/analyzer/languages/types.js +2 -0
- package/dist/analyzer/pack-format.d.ts +27 -0
- package/dist/analyzer/pack-format.js +139 -0
- package/dist/analyzer/pack.d.ts +26 -0
- package/dist/analyzer/pack.js +498 -0
- package/dist/analyzer/relationships.d.ts +17 -0
- package/dist/analyzer/relationships.js +34 -0
- package/dist/analyzer/risk-rules.d.ts +287 -0
- package/dist/analyzer/risk-rules.js +373 -0
- package/dist/analyzer/risks.d.ts +36 -0
- package/dist/analyzer/risks.js +480 -0
- package/dist/analyzer/roles.d.ts +11 -0
- package/dist/analyzer/roles.js +280 -0
- package/dist/analyzer/scan.d.ts +26 -0
- package/dist/analyzer/scan.js +157 -0
- package/dist/analyzer/signals.d.ts +20 -0
- package/dist/analyzer/signals.js +51 -0
- package/dist/analyzer/symbol-changes.d.ts +11 -0
- package/dist/analyzer/symbol-changes.js +101 -0
- package/dist/analyzer/symbol-types.d.ts +17 -0
- package/dist/analyzer/symbol-types.js +9 -0
- package/dist/analyzer/symbols.d.ts +4 -0
- package/dist/analyzer/symbols.js +16 -0
- package/dist/analyzer/trivial.d.ts +13 -0
- package/dist/analyzer/trivial.js +137 -0
- package/dist/analyzer/util.d.ts +6 -0
- package/dist/analyzer/util.js +24 -0
- package/dist/cli/commands/authoring.d.ts +9 -0
- package/dist/cli/commands/authoring.js +98 -0
- package/dist/cli/commands/cache.d.ts +4 -0
- package/dist/cli/commands/cache.js +37 -0
- package/dist/cli/commands/doctor.d.ts +5 -0
- package/dist/cli/commands/doctor.js +37 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.js +69 -0
- package/dist/cli/commands/jobs.d.ts +8 -0
- package/dist/cli/commands/jobs.js +70 -0
- package/dist/cli/commands/publish.d.ts +8 -0
- package/dist/cli/commands/publish.js +120 -0
- package/dist/cli/commands/serve.d.ts +4 -0
- package/dist/cli/commands/serve.js +69 -0
- package/dist/cli/commands/setup.d.ts +14 -0
- package/dist/cli/commands/setup.js +108 -0
- package/dist/cli/commands/shared.d.ts +18 -0
- package/dist/cli/commands/shared.js +24 -0
- package/dist/cli/files.d.ts +26 -0
- package/dist/cli/files.js +98 -0
- package/dist/cli/format.d.ts +55 -0
- package/dist/cli/format.js +295 -0
- package/dist/cli/inputs.d.ts +23 -0
- package/dist/cli/inputs.js +96 -0
- package/dist/cli/io.d.ts +19 -0
- package/dist/cli/io.js +31 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +15 -0
- package/dist/cli/options.d.ts +105 -0
- package/dist/cli/options.js +324 -0
- package/dist/cli/program.d.ts +12 -0
- package/dist/cli/program.js +146 -0
- package/dist/cli/runtime.d.ts +59 -0
- package/dist/cli/runtime.js +83 -0
- package/dist/cli/style.d.ts +13 -0
- package/dist/cli/style.js +27 -0
- package/dist/core/binaries.d.ts +7 -0
- package/dist/core/binaries.js +33 -0
- package/dist/core/binary-paths.d.ts +5 -0
- package/dist/core/binary-paths.js +92 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.js +43 -0
- package/dist/core/child-env.d.ts +9 -0
- package/dist/core/child-env.js +61 -0
- package/dist/core/concurrency.d.ts +13 -0
- package/dist/core/concurrency.js +58 -0
- package/dist/core/config.d.ts +223 -0
- package/dist/core/config.js +454 -0
- package/dist/core/context.d.ts +39 -0
- package/dist/core/context.js +44 -0
- package/dist/core/cost.d.ts +46 -0
- package/dist/core/cost.js +108 -0
- package/dist/core/diagram-metrics.d.ts +57 -0
- package/dist/core/diagram-metrics.js +63 -0
- package/dist/core/diff-view.d.ts +44 -0
- package/dist/core/diff-view.js +136 -0
- package/dist/core/errors.d.ts +47 -0
- package/dist/core/errors.js +94 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/json.d.ts +8 -0
- package/dist/core/json.js +17 -0
- package/dist/core/languages.d.ts +19 -0
- package/dist/core/languages.js +292 -0
- package/dist/core/logger.d.ts +29 -0
- package/dist/core/logger.js +68 -0
- package/dist/core/net.d.ts +16 -0
- package/dist/core/net.js +80 -0
- package/dist/core/path-policy.d.ts +20 -0
- package/dist/core/path-policy.js +202 -0
- package/dist/core/paths.d.ts +18 -0
- package/dist/core/paths.js +53 -0
- package/dist/core/posix.d.ts +12 -0
- package/dist/core/posix.js +50 -0
- package/dist/core/process.d.ts +22 -0
- package/dist/core/process.js +117 -0
- package/dist/core/providers.d.ts +204 -0
- package/dist/core/providers.js +2 -0
- package/dist/core/redact.d.ts +11 -0
- package/dist/core/redact.js +70 -0
- package/dist/core/render-plan.d.ts +307 -0
- package/dist/core/render-plan.js +7 -0
- package/dist/core/retry.d.ts +54 -0
- package/dist/core/retry.js +116 -0
- package/dist/core/run-folder.d.ts +74 -0
- package/dist/core/run-folder.js +129 -0
- package/dist/core/secrets.d.ts +56 -0
- package/dist/core/secrets.js +301 -0
- package/dist/core/storyboard-facts.d.ts +22 -0
- package/dist/core/storyboard-facts.js +61 -0
- package/dist/core/storyboard-schema.d.ts +1279 -0
- package/dist/core/storyboard-schema.js +342 -0
- package/dist/core/text.d.ts +43 -0
- package/dist/core/text.js +94 -0
- package/dist/core/types.d.ts +459 -0
- package/dist/core/types.js +17 -0
- package/dist/doctor/check.d.ts +6 -0
- package/dist/doctor/check.js +18 -0
- package/dist/doctor/deps.d.ts +2 -0
- package/dist/doctor/deps.js +90 -0
- package/dist/doctor/format.d.ts +9 -0
- package/dist/doctor/format.js +19 -0
- package/dist/doctor/github.d.ts +2 -0
- package/dist/doctor/github.js +13 -0
- package/dist/doctor/home.d.ts +2 -0
- package/dist/doctor/home.js +26 -0
- package/dist/doctor/index.d.ts +18 -0
- package/dist/doctor/index.js +81 -0
- package/dist/doctor/llm.d.ts +2 -0
- package/dist/doctor/llm.js +32 -0
- package/dist/doctor/publish.d.ts +2 -0
- package/dist/doctor/publish.js +16 -0
- package/dist/doctor/s3.d.ts +2 -0
- package/dist/doctor/s3.js +125 -0
- package/dist/doctor/speech.d.ts +2 -0
- package/dist/doctor/speech.js +112 -0
- package/dist/doctor/tools.d.ts +5 -0
- package/dist/doctor/tools.js +58 -0
- package/dist/doctor/types.d.ts +92 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/youtube.d.ts +2 -0
- package/dist/doctor/youtube.js +73 -0
- package/dist/github/client.d.ts +108 -0
- package/dist/github/client.js +499 -0
- package/dist/github/errors.d.ts +37 -0
- package/dist/github/errors.js +155 -0
- package/dist/github/index.d.ts +13 -0
- package/dist/github/index.js +9 -0
- package/dist/github/linked-issues.d.ts +37 -0
- package/dist/github/linked-issues.js +131 -0
- package/dist/github/model.d.ts +81 -0
- package/dist/github/model.js +114 -0
- package/dist/github/notify.d.ts +27 -0
- package/dist/github/notify.js +118 -0
- package/dist/github/pr-url.d.ts +27 -0
- package/dist/github/pr-url.js +122 -0
- package/dist/github/token.d.ts +16 -0
- package/dist/github/token.js +69 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +19 -0
- package/dist/jobs/input-rules.d.ts +20 -0
- package/dist/jobs/input-rules.js +100 -0
- package/dist/jobs/model.d.ts +47 -0
- package/dist/jobs/model.js +18 -0
- package/dist/jobs/runner.d.ts +43 -0
- package/dist/jobs/runner.js +165 -0
- package/dist/jobs/store.d.ts +67 -0
- package/dist/jobs/store.js +314 -0
- package/dist/jobs/view.d.ts +48 -0
- package/dist/jobs/view.js +111 -0
- package/dist/jobs/worker.d.ts +24 -0
- package/dist/jobs/worker.js +47 -0
- package/dist/llm/anthropic.d.ts +11 -0
- package/dist/llm/anthropic.js +225 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +27 -0
- package/dist/llm/openai-compatible.d.ts +33 -0
- package/dist/llm/openai-compatible.js +378 -0
- package/dist/llm/prices.d.ts +26 -0
- package/dist/llm/prices.js +41 -0
- package/dist/llm/shared.d.ts +30 -0
- package/dist/llm/shared.js +115 -0
- package/dist/narration/assemble.d.ts +36 -0
- package/dist/narration/assemble.js +282 -0
- package/dist/narration/audio.d.ts +61 -0
- package/dist/narration/audio.js +301 -0
- package/dist/narration/captions.d.ts +37 -0
- package/dist/narration/captions.js +195 -0
- package/dist/narration/chunking.d.ts +6 -0
- package/dist/narration/chunking.js +46 -0
- package/dist/narration/convert.d.ts +9 -0
- package/dist/narration/convert.js +90 -0
- package/dist/narration/elevenlabs.d.ts +5 -0
- package/dist/narration/elevenlabs.js +53 -0
- package/dist/narration/http-errors.d.ts +14 -0
- package/dist/narration/http-errors.js +74 -0
- package/dist/narration/index.d.ts +21 -0
- package/dist/narration/index.js +22 -0
- package/dist/narration/kokoro-install.d.ts +30 -0
- package/dist/narration/kokoro-install.js +284 -0
- package/dist/narration/kokoro-model.d.ts +54 -0
- package/dist/narration/kokoro-model.js +168 -0
- package/dist/narration/kokoro-plugin.d.ts +78 -0
- package/dist/narration/kokoro-plugin.js +245 -0
- package/dist/narration/kokoro.d.ts +22 -0
- package/dist/narration/kokoro.js +231 -0
- package/dist/narration/openai.d.ts +4 -0
- package/dist/narration/openai.js +54 -0
- package/dist/narration/pricing.d.ts +8 -0
- package/dist/narration/pricing.js +17 -0
- package/dist/narration/remote-speech.d.ts +53 -0
- package/dist/narration/remote-speech.js +100 -0
- package/dist/narration/say.d.ts +28 -0
- package/dist/narration/say.js +178 -0
- package/dist/narration/select.d.ts +27 -0
- package/dist/narration/select.js +80 -0
- package/dist/narration/silent.d.ts +2 -0
- package/dist/narration/silent.js +18 -0
- package/dist/narration/speakable.d.ts +20 -0
- package/dist/narration/speakable.js +398 -0
- package/dist/narration/synthesize.d.ts +25 -0
- package/dist/narration/synthesize.js +220 -0
- package/dist/narration/wav.d.ts +37 -0
- package/dist/narration/wav.js +170 -0
- package/dist/pipeline/authoring.d.ts +8 -0
- package/dist/pipeline/authoring.js +117 -0
- package/dist/pipeline/commands.d.ts +9 -0
- package/dist/pipeline/commands.js +21 -0
- package/dist/pipeline/fit-duration.d.ts +41 -0
- package/dist/pipeline/fit-duration.js +150 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/inputs.d.ts +42 -0
- package/dist/pipeline/inputs.js +171 -0
- package/dist/pipeline/plan.d.ts +8 -0
- package/dist/pipeline/plan.js +85 -0
- package/dist/pipeline/planned-egress.d.ts +21 -0
- package/dist/pipeline/planned-egress.js +43 -0
- package/dist/pipeline/prepare.d.ts +26 -0
- package/dist/pipeline/prepare.js +84 -0
- package/dist/pipeline/presentation.d.ts +26 -0
- package/dist/pipeline/presentation.js +110 -0
- package/dist/pipeline/publish-run.d.ts +71 -0
- package/dist/pipeline/publish-run.js +295 -0
- package/dist/pipeline/run.d.ts +7 -0
- package/dist/pipeline/run.js +196 -0
- package/dist/pipeline/storyboard-choice.d.ts +34 -0
- package/dist/pipeline/storyboard-choice.js +129 -0
- package/dist/pipeline/types.d.ts +76 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/publish/access-probe.d.ts +55 -0
- package/dist/publish/access-probe.js +249 -0
- package/dist/publish/bundle.d.ts +20 -0
- package/dist/publish/bundle.js +57 -0
- package/dist/publish/comment.d.ts +10 -0
- package/dist/publish/comment.js +184 -0
- package/dist/publish/content-types.d.ts +15 -0
- package/dist/publish/content-types.js +41 -0
- package/dist/publish/index.d.ts +18 -0
- package/dist/publish/index.js +30 -0
- package/dist/publish/keys.d.ts +10 -0
- package/dist/publish/keys.js +30 -0
- package/dist/publish/local.d.ts +33 -0
- package/dist/publish/local.js +143 -0
- package/dist/publish/privacy.d.ts +20 -0
- package/dist/publish/privacy.js +21 -0
- package/dist/publish/s3/bucket.d.ts +22 -0
- package/dist/publish/s3/bucket.js +82 -0
- package/dist/publish/s3/client.d.ts +33 -0
- package/dist/publish/s3/client.js +134 -0
- package/dist/publish/s3/failures.d.ts +22 -0
- package/dist/publish/s3/failures.js +110 -0
- package/dist/publish/s3/index.d.ts +5 -0
- package/dist/publish/s3/index.js +6 -0
- package/dist/publish/s3/links.d.ts +38 -0
- package/dist/publish/s3/links.js +60 -0
- package/dist/publish/s3/protected-links.d.ts +29 -0
- package/dist/publish/s3/protected-links.js +67 -0
- package/dist/publish/s3/publisher.d.ts +32 -0
- package/dist/publish/s3/publisher.js +123 -0
- package/dist/publish/s3/settings.d.ts +29 -0
- package/dist/publish/s3/settings.js +64 -0
- package/dist/publish/s3/upload.d.ts +29 -0
- package/dist/publish/s3/upload.js +145 -0
- package/dist/publish/severity.d.ts +9 -0
- package/dist/publish/severity.js +18 -0
- package/dist/publish/text.d.ts +23 -0
- package/dist/publish/text.js +94 -0
- package/dist/publish/types.d.ts +67 -0
- package/dist/publish/types.js +12 -0
- package/dist/publish/vtt.d.ts +9 -0
- package/dist/publish/vtt.js +43 -0
- package/dist/publish/watch-page.d.ts +4 -0
- package/dist/publish/watch-page.js +463 -0
- package/dist/publish/youtube/credentials.d.ts +33 -0
- package/dist/publish/youtube/credentials.js +162 -0
- package/dist/publish/youtube/description.d.ts +56 -0
- package/dist/publish/youtube/description.js +197 -0
- package/dist/publish/youtube/google-api.d.ts +95 -0
- package/dist/publish/youtube/google-api.js +339 -0
- package/dist/publish/youtube/index.d.ts +7 -0
- package/dist/publish/youtube/index.js +8 -0
- package/dist/publish/youtube/loopback.d.ts +13 -0
- package/dist/publish/youtube/loopback.js +144 -0
- package/dist/publish/youtube/oauth.d.ts +68 -0
- package/dist/publish/youtube/oauth.js +159 -0
- package/dist/publish/youtube/prompt.d.ts +27 -0
- package/dist/publish/youtube/prompt.js +94 -0
- package/dist/publish/youtube/publisher.d.ts +38 -0
- package/dist/publish/youtube/publisher.js +346 -0
- package/dist/publish/youtube/scopes.d.ts +32 -0
- package/dist/publish/youtube/scopes.js +55 -0
- package/dist/publish/youtube/sign-in.d.ts +37 -0
- package/dist/publish/youtube/sign-in.js +137 -0
- package/dist/publish/youtube/upload.d.ts +43 -0
- package/dist/publish/youtube/upload.js +210 -0
- package/dist/render/browser.d.ts +23 -0
- package/dist/render/browser.js +219 -0
- package/dist/render/chromium-renderer.d.ts +56 -0
- package/dist/render/chromium-renderer.js +519 -0
- package/dist/render/ffmpeg.d.ts +55 -0
- package/dist/render/ffmpeg.js +212 -0
- package/dist/render/fonts.d.ts +10 -0
- package/dist/render/fonts.js +42 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.js +11 -0
- package/dist/render/page.d.ts +46 -0
- package/dist/render/page.js +123 -0
- package/dist/render/playwright.d.ts +3 -0
- package/dist/render/playwright.js +6 -0
- package/dist/render/runtime-bundle.d.ts +2 -0
- package/dist/render/runtime-bundle.js +72 -0
- package/dist/runtime/runtime.js +1626 -0
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.js +58 -0
- package/dist/server/http.d.ts +43 -0
- package/dist/server/http.js +119 -0
- package/dist/server/index.d.ts +46 -0
- package/dist/server/index.js +310 -0
- package/dist/server/queue.d.ts +30 -0
- package/dist/server/queue.js +76 -0
- package/dist/server/schema.d.ts +103 -0
- package/dist/server/schema.js +121 -0
- package/dist/server/source.d.ts +17 -0
- package/dist/server/source.js +100 -0
- package/dist/sources/assemble.d.ts +86 -0
- package/dist/sources/assemble.js +117 -0
- package/dist/sources/diff-parser.d.ts +14 -0
- package/dist/sources/diff-parser.js +84 -0
- package/dist/sources/git.d.ts +28 -0
- package/dist/sources/git.js +108 -0
- package/dist/sources/github.d.ts +20 -0
- package/dist/sources/github.js +192 -0
- package/dist/sources/hunk-selection.d.ts +25 -0
- package/dist/sources/hunk-selection.js +46 -0
- package/dist/sources/index.d.ts +23 -0
- package/dist/sources/index.js +62 -0
- package/dist/sources/limits.d.ts +27 -0
- package/dist/sources/limits.js +22 -0
- package/dist/sources/local.d.ts +34 -0
- package/dist/sources/local.js +555 -0
- package/dist/sources/reader.d.ts +13 -0
- package/dist/sources/reader.js +45 -0
- package/dist/sources/remote.d.ts +13 -0
- package/dist/sources/remote.js +41 -0
- package/dist/sources/repo-context.d.ts +34 -0
- package/dist/sources/repo-context.js +144 -0
- package/dist/sources/text.d.ts +25 -0
- package/dist/sources/text.js +71 -0
- package/dist/storyboard/authoring.d.ts +108 -0
- package/dist/storyboard/authoring.js +196 -0
- package/dist/storyboard/claims.d.ts +35 -0
- package/dist/storyboard/claims.js +318 -0
- package/dist/storyboard/coderef.d.ts +28 -0
- package/dist/storyboard/coderef.js +118 -0
- package/dist/storyboard/generate.d.ts +25 -0
- package/dist/storyboard/generate.js +194 -0
- package/dist/storyboard/heuristic-code.d.ts +91 -0
- package/dist/storyboard/heuristic-code.js +524 -0
- package/dist/storyboard/heuristic-context.d.ts +42 -0
- package/dist/storyboard/heuristic-context.js +102 -0
- package/dist/storyboard/heuristic-facts.d.ts +106 -0
- package/dist/storyboard/heuristic-facts.js +415 -0
- package/dist/storyboard/heuristic-overview.d.ts +4 -0
- package/dist/storyboard/heuristic-overview.js +151 -0
- package/dist/storyboard/heuristic-review.d.ts +10 -0
- package/dist/storyboard/heuristic-review.js +158 -0
- package/dist/storyboard/heuristic-scenes.d.ts +8 -0
- package/dist/storyboard/heuristic-scenes.js +357 -0
- package/dist/storyboard/heuristic-shared.d.ts +43 -0
- package/dist/storyboard/heuristic-shared.js +136 -0
- package/dist/storyboard/heuristic.d.ts +15 -0
- package/dist/storyboard/heuristic.js +324 -0
- package/dist/storyboard/identifiers.d.ts +51 -0
- package/dist/storyboard/identifiers.js +195 -0
- package/dist/storyboard/index.d.ts +10 -0
- package/dist/storyboard/index.js +10 -0
- package/dist/storyboard/prompts.d.ts +16 -0
- package/dist/storyboard/prompts.js +61 -0
- package/dist/storyboard/run.d.ts +82 -0
- package/dist/storyboard/run.js +332 -0
- package/dist/storyboard/text.d.ts +16 -0
- package/dist/storyboard/text.js +103 -0
- package/dist/storyboard/types.d.ts +47 -0
- package/dist/storyboard/types.js +2 -0
- package/dist/storyboard/urls.d.ts +15 -0
- package/dist/storyboard/urls.js +83 -0
- package/dist/storyboard/validate.d.ts +8 -0
- package/dist/storyboard/validate.js +525 -0
- package/dist/storyboard/visuals.d.ts +23 -0
- package/dist/storyboard/visuals.js +324 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/visuals/code.d.ts +68 -0
- package/dist/visuals/code.js +385 -0
- package/dist/visuals/highlight.d.ts +17 -0
- package/dist/visuals/highlight.js +85 -0
- package/dist/visuals/image.d.ts +12 -0
- package/dist/visuals/image.js +96 -0
- package/dist/visuals/index.d.ts +10 -0
- package/dist/visuals/index.js +10 -0
- package/dist/visuals/layout.d.ts +89 -0
- package/dist/visuals/layout.js +506 -0
- package/dist/visuals/plan.d.ts +33 -0
- package/dist/visuals/plan.js +511 -0
- package/dist/visuals/timeline.d.ts +31 -0
- package/dist/visuals/timeline.js +96 -0
- package/package.json +74 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// biome-ignore-all lint/suspicious/noAssignInExpressions: regex matches are assigned in the condition so the else-if chain stays flat
|
|
2
|
+
/** Rust, with the routes of `#[get("/x")]` attributes and axum's `.route("/x", get(handler))`. */
|
|
3
|
+
import { basename, dirname, joinPosix } from '../../core/posix.js';
|
|
4
|
+
import { blockEnd, nestingDepths } from '../scan.js';
|
|
5
|
+
import { C_COMMENTS, matchAll, packageRootOf, symbolEmitter } from './shared.js';
|
|
6
|
+
const PROFILE = { lineComments: ['//'], blockComments: true, rustLifetimes: true };
|
|
7
|
+
const PUB = '(pub(?:\\([^)]*\\))?\\s+)?';
|
|
8
|
+
const RS_FN = new RegExp(`^${PUB}(?:(?:async|unsafe|const|default)\\s+|extern\\s+"[^"]*"\\s+)*fn\\s+(\\w+)`);
|
|
9
|
+
const RS_ADT = new RegExp(`^${PUB}(struct|enum|trait|union)\\s+(\\w+)`);
|
|
10
|
+
const RS_TYPE = new RegExp(`^${PUB}type\\s+(\\w+)`);
|
|
11
|
+
const RS_CONST = new RegExp(`^${PUB}(?:const|static)\\s+(?:mut\\s+)?(\\w+)\\s*:`);
|
|
12
|
+
const RS_ATTR_ROUTE = /^#\[(get|post|put|patch|delete|head|options)\(\s*"([^"]*)"/;
|
|
13
|
+
const RS_AXUM = /\.route\(\s*"([^"]*)"\s*,\s*(get|post|put|patch|delete)\(/;
|
|
14
|
+
/** Type name and trait-impl flag of an `impl` header line, or null when the line is not one. */
|
|
15
|
+
function rustImpl(line) {
|
|
16
|
+
if (!/^impl\b/.test(line))
|
|
17
|
+
return null;
|
|
18
|
+
let head = line
|
|
19
|
+
.replace(/\{.*$/, '')
|
|
20
|
+
.replace(/^impl\b/, '')
|
|
21
|
+
.trim();
|
|
22
|
+
if (head.startsWith('<')) {
|
|
23
|
+
let depth = 0;
|
|
24
|
+
let end = 0;
|
|
25
|
+
for (let k = 0; k < head.length; k++) {
|
|
26
|
+
if (head[k] === '<')
|
|
27
|
+
depth++;
|
|
28
|
+
else if (head[k] === '>' && --depth === 0) {
|
|
29
|
+
end = k + 1;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
head = head.slice(end).trim();
|
|
34
|
+
}
|
|
35
|
+
const viaTrait = /\sfor\s/.test(head);
|
|
36
|
+
const typePart = viaTrait ? head.slice(head.search(/\sfor\s/) + 5) : head;
|
|
37
|
+
const type = /^[&\s]*(?:mut\s+)?([\w:]+)/.exec(typePart)?.[1];
|
|
38
|
+
return type ? { type: type.split('::').pop() ?? type, viaTrait } : null;
|
|
39
|
+
}
|
|
40
|
+
function detectRust(lines) {
|
|
41
|
+
const depths = nestingDepths(lines, PROFILE);
|
|
42
|
+
const { symbols, emit } = symbolEmitter(lines, depths);
|
|
43
|
+
let block = null;
|
|
44
|
+
let pending = null;
|
|
45
|
+
for (const [i, line] of lines.entries()) {
|
|
46
|
+
const t = line.trim();
|
|
47
|
+
if (!t || t.startsWith('//'))
|
|
48
|
+
continue;
|
|
49
|
+
const axum = RS_AXUM.exec(t);
|
|
50
|
+
if (axum) {
|
|
51
|
+
const [, path = '', verb = ''] = axum;
|
|
52
|
+
emit(`${verb.toUpperCase()} ${path}`, 'route', i);
|
|
53
|
+
}
|
|
54
|
+
if (block && i > block.end)
|
|
55
|
+
block = null;
|
|
56
|
+
const attr = RS_ATTR_ROUTE.exec(t);
|
|
57
|
+
if (attr) {
|
|
58
|
+
const [, verb = '', path = ''] = attr;
|
|
59
|
+
pending = `${verb.toUpperCase()} ${path}`;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let m;
|
|
63
|
+
if (depths[i] === 0) {
|
|
64
|
+
const impl = rustImpl(t);
|
|
65
|
+
if (impl) {
|
|
66
|
+
block = { ...impl, end: blockEnd(depths, i, lines.length), trait: false };
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if ((m = RS_ADT.exec(t))) {
|
|
70
|
+
const [, pub, keyword = '', name = ''] = m;
|
|
71
|
+
const end = blockEnd(depths, i, lines.length);
|
|
72
|
+
const kind = keyword === 'trait' ? 'interface' : keyword === 'enum' ? 'type' : 'class';
|
|
73
|
+
emit(name, kind, i, { exported: !!pub, end });
|
|
74
|
+
if (keyword === 'trait')
|
|
75
|
+
block = { type: name, viaTrait: false, end, trait: true };
|
|
76
|
+
}
|
|
77
|
+
else if ((m = RS_FN.exec(t))) {
|
|
78
|
+
const [, pub, name = ''] = m;
|
|
79
|
+
if (pending)
|
|
80
|
+
emit(pending, 'route', i);
|
|
81
|
+
else
|
|
82
|
+
emit(name, 'function', i, { exported: !!pub });
|
|
83
|
+
pending = null;
|
|
84
|
+
}
|
|
85
|
+
else if ((m = RS_TYPE.exec(t))) {
|
|
86
|
+
const [, pub, name = ''] = m;
|
|
87
|
+
emit(name, 'type', i, { exported: !!pub });
|
|
88
|
+
}
|
|
89
|
+
else if ((m = RS_CONST.exec(t))) {
|
|
90
|
+
const [, pub, name = ''] = m;
|
|
91
|
+
emit(name, 'constant', i, { exported: !!pub });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (block && depths[i] === 1 && (m = RS_FN.exec(t))) {
|
|
95
|
+
const [, pub, name = ''] = m;
|
|
96
|
+
if (pending)
|
|
97
|
+
emit(pending, 'route', i);
|
|
98
|
+
else
|
|
99
|
+
emit(`${block.type}.${name}`, 'method', i, { exported: !!pub || block.viaTrait || block.trait });
|
|
100
|
+
pending = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return symbols;
|
|
104
|
+
}
|
|
105
|
+
function extractImports(text) {
|
|
106
|
+
const refs = [];
|
|
107
|
+
for (const [, spec = ''] of matchAll(text, /^\s*(?:pub(?:\([^)]*\))?\s+)?mod\s+(\w+)\s*;/gm)) {
|
|
108
|
+
refs.push({ lang: 'rs', spec, isMod: true });
|
|
109
|
+
}
|
|
110
|
+
for (const [, spec = ''] of matchAll(text, /^\s*(?:pub(?:\([^)]*\))?\s+)?use\s+([\w:]+)/gm)) {
|
|
111
|
+
refs.push({ lang: 'rs', spec, isMod: false });
|
|
112
|
+
}
|
|
113
|
+
return refs;
|
|
114
|
+
}
|
|
115
|
+
function resolveImport(importer, ref, index) {
|
|
116
|
+
const root = packageRootOf(importer);
|
|
117
|
+
const crateSrc = joinPosix(root, 'src');
|
|
118
|
+
const toFiles = (dir, parts) => {
|
|
119
|
+
const out = [];
|
|
120
|
+
for (let n = parts.length; n >= 1; n--) {
|
|
121
|
+
const base = joinPosix(dir, ...parts.slice(0, n));
|
|
122
|
+
out.push(`${base}.rs`, `${base}/mod.rs`);
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
};
|
|
126
|
+
const pick = (candidates, fallbackDir, name) => {
|
|
127
|
+
const hit = index.firstKnown(candidates);
|
|
128
|
+
if (hit)
|
|
129
|
+
return [hit];
|
|
130
|
+
return name ? [joinPosix(fallbackDir, `${name}.rs`)] : [];
|
|
131
|
+
};
|
|
132
|
+
if (ref.isMod) {
|
|
133
|
+
const name = basename(importer);
|
|
134
|
+
const dir = name === 'lib.rs' || name === 'main.rs' || name === 'mod.rs'
|
|
135
|
+
? dirname(importer)
|
|
136
|
+
: joinPosix(dirname(importer), name.replace(/\.rs$/, ''));
|
|
137
|
+
return [index.firstKnown(toFiles(dir, [ref.spec])) ?? joinPosix(dir, `${ref.spec}.rs`)];
|
|
138
|
+
}
|
|
139
|
+
const parts = ref.spec.split('::').filter(Boolean);
|
|
140
|
+
const head = parts[0];
|
|
141
|
+
if (head === 'crate')
|
|
142
|
+
return pick(toFiles(crateSrc, parts.slice(1)), crateSrc, parts[1]);
|
|
143
|
+
if (head === 'super')
|
|
144
|
+
return pick(toFiles(dirname(dirname(importer)), parts.slice(1)), dirname(dirname(importer)), parts[1]);
|
|
145
|
+
if (head && index.known.size > 0) {
|
|
146
|
+
for (const p of index.known) {
|
|
147
|
+
const crate = /^(?:crates|packages|libs)\/([^/]+)\/Cargo\.toml$/.exec(p)?.[1];
|
|
148
|
+
if (crate?.replace(/-/g, '_') === head) {
|
|
149
|
+
const src = `${p.split('/').slice(0, 2).join('/')}/src`;
|
|
150
|
+
return pick(toFiles(src, parts.slice(1)), src, parts[1]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
const IMPORTS = {
|
|
157
|
+
lang: 'rs',
|
|
158
|
+
extract: extractImports,
|
|
159
|
+
resolve: resolveImport,
|
|
160
|
+
};
|
|
161
|
+
export const RUST = [
|
|
162
|
+
{ extensions: ['.rs'], symbols: detectRust, imports: IMPORTS, comments: C_COMMENTS },
|
|
163
|
+
];
|
|
164
|
+
//# sourceMappingURL=rust.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Helpers that the language modules share. */
|
|
2
|
+
import type { SymbolKind } from '../../core/types.ts';
|
|
3
|
+
import { type RawSymbol } from '../symbol-types.ts';
|
|
4
|
+
/** What a full-line comment starts with, by syntax family. A line that starts with "*" continues a block. */
|
|
5
|
+
export declare const C_COMMENTS: readonly ['//', '/*', '*'];
|
|
6
|
+
export declare const HASH_COMMENTS: readonly ['#'];
|
|
7
|
+
export declare const SQL_COMMENTS: readonly ['--'];
|
|
8
|
+
export declare const MARKUP_COMMENTS: readonly ['<!--', '-->'];
|
|
9
|
+
/** Every match of a global pattern in a text, counted from its start. */
|
|
10
|
+
export declare function matchAll(text: string, pattern: RegExp): RegExpExecArray[];
|
|
11
|
+
/** The package folder of a path in a monorepo ("packages/api" for "packages/api/src/a.ts"); "" elsewhere. */
|
|
12
|
+
export declare function packageRootOf(path: string): string;
|
|
13
|
+
export interface EmitOptions {
|
|
14
|
+
/** Whether other code can use the symbol. Default: true. */
|
|
15
|
+
exported?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Last line, as a 0-based index. Default: the line where the bracket block that starts on the
|
|
18
|
+
* declaring line closes, or the declaring line itself when the detector tracks no brackets.
|
|
19
|
+
*/
|
|
20
|
+
end?: number;
|
|
21
|
+
/** First line, as a 0-based index, when decorators or annotations come before the declaring line. */
|
|
22
|
+
start?: number;
|
|
23
|
+
/** The declaration text. Default: the declaring line up to its first "{". */
|
|
24
|
+
decl?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SymbolEmitter {
|
|
27
|
+
symbols: RawSymbol[];
|
|
28
|
+
/** Records a symbol. `line` is the 0-based index of the line that declares it. */
|
|
29
|
+
emit(name: string, kind: SymbolKind, line: number, options?: EmitOptions): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Collects the symbols that a detector finds. A detector that tracks brackets passes their depths
|
|
33
|
+
* (see `nestingDepths`), so that a symbol ends where its block closes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function symbolEmitter(lines: readonly string[], depths?: readonly number[]): SymbolEmitter;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { blockEnd } from '../scan.js';
|
|
2
|
+
import { signature } from '../symbol-types.js';
|
|
3
|
+
/** What a full-line comment starts with, by syntax family. A line that starts with "*" continues a block. */
|
|
4
|
+
export const C_COMMENTS = ['//', '/*', '*'];
|
|
5
|
+
export const HASH_COMMENTS = ['#'];
|
|
6
|
+
export const SQL_COMMENTS = ['--'];
|
|
7
|
+
export const MARKUP_COMMENTS = ['<!--', '-->'];
|
|
8
|
+
/** Every match of a global pattern in a text, counted from its start. */
|
|
9
|
+
export function matchAll(text, pattern) {
|
|
10
|
+
pattern.lastIndex = 0;
|
|
11
|
+
return [...text.matchAll(pattern)];
|
|
12
|
+
}
|
|
13
|
+
const MONOREPO_PREFIXES = new Set(['packages', 'apps', 'services', 'libs', 'crates', 'modules', 'cmd']);
|
|
14
|
+
/** The package folder of a path in a monorepo ("packages/api" for "packages/api/src/a.ts"); "" elsewhere. */
|
|
15
|
+
export function packageRootOf(path) {
|
|
16
|
+
const [first, second] = path.split('/');
|
|
17
|
+
return first && second && MONOREPO_PREFIXES.has(first) && path.split('/').length > 2
|
|
18
|
+
? `${first}/${second}`
|
|
19
|
+
: '';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Collects the symbols that a detector finds. A detector that tracks brackets passes their depths
|
|
23
|
+
* (see `nestingDepths`), so that a symbol ends where its block closes.
|
|
24
|
+
*/
|
|
25
|
+
export function symbolEmitter(lines, depths) {
|
|
26
|
+
const symbols = [];
|
|
27
|
+
return {
|
|
28
|
+
symbols,
|
|
29
|
+
emit(name, kind, line, options = {}) {
|
|
30
|
+
const { exported = true, start, end = depths ? blockEnd(depths, line, lines.length) : line, decl = signature(lines[line] ?? ''), } = options;
|
|
31
|
+
symbols.push({
|
|
32
|
+
name,
|
|
33
|
+
kind,
|
|
34
|
+
exported,
|
|
35
|
+
decl,
|
|
36
|
+
startLine: (start ?? line) + 1,
|
|
37
|
+
endLine: end + 1,
|
|
38
|
+
...(start === undefined ? {} : { declLine: line + 1 }),
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** What the analyzer knows about a kind of file. Each language module fills in the parts that apply. */
|
|
2
|
+
import type { RawSymbol } from '../symbol-types.ts';
|
|
3
|
+
/** Finds the declarations of a file. `path` is for the languages whose rules depend on where a file is. */
|
|
4
|
+
export type SymbolDetector = (lines: readonly string[], path: string) => RawSymbol[];
|
|
5
|
+
/**
|
|
6
|
+
* One import statement, as the language writes it. `spec` is what the statement names: "./a",
|
|
7
|
+
* "com.acme.Foo", "crate::net".
|
|
8
|
+
*/
|
|
9
|
+
export type ImportRef = {
|
|
10
|
+
lang: 'js';
|
|
11
|
+
spec: string;
|
|
12
|
+
} | {
|
|
13
|
+
lang: 'py';
|
|
14
|
+
spec: string;
|
|
15
|
+
dots: number;
|
|
16
|
+
names: string[];
|
|
17
|
+
} | {
|
|
18
|
+
lang: 'go';
|
|
19
|
+
spec: string;
|
|
20
|
+
} | {
|
|
21
|
+
lang: 'rs';
|
|
22
|
+
spec: string;
|
|
23
|
+
isMod: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
lang: 'jvm';
|
|
26
|
+
spec: string;
|
|
27
|
+
} | {
|
|
28
|
+
lang: 'rb';
|
|
29
|
+
spec: string;
|
|
30
|
+
} | {
|
|
31
|
+
lang: 'php';
|
|
32
|
+
spec: string;
|
|
33
|
+
};
|
|
34
|
+
export type ImportLang = ImportRef['lang'];
|
|
35
|
+
/** What a resolver may ask about the repository. */
|
|
36
|
+
export interface ImportIndex {
|
|
37
|
+
/** Every path known to exist at head: changed files plus the repository tree excerpt. */
|
|
38
|
+
readonly known: ReadonlySet<string>;
|
|
39
|
+
/** The known paths, by file name. */
|
|
40
|
+
readonly byBase: ReadonlyMap<string, readonly string[]>;
|
|
41
|
+
/** Go modules, longest module path first: the module path and the folder with go.mod ("" at the top). */
|
|
42
|
+
readonly goModules: readonly {
|
|
43
|
+
module: string;
|
|
44
|
+
dir: string;
|
|
45
|
+
}[];
|
|
46
|
+
/** Workspace package name (package.json "name") to its directory, in name order. */
|
|
47
|
+
readonly packageDirs: ReadonlyMap<string, string>;
|
|
48
|
+
/** The first candidate that is a known path once normalised, or null when none is. */
|
|
49
|
+
firstKnown(candidates: readonly string[]): string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface ImportSupport<R extends ImportRef = ImportRef> {
|
|
52
|
+
/** The `lang` of the refs it makes. A ref is resolved by the support that has its `lang`. */
|
|
53
|
+
lang: R['lang'];
|
|
54
|
+
/** The imports in a file's text. Only statements that sit outside full-line comments count. */
|
|
55
|
+
extract(text: string): R[];
|
|
56
|
+
/** The repository paths an import names; none for an external or unknown target. */
|
|
57
|
+
resolve(importer: string, ref: R, index: ImportIndex): string[];
|
|
58
|
+
}
|
|
59
|
+
/** The import refs of one language. */
|
|
60
|
+
export type ImportOf<L extends ImportLang> = Extract<ImportRef, {
|
|
61
|
+
lang: L;
|
|
62
|
+
}>;
|
|
63
|
+
export interface LanguageSupport {
|
|
64
|
+
/** Lower-case extensions with the dot. A file has the support of the one entry that lists its extension. */
|
|
65
|
+
extensions: readonly string[];
|
|
66
|
+
/** Lower-case names of files that have no extension, such as "makefile". */
|
|
67
|
+
names?: readonly string[];
|
|
68
|
+
/** Absent when the analyzer does not read declarations in the language. */
|
|
69
|
+
symbols?: SymbolDetector;
|
|
70
|
+
/** Absent when the analyzer does not read imports in the language. */
|
|
71
|
+
imports?: ImportSupport;
|
|
72
|
+
/** What a full-line comment starts with. Absent when the analyzer does not know the comment syntax. */
|
|
73
|
+
comments?: readonly string[];
|
|
74
|
+
/** Indentation carries meaning, so re-indenting is a real change. */
|
|
75
|
+
indentSensitive?: boolean;
|
|
76
|
+
/** Quote style, semicolons and trailing commas carry no meaning, so changing only those is formatting. */
|
|
77
|
+
looseSyntax?: boolean;
|
|
78
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DiffLine } from '../core/types.ts';
|
|
2
|
+
export interface Masker {
|
|
3
|
+
/** Single-line text: secrets masked, line breaks collapsed. */
|
|
4
|
+
text(value: string): string;
|
|
5
|
+
/** Multi-line text: secrets masked, line breaks kept. */
|
|
6
|
+
block(value: string): string;
|
|
7
|
+
/** Mask one line of code. */
|
|
8
|
+
code(value: string): string;
|
|
9
|
+
/** Mask the lines of one hunk, including multi-line private keys. */
|
|
10
|
+
hunk(lines: readonly DiffLine[]): string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createMasker(maskMail: boolean): Masker;
|
|
13
|
+
/** A Markdown fence longer than any backtick run inside, so untrusted text cannot close it early. */
|
|
14
|
+
export declare function fence(body: string, info?: string): string;
|
|
15
|
+
/** Make text safe for one Markdown table cell. */
|
|
16
|
+
export declare function cell(value: string): string;
|
|
17
|
+
/** Inline code span that survives backticks in the text. */
|
|
18
|
+
export declare function code(value: string): string;
|
|
19
|
+
export declare function numberedLine(number: number | null, marker: '+' | '-' | ' ', text: string): string;
|
|
20
|
+
/** Collapse runs of consecutive ids with the same prefix: S1 S2 S3 -> "S1-S3". Other ids stay as they are. */
|
|
21
|
+
export declare function compressIds(ids: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Collapse hunk ids: F2.H1 F2.H2 F2.H3 -> "F2.H1-H3", and a run of files that each have only H1
|
|
24
|
+
* -> "F5.H1-F9.H1" (H1 of every file from F5 to F9). Used only for very long lists. An id of another
|
|
25
|
+
* shape is kept as it is, after the collapsed ones.
|
|
26
|
+
*/
|
|
27
|
+
export declare function compressHunkIds(ids: readonly string[]): string;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Formatting and masking helpers for the evidence pack. */
|
|
2
|
+
import { MASK_CHAR, maskPrivate } from '../core/secrets.js';
|
|
3
|
+
import { truncate } from '../core/text.js';
|
|
4
|
+
const MASK = MASK_CHAR.repeat(8);
|
|
5
|
+
const KEY_BEGIN = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
6
|
+
const KEY_END = /-----END [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
7
|
+
const BASE64_BODY = /^[A-Za-z0-9+/=]{48,}$/;
|
|
8
|
+
const MAX_CODE_LINE = 240;
|
|
9
|
+
export function createMasker(maskMail) {
|
|
10
|
+
const block = (value) => maskPrivate(value, { maskEmails: maskMail });
|
|
11
|
+
const text = (value) => block(value).replace(/[\r\n\u2028\u2029]+/g, ' ');
|
|
12
|
+
const code = (value) => truncate(text(value.replace(/\t/g, ' ')), MAX_CODE_LINE);
|
|
13
|
+
return {
|
|
14
|
+
text,
|
|
15
|
+
block,
|
|
16
|
+
code,
|
|
17
|
+
hunk(lines) {
|
|
18
|
+
let inKey = false;
|
|
19
|
+
return lines.map((line) => {
|
|
20
|
+
const t = line.text;
|
|
21
|
+
if (KEY_BEGIN.test(t)) {
|
|
22
|
+
inKey = !KEY_END.test(t);
|
|
23
|
+
return MASK;
|
|
24
|
+
}
|
|
25
|
+
if (inKey) {
|
|
26
|
+
if (KEY_END.test(t))
|
|
27
|
+
inKey = false;
|
|
28
|
+
return MASK;
|
|
29
|
+
}
|
|
30
|
+
if (BASE64_BODY.test(t.trim()))
|
|
31
|
+
return MASK;
|
|
32
|
+
return code(t);
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** A Markdown fence longer than any backtick run inside, so untrusted text cannot close it early. */
|
|
38
|
+
export function fence(body, info = '') {
|
|
39
|
+
let longest = 0;
|
|
40
|
+
for (const m of body.matchAll(/`+/g))
|
|
41
|
+
longest = Math.max(longest, m[0].length);
|
|
42
|
+
const marks = '`'.repeat(Math.max(3, longest + 1));
|
|
43
|
+
return `${marks}${info}\n${body}\n${marks}`;
|
|
44
|
+
}
|
|
45
|
+
/** Make text safe for one Markdown table cell. */
|
|
46
|
+
export function cell(value) {
|
|
47
|
+
return value
|
|
48
|
+
.replace(/[\r\n]+/g, ' ')
|
|
49
|
+
.replace(/\|/g, '\\|')
|
|
50
|
+
.replace(/`/g, "'");
|
|
51
|
+
}
|
|
52
|
+
/** Inline code span that survives backticks in the text. */
|
|
53
|
+
export function code(value) {
|
|
54
|
+
return `\`${value.replace(/[\r\n`]+/g, ' ')}\``;
|
|
55
|
+
}
|
|
56
|
+
export function numberedLine(number, marker, text) {
|
|
57
|
+
return `${String(number ?? '').padStart(4)} ${marker} ${text}`;
|
|
58
|
+
}
|
|
59
|
+
const SIMPLE_ID = /^([A-Z]+)(\d+)$/;
|
|
60
|
+
/** Collapse runs of consecutive ids with the same prefix: S1 S2 S3 -> "S1-S3". Other ids stay as they are. */
|
|
61
|
+
export function compressIds(ids) {
|
|
62
|
+
const parts = [];
|
|
63
|
+
let i = 0;
|
|
64
|
+
while (i < ids.length) {
|
|
65
|
+
const first = SIMPLE_ID.exec(ids[i]);
|
|
66
|
+
if (!first) {
|
|
67
|
+
parts.push(ids[i]);
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
let j = i;
|
|
72
|
+
let last = Number(first[2]);
|
|
73
|
+
while (j + 1 < ids.length) {
|
|
74
|
+
const next = SIMPLE_ID.exec(ids[j + 1]);
|
|
75
|
+
if (!next || next[1] !== first[1] || Number(next[2]) !== last + 1)
|
|
76
|
+
break;
|
|
77
|
+
last = Number(next[2]);
|
|
78
|
+
j++;
|
|
79
|
+
}
|
|
80
|
+
parts.push(j > i ? `${first[1]}${first[2]}-${first[1]}${last}` : ids[i]);
|
|
81
|
+
i = j + 1;
|
|
82
|
+
}
|
|
83
|
+
return parts.join(', ');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Collapse hunk ids: F2.H1 F2.H2 F2.H3 -> "F2.H1-H3", and a run of files that each have only H1
|
|
87
|
+
* -> "F5.H1-F9.H1" (H1 of every file from F5 to F9). Used only for very long lists. An id of another
|
|
88
|
+
* shape is kept as it is, after the collapsed ones.
|
|
89
|
+
*/
|
|
90
|
+
export function compressHunkIds(ids) {
|
|
91
|
+
const byFile = new Map();
|
|
92
|
+
const others = [];
|
|
93
|
+
for (const id of ids) {
|
|
94
|
+
const m = /^F(\d+)\.H(\d+)$/.exec(id);
|
|
95
|
+
if (!m) {
|
|
96
|
+
others.push(id);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const file = Number(m[1]);
|
|
100
|
+
byFile.set(file, [...(byFile.get(file) ?? []), Number(m[2])]);
|
|
101
|
+
}
|
|
102
|
+
const parts = [];
|
|
103
|
+
let run = [];
|
|
104
|
+
const flushRun = () => {
|
|
105
|
+
if (run.length === 1)
|
|
106
|
+
parts.push(`F${run[0]}.H1`);
|
|
107
|
+
else if (run.length > 1)
|
|
108
|
+
parts.push(`F${run[0]}.H1-F${run[run.length - 1]}.H1`);
|
|
109
|
+
run = [];
|
|
110
|
+
};
|
|
111
|
+
for (const [file, hunks] of byFile) {
|
|
112
|
+
hunks.sort((a, b) => a - b);
|
|
113
|
+
if (hunks.length === 1 && hunks[0] === 1) {
|
|
114
|
+
if (run.length > 0 && run[run.length - 1] + 1 !== file)
|
|
115
|
+
flushRun();
|
|
116
|
+
run.push(file);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
flushRun();
|
|
120
|
+
let start = hunks[0];
|
|
121
|
+
let prev = start;
|
|
122
|
+
const emit = () => {
|
|
123
|
+
parts.push(start === prev ? `F${file}.H${start}` : `F${file}.H${start}-H${prev}`);
|
|
124
|
+
};
|
|
125
|
+
for (const n of hunks.slice(1)) {
|
|
126
|
+
if (n === prev + 1)
|
|
127
|
+
prev = n;
|
|
128
|
+
else {
|
|
129
|
+
emit();
|
|
130
|
+
start = n;
|
|
131
|
+
prev = n;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
emit();
|
|
135
|
+
}
|
|
136
|
+
flushRun();
|
|
137
|
+
return [...parts, ...others].join(', ');
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=pack-format.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Analysis, ChangeSet, ContextInputs } from '../core/types.ts';
|
|
2
|
+
export interface EvidencePackOptions {
|
|
3
|
+
/** Approximate token budget for the whole pack. */
|
|
4
|
+
maxTokens: number;
|
|
5
|
+
/** "minimal" leaves out all code lines (metadata, paths and symbol names only). */
|
|
6
|
+
llmContext: 'full' | 'minimal';
|
|
7
|
+
targetDurationSec: number;
|
|
8
|
+
style: 'technical' | 'product' | 'hybrid';
|
|
9
|
+
language: string;
|
|
10
|
+
/** Mask e-mail addresses in the pack. Default true. */
|
|
11
|
+
maskEmails?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface EvidencePack {
|
|
14
|
+
/** Markdown document: the LLM prompt body and the agent-facing evidence.md. */
|
|
15
|
+
markdown: string;
|
|
16
|
+
approxTokens: number;
|
|
17
|
+
/** Hunk ids whose code is included. */
|
|
18
|
+
includedHunks: string[];
|
|
19
|
+
/** Hunk ids left out to stay within the budget. */
|
|
20
|
+
omittedHunks: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build the evidence pack. It stays within `options.maxTokens` by shrinking the fixed sections
|
|
24
|
+
* and then including key hunks in score order; hunks that do not fit are listed by id.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildEvidencePack(changeSet: ChangeSet, analysis: Analysis, inputs: ContextInputs, options: EvidencePackOptions): EvidencePack;
|