@ruverd/julius 0.0.0-stage → 0.24.1
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/CHANGELOG.md +47 -0
- package/CREDITS.md +25 -0
- package/LICENSE +21 -0
- package/PROVENANCE.md +9 -0
- package/README.md +229 -2
- package/dist/ai/crux.d.ts +60 -0
- package/dist/ai/crux.d.ts.map +1 -0
- package/dist/ai/crux.js +141 -0
- package/dist/ai/crux.js.map +1 -0
- package/dist/ai/failure.d.ts +60 -0
- package/dist/ai/failure.d.ts.map +1 -0
- package/dist/ai/failure.js +86 -0
- package/dist/ai/failure.js.map +1 -0
- package/dist/ai/llm/anthropic.d.ts +37 -0
- package/dist/ai/llm/anthropic.d.ts.map +1 -0
- package/dist/ai/llm/anthropic.js +144 -0
- package/dist/ai/llm/anthropic.js.map +1 -0
- package/dist/ai/llm/factory.d.ts +28 -0
- package/dist/ai/llm/factory.d.ts.map +1 -0
- package/dist/ai/llm/factory.js +36 -0
- package/dist/ai/llm/factory.js.map +1 -0
- package/dist/ai/llm/litellm.d.ts +34 -0
- package/dist/ai/llm/litellm.d.ts.map +1 -0
- package/dist/ai/llm/litellm.js +45 -0
- package/dist/ai/llm/litellm.js.map +1 -0
- package/dist/ai/llm/openai.d.ts +44 -0
- package/dist/ai/llm/openai.d.ts.map +1 -0
- package/dist/ai/llm/openai.js +239 -0
- package/dist/ai/llm/openai.js.map +1 -0
- package/dist/ai/llm/orcarouter.d.ts +34 -0
- package/dist/ai/llm/orcarouter.d.ts.map +1 -0
- package/dist/ai/llm/orcarouter.js +45 -0
- package/dist/ai/llm/orcarouter.js.map +1 -0
- package/dist/ai/llm/recover-tool.d.ts +19 -0
- package/dist/ai/llm/recover-tool.d.ts.map +1 -0
- package/dist/ai/llm/recover-tool.js +109 -0
- package/dist/ai/llm/recover-tool.js.map +1 -0
- package/dist/ai/llm/types.d.ts +122 -0
- package/dist/ai/llm/types.d.ts.map +1 -0
- package/dist/ai/llm/types.js +33 -0
- package/dist/ai/llm/types.js.map +1 -0
- package/dist/ai/providers.d.ts +59 -0
- package/dist/ai/providers.d.ts.map +1 -0
- package/dist/ai/providers.js +54 -0
- package/dist/ai/providers.js.map +1 -0
- package/dist/ai/summarize.d.ts +25 -0
- package/dist/ai/summarize.d.ts.map +1 -0
- package/dist/ai/summarize.js +34 -0
- package/dist/ai/summarize.js.map +1 -0
- package/dist/ai/synthesize.d.ts +40 -0
- package/dist/ai/synthesize.d.ts.map +1 -0
- package/dist/ai/synthesize.js +131 -0
- package/dist/ai/synthesize.js.map +1 -0
- package/dist/app/checkout.d.ts +46 -0
- package/dist/app/checkout.d.ts.map +1 -0
- package/dist/app/checkout.js +223 -0
- package/dist/app/checkout.js.map +1 -0
- package/dist/app/events.d.ts +44 -0
- package/dist/app/events.d.ts.map +1 -0
- package/dist/app/events.js +64 -0
- package/dist/app/events.js.map +1 -0
- package/dist/app/identity.d.ts +54 -0
- package/dist/app/identity.d.ts.map +1 -0
- package/dist/app/identity.js +96 -0
- package/dist/app/identity.js.map +1 -0
- package/dist/app/main.d.ts +2 -0
- package/dist/app/main.d.ts.map +1 -0
- package/dist/app/main.js +62 -0
- package/dist/app/main.js.map +1 -0
- package/dist/app/pages.d.ts +56 -0
- package/dist/app/pages.d.ts.map +1 -0
- package/dist/app/pages.js +193 -0
- package/dist/app/pages.js.map +1 -0
- package/dist/app/queue.d.ts +40 -0
- package/dist/app/queue.d.ts.map +1 -0
- package/dist/app/queue.js +68 -0
- package/dist/app/queue.js.map +1 -0
- package/dist/app/review-process.d.ts +66 -0
- package/dist/app/review-process.d.ts.map +1 -0
- package/dist/app/review-process.js +200 -0
- package/dist/app/review-process.js.map +1 -0
- package/dist/app/review-worker.d.ts +2 -0
- package/dist/app/review-worker.d.ts.map +1 -0
- package/dist/app/review-worker.js +108 -0
- package/dist/app/review-worker.js.map +1 -0
- package/dist/app/review.d.ts +23 -0
- package/dist/app/review.d.ts.map +1 -0
- package/dist/app/review.js +142 -0
- package/dist/app/review.js.map +1 -0
- package/dist/app/server.d.ts +49 -0
- package/dist/app/server.d.ts.map +1 -0
- package/dist/app/server.js +123 -0
- package/dist/app/server.js.map +1 -0
- package/dist/ask/ask.d.ts +195 -0
- package/dist/ask/ask.d.ts.map +1 -0
- package/dist/ask/ask.js +1252 -0
- package/dist/ask/ask.js.map +1 -0
- package/dist/ask/file-rank.d.ts +72 -0
- package/dist/ask/file-rank.d.ts.map +1 -0
- package/dist/ask/file-rank.js +160 -0
- package/dist/ask/file-rank.js.map +1 -0
- package/dist/ask/file-selection.d.ts +22 -0
- package/dist/ask/file-selection.d.ts.map +1 -0
- package/dist/ask/file-selection.js +66 -0
- package/dist/ask/file-selection.js.map +1 -0
- package/dist/ask/fuse.d.ts +195 -0
- package/dist/ask/fuse.d.ts.map +1 -0
- package/dist/ask/fuse.js +344 -0
- package/dist/ask/fuse.js.map +1 -0
- package/dist/ask/graphrank.d.ts +61 -0
- package/dist/ask/graphrank.d.ts.map +1 -0
- package/dist/ask/graphrank.js +130 -0
- package/dist/ask/graphrank.js.map +1 -0
- package/dist/ask/index-file.d.ts +44 -0
- package/dist/ask/index-file.d.ts.map +1 -0
- package/dist/ask/index-file.js +128 -0
- package/dist/ask/index-file.js.map +1 -0
- package/dist/bin/julius.d.ts +3 -0
- package/dist/bin/julius.d.ts.map +1 -0
- package/dist/bin/julius.js +4 -0
- package/dist/bin/julius.js.map +1 -0
- package/dist/blast/blast-cli.d.ts +35 -0
- package/dist/blast/blast-cli.d.ts.map +1 -0
- package/dist/blast/blast-cli.js +155 -0
- package/dist/blast/blast-cli.js.map +1 -0
- package/dist/blast/blast.d.ts +128 -0
- package/dist/blast/blast.d.ts.map +1 -0
- package/dist/blast/blast.js +383 -0
- package/dist/blast/blast.js.map +1 -0
- package/dist/blast/diff.d.ts +53 -0
- package/dist/blast/diff.d.ts.map +1 -0
- package/dist/blast/diff.js +193 -0
- package/dist/blast/diff.js.map +1 -0
- package/dist/blast/evidence.d.ts +51 -0
- package/dist/blast/evidence.d.ts.map +1 -0
- package/dist/blast/evidence.js +162 -0
- package/dist/blast/evidence.js.map +1 -0
- package/dist/blast/modules.d.ts +33 -0
- package/dist/blast/modules.d.ts.map +1 -0
- package/dist/blast/modules.js +83 -0
- package/dist/blast/modules.js.map +1 -0
- package/dist/blast/name.d.ts +74 -0
- package/dist/blast/name.d.ts.map +1 -0
- package/dist/blast/name.js +269 -0
- package/dist/blast/name.js.map +1 -0
- package/dist/blast/owners.d.ts +85 -0
- package/dist/blast/owners.d.ts.map +1 -0
- package/dist/blast/owners.js +272 -0
- package/dist/blast/owners.js.map +1 -0
- package/dist/blast/render.d.ts +46 -0
- package/dist/blast/render.d.ts.map +1 -0
- package/dist/blast/render.js +422 -0
- package/dist/blast/render.js.map +1 -0
- package/dist/blast/viz.d.ts +37 -0
- package/dist/blast/viz.d.ts.map +1 -0
- package/dist/blast/viz.js +180 -0
- package/dist/blast/viz.js.map +1 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +43 -0
- package/dist/brand.js.map +1 -0
- package/dist/check/learning-edits.d.ts +9 -0
- package/dist/check/learning-edits.d.ts.map +1 -0
- package/dist/check/learning-edits.js +62 -0
- package/dist/check/learning-edits.js.map +1 -0
- package/dist/check/local-check.d.ts +104 -0
- package/dist/check/local-check.d.ts.map +1 -0
- package/dist/check/local-check.js +830 -0
- package/dist/check/local-check.js.map +1 -0
- package/dist/check/types.d.ts +31 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +2 -0
- package/dist/check/types.js.map +1 -0
- package/dist/claude/build-progress.d.ts +29 -0
- package/dist/claude/build-progress.d.ts.map +1 -0
- package/dist/claude/build-progress.js +76 -0
- package/dist/claude/build-progress.js.map +1 -0
- package/dist/claude/format.d.ts +131 -0
- package/dist/claude/format.d.ts.map +1 -0
- package/dist/claude/format.js +328 -0
- package/dist/claude/format.js.map +1 -0
- package/dist/claude/hook-layers.d.ts +8 -0
- package/dist/claude/hook-layers.d.ts.map +1 -0
- package/dist/claude/hook-layers.js +74 -0
- package/dist/claude/hook-layers.js.map +1 -0
- package/dist/claude/hooks.d.ts +101 -0
- package/dist/claude/hooks.d.ts.map +1 -0
- package/dist/claude/hooks.js +849 -0
- package/dist/claude/hooks.js.map +1 -0
- package/dist/claude/init.d.ts +70 -0
- package/dist/claude/init.d.ts.map +1 -0
- package/dist/claude/init.js +207 -0
- package/dist/claude/init.js.map +1 -0
- package/dist/claude/note-signals.d.ts +28 -0
- package/dist/claude/note-signals.d.ts.map +1 -0
- package/dist/claude/note-signals.js +325 -0
- package/dist/claude/note-signals.js.map +1 -0
- package/dist/claude/paths.d.ts +9 -0
- package/dist/claude/paths.d.ts.map +1 -0
- package/dist/claude/paths.js +22 -0
- package/dist/claude/paths.js.map +1 -0
- package/dist/claude/session-metrics.d.ts +73 -0
- package/dist/claude/session-metrics.d.ts.map +1 -0
- package/dist/claude/session-metrics.js +209 -0
- package/dist/claude/session-metrics.js.map +1 -0
- package/dist/claude/settings-merge.d.ts +66 -0
- package/dist/claude/settings-merge.d.ts.map +1 -0
- package/dist/claude/settings-merge.js +249 -0
- package/dist/claude/settings-merge.js.map +1 -0
- package/dist/claude/shim-template.d.ts +18 -0
- package/dist/claude/shim-template.d.ts.map +1 -0
- package/dist/claude/shim-template.js +226 -0
- package/dist/claude/shim-template.js.map +1 -0
- package/dist/claude/skill-template.d.ts +12 -0
- package/dist/claude/skill-template.d.ts.map +1 -0
- package/dist/claude/skill-template.js +294 -0
- package/dist/claude/skill-template.js.map +1 -0
- package/dist/claude/state.d.ts +73 -0
- package/dist/claude/state.d.ts.map +1 -0
- package/dist/claude/state.js +33 -0
- package/dist/claude/state.js.map +1 -0
- package/dist/claude/stats.d.ts +5 -0
- package/dist/claude/stats.d.ts.map +1 -0
- package/dist/claude/stats.js +24 -0
- package/dist/claude/stats.js.map +1 -0
- package/dist/claude/statusline.d.ts +14 -0
- package/dist/claude/statusline.d.ts.map +1 -0
- package/dist/claude/statusline.js +45 -0
- package/dist/claude/statusline.js.map +1 -0
- package/dist/claude/sync-run.d.ts +3 -0
- package/dist/claude/sync-run.d.ts.map +1 -0
- package/dist/claude/sync-run.js +46 -0
- package/dist/claude/sync-run.js.map +1 -0
- package/dist/claude/tally.d.ts +50 -0
- package/dist/claude/tally.d.ts.map +1 -0
- package/dist/claude/tally.js +211 -0
- package/dist/claude/tally.js.map +1 -0
- package/dist/cli-epilogue.d.ts +12 -0
- package/dist/cli-epilogue.d.ts.map +1 -0
- package/dist/cli-epilogue.js +55 -0
- package/dist/cli-epilogue.js.map +1 -0
- package/dist/cli-meta.d.ts +45 -0
- package/dist/cli-meta.d.ts.map +1 -0
- package/dist/cli-meta.js +145 -0
- package/dist/cli-meta.js.map +1 -0
- package/dist/cli-picker.d.ts +129 -0
- package/dist/cli-picker.d.ts.map +1 -0
- package/dist/cli-picker.js +432 -0
- package/dist/cli-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2213 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/diff.d.ts +20 -0
- package/dist/cloud/diff.d.ts.map +1 -0
- package/dist/cloud/diff.js +59 -0
- package/dist/cloud/diff.js.map +1 -0
- package/dist/cloud/nudge.d.ts +66 -0
- package/dist/cloud/nudge.d.ts.map +1 -0
- package/dist/cloud/nudge.js +268 -0
- package/dist/cloud/nudge.js.map +1 -0
- package/dist/cloud/workspace-sync.d.ts +58 -0
- package/dist/cloud/workspace-sync.d.ts.map +1 -0
- package/dist/cloud/workspace-sync.js +268 -0
- package/dist/cloud/workspace-sync.js.map +1 -0
- package/dist/cloud/workspace.d.ts +159 -0
- package/dist/cloud/workspace.d.ts.map +1 -0
- package/dist/cloud/workspace.js +134 -0
- package/dist/cloud/workspace.js.map +1 -0
- package/dist/context/build.d.ts +52 -0
- package/dist/context/build.d.ts.map +1 -0
- package/dist/context/build.js +362 -0
- package/dist/context/build.js.map +1 -0
- package/dist/context/check.d.ts +42 -0
- package/dist/context/check.d.ts.map +1 -0
- package/dist/context/check.js +162 -0
- package/dist/context/check.js.map +1 -0
- package/dist/context/map-dir.d.ts +4 -0
- package/dist/context/map-dir.d.ts.map +1 -0
- package/dist/context/map-dir.js +6 -0
- package/dist/context/map-dir.js.map +1 -0
- package/dist/context/node-file.d.ts +109 -0
- package/dist/context/node-file.d.ts.map +1 -0
- package/dist/context/node-file.js +362 -0
- package/dist/context/node-file.js.map +1 -0
- package/dist/context/price.d.ts +49 -0
- package/dist/context/price.d.ts.map +1 -0
- package/dist/context/price.js +83 -0
- package/dist/context/price.js.map +1 -0
- package/dist/context/savings.d.ts +26 -0
- package/dist/context/savings.d.ts.map +1 -0
- package/dist/context/savings.js +59 -0
- package/dist/context/savings.js.map +1 -0
- package/dist/economy/cli.d.ts +3 -0
- package/dist/economy/cli.d.ts.map +1 -0
- package/dist/economy/cli.js +52 -0
- package/dist/economy/cli.js.map +1 -0
- package/dist/economy/delivery.d.ts +49 -0
- package/dist/economy/delivery.d.ts.map +1 -0
- package/dist/economy/delivery.js +176 -0
- package/dist/economy/delivery.js.map +1 -0
- package/dist/economy/index.d.ts +68 -0
- package/dist/economy/index.d.ts.map +1 -0
- package/dist/economy/index.js +524 -0
- package/dist/economy/index.js.map +1 -0
- package/dist/engine.d.ts +83 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +122 -0
- package/dist/engine.js.map +1 -0
- package/dist/evaluation/index.d.ts +41 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +61 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/graph/bindings.d.ts +64 -0
- package/dist/graph/bindings.d.ts.map +1 -0
- package/dist/graph/bindings.js +713 -0
- package/dist/graph/bindings.js.map +1 -0
- package/dist/graph/build.d.ts +88 -0
- package/dist/graph/build.d.ts.map +1 -0
- package/dist/graph/build.js +375 -0
- package/dist/graph/build.js.map +1 -0
- package/dist/graph/cards.d.ts +46 -0
- package/dist/graph/cards.d.ts.map +1 -0
- package/dist/graph/cards.js +280 -0
- package/dist/graph/cards.js.map +1 -0
- package/dist/graph/check.d.ts +25 -0
- package/dist/graph/check.d.ts.map +1 -0
- package/dist/graph/check.js +192 -0
- package/dist/graph/check.js.map +1 -0
- package/dist/graph/container.d.ts +63 -0
- package/dist/graph/container.d.ts.map +1 -0
- package/dist/graph/container.js +190 -0
- package/dist/graph/container.js.map +1 -0
- package/dist/graph/enrich.d.ts +62 -0
- package/dist/graph/enrich.d.ts.map +1 -0
- package/dist/graph/enrich.js +253 -0
- package/dist/graph/enrich.js.map +1 -0
- package/dist/graph/extract-cache.d.ts +101 -0
- package/dist/graph/extract-cache.d.ts.map +1 -0
- package/dist/graph/extract-cache.js +199 -0
- package/dist/graph/extract-cache.js.map +1 -0
- package/dist/graph/extract.d.ts +85 -0
- package/dist/graph/extract.d.ts.map +1 -0
- package/dist/graph/extract.js +2376 -0
- package/dist/graph/extract.js.map +1 -0
- package/dist/graph/fingerprint.d.ts +76 -0
- package/dist/graph/fingerprint.d.ts.map +1 -0
- package/dist/graph/fingerprint.js +160 -0
- package/dist/graph/fingerprint.js.map +1 -0
- package/dist/graph/generic.d.ts +74 -0
- package/dist/graph/generic.d.ts.map +1 -0
- package/dist/graph/generic.js +580 -0
- package/dist/graph/generic.js.map +1 -0
- package/dist/graph/invariants.d.ts +33 -0
- package/dist/graph/invariants.d.ts.map +1 -0
- package/dist/graph/invariants.js +52 -0
- package/dist/graph/invariants.js.map +1 -0
- package/dist/graph/load.d.ts +29 -0
- package/dist/graph/load.d.ts.map +1 -0
- package/dist/graph/load.js +97 -0
- package/dist/graph/load.js.map +1 -0
- package/dist/graph/lsp/client.d.ts +43 -0
- package/dist/graph/lsp/client.d.ts.map +1 -0
- package/dist/graph/lsp/client.js +179 -0
- package/dist/graph/lsp/client.js.map +1 -0
- package/dist/graph/lsp/enrich.d.ts +11 -0
- package/dist/graph/lsp/enrich.d.ts.map +1 -0
- package/dist/graph/lsp/enrich.js +155 -0
- package/dist/graph/lsp/enrich.js.map +1 -0
- package/dist/graph/lsp/registry.d.ts +15 -0
- package/dist/graph/lsp/registry.d.ts.map +1 -0
- package/dist/graph/lsp/registry.js +46 -0
- package/dist/graph/lsp/registry.js.map +1 -0
- package/dist/graph/map.d.ts +107 -0
- package/dist/graph/map.d.ts.map +1 -0
- package/dist/graph/map.js +239 -0
- package/dist/graph/map.js.map +1 -0
- package/dist/graph/native.d.ts +38 -0
- package/dist/graph/native.d.ts.map +1 -0
- package/dist/graph/native.js +169 -0
- package/dist/graph/native.js.map +1 -0
- package/dist/graph/queries/c.scm +13 -0
- package/dist/graph/queries/c_sharp.scm +19 -0
- package/dist/graph/queries/clojure.scm +58 -0
- package/dist/graph/queries/cpp.scm +23 -0
- package/dist/graph/queries/dart.scm +42 -0
- package/dist/graph/queries/elixir.scm +54 -0
- package/dist/graph/queries/java.scm +20 -0
- package/dist/graph/queries/kotlin.scm +43 -0
- package/dist/graph/queries/lua.scm +36 -0
- package/dist/graph/queries/nix.scm +32 -0
- package/dist/graph/queries/php.scm +40 -0
- package/dist/graph/queries/ruby.scm +65 -0
- package/dist/graph/queries/rust.scm +41 -0
- package/dist/graph/queries/scala.scm +66 -0
- package/dist/graph/queries/solidity.scm +43 -0
- package/dist/graph/queries/swift.scm +51 -0
- package/dist/graph/refresh.d.ts +49 -0
- package/dist/graph/refresh.d.ts.map +1 -0
- package/dist/graph/refresh.js +255 -0
- package/dist/graph/refresh.js.map +1 -0
- package/dist/graph/relations.d.ts +14 -0
- package/dist/graph/relations.d.ts.map +1 -0
- package/dist/graph/relations.js +8 -0
- package/dist/graph/relations.js.map +1 -0
- package/dist/graph/resolve.d.ts +17 -0
- package/dist/graph/resolve.d.ts.map +1 -0
- package/dist/graph/resolve.js +654 -0
- package/dist/graph/resolve.js.map +1 -0
- package/dist/graph/root.d.ts +11 -0
- package/dist/graph/root.d.ts.map +1 -0
- package/dist/graph/root.js +40 -0
- package/dist/graph/root.js.map +1 -0
- package/dist/graph/scopes.d.ts +42 -0
- package/dist/graph/scopes.d.ts.map +1 -0
- package/dist/graph/scopes.js +342 -0
- package/dist/graph/scopes.js.map +1 -0
- package/dist/graph/seed.d.ts +38 -0
- package/dist/graph/seed.d.ts.map +1 -0
- package/dist/graph/seed.js +226 -0
- package/dist/graph/seed.js.map +1 -0
- package/dist/graph/source-files.d.ts +40 -0
- package/dist/graph/source-files.d.ts.map +1 -0
- package/dist/graph/source-files.js +85 -0
- package/dist/graph/source-files.js.map +1 -0
- package/dist/graph/traverse-cli.d.ts +55 -0
- package/dist/graph/traverse-cli.d.ts.map +1 -0
- package/dist/graph/traverse-cli.js +189 -0
- package/dist/graph/traverse-cli.js.map +1 -0
- package/dist/graph/traverse.d.ts +112 -0
- package/dist/graph/traverse.d.ts.map +1 -0
- package/dist/graph/traverse.js +192 -0
- package/dist/graph/traverse.js.map +1 -0
- package/dist/graph/types.d.ts +78 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +14 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/workspace-cli.d.ts +48 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -0
- package/dist/graph/workspace-cli.js +102 -0
- package/dist/graph/workspace-cli.js.map +1 -0
- package/dist/graph/workspace.d.ts +135 -0
- package/dist/graph/workspace.d.ts.map +1 -0
- package/dist/graph/workspace.js +598 -0
- package/dist/graph/workspace.js.map +1 -0
- package/dist/graph/write.d.ts +13 -0
- package/dist/graph/write.d.ts.map +1 -0
- package/dist/graph/write.js +86 -0
- package/dist/graph/write.js.map +1 -0
- package/dist/hosts/antigravity.d.ts +8 -0
- package/dist/hosts/antigravity.d.ts.map +1 -0
- package/dist/hosts/antigravity.js +42 -0
- package/dist/hosts/antigravity.js.map +1 -0
- package/dist/hosts/claude-global.d.ts +36 -0
- package/dist/hosts/claude-global.d.ts.map +1 -0
- package/dist/hosts/claude-global.js +153 -0
- package/dist/hosts/claude-global.js.map +1 -0
- package/dist/hosts/codex-hooks.d.ts +11 -0
- package/dist/hosts/codex-hooks.d.ts.map +1 -0
- package/dist/hosts/codex-hooks.js +80 -0
- package/dist/hosts/codex-hooks.js.map +1 -0
- package/dist/hosts/config-write.d.ts +36 -0
- package/dist/hosts/config-write.d.ts.map +1 -0
- package/dist/hosts/config-write.js +64 -0
- package/dist/hosts/config-write.js.map +1 -0
- package/dist/hosts/cursor-hooks.d.ts +21 -0
- package/dist/hosts/cursor-hooks.d.ts.map +1 -0
- package/dist/hosts/cursor-hooks.js +103 -0
- package/dist/hosts/cursor-hooks.js.map +1 -0
- package/dist/hosts/init.d.ts +26 -0
- package/dist/hosts/init.d.ts.map +1 -0
- package/dist/hosts/init.js +82 -0
- package/dist/hosts/init.js.map +1 -0
- package/dist/hosts/install.d.ts +12 -0
- package/dist/hosts/install.d.ts.map +1 -0
- package/dist/hosts/install.js +347 -0
- package/dist/hosts/install.js.map +1 -0
- package/dist/hosts/instructions.d.ts +7 -0
- package/dist/hosts/instructions.d.ts.map +1 -0
- package/dist/hosts/instructions.js +71 -0
- package/dist/hosts/instructions.js.map +1 -0
- package/dist/hosts/investigation-instructions.d.ts +2 -0
- package/dist/hosts/investigation-instructions.d.ts.map +1 -0
- package/dist/hosts/investigation-instructions.js +2 -0
- package/dist/hosts/investigation-instructions.js.map +1 -0
- package/dist/hosts/mcp-config.d.ts +59 -0
- package/dist/hosts/mcp-config.d.ts.map +1 -0
- package/dist/hosts/mcp-config.js +229 -0
- package/dist/hosts/mcp-config.js.map +1 -0
- package/dist/hosts/plan.d.ts +32 -0
- package/dist/hosts/plan.d.ts.map +1 -0
- package/dist/hosts/plan.js +77 -0
- package/dist/hosts/plan.js.map +1 -0
- package/dist/hosts/registry.d.ts +35 -0
- package/dist/hosts/registry.d.ts.map +1 -0
- package/dist/hosts/registry.js +157 -0
- package/dist/hosts/registry.js.map +1 -0
- package/dist/hosts/retract.d.ts +47 -0
- package/dist/hosts/retract.d.ts.map +1 -0
- package/dist/hosts/retract.js +541 -0
- package/dist/hosts/retract.js.map +1 -0
- package/dist/hosts/sections.d.ts +46 -0
- package/dist/hosts/sections.d.ts.map +1 -0
- package/dist/hosts/sections.js +126 -0
- package/dist/hosts/sections.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/fs.d.ts +79 -0
- package/dist/ingest/fs.d.ts.map +1 -0
- package/dist/ingest/fs.js +307 -0
- package/dist/ingest/fs.js.map +1 -0
- package/dist/init-guard.d.ts +11 -0
- package/dist/init-guard.d.ts.map +1 -0
- package/dist/init-guard.js +21 -0
- package/dist/init-guard.js.map +1 -0
- package/dist/investigation/index.d.ts +57 -0
- package/dist/investigation/index.d.ts.map +1 -0
- package/dist/investigation/index.js +346 -0
- package/dist/investigation/index.js.map +1 -0
- package/dist/mcp/compact.d.ts +9 -0
- package/dist/mcp/compact.d.ts.map +1 -0
- package/dist/mcp/compact.js +133 -0
- package/dist/mcp/compact.js.map +1 -0
- package/dist/mcp/instructions.d.ts +5 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +57 -0
- package/dist/mcp/instructions.js.map +1 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +128 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-names.d.ts +20 -0
- package/dist/mcp/tool-names.d.ts.map +1 -0
- package/dist/mcp/tool-names.js +36 -0
- package/dist/mcp/tool-names.js.map +1 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +300 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/notes/ask-notes.d.ts +8 -0
- package/dist/notes/ask-notes.d.ts.map +1 -0
- package/dist/notes/ask-notes.js +19 -0
- package/dist/notes/ask-notes.js.map +1 -0
- package/dist/notes/branches.d.ts +102 -0
- package/dist/notes/branches.d.ts.map +1 -0
- package/dist/notes/branches.js +304 -0
- package/dist/notes/branches.js.map +1 -0
- package/dist/notes/cold-start.d.ts +177 -0
- package/dist/notes/cold-start.d.ts.map +1 -0
- package/dist/notes/cold-start.js +537 -0
- package/dist/notes/cold-start.js.map +1 -0
- package/dist/notes/edit-overlap.d.ts +62 -0
- package/dist/notes/edit-overlap.d.ts.map +1 -0
- package/dist/notes/edit-overlap.js +202 -0
- package/dist/notes/edit-overlap.js.map +1 -0
- package/dist/notes/git-facts.d.ts +21 -0
- package/dist/notes/git-facts.d.ts.map +1 -0
- package/dist/notes/git-facts.js +121 -0
- package/dist/notes/git-facts.js.map +1 -0
- package/dist/notes/home.d.ts +87 -0
- package/dist/notes/home.d.ts.map +1 -0
- package/dist/notes/home.js +430 -0
- package/dist/notes/home.js.map +1 -0
- package/dist/notes/learning-fields.d.ts +102 -0
- package/dist/notes/learning-fields.d.ts.map +1 -0
- package/dist/notes/learning-fields.js +217 -0
- package/dist/notes/learning-fields.js.map +1 -0
- package/dist/notes/note-gate.d.ts +42 -0
- package/dist/notes/note-gate.d.ts.map +1 -0
- package/dist/notes/note-gate.js +181 -0
- package/dist/notes/note-gate.js.map +1 -0
- package/dist/notes/notes.d.ts +214 -0
- package/dist/notes/notes.d.ts.map +1 -0
- package/dist/notes/notes.js +591 -0
- package/dist/notes/notes.js.map +1 -0
- package/dist/notes/pr-reviews.d.ts +108 -0
- package/dist/notes/pr-reviews.d.ts.map +1 -0
- package/dist/notes/pr-reviews.js +325 -0
- package/dist/notes/pr-reviews.js.map +1 -0
- package/dist/notes/repo-julius.d.ts +18 -0
- package/dist/notes/repo-julius.d.ts.map +1 -0
- package/dist/notes/repo-julius.js +111 -0
- package/dist/notes/repo-julius.js.map +1 -0
- package/dist/notes/session-cost.d.ts +35 -0
- package/dist/notes/session-cost.d.ts.map +1 -0
- package/dist/notes/session-cost.js +276 -0
- package/dist/notes/session-cost.js.map +1 -0
- package/dist/search/grep-cli.d.ts +37 -0
- package/dist/search/grep-cli.d.ts.map +1 -0
- package/dist/search/grep-cli.js +119 -0
- package/dist/search/grep-cli.js.map +1 -0
- package/dist/search/grep.d.ts +60 -0
- package/dist/search/grep.d.ts.map +1 -0
- package/dist/search/grep.js +176 -0
- package/dist/search/grep.js.map +1 -0
- package/dist/search/ignored-code.d.ts +9 -0
- package/dist/search/ignored-code.d.ts.map +1 -0
- package/dist/search/ignored-code.js +73 -0
- package/dist/search/ignored-code.js.map +1 -0
- package/dist/skills/skills.d.ts +118 -0
- package/dist/skills/skills.d.ts.map +1 -0
- package/dist/skills/skills.js +370 -0
- package/dist/skills/skills.js.map +1 -0
- package/dist/telemetry/contract.d.ts +103 -0
- package/dist/telemetry/contract.d.ts.map +1 -0
- package/dist/telemetry/contract.js +270 -0
- package/dist/telemetry/contract.js.map +1 -0
- package/dist/telemetry/flush.d.ts +21 -0
- package/dist/telemetry/flush.d.ts.map +1 -0
- package/dist/telemetry/flush.js +85 -0
- package/dist/telemetry/flush.js.map +1 -0
- package/dist/telemetry/gate.d.ts +30 -0
- package/dist/telemetry/gate.d.ts.map +1 -0
- package/dist/telemetry/gate.js +81 -0
- package/dist/telemetry/gate.js.map +1 -0
- package/dist/telemetry/identity.d.ts +40 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +80 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +16 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/key.d.ts +4 -0
- package/dist/telemetry/key.d.ts.map +1 -0
- package/dist/telemetry/key.js +4 -0
- package/dist/telemetry/key.js.map +1 -0
- package/dist/telemetry/notice.d.ts +19 -0
- package/dist/telemetry/notice.d.ts.map +1 -0
- package/dist/telemetry/notice.js +93 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +162 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/send.d.ts +19 -0
- package/dist/telemetry/send.d.ts.map +1 -0
- package/dist/telemetry/send.js +84 -0
- package/dist/telemetry/send.js.map +1 -0
- package/dist/telemetry/sessions.d.ts +25 -0
- package/dist/telemetry/sessions.d.ts.map +1 -0
- package/dist/telemetry/sessions.js +104 -0
- package/dist/telemetry/sessions.js.map +1 -0
- package/dist/telemetry/track.d.ts +62 -0
- package/dist/telemetry/track.d.ts.map +1 -0
- package/dist/telemetry/track.js +142 -0
- package/dist/telemetry/track.js.map +1 -0
- package/dist/upkeep-run.d.ts +15 -0
- package/dist/upkeep-run.d.ts.map +1 -0
- package/dist/upkeep-run.js +71 -0
- package/dist/upkeep-run.js.map +1 -0
- package/dist/upkeep.d.ts +125 -0
- package/dist/upkeep.d.ts.map +1 -0
- package/dist/upkeep.js +255 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/util/browser.d.ts +3 -0
- package/dist/util/browser.d.ts.map +1 -0
- package/dist/util/browser.js +14 -0
- package/dist/util/browser.js.map +1 -0
- package/dist/util/front-matter.d.ts +19 -0
- package/dist/util/front-matter.d.ts.map +1 -0
- package/dist/util/front-matter.js +21 -0
- package/dist/util/front-matter.js.map +1 -0
- package/dist/util/id.d.ts +7 -0
- package/dist/util/id.d.ts.map +1 -0
- package/dist/util/id.js +14 -0
- package/dist/util/id.js.map +1 -0
- package/dist/util/paths.d.ts +29 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +71 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/source.d.ts +4 -0
- package/dist/util/source.d.ts.map +1 -0
- package/dist/util/source.js +12 -0
- package/dist/util/source.js.map +1 -0
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.d.ts.map +1 -0
- package/dist/util/spinner.js +52 -0
- package/dist/util/spinner.js.map +1 -0
- package/dist/util/state.d.ts +100 -0
- package/dist/util/state.d.ts.map +1 -0
- package/dist/util/state.js +186 -0
- package/dist/util/state.js.map +1 -0
- package/dist/viewer/app.js +2 -0
- package/dist/viewer/index.html +49 -0
- package/dist/viewer/style.css +154 -0
- package/dist/viz/assemble.d.ts +83 -0
- package/dist/viz/assemble.d.ts.map +1 -0
- package/dist/viz/assemble.js +101 -0
- package/dist/viz/assemble.js.map +1 -0
- package/dist/viz/export.d.ts +39 -0
- package/dist/viz/export.d.ts.map +1 -0
- package/dist/viz/export.js +98 -0
- package/dist/viz/export.js.map +1 -0
- package/dist/viz/serve.d.ts +12 -0
- package/dist/viz/serve.d.ts.map +1 -0
- package/dist/viz/serve.js +129 -0
- package/dist/viz/serve.js.map +1 -0
- package/docs/assets/context-benchmark.svg +31 -0
- package/docs/assets/julius-hero.png +0 -0
- package/docs/upstream-changelog.md +785 -0
- package/package.json +138 -4
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting a pull request's code onto disk without running any of it.
|
|
3
|
+
*
|
|
4
|
+
* On a fork PR every byte here was written by a stranger, and this service holds
|
|
5
|
+
* an installation token for the base repository. So the rules are absolute:
|
|
6
|
+
*
|
|
7
|
+
* - **Nothing is executed.** No `npm install`, no build, no hooks. The graph is
|
|
8
|
+
* produced by tree-sitter reading source text, which runs none of it.
|
|
9
|
+
* - **Git is told not to run things either.** A repository can carry hooks, and
|
|
10
|
+
* `core.hooksPath` is a per-repo config a clone would otherwise honour; both
|
|
11
|
+
* are disabled explicitly rather than assumed absent.
|
|
12
|
+
* - **The token never lands in the repo.** It is passed per-invocation through
|
|
13
|
+
* an http header config, not baked into a remote URL that `git remote -v`,
|
|
14
|
+
* the reflog and any submodule would carry.
|
|
15
|
+
* - **Bounded.** A hostile or merely enormous repository must not hold a worker
|
|
16
|
+
* forever: every git call has a timeout, and the fetch is shallow.
|
|
17
|
+
*/
|
|
18
|
+
import { spawnSync } from "node:child_process";
|
|
19
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
20
|
+
import { tmpdir } from "node:os";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
/** Enough history for a merge base against the pull request's base branch. */
|
|
23
|
+
const FETCH_DEPTH = 50;
|
|
24
|
+
/**
|
|
25
|
+
* One extra reach back, used only on the `/head` fallback below.
|
|
26
|
+
*
|
|
27
|
+
* An open PR's base tip is a commit or two from the merge base, so 50 is plenty.
|
|
28
|
+
* A pull request being re-reviewed weeks after it merged is the opposite case:
|
|
29
|
+
* the base branch has moved on by however many commits the repo lands in that
|
|
30
|
+
* time, and the commit the branch was actually merged on top of sits behind all
|
|
31
|
+
* of them. Deepening once is cheaper than raising `FETCH_DEPTH` for every review.
|
|
32
|
+
*/
|
|
33
|
+
const DEEPEN_DEPTH = 500;
|
|
34
|
+
const GIT_TIMEOUT_MS = 120_000;
|
|
35
|
+
/** A git invocation with the dangerous parts of the environment removed. */
|
|
36
|
+
function git(dir, args, token) {
|
|
37
|
+
const auth = token
|
|
38
|
+
? [
|
|
39
|
+
"-c",
|
|
40
|
+
// Basic auth with the token as the password, per GitHub's own guidance for
|
|
41
|
+
// installation tokens. Passed as an argument to THIS call so it is never
|
|
42
|
+
// written into .git/config.
|
|
43
|
+
`http.extraheader=Authorization: Basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`,
|
|
44
|
+
]
|
|
45
|
+
: [];
|
|
46
|
+
const res = spawnSync("git", ["-c", "core.hooksPath=/dev/null", "-c", "protocol.version=2", ...auth, ...args], {
|
|
47
|
+
cwd: dir,
|
|
48
|
+
encoding: "utf8",
|
|
49
|
+
timeout: GIT_TIMEOUT_MS,
|
|
50
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
51
|
+
env: {
|
|
52
|
+
...process.env,
|
|
53
|
+
// No credential prompts, no system config, no repo-supplied helpers.
|
|
54
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
55
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
56
|
+
GIT_ASKPASS: "",
|
|
57
|
+
HOME: dir,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
ok: res.status === 0,
|
|
62
|
+
out: res.stdout ?? "",
|
|
63
|
+
err: `${res.stderr ?? ""}${res.error ? ` ${res.error.message}` : ""}`.trim(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** First line of a git command's output, or null when it said nothing useful. */
|
|
67
|
+
function line(dir, args) {
|
|
68
|
+
const { ok, out } = git(dir, args);
|
|
69
|
+
const first = out.split("\n")[0]?.trim() ?? "";
|
|
70
|
+
return ok && first !== "" ? first : null;
|
|
71
|
+
}
|
|
72
|
+
const short = (sha) => sha.slice(0, 7);
|
|
73
|
+
/**
|
|
74
|
+
* Fetch the PR's code and its base, shallow, and land on it.
|
|
75
|
+
*
|
|
76
|
+
* `refs/pull/N/merge` is GitHub's own merge of the PR into its base — the same
|
|
77
|
+
* thing the checks see, and the right thing to review: it is what will land, not
|
|
78
|
+
* what the contributor's branch says in isolation. It is preferred whenever it
|
|
79
|
+
* exists.
|
|
80
|
+
*
|
|
81
|
+
* But GitHub DELETES that ref the moment a pull request is closed or merged: it
|
|
82
|
+
* is only a preview of a merge, and there is nothing left to preview afterwards.
|
|
83
|
+
* Re-reviewing any merged PR therefore died at the fetch with `couldn't find
|
|
84
|
+
* remote ref refs/pull/N/merge` — 16 in a row on one installation — which is why
|
|
85
|
+
* `refs/pull/N/head` (the branch tip as the author pushed it, kept indefinitely
|
|
86
|
+
* in the BASE repository, so it survives even the fork being deleted) is fetched
|
|
87
|
+
* as a fallback. What changes with it is the diff basis, which
|
|
88
|
+
* {@link headDiffBase} is entirely about.
|
|
89
|
+
*/
|
|
90
|
+
export function checkoutPullRequest(req) {
|
|
91
|
+
const host = (req.api ?? "https://github.com").replace(/\/$/, "");
|
|
92
|
+
const dir = mkdtempSync(join(tmpdir(), `julius-app-${req.owner}-${req.repo}-`));
|
|
93
|
+
const cleanup = () => rmSync(dir, { recursive: true, force: true });
|
|
94
|
+
const log = req.log ?? (() => { });
|
|
95
|
+
const tag = `${req.owner}/${req.repo}#${req.number}`;
|
|
96
|
+
const fail = (step, err) => {
|
|
97
|
+
cleanup();
|
|
98
|
+
// A merge ref is absent while GitHub is still computing mergeability, and
|
|
99
|
+
// present-but-stale right after a push — worth saying which step failed so
|
|
100
|
+
// that case is distinguishable from a permissions problem.
|
|
101
|
+
throw new Error(`checkout ${tag} failed at ${step}: ${redact(err, req.token)}`);
|
|
102
|
+
};
|
|
103
|
+
const setup = [
|
|
104
|
+
["init", ["init", "--quiet", "-b", "__julius_base"]],
|
|
105
|
+
["remote", ["remote", "add", "origin", `${host}/${req.owner}/${req.repo}.git`]],
|
|
106
|
+
];
|
|
107
|
+
for (const [name, args] of setup) {
|
|
108
|
+
const { ok, err } = git(dir, args);
|
|
109
|
+
if (!ok)
|
|
110
|
+
fail(name, err);
|
|
111
|
+
}
|
|
112
|
+
// Both refs in one fetch: the ref to review, the base to diff against.
|
|
113
|
+
const merge = git(dir, fetchArgs(req, "merge"), req.token);
|
|
114
|
+
const ref = merge.ok ? "merge" : "head";
|
|
115
|
+
if (!merge.ok) {
|
|
116
|
+
const head = git(dir, fetchArgs(req, "head"), req.token);
|
|
117
|
+
// Neither ref: a base branch that has since been deleted, an installation
|
|
118
|
+
// that lost access, a repository that is gone. Both errors go out, because a
|
|
119
|
+
// bare "couldn't find refs/pull/N/merge" now means only "this PR is closed"
|
|
120
|
+
// and says nothing about why the fallback did not save it either.
|
|
121
|
+
if (!head.ok) {
|
|
122
|
+
fail("fetch", `${merge.err} | falling back to refs/pull/${req.number}/head: ${head.err}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const co = git(dir, ["checkout", "--quiet", "--detach", `refs/julius/${ref}`]);
|
|
126
|
+
if (!co.ok)
|
|
127
|
+
fail("checkout", co.err);
|
|
128
|
+
if (ref === "merge") {
|
|
129
|
+
log(`${tag}: reviewing refs/pull/${req.number}/merge against ${req.baseRef}`);
|
|
130
|
+
return { dir, base: "refs/julius/base", ref, cleanup };
|
|
131
|
+
}
|
|
132
|
+
const against = headDiffBase(dir, req);
|
|
133
|
+
if (against === null) {
|
|
134
|
+
fail("diff base", `refs/pull/${req.number}/merge is gone and refs/pull/${req.number}/head gives no diff against ` +
|
|
135
|
+
`${req.baseRef}: within ${FETCH_DEPTH + DEEPEN_DEPTH} commits they share no history, or the branch ` +
|
|
136
|
+
`is already in ${req.baseRef} with no merge commit to diff against (a fast-forward merge)`);
|
|
137
|
+
}
|
|
138
|
+
// Not "the PR is closed": that is only the usual reason the merge ref is
|
|
139
|
+
// missing, and stating it as fact would send an operator chasing the wrong
|
|
140
|
+
// thing when the fetch failed for some other reason.
|
|
141
|
+
log(`${tag}: no refs/pull/${req.number}/merge (GitHub deletes it when a pull request closes), reviewing refs/pull/${req.number}/head against ${against}`);
|
|
142
|
+
return { dir, base: "refs/julius/base", ref, cleanup };
|
|
143
|
+
}
|
|
144
|
+
/** The one fetch each attempt makes: the PR ref to review plus the base branch. */
|
|
145
|
+
function fetchArgs(req, pull, deepen = false) {
|
|
146
|
+
return [
|
|
147
|
+
"fetch",
|
|
148
|
+
"--quiet",
|
|
149
|
+
deepen ? `--deepen=${DEEPEN_DEPTH}` : `--depth=${FETCH_DEPTH}`,
|
|
150
|
+
"--no-recurse-submodules",
|
|
151
|
+
"origin",
|
|
152
|
+
`+refs/pull/${req.number}/${pull}:refs/julius/${pull}`,
|
|
153
|
+
`+refs/heads/${req.baseRef}:refs/julius/base`,
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Point `refs/julius/base` at the commit the head ref should be diffed against,
|
|
158
|
+
* and describe it for the log — or null when this history cannot answer.
|
|
159
|
+
*
|
|
160
|
+
* The two refs do NOT give the same diff, and the difference is not a detail:
|
|
161
|
+
*
|
|
162
|
+
* - `/merge` is a commit whose parents are the base tip and the head, so
|
|
163
|
+
* `refs/julius/base...HEAD` resolves its merge base to the base tip and the
|
|
164
|
+
* diff is exactly the pull request.
|
|
165
|
+
* - `/head` is the author's branch tip. While the branch is *not* in the base
|
|
166
|
+
* branch's history — an open PR, a closed-unmerged one, and also a squash or
|
|
167
|
+
* rebase merge, which land new commits with new shas — the three-dot diff
|
|
168
|
+
* still resolves to the fork point and still reports exactly the author's
|
|
169
|
+
* changes (that is what three dots is for; see `rangeArgs` in blast/diff.ts).
|
|
170
|
+
* - After a MERGE COMMIT, though, the head commit is an ancestor of the base
|
|
171
|
+
* branch, so the merge base of the two IS the head commit and
|
|
172
|
+
* `refs/julius/base...HEAD` reports that nothing changed. An empty blast
|
|
173
|
+
* radius posted with total confidence is worse than the fetch error it
|
|
174
|
+
* replaced, so that case is detected and given the basis `/merge` would have
|
|
175
|
+
* had: the first parent of the merge commit that brought the branch in, which
|
|
176
|
+
* is the base branch as it stood at the merge.
|
|
177
|
+
*/
|
|
178
|
+
function headDiffBase(dir, req) {
|
|
179
|
+
for (const deepen of [false, true]) {
|
|
180
|
+
// The shallow window is measured from each tip, so a base branch that moved
|
|
181
|
+
// on since the merge can leave the shared history out of it entirely: git
|
|
182
|
+
// then has no merge base at all and `git diff a...b` fails outright. One
|
|
183
|
+
// deepening is the difference between reviewing a months-old PR and not.
|
|
184
|
+
if (deepen && !git(dir, fetchArgs(req, "head", true), req.token).ok)
|
|
185
|
+
return null;
|
|
186
|
+
const against = resolveHeadBase(dir, req);
|
|
187
|
+
if (against !== null)
|
|
188
|
+
return against;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function resolveHeadBase(dir, req) {
|
|
193
|
+
const head = line(dir, ["rev-parse", "refs/julius/head"]);
|
|
194
|
+
const shared = line(dir, ["merge-base", "refs/julius/base", "refs/julius/head"]);
|
|
195
|
+
if (head === null || shared === null)
|
|
196
|
+
return null;
|
|
197
|
+
if (shared !== head)
|
|
198
|
+
return `${req.baseRef} (merge base ${short(shared)})`;
|
|
199
|
+
// The head commit is in the base branch: find the merge that put it there. The
|
|
200
|
+
// EARLIEST merge on the ancestry path is the one — a later one is some other
|
|
201
|
+
// branch's merge that happens to sit above it.
|
|
202
|
+
const merge = line(dir, ["rev-list", "--reverse", "--ancestry-path", "--merges", "refs/julius/head..refs/julius/base"]);
|
|
203
|
+
if (merge === null)
|
|
204
|
+
return null;
|
|
205
|
+
const parent = line(dir, ["rev-parse", `${merge}^1`]);
|
|
206
|
+
if (parent === null)
|
|
207
|
+
return null;
|
|
208
|
+
// Only worth using if it is diffable: a shallow boundary can hold the merge
|
|
209
|
+
// commit while leaving the fork point below it out of the repository.
|
|
210
|
+
if (line(dir, ["merge-base", parent, "refs/julius/head"]) === null)
|
|
211
|
+
return null;
|
|
212
|
+
if (!git(dir, ["update-ref", "refs/julius/base", parent]).ok)
|
|
213
|
+
return null;
|
|
214
|
+
return `${req.baseRef} as it stood at the merge (${short(parent)})`;
|
|
215
|
+
}
|
|
216
|
+
/** Never let a token reach a log line, even inside git's own error text. */
|
|
217
|
+
export function redact(text, token) {
|
|
218
|
+
if (!token)
|
|
219
|
+
return text;
|
|
220
|
+
const encoded = Buffer.from(`x-access-token:${token}`).toString("base64");
|
|
221
|
+
return text.split(token).join("[token]").split(encoded).join("[token]");
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/app/checkout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,8EAA8E;AAC9E,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB;;;;;;;;GAQG;AACH,MAAM,YAAY,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
|
5
|
+
* and every accepted delivery costs a clone and a parse. Narrowing happens here,
|
|
6
|
+
* once, so the queue only ever holds jobs that will produce a comment.
|
|
7
|
+
*/
|
|
8
|
+
/** The subset of a `pull_request` delivery this App reads. */
|
|
9
|
+
export interface ReviewJob {
|
|
10
|
+
installationId: number;
|
|
11
|
+
owner: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
/** Base repository's full name, which is where the comment goes — a fork PR
|
|
14
|
+
* carries a different head repo, and posting there would be posting on the
|
|
15
|
+
* contributor's copy. */
|
|
16
|
+
number: number;
|
|
17
|
+
baseRef: string;
|
|
18
|
+
headSha: string;
|
|
19
|
+
/** True when the head branch lives in a fork: the PR's code is not ours. */
|
|
20
|
+
fromFork: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A delivery to act on, or null with the reason it was skipped.
|
|
24
|
+
*
|
|
25
|
+
* Draft pull requests are skipped deliberately: a draft is a work in progress and
|
|
26
|
+
* a bot commenting on every push to one is the fastest way to be uninstalled.
|
|
27
|
+
* `ready_for_review` is in the accepted set so the comment appears the moment the
|
|
28
|
+
* author asks for eyes.
|
|
29
|
+
*
|
|
30
|
+
* A CLOSED pull request is not skipped. The graph is most useful to whoever reads
|
|
31
|
+
* the PR later, and a merged PR is exactly what gets read — so the comment has to
|
|
32
|
+
* keep working after the merge. This costs nothing on live traffic: none of the
|
|
33
|
+
* four accepted actions fire on an already-merged PR, so in practice this only
|
|
34
|
+
* admits a `synchronize` that raced a merge, and a deliberate re-delivery. The
|
|
35
|
+
* accepted-action set, not the PR state, is what bounds the work.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reviewJobFor(event: string, payload: unknown): {
|
|
38
|
+
job: ReviewJob;
|
|
39
|
+
} | {
|
|
40
|
+
skip: string;
|
|
41
|
+
};
|
|
42
|
+
/** Collapse queued work per pull request: only the newest push is worth reviewing. */
|
|
43
|
+
export declare const jobKey: (j: ReviewJob) => string;
|
|
44
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/app/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb;;6BAEyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAmBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAoCnG;AAED,sFAAsF;AACtF,eAAO,MAAM,MAAM,MAAO,SAAS,KAAG,MAA4C,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What arrived, and whether it is worth work.
|
|
3
|
+
*
|
|
4
|
+
* A busy installation delivers a lot of noise — labels, assignments, reviews —
|
|
5
|
+
* and every accepted delivery costs a clone and a parse. Narrowing happens here,
|
|
6
|
+
* once, so the queue only ever holds jobs that will produce a comment.
|
|
7
|
+
*/
|
|
8
|
+
/** Actions that change the diff. `edited` (a retitled PR) and `labeled` do not. */
|
|
9
|
+
const ACTIONS = new Set(["opened", "synchronize", "reopened", "ready_for_review"]);
|
|
10
|
+
/**
|
|
11
|
+
* A delivery to act on, or null with the reason it was skipped.
|
|
12
|
+
*
|
|
13
|
+
* Draft pull requests are skipped deliberately: a draft is a work in progress and
|
|
14
|
+
* a bot commenting on every push to one is the fastest way to be uninstalled.
|
|
15
|
+
* `ready_for_review` is in the accepted set so the comment appears the moment the
|
|
16
|
+
* author asks for eyes.
|
|
17
|
+
*
|
|
18
|
+
* A CLOSED pull request is not skipped. The graph is most useful to whoever reads
|
|
19
|
+
* the PR later, and a merged PR is exactly what gets read — so the comment has to
|
|
20
|
+
* keep working after the merge. This costs nothing on live traffic: none of the
|
|
21
|
+
* four accepted actions fire on an already-merged PR, so in practice this only
|
|
22
|
+
* admits a `synchronize` that raced a merge, and a deliberate re-delivery. The
|
|
23
|
+
* accepted-action set, not the PR state, is what bounds the work.
|
|
24
|
+
*/
|
|
25
|
+
export function reviewJobFor(event, payload) {
|
|
26
|
+
if (event === "ping")
|
|
27
|
+
return { skip: "ping" };
|
|
28
|
+
if (event !== "pull_request")
|
|
29
|
+
return { skip: `event ${event}` };
|
|
30
|
+
const p = payload;
|
|
31
|
+
const action = p.action ?? "";
|
|
32
|
+
if (!ACTIONS.has(action))
|
|
33
|
+
return { skip: `action ${action}` };
|
|
34
|
+
const pr = p.pull_request;
|
|
35
|
+
const installationId = p.installation?.id;
|
|
36
|
+
const owner = p.repository?.owner?.login;
|
|
37
|
+
const repo = p.repository?.name;
|
|
38
|
+
const number = pr?.number ?? p.number;
|
|
39
|
+
const baseRef = pr?.base?.ref;
|
|
40
|
+
const headSha = pr?.head?.sha;
|
|
41
|
+
if (!installationId || !owner || !repo || !number || !baseRef || !headSha) {
|
|
42
|
+
return { skip: "payload missing installation, repository or pull request fields" };
|
|
43
|
+
}
|
|
44
|
+
if (pr?.draft === true && action !== "ready_for_review")
|
|
45
|
+
return { skip: "draft" };
|
|
46
|
+
const base = pr?.base?.repo?.full_name;
|
|
47
|
+
const head = pr?.head?.repo?.full_name;
|
|
48
|
+
return {
|
|
49
|
+
job: {
|
|
50
|
+
installationId,
|
|
51
|
+
owner,
|
|
52
|
+
repo,
|
|
53
|
+
number,
|
|
54
|
+
baseRef,
|
|
55
|
+
headSha,
|
|
56
|
+
// A missing head repo means a deleted fork — treat it as one, since it is
|
|
57
|
+
// certainly not ours.
|
|
58
|
+
fromFork: head !== base,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Collapse queued work per pull request: only the newest push is worth reviewing. */
|
|
63
|
+
export const jobKey = (j) => `${j.owner}/${j.repo}#${j.number}`;
|
|
64
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/app/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+BH,mFAAmF;AACnF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,OAAgB;IAC1D,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,IAAI,KAAK,KAAK,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,EAAE,EAAE,CAAC;IAEhE,MAAM,CAAC,GAAG,OAAyB,CAAC;IACpC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,MAAM,EAAE,EAAE,CAAC;IAE9D,MAAM,EAAE,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1B,MAAM,cAAc,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC;IACzC,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC;IACtC,MAAM,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC;IAC9B,MAAM,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC;IAE9B,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,iEAAiE,EAAE,CAAC;IACrF,CAAC;IACD,IAAI,EAAE,EAAE,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,kBAAkB;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAElF,MAAM,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC;IACvC,MAAM,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC;IACvC,OAAO;QACL,GAAG,EAAE;YACH,cAAc;YACd,KAAK;YACL,IAAI;YACJ,MAAM;YACN,OAAO;YACP,OAAO;YACP,0EAA0E;YAC1E,sBAAsB;YACtB,QAAQ,EAAE,IAAI,KAAK,IAAI;SACxB;KACF,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAY,EAAU,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface AppCredentials {
|
|
2
|
+
appId: string;
|
|
3
|
+
/** PEM, as GitHub hands it over. */
|
|
4
|
+
privateKey: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A signed App JWT.
|
|
8
|
+
*
|
|
9
|
+
* `iat` is backdated a minute: GitHub compares against ITS clock, and a server
|
|
10
|
+
* running even slightly fast has its tokens rejected as "issued in the future" —
|
|
11
|
+
* a failure that looks like a bad key and is not.
|
|
12
|
+
*/
|
|
13
|
+
export declare function appJwt(creds: AppCredentials, nowMs: number): string;
|
|
14
|
+
export interface TokenResponse {
|
|
15
|
+
token: string;
|
|
16
|
+
expires_at: string;
|
|
17
|
+
}
|
|
18
|
+
/** Minimal shape of `fetch`, so tests need no network and no mocking library. */
|
|
19
|
+
export type Fetch = (url: string, init?: {
|
|
20
|
+
method?: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
body?: string;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
ok: boolean;
|
|
25
|
+
status: number;
|
|
26
|
+
text: () => Promise<string>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Installation tokens, fetched once and reused until they are nearly expired.
|
|
30
|
+
*
|
|
31
|
+
* Tokens last an hour and a busy repository can fire a dozen webhooks a minute;
|
|
32
|
+
* without the cache every one of them spends a round trip and a signature.
|
|
33
|
+
*/
|
|
34
|
+
export declare class InstallationTokens {
|
|
35
|
+
private readonly creds;
|
|
36
|
+
private readonly fetchImpl;
|
|
37
|
+
private readonly now;
|
|
38
|
+
private readonly api;
|
|
39
|
+
private readonly cache;
|
|
40
|
+
constructor(creds: AppCredentials, fetchImpl: Fetch, now?: () => number, api?: string);
|
|
41
|
+
get(installationId: number): Promise<string>;
|
|
42
|
+
/** Drop a token GitHub has rejected, so the next call fetches a fresh one. */
|
|
43
|
+
invalidate(installationId: number): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Is this delivery really from GitHub?
|
|
47
|
+
*
|
|
48
|
+
* The webhook endpoint is public, and everything downstream — cloning a repo,
|
|
49
|
+
* posting as the App — happens on its say-so. Compared in constant time because
|
|
50
|
+
* a byte-at-a-time comparison leaks the expected digest to anyone willing to
|
|
51
|
+
* measure, and forging a signature is a total compromise of the endpoint.
|
|
52
|
+
*/
|
|
53
|
+
export declare function verifySignature(secret: string, body: string, header: string | undefined): boolean;
|
|
54
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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G,IAAI,CAEvC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAMjG"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who the App is, to GitHub.
|
|
3
|
+
*
|
|
4
|
+
* A GitHub App authenticates twice over: it signs a short JWT with its private
|
|
5
|
+
* key to prove it is the App, then trades that for an *installation* token scoped
|
|
6
|
+
* to one repository owner. The installation token is what matters here — it is
|
|
7
|
+
* the reason this exists at all. A workflow on a fork's pull request gets a
|
|
8
|
+
* read-only token and cannot comment; an App's installation token belongs to the
|
|
9
|
+
* base repository, so a fork PR is no different from any other.
|
|
10
|
+
*
|
|
11
|
+
* `node:crypto` signs the JWT, so there is no dependency to audit for something
|
|
12
|
+
* that handles a private key.
|
|
13
|
+
*/
|
|
14
|
+
import { createHmac, createSign, timingSafeEqual } from "node:crypto";
|
|
15
|
+
/** GitHub rejects a JWT older than 60s or more than 10 minutes in the future. */
|
|
16
|
+
const JWT_TTL_S = 540; // 9 minutes, inside the limit with room for clock skew
|
|
17
|
+
/** Renew this long before expiry rather than racing it. */
|
|
18
|
+
const RENEW_MARGIN_MS = 60_000;
|
|
19
|
+
const b64url = (b) => Buffer.from(b).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
20
|
+
/**
|
|
21
|
+
* A signed App JWT.
|
|
22
|
+
*
|
|
23
|
+
* `iat` is backdated a minute: GitHub compares against ITS clock, and a server
|
|
24
|
+
* running even slightly fast has its tokens rejected as "issued in the future" —
|
|
25
|
+
* a failure that looks like a bad key and is not.
|
|
26
|
+
*/
|
|
27
|
+
export function appJwt(creds, nowMs) {
|
|
28
|
+
const iat = Math.floor(nowMs / 1000) - 60;
|
|
29
|
+
const header = b64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
30
|
+
const payload = b64url(JSON.stringify({ iat, exp: iat + JWT_TTL_S, iss: creds.appId }));
|
|
31
|
+
const signer = createSign("RSA-SHA256");
|
|
32
|
+
signer.update(`${header}.${payload}`);
|
|
33
|
+
return `${header}.${payload}.${b64url(signer.sign(creds.privateKey))}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Installation tokens, fetched once and reused until they are nearly expired.
|
|
37
|
+
*
|
|
38
|
+
* Tokens last an hour and a busy repository can fire a dozen webhooks a minute;
|
|
39
|
+
* without the cache every one of them spends a round trip and a signature.
|
|
40
|
+
*/
|
|
41
|
+
export class InstallationTokens {
|
|
42
|
+
creds;
|
|
43
|
+
fetchImpl;
|
|
44
|
+
now;
|
|
45
|
+
api;
|
|
46
|
+
cache = new Map();
|
|
47
|
+
constructor(creds, fetchImpl, now = Date.now, api = "https://api.github.com") {
|
|
48
|
+
this.creds = creds;
|
|
49
|
+
this.fetchImpl = fetchImpl;
|
|
50
|
+
this.now = now;
|
|
51
|
+
this.api = api;
|
|
52
|
+
}
|
|
53
|
+
async get(installationId) {
|
|
54
|
+
const hit = this.cache.get(installationId);
|
|
55
|
+
if (hit && hit.expiresMs - RENEW_MARGIN_MS > this.now())
|
|
56
|
+
return hit.token;
|
|
57
|
+
const res = await this.fetchImpl(`${this.api}/app/installations/${installationId}/access_tokens`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
authorization: `Bearer ${appJwt(this.creds, this.now())}`,
|
|
61
|
+
accept: "application/vnd.github+json",
|
|
62
|
+
"user-agent": "julius-app",
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const body = await res.text();
|
|
66
|
+
if (!res.ok) {
|
|
67
|
+
// The body carries GitHub's reason ("integration not found", a key that does
|
|
68
|
+
// not match the app id); losing it turns every setup mistake into "401".
|
|
69
|
+
throw new Error(`installation token for ${installationId} failed: ${res.status} ${body.slice(0, 200)}`);
|
|
70
|
+
}
|
|
71
|
+
const parsed = JSON.parse(body);
|
|
72
|
+
this.cache.set(installationId, { token: parsed.token, expiresMs: Date.parse(parsed.expires_at) });
|
|
73
|
+
return parsed.token;
|
|
74
|
+
}
|
|
75
|
+
/** Drop a token GitHub has rejected, so the next call fetches a fresh one. */
|
|
76
|
+
invalidate(installationId) {
|
|
77
|
+
this.cache.delete(installationId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Is this delivery really from GitHub?
|
|
82
|
+
*
|
|
83
|
+
* The webhook endpoint is public, and everything downstream — cloning a repo,
|
|
84
|
+
* posting as the App — happens on its say-so. Compared in constant time because
|
|
85
|
+
* a byte-at-a-time comparison leaks the expected digest to anyone willing to
|
|
86
|
+
* measure, and forging a signature is a total compromise of the endpoint.
|
|
87
|
+
*/
|
|
88
|
+
export function verifySignature(secret, body, header) {
|
|
89
|
+
if (!header)
|
|
90
|
+
return false;
|
|
91
|
+
const expected = `sha256=${createHmac("sha256", secret).update(body).digest("hex")}`;
|
|
92
|
+
const a = Buffer.from(expected);
|
|
93
|
+
const b = Buffer.from(header);
|
|
94
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/app/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,iFAAiF;AACjF,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,uDAAuD;AAC9E,2DAA2D;AAC3D,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,GAAG,CAAC,CAAkB,EAAU,EAAE,CAC5C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,C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AAM;QAAE,OAAO,KAAK,CAAC;IAC1B,MAAM,QAAQ,GAAG,UAAU,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACrF,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/app/main.ts"],"names":[],"mappings":""}
|
package/dist/app/main.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point: read the environment, refuse to start half-configured, listen.
|
|
3
|
+
*
|
|
4
|
+
* Every misconfiguration is fatal at boot rather than at the first webhook. A
|
|
5
|
+
* server that starts without a webhook secret looks healthy and silently rejects
|
|
6
|
+
* every delivery; one that starts without a private key looks healthy and fails
|
|
7
|
+
* every review. Both are worth a loud death on line one.
|
|
8
|
+
*/
|
|
9
|
+
import { createApp } from "./server.js";
|
|
10
|
+
function required(name) {
|
|
11
|
+
const value = process.env[name];
|
|
12
|
+
if (!value) {
|
|
13
|
+
console.error(`✗ ${name} is required`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* GitHub hands the private key over as a PEM file. Env vars cannot hold newlines
|
|
20
|
+
* comfortably, so both spellings are accepted: the raw PEM, or one with `\n`
|
|
21
|
+
* escaped — the shape you get from pasting a key into a hosting provider's UI.
|
|
22
|
+
*/
|
|
23
|
+
function privateKey() {
|
|
24
|
+
const raw = required("JULIUS_APP_PRIVATE_KEY");
|
|
25
|
+
const pem = raw.includes("\\n") ? raw.replace(/\\n/g, "\n") : raw;
|
|
26
|
+
if (!pem.includes("BEGIN") || !pem.includes("PRIVATE KEY")) {
|
|
27
|
+
console.error("✗ JULIUS_APP_PRIVATE_KEY does not look like a PEM private key");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
return pem;
|
|
31
|
+
}
|
|
32
|
+
const port = Number(process.env.PORT ?? 3000);
|
|
33
|
+
const { server, queue } = createApp({
|
|
34
|
+
appId: required("JULIUS_APP_ID"),
|
|
35
|
+
privateKey: privateKey(),
|
|
36
|
+
webhookSecret: required("JULIUS_WEBHOOK_SECRET"),
|
|
37
|
+
publicUrl: required("JULIUS_PUBLIC_URL"),
|
|
38
|
+
port,
|
|
39
|
+
concurrency: Number(process.env.JULIUS_CONCURRENCY ?? 2),
|
|
40
|
+
// Optional, unlike the four above, and deliberately so: point it at a mounted
|
|
41
|
+
// volume and the pages already linked from pull requests survive a restart;
|
|
42
|
+
// leave it unset and they do not. Neither is worth refusing to boot over — a
|
|
43
|
+
// server that will not start reviews nothing at all, which is strictly worse
|
|
44
|
+
// than one whose old links go stale.
|
|
45
|
+
pageDir: process.env.JULIUS_PAGE_DIR,
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Finish what is in flight before dying.
|
|
49
|
+
*
|
|
50
|
+
* A container gets a TERM and a grace period on every deploy. Dropping a review
|
|
51
|
+
* mid-clone leaves a stale comment on a pull request and no retry, because the
|
|
52
|
+
* delivery was acknowledged long ago.
|
|
53
|
+
*/
|
|
54
|
+
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
55
|
+
process.on(signal, () => {
|
|
56
|
+
console.log(`${signal}: draining ${queue.size} job(s)`);
|
|
57
|
+
server.close();
|
|
58
|
+
void queue.drain().then(() => process.exit(0));
|
|
59
|
+
setTimeout(() => process.exit(1), 25_000).unref();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
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Q,CAAC,uBAAuB,CAAC;IAChD,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IACxC,IAAI;IACJ,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,CAAC;IACxD,8EAA8E;IAC9E,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;CACrC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,KAAK,MAAM,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,cAAc,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface StoredPage {
|
|
2
|
+
html: string;
|
|
3
|
+
storedMs: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PageStoreOptions {
|
|
6
|
+
secret: string;
|
|
7
|
+
ttlMs?: number;
|
|
8
|
+
maxPages?: number;
|
|
9
|
+
now?: () => number;
|
|
10
|
+
/** Kept across restarts here. Absent: pages live only as long as the process. */
|
|
11
|
+
dir?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class PageStore {
|
|
14
|
+
private readonly pages;
|
|
15
|
+
private readonly secret;
|
|
16
|
+
private readonly ttlMs;
|
|
17
|
+
private readonly maxPages;
|
|
18
|
+
private readonly now;
|
|
19
|
+
private readonly dir;
|
|
20
|
+
constructor(opts: PageStoreOptions);
|
|
21
|
+
/** `owner/repo#number` → a path segment safe to put in a URL. */
|
|
22
|
+
static idFor(owner: string, repo: string, number: number): string;
|
|
23
|
+
/** Store (replacing any previous page for the same PR) and return `id` + `token`. */
|
|
24
|
+
put(owner: string, repo: string, number: number, html: string): {
|
|
25
|
+
id: string;
|
|
26
|
+
token: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The page, if the token is valid and it has not expired.
|
|
30
|
+
*
|
|
31
|
+
* Expiry is checked against the STORED time rather than encoded in the token,
|
|
32
|
+
* so a link cannot outlive the data it points at — and re-reviewing a PR
|
|
33
|
+
* refreshes both together.
|
|
34
|
+
*
|
|
35
|
+
* Answered from memory even when there is a directory: `id` comes off a URL,
|
|
36
|
+
* and an id that never reaches the filesystem cannot be walked out of it.
|
|
37
|
+
*/
|
|
38
|
+
get(id: string, token: string | undefined): string | null;
|
|
39
|
+
get size(): number;
|
|
40
|
+
private sign;
|
|
41
|
+
private valid;
|
|
42
|
+
/** Oldest out first, plus anything past its TTL. */
|
|
43
|
+
private evict;
|
|
44
|
+
/** Take back what a previous process left on disk. */
|
|
45
|
+
private hydrate;
|
|
46
|
+
/** A stored page, or nothing: truncated, corrupt and gone are one answer here. */
|
|
47
|
+
private read;
|
|
48
|
+
/**
|
|
49
|
+
* Temp file, then rename: a reader only ever sees a whole page, and two reviews
|
|
50
|
+
* of the same pull request racing each other leave one of them intact rather
|
|
51
|
+
* than the two interleaved.
|
|
52
|
+
*/
|
|
53
|
+
private write;
|
|
54
|
+
private remove;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=pages.d.ts.map
|