@humain/terminal 0.0.6 → 0.0.8
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 +62 -0
- package/README.md +17 -10
- package/dist/bundle/chunks/anthropic-messages-GDMGYAZB.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZN52D6YC.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +77 -0
- package/dist/bundle/chunks/chunk-3VI4HD7D.js +31 -0
- package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
- package/dist/bundle/chunks/chunk-72KO4OMP.js +2 -0
- package/dist/bundle/chunks/chunk-74NVHVNZ.js +16 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-ARF4OE6X.js +105 -0
- package/dist/bundle/chunks/chunk-BOW22LW6.js +42 -0
- package/dist/bundle/chunks/chunk-BZQ53VGE.js +70 -0
- package/dist/bundle/chunks/chunk-CBHC6EL7.js +133 -0
- package/dist/bundle/chunks/chunk-D7XAASZM.js +4 -0
- package/dist/bundle/chunks/chunk-ECWELYBH.js +17 -0
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
- package/dist/bundle/chunks/chunk-H2O6VOXT.js +11 -0
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-MA4UUCYX.js +18 -0
- package/dist/bundle/chunks/chunk-MMFBCF6F.js +5986 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-PSKDLDLZ.js +44 -0
- package/dist/bundle/chunks/chunk-SGTGQNNP.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TXBQIIIO.js +2 -0
- package/dist/bundle/chunks/chunk-WJZ4KLGL.js +2 -0
- package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
- package/dist/bundle/chunks/dist-BXEVYJIO.js +7 -0
- package/dist/bundle/chunks/es-P2KNSZYR.js +9 -0
- package/dist/bundle/chunks/es5-FGTJ7ZFW.js +2 -0
- package/dist/bundle/chunks/event-streams-JOSQQSII.js +2 -0
- package/dist/bundle/chunks/extract-2L7ZVN7F.js +106 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-FF7M7XHT.js +2 -0
- package/dist/bundle/chunks/google-vertex-YMUBFRBA.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-562J2I52.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-O4M7IQML.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-XY3CBY3C.js +294 -0
- package/dist/bundle/chunks/node-ZHY4LHC7.js +15 -0
- package/dist/bundle/chunks/openai-codex-responses-HRVCDY54.js +8 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-L4AHDQ5D.js +7 -0
- package/dist/bundle/chunks/openai-responses-4MWLJHIK.js +2 -0
- package/dist/bundle/chunks/openrouter-images-Y2PCWAQH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-UKQT3OWY.js +107 -0
- package/dist/bundle/chunks/pi-messages-57K43J6J.js +8 -0
- package/dist/bundle/chunks/promise-J5TGSM32.js +2 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/undici-D6ABF53Q.js +2 -0
- package/dist/bundle/chunks/webapi-AFS5FDJJ.js +5 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli.js +3 -0
- package/dist/bundle/client.js +2 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +2 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -11
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +62 -15
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +240 -104
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +6 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +7 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +59 -36
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +115 -48
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +44 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +56 -10
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -19
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +26 -5
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -8
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +22 -14
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +4 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +32 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +6 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +17 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +68 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +16 -3
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +62 -29
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +19 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +4 -1
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +6 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +3 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +29 -4
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-protocol.d.ts +1 -217
- package/dist/humain/agent-execution-protocol.d.ts.map +1 -1
- package/dist/humain/agent-execution-protocol.js +1 -203
- package/dist/humain/agent-execution-protocol.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +107 -16
- package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/dist/humain/mcp-adapter/vendor/README.md +47 -15
- package/dist/humain/mcp-adapter/vendor/cli.js +4 -4
- package/dist/humain/mcp-adapter/vendor/commands.ts +5 -3
- package/dist/humain/mcp-adapter/vendor/config.ts +46 -5
- package/dist/humain/mcp-adapter/vendor/direct-tools.ts +103 -92
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.d.ts +10 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js +63 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.d.ts +8 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js +356 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.d.ts +123 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js +1088 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.d.ts +24 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js +336 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.d.ts +19 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js +319 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.d.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js +156 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.d.ts +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js +15 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.d.ts +566 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js +287 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.d.ts +6 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js +37 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.d.ts +104 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js +59 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.d.ts +4 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js +27 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.d.ts +32 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js +338 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/failure-backoff.ts +23 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +4870 -3878
- package/dist/humain/mcp-adapter/vendor/index.ts +294 -88
- package/dist/humain/mcp-adapter/vendor/init.ts +41 -30
- package/dist/humain/mcp-adapter/vendor/lifecycle.ts +16 -8
- package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +124 -32
- package/dist/humain/mcp-adapter/vendor/mcp-bearer-store.ts +0 -2
- package/dist/humain/mcp-adapter/vendor/mcp-code.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +155 -16
- package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +95 -7
- package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +18 -4
- package/dist/humain/mcp-adapter/vendor/mcp-references.ts +376 -0
- package/dist/humain/mcp-adapter/vendor/mcp-status.ts +8 -19
- package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +20 -12
- package/dist/humain/mcp-adapter/vendor/namespace-tools.ts +276 -0
- package/dist/humain/mcp-adapter/vendor/package.json +26 -8
- package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +128 -32
- package/dist/humain/mcp-adapter/vendor/request-headers-command.ts +1 -1
- package/dist/humain/mcp-adapter/vendor/search-ranking.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/server-manager.ts +69 -12
- package/dist/humain/mcp-adapter/vendor/state.ts +1 -3
- package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +16 -2
- package/dist/humain/mcp-adapter/vendor/types.ts +51 -2
- package/dist/humain/mcp-adapter/vendor/ui-server.ts +3 -19
- package/dist/humain/mcp-adapter/vendor/ui-session.ts +2 -1
- package/dist/humain/mcp-adapter/vendor/utils.ts +21 -19
- package/dist/humain/mcp-adapter.d.ts.map +1 -1
- package/dist/humain/mcp-adapter.js +4 -0
- package/dist/humain/mcp-adapter.js.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts +14 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.js +85 -33
- package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.js +3 -1
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +10 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +4 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts +11 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +163 -20
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.js +11 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.d.ts +10 -0
- package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-adc.js +268 -0
- package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts +7 -1
- package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-api.js +51 -15
- package/dist/humain/web-access/vendor/gemini-api.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +9 -4
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +63 -21
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.js +3 -2
- package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts +8 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.js +49 -4
- package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts +2 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.js +8 -3
- package/dist/humain/web-access/vendor/gemini-web.js.map +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-api.js +6 -4
- package/dist/humain/web-access/vendor/github-api.js.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.js +50 -3
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts +27 -0
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js +701 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js.map +1 -0
- package/dist/humain/web-access/vendor/index.d.ts +3 -31
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +643 -530
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/kimi-search.d.ts +5 -0
- package/dist/humain/web-access/vendor/kimi-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/kimi-search.js +228 -0
- package/dist/humain/web-access/vendor/kimi-search.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +3 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/openai-search.js +89 -16
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +56 -8
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +6 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +12 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +343 -1
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts +4 -0
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/xcrawl.js +251 -0
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +19 -14
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +53 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +9 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +128 -55
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +151 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +68 -17
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +15 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +224 -130
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +16 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +188 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -5
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +7 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +10 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +3 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +14 -7
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +189 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +12 -2
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +23 -9
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +64 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/version-check.js +4 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +17 -0
- package/docs/custom-provider.md +12 -9
- package/docs/environment-variables.md +11 -8
- package/docs/extensions.md +35 -7
- package/docs/json.md +7 -2
- package/docs/keybindings.md +9 -9
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/packages.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +32 -3
- package/docs/sdk.md +7 -2
- package/docs/settings.md +23 -7
- package/docs/skills.md +3 -2
- package/docs/terminal-setup.md +20 -0
- package/docs/usage.md +14 -10
- package/docs/windows.md +15 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +70 -8
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/sandbox/package-lock.json +14 -40
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +4 -4
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +293 -221
- package/package.json +21 -18
- package/src/humain/mcp-adapter/UPSTREAM.md +15 -5
- package/src/humain/mcp-adapter/upstream.json +4 -3
- package/src/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/src/humain/web-access/UPSTREAM.md +1 -1
- package/src/humain/web-access/upstream.json +6 -4
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { checkGhAvailable, showGhHint } from "./github-api.js";
|
|
4
|
+
import { fetchRemoteUrl, loadFetchContentDomainPolicy, loadSsrfConfig } from "./ssrf-protection.js";
|
|
5
|
+
import { getWebSearchConfigPath } from "./utils.js";
|
|
6
|
+
const CONFIG_PATH = getWebSearchConfigPath();
|
|
7
|
+
const GH_TIMEOUT_MS = 10_000;
|
|
8
|
+
const GH_TOTAL_TIMEOUT_MS = 20_000;
|
|
9
|
+
const MAX_DOC_CHARS = 150_000;
|
|
10
|
+
const BODY_INLINE_CHARS = 4_000;
|
|
11
|
+
const COMMENT_INLINE_CHARS = 700;
|
|
12
|
+
const MAX_INLINE_COMMENTS = 15;
|
|
13
|
+
const MAX_INLINE_REVIEWS = 10;
|
|
14
|
+
const MAX_INLINE_CHECKS = 15;
|
|
15
|
+
const MAX_INLINE_FILES = 50;
|
|
16
|
+
const MAX_INLINE_COMMITS = 20;
|
|
17
|
+
const MAX_INLINE_REVIEW_THREADS = 30;
|
|
18
|
+
const REST_HEADERS = { "Accept": "application/vnd.github+json", "User-Agent": "pi-web-access" };
|
|
19
|
+
const PR_SUBPATHS = new Set(["files", "commits", "checks", "conversation"]);
|
|
20
|
+
const PR_FIELDS = [
|
|
21
|
+
"title", "number", "state", "isDraft", "author", "baseRefName", "headRefName", "headRepositoryOwner",
|
|
22
|
+
"createdAt", "mergedAt", "closedAt", "labels", "milestone", "additions", "deletions", "changedFiles",
|
|
23
|
+
"files", "commits", "reviews", "statusCheckRollup", "comments", "body", "closingIssuesReferences", "url",
|
|
24
|
+
];
|
|
25
|
+
const PR_CORE_FIELDS = [
|
|
26
|
+
"title", "number", "state", "isDraft", "author", "baseRefName", "headRefName", "headRepositoryOwner",
|
|
27
|
+
"createdAt", "mergedAt", "closedAt", "labels", "milestone", "additions", "deletions", "changedFiles",
|
|
28
|
+
"files", "commits", "reviews", "comments", "body", "url",
|
|
29
|
+
];
|
|
30
|
+
const ISSUE_FIELDS = [
|
|
31
|
+
"title", "number", "state", "stateReason", "author", "createdAt", "closedAt", "labels", "assignees", "milestone",
|
|
32
|
+
"comments", "body", "closedByPullRequestsReferences", "url",
|
|
33
|
+
];
|
|
34
|
+
const ISSUE_CORE_FIELDS = ["title", "number", "state", "author", "createdAt", "closedAt", "labels", "assignees", "milestone", "comments", "body", "url"];
|
|
35
|
+
let cachedConfig = null;
|
|
36
|
+
function loadConfig() {
|
|
37
|
+
if (cachedConfig)
|
|
38
|
+
return cachedConfig;
|
|
39
|
+
const defaults = { enabled: true };
|
|
40
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
41
|
+
cachedConfig = defaults;
|
|
42
|
+
return cachedConfig;
|
|
43
|
+
}
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
50
|
+
throw new Error(`Failed to parse ${CONFIG_PATH}: ${message}`);
|
|
51
|
+
}
|
|
52
|
+
const root = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
53
|
+
const value = root.githubPrIssue;
|
|
54
|
+
if (value !== undefined && (typeof value !== "object" || value === null || Array.isArray(value))) {
|
|
55
|
+
throw new Error(`githubPrIssue in ${CONFIG_PATH} must be an object`);
|
|
56
|
+
}
|
|
57
|
+
const enabled = typeof value?.enabled === "boolean"
|
|
58
|
+
? value.enabled
|
|
59
|
+
: true;
|
|
60
|
+
cachedConfig = { enabled };
|
|
61
|
+
return cachedConfig;
|
|
62
|
+
}
|
|
63
|
+
function validOwner(owner) {
|
|
64
|
+
return /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/.test(owner) && !owner.includes("--");
|
|
65
|
+
}
|
|
66
|
+
function validRepo(repo) {
|
|
67
|
+
return /^[A-Za-z0-9._-]{1,100}$/.test(repo) && repo !== "." && repo !== "..";
|
|
68
|
+
}
|
|
69
|
+
function errorMessage(err) {
|
|
70
|
+
return err instanceof Error ? err.message : String(err);
|
|
71
|
+
}
|
|
72
|
+
function isAbortError(err) {
|
|
73
|
+
return errorMessage(err).toLowerCase().includes("abort");
|
|
74
|
+
}
|
|
75
|
+
export function parseGitHubIssuePrUrl(url) {
|
|
76
|
+
let parsed;
|
|
77
|
+
try {
|
|
78
|
+
parsed = new URL(url);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const host = parsed.hostname.toLowerCase();
|
|
84
|
+
if (host !== "github.com" && host !== "www.github.com")
|
|
85
|
+
return null;
|
|
86
|
+
const segments = [];
|
|
87
|
+
for (const segment of parsed.pathname.split("/").filter(Boolean)) {
|
|
88
|
+
try {
|
|
89
|
+
segments.push(decodeURIComponent(segment));
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (segments.length < 4)
|
|
96
|
+
return null;
|
|
97
|
+
const owner = segments[0];
|
|
98
|
+
const repo = segments[1].replace(/\.git$/, "");
|
|
99
|
+
if (!validOwner(owner) || !validRepo(repo))
|
|
100
|
+
return null;
|
|
101
|
+
const route = segments[2].toLowerCase();
|
|
102
|
+
if (route !== "pull" && route !== "issues")
|
|
103
|
+
return null;
|
|
104
|
+
if (!/^\d+$/.test(segments[3]))
|
|
105
|
+
return null;
|
|
106
|
+
const subpath = segments[4]?.toLowerCase();
|
|
107
|
+
if (route === "pull" && subpath && !PR_SUBPATHS.has(subpath))
|
|
108
|
+
return null;
|
|
109
|
+
if (route === "issues" && subpath)
|
|
110
|
+
return null;
|
|
111
|
+
const number = Number.parseInt(segments[3], 10);
|
|
112
|
+
if (!Number.isSafeInteger(number) || number <= 0)
|
|
113
|
+
return null;
|
|
114
|
+
const fragment = parsed.hash.slice(1);
|
|
115
|
+
const anchorPattern = route === "pull" ? /^(?:issuecomment-\d+|discussion_r\d+)$/i : /^issuecomment-\d+$/i;
|
|
116
|
+
const anchor = anchorPattern.test(fragment) ? fragment : undefined;
|
|
117
|
+
return { owner, repo, kind: route === "pull" ? "pull" : "issue", number, ...(anchor ? { anchor } : {}) };
|
|
118
|
+
}
|
|
119
|
+
function runGh(args, timeoutMs = GH_TIMEOUT_MS, signal) {
|
|
120
|
+
return new Promise((resolve) => {
|
|
121
|
+
execFile("gh", args, {
|
|
122
|
+
timeout: timeoutMs,
|
|
123
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
124
|
+
...(signal ? { signal } : {}),
|
|
125
|
+
env: { ...process.env, GH_PROMPT_DISABLED: "1", GIT_TERMINAL_PROMPT: "0" },
|
|
126
|
+
}, (err, stdout, stderr) => {
|
|
127
|
+
const nodeErr = err;
|
|
128
|
+
resolve({
|
|
129
|
+
ok: !err,
|
|
130
|
+
stdout,
|
|
131
|
+
stderr,
|
|
132
|
+
code: typeof nodeErr?.code === "number" ? nodeErr.code : null,
|
|
133
|
+
...(err ? { error: nodeErr?.message ?? String(err) } : {}),
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function remainingGhTimeout(deadlineMs) {
|
|
139
|
+
return Math.max(1, Math.min(GH_TIMEOUT_MS, deadlineMs - Date.now()));
|
|
140
|
+
}
|
|
141
|
+
function unknownJsonField(result) {
|
|
142
|
+
return /unknown (?:json )?field|UnknownField|Unknown JSON field/i.test(`${result.stderr}\n${result.error ?? ""}`);
|
|
143
|
+
}
|
|
144
|
+
async function ghView(info, deadlineMs, signal) {
|
|
145
|
+
const repoArg = `${info.owner}/${info.repo}`;
|
|
146
|
+
const command = info.kind === "pull" ? "pr" : "issue";
|
|
147
|
+
const fields = info.kind === "pull" ? PR_FIELDS : ISSUE_FIELDS;
|
|
148
|
+
const coreFields = info.kind === "pull" ? PR_CORE_FIELDS : ISSUE_CORE_FIELDS;
|
|
149
|
+
let result = await runGh([command, "view", String(info.number), "--repo", repoArg, "--json", fields.join(",")], remainingGhTimeout(deadlineMs), signal);
|
|
150
|
+
const notes = [];
|
|
151
|
+
let linkedReferencesUnavailable = false;
|
|
152
|
+
if (!result.ok && unknownJsonField(result)) {
|
|
153
|
+
result = await runGh([command, "view", String(info.number), "--repo", repoArg, "--json", coreFields.join(",")], remainingGhTimeout(deadlineMs), signal);
|
|
154
|
+
notes.push("Some GitHub fields were unavailable from this gh version; retried with the core field set.");
|
|
155
|
+
linkedReferencesUnavailable = true;
|
|
156
|
+
}
|
|
157
|
+
if (!result.ok)
|
|
158
|
+
return null;
|
|
159
|
+
try {
|
|
160
|
+
const parsed = JSON.parse(result.stdout);
|
|
161
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
162
|
+
return null;
|
|
163
|
+
const view = parsed;
|
|
164
|
+
if (linkedReferencesUnavailable)
|
|
165
|
+
view.linkedReferencesUnavailable = true;
|
|
166
|
+
return { view, notes };
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function ghReviewThreads(info, deadlineMs, signal) {
|
|
173
|
+
if (info.kind !== "pull")
|
|
174
|
+
return { comments: [] };
|
|
175
|
+
const comments = [];
|
|
176
|
+
let bounded = false;
|
|
177
|
+
let pageFailed = false;
|
|
178
|
+
for (let page = 1; page <= 3; page++) {
|
|
179
|
+
const result = await runGh(["api", `repos/${info.owner}/${info.repo}/pulls/${info.number}/comments?per_page=100&page=${page}`], remainingGhTimeout(deadlineMs), signal);
|
|
180
|
+
if (!result.ok) {
|
|
181
|
+
pageFailed = true;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
let pageItems;
|
|
185
|
+
try {
|
|
186
|
+
pageItems = JSON.parse(result.stdout);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
pageFailed = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (!Array.isArray(pageItems) || pageItems.length === 0)
|
|
193
|
+
break;
|
|
194
|
+
comments.push(...pageItems.filter((item) => !!item && typeof item === "object" && !Array.isArray(item)));
|
|
195
|
+
if (pageItems.length < 100)
|
|
196
|
+
break;
|
|
197
|
+
if (page === 3)
|
|
198
|
+
bounded = true;
|
|
199
|
+
}
|
|
200
|
+
const discussionId = anchorId(info.anchor, "discussion_r");
|
|
201
|
+
if (discussionId && !hasCommentId(comments, discussionId)) {
|
|
202
|
+
const result = await runGh(["api", `repos/${info.owner}/${info.repo}/pulls/comments/${discussionId}`], remainingGhTimeout(deadlineMs), signal);
|
|
203
|
+
if (result.ok) {
|
|
204
|
+
try {
|
|
205
|
+
const comment = JSON.parse(result.stdout);
|
|
206
|
+
if (comment && typeof comment === "object" && !Array.isArray(comment) && belongsToPull(comment, discussionId, info))
|
|
207
|
+
comments.push(comment);
|
|
208
|
+
else
|
|
209
|
+
return { comments, bounded: bounded || (pageFailed && comments.length > 0), unavailable: pageFailed && comments.length === 0, anchorUnavailable: true };
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return { comments, bounded: bounded || (pageFailed && comments.length > 0), unavailable: pageFailed && comments.length === 0, note: "Anchored review thread comment unavailable from gh." };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return { comments, bounded: bounded || (pageFailed && comments.length > 0), unavailable: pageFailed && comments.length === 0, anchorUnavailable: true };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return { comments, bounded: bounded || (pageFailed && comments.length > 0), unavailable: pageFailed && comments.length === 0 };
|
|
220
|
+
}
|
|
221
|
+
function isRateLimited(response) {
|
|
222
|
+
return response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0";
|
|
223
|
+
}
|
|
224
|
+
function anchorId(anchor, prefix) {
|
|
225
|
+
const match = anchor?.match(prefix === "issuecomment" ? /^issuecomment-(\d+)$/i : /^discussion_r(\d+)$/i);
|
|
226
|
+
return match?.[1] ?? null;
|
|
227
|
+
}
|
|
228
|
+
function hasCommentId(comments, id) {
|
|
229
|
+
return comments.some(comment => commentId(comment) === id);
|
|
230
|
+
}
|
|
231
|
+
function belongsToIssue(comment, id, info) {
|
|
232
|
+
return commentId(comment) === id && associationMatches(comment.issue_url, info, "issues");
|
|
233
|
+
}
|
|
234
|
+
function belongsToPull(comment, id, info) {
|
|
235
|
+
return commentId(comment) === id && associationMatches(comment.pull_request_url, info, "pulls");
|
|
236
|
+
}
|
|
237
|
+
function associationMatches(value, info, route) {
|
|
238
|
+
if (typeof value !== "string")
|
|
239
|
+
return false;
|
|
240
|
+
try {
|
|
241
|
+
const parsed = new URL(value);
|
|
242
|
+
if (parsed.protocol !== "https:" || parsed.hostname.toLowerCase() !== "api.github.com")
|
|
243
|
+
return false;
|
|
244
|
+
return parsed.pathname.toLowerCase() === `/repos/${info.owner}/${info.repo}/${route}/${info.number}`.toLowerCase();
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function rateLimitResult(url, info, response) {
|
|
251
|
+
const reset = response.headers.get("x-ratelimit-reset");
|
|
252
|
+
const resetNote = reset ? ` Rate limit resets at Unix time ${reset}.` : "";
|
|
253
|
+
return {
|
|
254
|
+
url,
|
|
255
|
+
title: `${info.owner}/${info.repo}#${info.number}`,
|
|
256
|
+
content: `GitHub API rate limit reached for ${info.owner}/${info.repo} ${info.kind} #${info.number}.${resetNote}\n\nAuthenticate the gh CLI and retry:\n\n\`gh auth login\`\n\nThen fetch this URL again.`,
|
|
257
|
+
error: "GitHub API rate limit reached; authenticate gh to fetch this PR or issue.",
|
|
258
|
+
status: response.status,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
async function restJson(url, options, signal) {
|
|
262
|
+
const ssrf = loadSsrfConfig();
|
|
263
|
+
const domainPolicy = loadFetchContentDomainPolicy();
|
|
264
|
+
const response = await fetchRemoteUrl(url, { headers: REST_HEADERS, ...(signal ? { signal } : {}) }, {
|
|
265
|
+
allowRanges: ssrf.allowRanges,
|
|
266
|
+
trustEnvProxy: ssrf.trustEnvProxy,
|
|
267
|
+
domainPolicy,
|
|
268
|
+
...(options?.lookup ? { lookup: options.lookup } : {}),
|
|
269
|
+
});
|
|
270
|
+
if (!response.ok)
|
|
271
|
+
return { value: null, response };
|
|
272
|
+
return { value: await response.json(), response };
|
|
273
|
+
}
|
|
274
|
+
async function restFallback(url, info, options, signal) {
|
|
275
|
+
try {
|
|
276
|
+
const base = `https://api.github.com/repos/${info.owner}/${info.repo}`;
|
|
277
|
+
const mainPath = info.kind === "pull" ? `${base}/pulls/${info.number}` : `${base}/issues/${info.number}`;
|
|
278
|
+
const main = await restJson(mainPath, options, signal);
|
|
279
|
+
if (!main)
|
|
280
|
+
return null;
|
|
281
|
+
if (isRateLimited(main.response))
|
|
282
|
+
return rateLimitResult(url, info, main.response);
|
|
283
|
+
if (!main.response.ok)
|
|
284
|
+
return null;
|
|
285
|
+
const view = mapRestView(info, main.value);
|
|
286
|
+
view.linkedReferencesUnavailable = true;
|
|
287
|
+
const comments = await restJson(`${base}/issues/${info.number}/comments?per_page=50`, options, signal);
|
|
288
|
+
if (comments && isRateLimited(comments.response))
|
|
289
|
+
return rateLimitResult(url, info, comments.response);
|
|
290
|
+
const conversationComments = comments?.response.ok && Array.isArray(comments.value)
|
|
291
|
+
? comments.value.filter((item) => !!item && typeof item === "object" && !Array.isArray(item))
|
|
292
|
+
: [];
|
|
293
|
+
const issueCommentId = anchorId(info.anchor, "issuecomment");
|
|
294
|
+
if (issueCommentId && !hasCommentId(conversationComments, issueCommentId)) {
|
|
295
|
+
const anchoredComment = await restJson(`${base}/issues/comments/${issueCommentId}`, options, signal);
|
|
296
|
+
if (anchoredComment && isRateLimited(anchoredComment.response))
|
|
297
|
+
return rateLimitResult(url, info, anchoredComment.response);
|
|
298
|
+
if (anchoredComment?.response.ok && anchoredComment.value && typeof anchoredComment.value === "object" && !Array.isArray(anchoredComment.value)) {
|
|
299
|
+
const comment = anchoredComment.value;
|
|
300
|
+
if (belongsToIssue(comment, issueCommentId, info))
|
|
301
|
+
conversationComments.push(comment);
|
|
302
|
+
else
|
|
303
|
+
view.anchorUnavailable = true;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
view.anchorUnavailable = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
view.comments = conversationComments;
|
|
310
|
+
const reviewThreads = [];
|
|
311
|
+
const notes = [info.kind === "pull" ? "Checks unavailable in REST fallback; install or authenticate gh for check status." : "REST fallback used; gh fields unavailable."];
|
|
312
|
+
if (info.kind === "pull") {
|
|
313
|
+
view.reviewsUnavailable = true;
|
|
314
|
+
view.commitsUnavailable = true;
|
|
315
|
+
const files = await restJson(`${base}/pulls/${info.number}/files?per_page=50`, options, signal);
|
|
316
|
+
if (files && isRateLimited(files.response))
|
|
317
|
+
return rateLimitResult(url, info, files.response);
|
|
318
|
+
if (files?.response.ok && Array.isArray(files.value))
|
|
319
|
+
view.files = files.value;
|
|
320
|
+
const threads = await restJson(`${base}/pulls/${info.number}/comments?per_page=50`, options, signal);
|
|
321
|
+
if (threads && isRateLimited(threads.response))
|
|
322
|
+
return rateLimitResult(url, info, threads.response);
|
|
323
|
+
if (threads?.response.ok && Array.isArray(threads.value)) {
|
|
324
|
+
reviewThreads.push(...threads.value.filter((item) => !!item && typeof item === "object" && !Array.isArray(item)));
|
|
325
|
+
}
|
|
326
|
+
const discussionId = anchorId(info.anchor, "discussion_r");
|
|
327
|
+
if (discussionId && !hasCommentId(reviewThreads, discussionId)) {
|
|
328
|
+
const anchoredThread = await restJson(`${base}/pulls/comments/${discussionId}`, options, signal);
|
|
329
|
+
if (anchoredThread && isRateLimited(anchoredThread.response))
|
|
330
|
+
return rateLimitResult(url, info, anchoredThread.response);
|
|
331
|
+
if (anchoredThread?.response.ok && anchoredThread.value && typeof anchoredThread.value === "object" && !Array.isArray(anchoredThread.value)) {
|
|
332
|
+
const comment = anchoredThread.value;
|
|
333
|
+
if (belongsToPull(comment, discussionId, info))
|
|
334
|
+
reviewThreads.push(comment);
|
|
335
|
+
else
|
|
336
|
+
view.anchorUnavailable = true;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
view.anchorUnavailable = true;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return { data: { url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view, reviewThreads, fallbackNotes: notes } };
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
if (signal?.aborted || isAbortError(err))
|
|
347
|
+
return { url, title: "", content: "", error: "Aborted" };
|
|
348
|
+
const message = errorMessage(err);
|
|
349
|
+
return { url, title: `${info.owner}/${info.repo}#${info.number}`, content: message, error: `GitHub REST fallback failed: ${message}` };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function mapRestView(info, value) {
|
|
353
|
+
const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
354
|
+
const user = source.user && typeof source.user === "object" ? source.user : undefined;
|
|
355
|
+
const base = source.base && typeof source.base === "object" ? source.base : undefined;
|
|
356
|
+
const head = source.head && typeof source.head === "object" ? source.head : undefined;
|
|
357
|
+
return {
|
|
358
|
+
title: stringValue(source.title),
|
|
359
|
+
number: numberValue(source.number) ?? info.number,
|
|
360
|
+
state: stringValue(source.state),
|
|
361
|
+
stateReason: stringValue(source.state_reason),
|
|
362
|
+
isDraft: Boolean(source.draft),
|
|
363
|
+
author: { login: user ? stringValue(user.login) : "" },
|
|
364
|
+
baseRefName: base ? stringValue(base.ref) : "",
|
|
365
|
+
headRefName: head ? stringValue(head.ref) : "",
|
|
366
|
+
headRepositoryOwner: { login: head && typeof head.repo === "object" && head.repo && typeof head.repo.owner === "object" ? stringValue(head.repo.owner.login) : "" },
|
|
367
|
+
createdAt: stringValue(source.created_at),
|
|
368
|
+
mergedAt: stringValue(source.merged_at),
|
|
369
|
+
closedAt: stringValue(source.closed_at),
|
|
370
|
+
labels: source.labels,
|
|
371
|
+
assignees: source.assignees,
|
|
372
|
+
milestone: source.milestone,
|
|
373
|
+
additions: source.additions,
|
|
374
|
+
deletions: source.deletions,
|
|
375
|
+
changedFiles: source.changed_files,
|
|
376
|
+
body: stringValue(source.body),
|
|
377
|
+
url: stringValue(source.html_url),
|
|
378
|
+
commentsCount: source.comments,
|
|
379
|
+
reviewCommentsCount: source.review_comments,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function stringValue(value) {
|
|
383
|
+
return typeof value === "string" ? value : "";
|
|
384
|
+
}
|
|
385
|
+
function numberValue(value) {
|
|
386
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
387
|
+
}
|
|
388
|
+
function authorLogin(value) {
|
|
389
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
390
|
+
return "unknown";
|
|
391
|
+
const login = value.login;
|
|
392
|
+
return typeof login === "string" && login ? login : "unknown";
|
|
393
|
+
}
|
|
394
|
+
function listNames(value) {
|
|
395
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
396
|
+
return "none";
|
|
397
|
+
const names = value.map((item) => {
|
|
398
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
399
|
+
return "";
|
|
400
|
+
const record = item;
|
|
401
|
+
return stringValue(record.name) || stringValue(record.login) || stringValue(record.title);
|
|
402
|
+
}).filter(Boolean);
|
|
403
|
+
return names.length > 0 ? names.join(", ") : "none";
|
|
404
|
+
}
|
|
405
|
+
function milestoneTitle(value) {
|
|
406
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
407
|
+
return "none";
|
|
408
|
+
return stringValue(value.title) || "none";
|
|
409
|
+
}
|
|
410
|
+
function truncateText(text, limit, label, appendix) {
|
|
411
|
+
if (text.length <= limit)
|
|
412
|
+
return text;
|
|
413
|
+
appendix.push(`## Full ${label}\n\n${text}`);
|
|
414
|
+
return `${text.slice(0, limit)}\n\n[${label} truncated; use get_search_content findText or offset for the full text]`;
|
|
415
|
+
}
|
|
416
|
+
function appendLimitedSection(lines, title, items, max, marker) {
|
|
417
|
+
lines.push(`## ${title}`);
|
|
418
|
+
if (items.length === 0) {
|
|
419
|
+
lines.push("none", "");
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
lines.push(...items.slice(0, max));
|
|
423
|
+
if (items.length > max)
|
|
424
|
+
lines.push(`[${max} of ${items.length} ${marker} shown; use get_search_content offset or the gh command below for more]`);
|
|
425
|
+
lines.push("");
|
|
426
|
+
}
|
|
427
|
+
function objectArray(value) {
|
|
428
|
+
if (!Array.isArray(value))
|
|
429
|
+
return [];
|
|
430
|
+
return value.filter((item) => !!item && typeof item === "object" && !Array.isArray(item));
|
|
431
|
+
}
|
|
432
|
+
function commentId(comment) {
|
|
433
|
+
return String(comment.id ?? comment.databaseId ?? "");
|
|
434
|
+
}
|
|
435
|
+
function anchorMatches(anchor, comment) {
|
|
436
|
+
if (!anchor)
|
|
437
|
+
return false;
|
|
438
|
+
const id = commentId(comment);
|
|
439
|
+
return anchor === `issuecomment-${id}` || anchor === `discussion_r${id}`;
|
|
440
|
+
}
|
|
441
|
+
function renderComments(comments, anchor, appendix) {
|
|
442
|
+
const forced = anchor ? comments.find(comment => anchorMatches(anchor, comment)) : undefined;
|
|
443
|
+
const selected = comments.slice(0, MAX_INLINE_COMMENTS);
|
|
444
|
+
if (forced && !selected.includes(forced))
|
|
445
|
+
selected.push(forced);
|
|
446
|
+
const lines = selected.map((comment) => {
|
|
447
|
+
const body = stringValue(comment.body);
|
|
448
|
+
const label = `comment ${commentId(comment) || selected.indexOf(comment) + 1}`;
|
|
449
|
+
return `- ${authorLogin(comment.author ?? comment.user)} at ${stringValue(comment.createdAt) || stringValue(comment.created_at)}${forced === comment ? " [anchored]" : ""}:\n ${truncateText(body, COMMENT_INLINE_CHARS, label, appendix).replace(/\n/g, "\n ")}`;
|
|
450
|
+
});
|
|
451
|
+
return lines;
|
|
452
|
+
}
|
|
453
|
+
function renderCommentMarker(comments, renderedCount, total) {
|
|
454
|
+
const knownTotal = numberValue(total);
|
|
455
|
+
if (knownTotal !== null && knownTotal > comments.length) {
|
|
456
|
+
return `[${renderedCount} comments shown from at least ${knownTotal}; use get_search_content findText or offset, or gh issue view -c]`;
|
|
457
|
+
}
|
|
458
|
+
if (comments.length > renderedCount)
|
|
459
|
+
return `[${renderedCount} of ${comments.length} comments shown; use get_search_content findText or offset, or gh issue view -c]`;
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
function commentCountText(view) {
|
|
463
|
+
const comments = objectArray(view.comments).length;
|
|
464
|
+
const total = numberValue(view.commentsCount);
|
|
465
|
+
if (total !== null && total > comments)
|
|
466
|
+
return `at least ${total}`;
|
|
467
|
+
return String(comments || total || 0);
|
|
468
|
+
}
|
|
469
|
+
function reviewThreadCountText(comments, total, bounded, unavailable) {
|
|
470
|
+
if (unavailable)
|
|
471
|
+
return "unavailable";
|
|
472
|
+
const knownTotal = numberValue(total);
|
|
473
|
+
if (bounded)
|
|
474
|
+
return `at least ${comments.length}`;
|
|
475
|
+
if (knownTotal !== null && knownTotal > comments.length)
|
|
476
|
+
return `at least ${knownTotal}`;
|
|
477
|
+
return String(comments.length || knownTotal || 0);
|
|
478
|
+
}
|
|
479
|
+
function renderChecks(value) {
|
|
480
|
+
const checks = objectArray(value);
|
|
481
|
+
if (checks.length === 0)
|
|
482
|
+
return ["No check rollup data available."];
|
|
483
|
+
const rows = checks.map((check) => {
|
|
484
|
+
const name = stringValue(check.name) || stringValue(check.context) || stringValue(check.workflowName) || "check";
|
|
485
|
+
const state = stringValue(check.conclusion) || stringValue(check.status) || stringValue(check.state) || "unknown";
|
|
486
|
+
return `- ${name}: ${state}`;
|
|
487
|
+
});
|
|
488
|
+
const failing = rows.filter(row => !/(success|neutral|skipped|completed)$/i.test(row));
|
|
489
|
+
return [`Rollup: ${failing.length === 0 ? "no failing checks in shown data" : `${failing.length} non-passing checks in shown data`}`, ...rows.slice(0, MAX_INLINE_CHECKS), ...(rows.length > MAX_INLINE_CHECKS ? [`[${MAX_INLINE_CHECKS} of ${rows.length} checks shown]`] : [])];
|
|
490
|
+
}
|
|
491
|
+
function renderReviewVerdicts(value, appendix) {
|
|
492
|
+
const latest = new Map();
|
|
493
|
+
for (const review of objectArray(value))
|
|
494
|
+
latest.set(authorLogin(review.author ?? review.user), review);
|
|
495
|
+
return [...latest.entries()].map(([author, review]) => {
|
|
496
|
+
const state = stringValue(review.state) || "COMMENTED";
|
|
497
|
+
const body = truncateText(stringValue(review.body), 300, `review by ${author}`, appendix);
|
|
498
|
+
return `- ${author}: ${state}${body ? ` — ${body.replace(/\n/g, " ")}` : ""}`;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function renderReviewVerdictsOrUnavailable(view, appendix) {
|
|
502
|
+
const rendered = renderReviewVerdicts(view.reviews, appendix);
|
|
503
|
+
if (rendered.length > 0)
|
|
504
|
+
return rendered;
|
|
505
|
+
return view.reviewsUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for review verdicts."] : [];
|
|
506
|
+
}
|
|
507
|
+
function renderFiles(value) {
|
|
508
|
+
return objectArray(value).map((file) => {
|
|
509
|
+
const path = stringValue(file.path) || stringValue(file.filename) || "file";
|
|
510
|
+
const additions = numberValue(file.additions) ?? 0;
|
|
511
|
+
const deletions = numberValue(file.deletions) ?? 0;
|
|
512
|
+
return `- ${path} (+${additions}/−${deletions})`;
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function appendFilesSection(lines, view) {
|
|
516
|
+
lines.push("## Files");
|
|
517
|
+
const files = renderFiles(view.files);
|
|
518
|
+
if (files.length === 0) {
|
|
519
|
+
const total = numberValue(view.changedFiles);
|
|
520
|
+
if (total !== null && total > 0) {
|
|
521
|
+
lines.push(`[0 files shown from at least ${total}; use get_search_content offset or the gh command below for more]`, "");
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
lines.push("none", "");
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
lines.push(...files.slice(0, MAX_INLINE_FILES));
|
|
528
|
+
const total = numberValue(view.changedFiles);
|
|
529
|
+
if (total !== null && total > files.length) {
|
|
530
|
+
lines.push(`[${Math.min(files.length, MAX_INLINE_FILES)} files shown from at least ${total}; use get_search_content offset or the gh command below for more]`);
|
|
531
|
+
}
|
|
532
|
+
else if (files.length > MAX_INLINE_FILES) {
|
|
533
|
+
lines.push(`[${MAX_INLINE_FILES} of ${files.length} files shown; use get_search_content offset or the gh command below for more]`);
|
|
534
|
+
}
|
|
535
|
+
lines.push("");
|
|
536
|
+
}
|
|
537
|
+
function renderCommits(value) {
|
|
538
|
+
return objectArray(value).map((commit) => {
|
|
539
|
+
const oid = stringValue(commit.oid) || stringValue(commit.sha);
|
|
540
|
+
const message = stringValue(commit.messageHeadline) || (commit.commit && typeof commit.commit === "object" ? stringValue(commit.commit.message).split("\n")[0] : "");
|
|
541
|
+
return `- ${oid.slice(0, 7)} ${message}`.trim();
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function renderCommitsOrUnavailable(view) {
|
|
545
|
+
const rendered = renderCommits(view.commits);
|
|
546
|
+
if (rendered.length > 0)
|
|
547
|
+
return rendered;
|
|
548
|
+
return view.commitsUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for commits."] : [];
|
|
549
|
+
}
|
|
550
|
+
function renderLinked(value, kind) {
|
|
551
|
+
return objectArray(value).map((item) => `- #${numberValue(item.number) ?? "?"} ${stringValue(item.title)}${kind === "closedBy" ? ` (${stringValue(item.url)})` : ""}`);
|
|
552
|
+
}
|
|
553
|
+
function renderLinkedOrUnavailable(view, field, kind) {
|
|
554
|
+
const linked = renderLinked(view[field], kind);
|
|
555
|
+
if (linked.length > 0)
|
|
556
|
+
return linked;
|
|
557
|
+
return view.linkedReferencesUnavailable === true ? ["Unavailable in this GitHub fetch path; use gh for linked references."] : [];
|
|
558
|
+
}
|
|
559
|
+
function renderReviewThreads(comments, anchor, appendix, total, bounded, unavailable) {
|
|
560
|
+
if (unavailable)
|
|
561
|
+
return ["Unavailable in this GitHub fetch path; use gh for review thread comments."];
|
|
562
|
+
const forced = anchor ? comments.find(comment => anchorMatches(anchor, comment)) : undefined;
|
|
563
|
+
const selected = comments.slice(0, MAX_INLINE_REVIEW_THREADS);
|
|
564
|
+
if (forced && !selected.includes(forced))
|
|
565
|
+
selected.push(forced);
|
|
566
|
+
const lines = selected.map((comment) => {
|
|
567
|
+
const path = stringValue(comment.path) || "unknown path";
|
|
568
|
+
const line = numberValue(comment.line) ?? numberValue(comment.original_line) ?? numberValue(comment.position) ?? "?";
|
|
569
|
+
const body = truncateText(stringValue(comment.body), COMMENT_INLINE_CHARS, `review thread comment ${commentId(comment) || selected.indexOf(comment) + 1}`, appendix);
|
|
570
|
+
return `- ${path}:${line} — ${authorLogin(comment.user ?? comment.author)}${forced === comment ? " [anchored]" : ""} (resolution state unknown):\n ${body.replace(/\n/g, "\n ")}`;
|
|
571
|
+
});
|
|
572
|
+
const knownTotal = numberValue(total);
|
|
573
|
+
if (bounded) {
|
|
574
|
+
lines.push(`[${selected.length} review thread comments shown from at least ${comments.length}; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
|
|
575
|
+
}
|
|
576
|
+
else if (knownTotal !== null && knownTotal > comments.length) {
|
|
577
|
+
lines.push(`[${selected.length} review thread comments shown from at least ${knownTotal}; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
|
|
578
|
+
}
|
|
579
|
+
else if (comments.length > selected.length) {
|
|
580
|
+
lines.push(`[${selected.length} of ${comments.length} review thread comments shown; use get_search_content offset, or gh api repos/<owner>/<repo>/pulls/<number>/comments]`);
|
|
581
|
+
}
|
|
582
|
+
return lines;
|
|
583
|
+
}
|
|
584
|
+
export function renderGitHubPrIssue(data) {
|
|
585
|
+
const { view } = data;
|
|
586
|
+
const appendix = [];
|
|
587
|
+
const title = stringValue(view.title) || `${data.owner}/${data.repo}#${data.number}`;
|
|
588
|
+
const number = numberValue(view.number) ?? data.number;
|
|
589
|
+
const stateParts = [stringValue(view.state) || "unknown"];
|
|
590
|
+
if (view.isDraft === true)
|
|
591
|
+
stateParts.push("draft");
|
|
592
|
+
const lines = [`#${number} ${title}`, ""];
|
|
593
|
+
lines.push(`- type: ${data.kind}`);
|
|
594
|
+
lines.push(`- state: ${stateParts.join(" ")}${stringValue(view.stateReason) ? ` (${stringValue(view.stateReason)})` : ""}`);
|
|
595
|
+
lines.push(`- author: ${authorLogin(view.author)}`);
|
|
596
|
+
if (data.kind === "pull") {
|
|
597
|
+
const headOwner = authorLogin(view.headRepositoryOwner);
|
|
598
|
+
const headRef = stringValue(view.headRefName);
|
|
599
|
+
const head = headOwner !== "unknown" && headOwner !== data.owner ? `${headOwner}:${headRef}` : headRef;
|
|
600
|
+
lines.push(`- branch: ${stringValue(view.baseRefName)} ← ${head}`);
|
|
601
|
+
const commitSummary = view.commitsUnavailable === true ? "commits unavailable" : `${objectArray(view.commits).length} commits`;
|
|
602
|
+
lines.push(`- changes: +${numberValue(view.additions) ?? 0} −${numberValue(view.deletions) ?? 0}, ${numberValue(view.changedFiles) ?? objectArray(view.files).length} files, ${commitSummary}`);
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
lines.push(`- assignees: ${listNames(view.assignees)}`);
|
|
606
|
+
}
|
|
607
|
+
lines.push(`- created: ${stringValue(view.createdAt) || "unknown"}`);
|
|
608
|
+
if (stringValue(view.mergedAt))
|
|
609
|
+
lines.push(`- merged: ${stringValue(view.mergedAt)}`);
|
|
610
|
+
if (stringValue(view.closedAt))
|
|
611
|
+
lines.push(`- closed: ${stringValue(view.closedAt)}`);
|
|
612
|
+
lines.push(`- labels: ${listNames(view.labels)}`);
|
|
613
|
+
lines.push(`- milestone: ${milestoneTitle(view.milestone)}`);
|
|
614
|
+
lines.push(`- comments: ${commentCountText(view)}; review threads: ${reviewThreadCountText(data.reviewThreads, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable)}`);
|
|
615
|
+
if (data.anchor)
|
|
616
|
+
lines.push(`- requested anchor: #${data.anchor}`);
|
|
617
|
+
lines.push("");
|
|
618
|
+
lines.push("## Body");
|
|
619
|
+
lines.push(truncateText(stringValue(view.body) || "(empty)", BODY_INLINE_CHARS, "body", appendix), "");
|
|
620
|
+
if (data.kind === "pull") {
|
|
621
|
+
lines.push("## Checks");
|
|
622
|
+
lines.push(...renderChecks(view.statusCheckRollup), "");
|
|
623
|
+
appendLimitedSection(lines, "Review verdicts", renderReviewVerdictsOrUnavailable(view, appendix), MAX_INLINE_REVIEWS, "review verdicts");
|
|
624
|
+
appendLimitedSection(lines, "Linked references", renderLinkedOrUnavailable(view, "closingIssuesReferences", "closing"), 20, "linked references");
|
|
625
|
+
appendFilesSection(lines, view);
|
|
626
|
+
appendLimitedSection(lines, "Commits", renderCommitsOrUnavailable(view), MAX_INLINE_COMMITS, "commits");
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
appendLimitedSection(lines, "Closed by pull requests", renderLinkedOrUnavailable(view, "closedByPullRequestsReferences", "closedBy"), 20, "pull requests");
|
|
630
|
+
}
|
|
631
|
+
lines.push("## Conversation comments");
|
|
632
|
+
const commentLines = renderComments(objectArray(view.comments), data.anchor, appendix);
|
|
633
|
+
const commentMarker = renderCommentMarker(objectArray(view.comments), commentLines.length, view.commentsCount);
|
|
634
|
+
if (commentMarker)
|
|
635
|
+
commentLines.push(commentMarker);
|
|
636
|
+
if (view.anchorUnavailable === true && data.anchor?.startsWith("issuecomment-"))
|
|
637
|
+
commentLines.push("[anchored comment unavailable for this issue or pull request]");
|
|
638
|
+
lines.push(...(commentLines.length > 0 ? commentLines : ["none"]), "");
|
|
639
|
+
if (data.kind === "pull") {
|
|
640
|
+
lines.push("## Review thread comments");
|
|
641
|
+
const threadLines = renderReviewThreads(data.reviewThreads, data.anchor, appendix, view.reviewCommentsCount, data.reviewThreadsBounded, data.reviewThreadsUnavailable);
|
|
642
|
+
if (view.anchorUnavailable === true && data.anchor?.startsWith("discussion_r"))
|
|
643
|
+
threadLines.push("[anchored review thread comment unavailable for this pull request]");
|
|
644
|
+
lines.push(...(threadLines.length > 0 ? threadLines : ["none"]), "");
|
|
645
|
+
}
|
|
646
|
+
if (data.fallbackNotes.length > 0) {
|
|
647
|
+
lines.push("## Availability notes", ...data.fallbackNotes.map(note => `- ${note}`), "");
|
|
648
|
+
}
|
|
649
|
+
if (appendix.length > 0)
|
|
650
|
+
lines.push("## Appendix", ...appendix, "");
|
|
651
|
+
const viewCommand = data.kind === "pull" ? `gh pr view ${data.number} --repo ${data.owner}/${data.repo}` : `gh issue view ${data.number} --repo ${data.owner}/${data.repo} -c`;
|
|
652
|
+
lines.push("## Escalation commands");
|
|
653
|
+
lines.push(`- Full view: \`${viewCommand}\``);
|
|
654
|
+
if (data.kind === "pull")
|
|
655
|
+
lines.push(`- Complete diff: \`gh pr diff ${data.number} --repo ${data.owner}/${data.repo}\``);
|
|
656
|
+
lines.push("- Stored full document: use `get_search_content` with `offset` or `findText`.");
|
|
657
|
+
const content = lines.join("\n");
|
|
658
|
+
return {
|
|
659
|
+
url: data.url,
|
|
660
|
+
title: `${data.owner}/${data.repo} ${data.kind} #${data.number}: ${title}`,
|
|
661
|
+
content: content.length > MAX_DOC_CHARS ? `${content.slice(0, MAX_DOC_CHARS)}\n\n[GitHub document truncated at ${MAX_DOC_CHARS} chars; use the gh escalation commands for complete data]` : content,
|
|
662
|
+
error: null,
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
export async function extractGitHubIssuePr(url, signal, options) {
|
|
666
|
+
const info = parseGitHubIssuePrUrl(url);
|
|
667
|
+
if (!info)
|
|
668
|
+
return null;
|
|
669
|
+
if (!loadConfig().enabled)
|
|
670
|
+
return null;
|
|
671
|
+
if (signal?.aborted)
|
|
672
|
+
return { url, title: "", content: "", error: "Aborted" };
|
|
673
|
+
const ghAvailable = await checkGhAvailable(signal);
|
|
674
|
+
if (signal?.aborted)
|
|
675
|
+
return { url, title: "", content: "", error: "Aborted" };
|
|
676
|
+
if (ghAvailable) {
|
|
677
|
+
const ghDeadlineMs = Date.now() + GH_TOTAL_TIMEOUT_MS;
|
|
678
|
+
const viewed = await ghView(info, ghDeadlineMs, signal);
|
|
679
|
+
if (signal?.aborted)
|
|
680
|
+
return { url, title: "", content: "", error: "Aborted" };
|
|
681
|
+
if (viewed) {
|
|
682
|
+
const threads = await ghReviewThreads(info, ghDeadlineMs, signal);
|
|
683
|
+
if (signal?.aborted)
|
|
684
|
+
return { url, title: "", content: "", error: "Aborted" };
|
|
685
|
+
if (threads.anchorUnavailable)
|
|
686
|
+
viewed.view.anchorUnavailable = true;
|
|
687
|
+
const notes = [...viewed.notes, ...(threads.note ? [threads.note] : [])];
|
|
688
|
+
return renderGitHubPrIssue({ url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view: viewed.view, reviewThreads: threads.comments, reviewThreadsBounded: threads.bounded, reviewThreadsUnavailable: threads.unavailable, fallbackNotes: notes });
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
showGhHint();
|
|
693
|
+
}
|
|
694
|
+
const fallback = await restFallback(url, info, options, signal);
|
|
695
|
+
if (!fallback)
|
|
696
|
+
return null;
|
|
697
|
+
if ("data" in fallback)
|
|
698
|
+
return renderGitHubPrIssue(fallback.data);
|
|
699
|
+
return fallback;
|
|
700
|
+
}
|
|
701
|
+
//# sourceMappingURL=github-issue-pr.js.map
|