Skip to content

Instantly share code, notes, and snippets.

@TiLopes
Created January 27, 2024 11:36
Show Gist options
  • Save TiLopes/80d6c19a0ac85e73005987f507399594 to your computer and use it in GitHub Desktop.
Save TiLopes/80d6c19a0ac85e73005987f507399594 to your computer and use it in GitHub Desktop.
helix-gpt not working log files
APP 2024-01-26T23:34:09.225Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit","command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.10 (f6021dd0)"},"processId":32040,"rootPath":"/home/xou/Projetos/rust/aoc2015","rootUri":"file:///home/xou/Projetos/rust/aoc2015","workspaceFolders":[{"name":"aoc2015","uri":"file:///home/xou/Projetos/rust/aoc2015"}]},"id":0}
APP 2024-01-26T23:34:09.226Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
APP 2024-01-26T23:34:09.226Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}
APP 2024-01-26T23:34:13.991Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":11,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":1}
APP 2024-01-26T23:34:14.193Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:14.193Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:14.193Z --> sent request | {"jsonrpc":"2.0","id":1,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:14.209Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":12,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":2}
APP 2024-01-26T23:34:14.410Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:14.410Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:14.410Z --> sent request | {"jsonrpc":"2.0","id":2,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:15.407Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":20,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":4}
APP 2024-01-26T23:34:15.499Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":21,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":5}
APP 2024-01-26T23:34:15.700Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:15.700Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:15.700Z --> sent request | {"jsonrpc":"2.0","id":5,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:18.357Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":22,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":6}
APP 2024-01-26T23:34:18.559Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:18.559Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:18.559Z --> sent request | {"jsonrpc":"2.0","id":6,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:19.654Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":23,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":7}
APP 2024-01-26T23:34:19.855Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:19.855Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:19.855Z --> sent request | {"jsonrpc":"2.0","id":7,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:21.193Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":26,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":8}
APP 2024-01-26T23:34:21.394Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:21.394Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:21.394Z --> sent request | {"jsonrpc":"2.0","id":8,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:22.017Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":27,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":9}
APP 2024-01-26T23:34:22.218Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:22.219Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:22.219Z --> sent request | {"jsonrpc":"2.0","id":9,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:22.787Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":30,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":10}
APP 2024-01-26T23:34:22.989Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:22.989Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:22.989Z --> sent request | {"jsonrpc":"2.0","id":10,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:26.521Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":10,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":11}
APP 2024-01-26T23:34:26.722Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:26.722Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:26.722Z --> sent request | {"jsonrpc":"2.0","id":11,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:28.567Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":12,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":12}
APP 2024-01-26T23:34:28.768Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:28.768Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:28.768Z --> sent request | {"jsonrpc":"2.0","id":12,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:30.055Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":20,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":13}
APP 2024-01-26T23:34:30.247Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":21,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":14}
APP 2024-01-26T23:34:30.351Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":22,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":15}
APP 2024-01-26T23:34:30.552Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:30.552Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:30.552Z --> sent request | {"jsonrpc":"2.0","id":15,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:42.382Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":25,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":16}
APP 2024-01-26T23:34:42.583Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:42.583Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:42.583Z --> sent request | {"jsonrpc":"2.0","id":16,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:43.237Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":25,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":17}
APP 2024-01-26T23:34:43.438Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:43.438Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:43.438Z --> sent request | {"jsonrpc":"2.0","id":17,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:43.766Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":27,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":18}
APP 2024-01-26T23:34:43.967Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:43.967Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:43.967Z --> sent request | {"jsonrpc":"2.0","id":18,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:45.336Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":29,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":19}
APP 2024-01-26T23:34:45.537Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:45.537Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:45.537Z --> sent request | {"jsonrpc":"2.0","id":19,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:45.942Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":31,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":20}
APP 2024-01-26T23:34:46.143Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:46.143Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:46.143Z --> sent request | {"jsonrpc":"2.0","id":20,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:46.486Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":33,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":21}
APP 2024-01-26T23:34:46.687Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:46.687Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:46.687Z --> sent request | {"jsonrpc":"2.0","id":21,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:47.054Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":35,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":22}
APP 2024-01-26T23:34:47.256Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:47.256Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:47.256Z --> sent request | {"jsonrpc":"2.0","id":22,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:48.037Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":36,"line":11},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":23}
APP 2024-01-26T23:34:48.238Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:34:48.238Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:34:48.238Z --> sent request | {"jsonrpc":"2.0","id":23,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:34:51.052Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":24}
APP 2024-01-26T23:34:51.052Z --> received shutdown request
APP 2024-01-26T23:34:59.346Z --> received request: | {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit","command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.10 (f6021dd0)"},"processId":32139,"rootPath":"/home/xou/Projetos/rust/aoc2015","rootUri":"file:///home/xou/Projetos/rust/aoc2015","workspaceFolders":[{"name":"aoc2015","uri":"file:///home/xou/Projetos/rust/aoc2015"}]},"id":0}
APP 2024-01-26T23:34:59.347Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["generateDocs","improveCode","refactorFromComment"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
APP 2024-01-26T23:34:59.347Z --> received request: | {"jsonrpc":"2.0","method":"initialized","params":{}}
APP 2024-01-26T23:35:03.862Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":12,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":1}
APP 2024-01-26T23:35:04.064Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:04.064Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:04.064Z --> sent request | {"jsonrpc":"2.0","id":1,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:04.961Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":19,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":2}
APP 2024-01-26T23:35:05.087Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":20,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":3}
APP 2024-01-26T23:35:05.144Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":21,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":4}
APP 2024-01-26T23:35:05.346Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:05.346Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:05.346Z --> sent request | {"jsonrpc":"2.0","id":4,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:07.190Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":23,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":5}
APP 2024-01-26T23:35:07.391Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:07.391Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:07.391Z --> sent request | {"jsonrpc":"2.0","id":5,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:08.637Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":23,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":6}
APP 2024-01-26T23:35:08.789Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":23,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":7}
APP 2024-01-26T23:35:08.992Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:08.992Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:08.992Z --> sent request | {"jsonrpc":"2.0","id":7,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:10.959Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":24,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":8}
APP 2024-01-26T23:35:11.160Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:11.160Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:11.160Z --> sent request | {"jsonrpc":"2.0","id":8,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:13.041Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":25,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":9}
APP 2024-01-26T23:35:13.242Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:13.242Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:13.242Z --> sent request | {"jsonrpc":"2.0","id":9,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:15.105Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":26,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":10}
APP 2024-01-26T23:35:15.306Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:15.307Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:15.307Z --> sent request | {"jsonrpc":"2.0","id":10,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:16.144Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":28,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":11}
APP 2024-01-26T23:35:16.353Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:16.354Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:16.354Z --> sent request | {"jsonrpc":"2.0","id":11,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:16.615Z --> received request: | {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":30,"line":10},"textDocument":{"uri":"file:///home/xou/Projetos/rust/aoc2015/src/main.rs"}},"id":12}
APP 2024-01-26T23:35:16.817Z --> skipping | | not in | {,(,),=,>, ,,,:,.,<,/
APP 2024-01-26T23:35:16.817Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[]}}
APP 2024-01-26T23:35:16.817Z --> sent request | {"jsonrpc":"2.0","id":12,"result":{"isIncomplete":false,"items":[]}}
APP 2024-01-26T23:35:17.908Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":13}
APP 2024-01-26T23:35:17.908Z --> received shutdown request
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- "1 | // @bun\n"
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- "2 | import i from\"events\";import{appendFileSync as a} from\"fs\";import{parseArgs as c} from\"util\";var D={openai:\"Continue the input code from the language <languageId>. Only respond with code.\",copilot:\"<languageId> completions. Only respond with code.\"};var b=[{key:\"generateDocs\",label:\"Generate documentation\",query:\"Add documentation to this code.\"},{key:\"improveCode\",label:\"Improve code\",query:\"Improve this code.\"},{key:\"refactorFromComment\",label:\"Refactor code from a comment\",query:\"Refactor this code based on the comment.\"}];var f=($)=>{const N=new URLSearchParams($);return Object.fromEntries(N.entries())},g=async()=>{const $=await fetch(\"https://github.com/login/device/code?client_id=Iv1.b507a08c87ecfe98&scope=read:user\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"}});if(!$.ok)throw new Error(`fetchDeviceCode failed: ${$.status} ${await $.text()}`);return f(await $.text())},E=async()=>{const $=await g();console.log(`Visit: ${$.verification_uri} in your browser and enter: ${$.user_code}`);while(!0){await new Promise((J)=>setTimeout(J,5000));const N=await fetch(`https://github.com/login/oauth/access_token?client_id=Iv1.b507a08c87ecfe98&device_code=${$.device_code}&grant_type=urn:ietf:params:oauth:grant-type:device_code`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"}}),j=f(await N.text());if(j?.access_token?.length){console.log(\"\\n\\nGot token:\",j.access_token,\"\\n\\n\",\"Store this in the COPILOT_API_KEY environment variable\");break}console.log(\"Waiting for user authorization...\")}};var{values:Q}=c({args:Bun.argv,options:{logFile:{type:\"string\",default:Bun.env.LOG_FILE},handler:{type:\"string\",default:Bun.env.HANDLER??\"openai\"},openaiKey:{type:\"string\",default:Bun.env.OPENAI_API_KEY},openaiContext:{type:\"string\",default:Bun.env.OPENAI_CONTEXT?.length?Bun.env.OPENAI_CONTEXT:D.openai},openaiModel:{type:\"string\",default:Bun.env.OPENAI_MODEL??\"gpt-3.5-turbo-16k\"},openaiMaxTokens:{type:\"string\",default:Bun.env.OPENAI_MAX_TOKENS??\"7000\"},openaiEndpoint:{type:\"string\",default:Bun.env.OPENAI_ENDPOINT??\"https://api.openai.com/v1/chat/completions\"},copilotEndpoint:{type:\"string\",default:Bun.env.GITHUB_ENDPOINT??\"https://api.githubcopilot.com\"},copilotContext:{type:\"string\",default:Bun.env.COPILOT_CONTEXT?.length?Bun.env.COPILOT_CONTEXT:D.copilot},copilotModel:{type:\"string\",default:Bun.env.COPILOT_MODEL??\"gpt-3.5-turbo\"},copilotApiKey:{type:\"string\",default:Bun.env.COPILOT_API_KEY},authCopilot:{type:\"boolean\",default:!1}},strict:!0,allowPositionals:!0});if(Q.authCopilot)await E(),process.exit(0);if(!Q.openaiKey?.length&&!Q.copilotApiKey?.length)throw R(\"no handler key provided\"),new Error(\"no handler key provided\");var K=Q;import o from\"crypto\";var T={},S=($,N,j)=>{if(T[$])clearTimeout(T[$]);T[$]=setTimeout(N,j)};var G=($)=>{return o.randomBytes($/2).toString(\"hex\")},h=async($,N,j)=>{const J=$?.split(\"\\n\").slice(0,N+1);J[J.length-1]=J[J.length-1].split(\"\").slice(0,j).join(\"\");const O=J[J.length-1],z=J.join(\"\\n\"),_=$?.split(\"\\n\").slice(N+1).join(\"\\n\"),W=z.slice(-1),I=`${z}<BEGIN_COMPLETION>\\n${_}`;return{contentBefore:z,contentAfter:_,lastCharacter:W,templatedContent:I,lastLine:O}},R=(...$)=>{if(!K.logFile)return;if(Bun.env.TEST_RUNNER)console.log(y(...$));else a(K.logFile,y(...$)+\"\\n\\n\")},y=(...$)=>{let N=[];return $.forEach((j)=>{N.push(j),N.push(\"|\")}),N=N.slice(0,N.length-1),[\"APP\",(new Date()).toISOString(),\"-->\",...N].join(\" \")},v=($)=>{return Array.from(new Set($))},C=($)=>{if(!$?.length)return{};const N={},j=$.split(\";\");for(let J of j){const[O,z]=J.split(\"=\");N[O]=z}return N},L=()=>{return Math.floor(Date.now()/1000)};var P;(function(F){F[\"DidOpen\"]=\"textDocument/didOpen\";F[\"DidChange\"]=\"textDocument/didChange\";F[\"Completion\"]=\"textDocument/completion\";F[\"CodeAction\"]=\"textDocument/codeAction\";F[\"ApplyEdit\"]=\"workspace/applyEdit\";F[\"ExecuteCommand\"]=\"workspace/executeCommand\";F[\"Initialize\"]=\"initialize\";F[\"Shutdown\"]=\"shutdown\";F[\"Exit\"]=\"exit\";F[\"PublishDiagnostics\"]=\"textDocument/publishDiagnostics\"})(P||(P={}));var H;(function(O){O[O[\"Error\"]=1]=\"Error\";O[O[\"Warning\"]=2]=\"Warning\";O[O[\"Information\"]=3]=\"Information\";O[O[\"Hint\"]=4]=\"Hint\"})(H||(H={}));class d{emitter;capabilities;currentUri;contentVersion;language;contents;constructor({capabilities:$}){this.emitter=new i,this.capabilities=$,this.contentVersion=0,this.contents=\"\",this.registerDefault()}registerDefault(){this.on(P.Initialize,async({ctx:$})=>{$.send({method:P.Initialize,id:0,result:{capabilities:this.capabilities}})}),this.on(P.DidOpen,({ctx:$,request:N})=>{$.currentUri=N.params.textDocument.uri,$.contents=N.params.textDocument.text,$.language=N.params.textDocument.languageId,$.contentVersion=0}),this.on(P.Shutdown,()=>{R(\"received shutdown request\"),process.exit(0)}),this.on(P.DidChange,async({ctx:$,request:N})=>{N.params.contentChanges.forEach((j)=>{this.positionalUpdate(j.text,j.range)}),$.contentVersion=N.params.textDocument.version})}getContentFromRange($){R(\"getting content from range\",JSON.stringify($),this.contents);const{start:N,end:j}=$;return this.contents.split(\"\\n\").slice(N.line,j.line+1).join(\"\\n\")}positionalUpdate($,N){const j=this.contents.split(\"\\n\"),J=N.start.line,O=N.end.line,z=j[J],_=j[O],W=z.substring(0,N.start.character),I=_.substring(N.end.character),Y=[W+$+I],F=j.reduce((M,V,B)=>{if(B<J||B>O)M.push(V);else if(B===J)M.push(Y[0]);return M},[]);this.contents=F.join(\"\\n\")}on($,N){const j=this;this.emitter.on($,async(J)=>{try{N({ctx:j,request:J})}catch(O){R(\"error in event\",JSON.stringify(J),O.message)}})}send({method:$,id:N,result:j,params:J}){if(j===null)return;const O=JSON.stringify({jsonrpc:\"2.0\",method:$,id:N,result:j,params:J});console.log(`Content-Length: ${O.length}\\r\\n\\r\\n${O}`),R(\"sent request\",O)}sendDiagnostics($,N=0){R(\"sending diagnostics\",JSON.stringify($));const j={uri:this.currentUri,diagnostics:$.map((J)=>{return J.source=\"helix-gpt\",J})};if(this.send({method:P.PublishDiagnostics,params:j}),N>0)setTimeout(()=>{this.send({method:P.PublishDiagnostics,params:{uri:this.currentUri,diagnostics:[]}})},N)}resetDiagnostics(){this.send({method:P.PublishDiagnostics,params:{uri:this.currentUri,diagnostics:[]}})}async receiveLine($){try{const N=JSON.parse($.split(\"\\r\\n\")[2].split(\"Content-Length\")[0]);if(![P.DidChange,P.DidOpen].includes(N.method))R(\"received request:\",JSON.stringify(N));this.emitter.emit(N.method,N)}catch(N){R(\"failed to parse line:\",N.message,$)}}async start(){for await(let $ of Bun.stdin.stream()){const N=Buffer.from($).toString();this.receiveLine(N)}}}var X={Service:d,Event:P,DiagnosticSeverity:H};var q=async($,N,j)=>{R(\"sending completion request\",JSON.stringify(j));const J=await fetch($,{method:\"POST\",headers:N,body:JSON.stringify(j)});if(!J.ok)throw R(\"completion error\",J.status,await J.text()),new Error(\"request error with status code \"+J.status);return J},r=async($,N,j)=>{return(await(await q($,N,j)).json())?.choices?.map((z)=>z.message?.content)},s=async($,N,j)=>{const z=(await(await q($,N,j)).text()).split(\"\\n\").map((_)=>_.slice(5)).map((_)=>{try{return JSON.parse(_).choices[0]}catch(W){return null}}).filter((_)=>_).reduce(function(_,W){return _[W.index]=_[W.index]||[],_[W.index].push(W),_},Object.create(null));return Object.values(z).map((_)=>_.map((W)=>W.text).join(\"\"))},w={stream:s,standard:r};var U,n=($,N,j)=>{const J=new RegExp(`\\`\\`\\`${j}([\\\\s\\\\S]*?)\\`\\`\\``,\"g\");let O;const z=[];while((O=J.exec(N))!==null)z.push(O[0]);const W=z[0].replace(`// FILEPATH: ${$.replace(\"file://\",\"\")}\\n`,\"\").split(\"\\n\");return W.slice(1,W.length-1).join(\"\\n\")+\"\\n\"},p={openai:async($,N,j,J=3)=>{const O=[{role:\"system\",content:K.openaiContext.replace(\"<languageId>\",j)+\"\\n\\n\"+`End of file context:\\n\\n${$.contentAfter}`},{role:\"user\",content:`Start of file context:\\n\\n${$.contentBefore}`}],z={model:K.openaiModel,max_tokens:parseInt(K.openaiMaxTokens),n:J,temperature:1,top_p:0.7,frequency_penalty:1,presence_penalty:2,messages:O},_={Authorization:`Bearer ${K.openaiKey}`,\"Content-Type\":\"application/json\"};return await w.standard(K.openaiEndpoint,_,z)},copilot:async($,N,j,J=3)=>{const O=C(U);if(!O?.exp||parseInt(O.exp)<=L()){R(\"refreshing copilot token\");const W=await fetch(\"https://api.github.com/copilot_internal/v2/token\",{headers:{Authorization:`Bearer ${K.copilotApiKey}`}});if(!W.ok)throw R(\"failed to refresh copilot token\",W.status,await W.text()),new Error(\"failed to refresh copilot token: \"+W.status);const{token:I}=await W.json();U=I,R(\"updated token\",I)}const z={\"Content-Type\":\"application/json; charset=utf-8\",\"User-Agent\":\"GithubCopilot/1.155.0\",Authorization:`Bearer ${U}`,\"Editor-Plugin-Version\":\"copilot/1.155.0\",\"Editor-Version\":\"vscode/1.85.1\",\"Openai-Intent\":\"copilot-ghost\",\"Openai-Organization\":\"github-copilot\",\"VScode-MachineId\":G(64),\"VScode-SessionId\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(25),\"X-Request-Id\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(12),\"Accept-Encoding\":\"gzip,deflate,br\",Accept:\"*/*\"},_={extra:{language:j,next_indent:0,prompt_tokens:500,suffix_tokens:400,trim_by_indentation:!0},max_tokens:500,n:J,nwo:\"app\",prompt:`// Path: ${N.replace(\"file://\",\"\")}\\n${$.contentBefore}`,stop:[\"\\n\\n\"],stream:!0,suffix:$.contentAfter,temperature:J>1?0.4:0,top_p:1};try{return await w.stream(\"https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions\",z,_)}catch(W){throw R(\"copilot request failed: \"+W.message),W}}},x={copilot:async($,N,j,J)=>{const O=C(U);if(!O?.exp||parseInt(O.exp)<=L()){R(\"refreshing copilot token\");const I=await fetch(\"https://api.github.com/copilot_internal/v2/token\",{headers:{Authorization:`Bearer ${K.copilotApiKey}`}});if(!I.ok)throw R(\"failed to refresh copilot token\",I.status,await I.text()),new Error(\"failed to refresh copilot token: \"+I.status);const{token:Y}=await I.json();U=Y,R(\"updated token\",Y)}const _={intent:!0,max_tokens:7909,model:\"gpt-3.5-turbo\",n:1,stream:!1,temperature:0.1,top_p:1,messages:[{content:`You are an AI programming assistant.\\nWhen asked for your name, you must respond with \\\"GitHub Copilot\\\".\\nFollow the user's requirements carefully & to the letter.\\n- Each code block starts with \\`\\`\\` and // FILEPATH.\\n- You always answer with ${J} code.\\n- When the user asks you to document something, you must answer in the form of a ${J} code block.\\nYour expertise is strictly limited to software development topics.\\nFor questions not related to software development, simply give a reminder that you are an AI programming assistant.\\nKeep your answers short and impersonal.`,role:\"system\"},{content:`I have the following code in the selection:\\n\\`\\`\\`${J}\\n// FILEPATH: ${j.replace(\"file://\",\"\")}\\n${N}`,role:\"user\"},{content:$,role:\"user\"}]},W={\"Content-Type\":\"application/json; charset=utf-8\",\"User-Agent\":\"GitHubCopilotChat/0.8.0\",Authorization:`Bearer ${U}`,\"Editor-Plugin-Version\":\"copilot-chat/0.8.0\",\"Editor-Version\":\"vscode/1.83.1\",\"Openai-Intent\":\"conversation-panel\",\"Openai-Organization\":\"github-copilot\",\"VScode-MachineId\":G(64),\"VScode-SessionId\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(25),\"X-Request-Id\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(12),\"Accept-Encoding\":\"gzip,deflate,br\",Accept:\"*/*\",Connection:\"close\"};try{const I=await w.standard(K.copilotEndpoint+\"/chat/completions\",W,_);return R(\"got copilot chat result:\",I),n(j,I,J)}catch(I){throw R(\"copilot request failed: \"+I.message),I}}},u=async($,N,j,J)=>{if(!x[K.handler])throw R(\"chat handler does not exist\"),new Error(`chat handler: ${K.handler} does not exist`);try{return R(\"running chat handler:\",K.handler),await x[K.handler]($,N,j,J)}catch(O){throw R(\"chat failed\",O.message),new Error(\"Chat failed: \"+O.message)}},l=async($,N,j=3)=>{if(!p[K.handler])throw R(\"completion handler does not exist\"),new Error(`completion handler: ${K.handler} does not exist`);try{return R(\"running completion handler:\",K.handler),v(await p[K.handler]($,N,j))}catch(J){throw R(\"completion failed\",J.message),new Error(\"Completion failed: \"+J.message)}};var t=async()=>{const $=new X.Service({capabilities:{codeActionProvider:!0,executeCommandProvider:{commands:b.map((j)=>j.key)},completionProvider:{resolveProvider:!1,triggerCharacters:[\"{\",\"(\",\")\",\"=\",\">\",\" \",\",\",\":\",\".\",\"<\",\"/\"]},textDocumentSync:{change:2}}});$.on(X.Event.ExecuteCommand,async({ctx:j,request:J})=>{const{command:O}=J.params,{range:z,query:_}=J.params.arguments[0];j.sendDiagnostics([{message:`Executing ${O}...`,range:z,severity:X.DiagnosticSeverity.Information}],1e4);const W=j.getContentFromRange(z);try{var I=await u(_,W,j.currentUri,j.language)}catch(Y){return R(\"chat failed\",Y.message),j.sendDiagnostics([{message:Y.message,severity:X.DiagnosticSeverity.Error,range:z}],1e4)}R(\"received chat result:\",I),j.send({method:X.Event.ApplyEdit,id:J.id,params:{label:O,edit:{changes:{[j.currentUri]:[{range:z,newText:I}]}}}}),j.resetDiagnostics()}),$.on(X.Event.CodeAction,({ctx:j,request:J})=>{j.send({id:J.id,result:b.map((O)=>({title:O.label,kind:\"quickfix\",diagnostics:[],command:{title:O.label,command:O.key,arguments:[{range:J.params.range,query:O.query}]}}))})}),$.on(X.Event.Completion,async({ctx:j,request:J})=>{const O=j.contentVersion;S(\"completion\",()=>{N({ctx:j,request:J,lastContentVersion:O})},200)});const N=async({ctx:j,request:J,lastContentVersion:O})=>{const z=()=>{j.resetDiagnostics(),j.send({id:J.id,result:{isIncomplete:!1,items:[]}})};if(j.contentVersion>O)return R(\"skipping because content is stale\",j.contentVersion,\">\",O),z();const{lastCharacter:_,lastLine:W,templatedContent:I,contentBefore:Y,contentAfter:F}=await h(j.contents,J.params.position.line,J.params.position.character),{triggerCharacters:M}=j.capabilities.completionProvider;if(!M.includes(_))return R(\"skipping\",_,\"not in\",M),z();R(\"calling completion event\",j.contentVersion,\"<\",O),j.sendDiagnostics([{message:\"Fetching completion...\",severity:X.DiagnosticSeverity.Information,range:{start:{line:J.params.position.line,character:0},end:{line:J.params.position.line+1,character:0}}}],1e4);try{var V=await l({contentBefore:Y,contentAfter:F},j.currentUri,j.language)}catch(Z){return j.sendDiagnostics([{message:Z.message,severity:X.DiagnosticSeverity.Error,range:{start:{line:J.params.position.line,character:0},end:{line:J.params.position.line+1,character:0}}}],1e4)}const B=V?.map((Z)=>{if(Z.startsWith(W.trim()))Z=Z.slice(W.trim().length);const m=Z.split(\"\\n\"),A=J.params.position.line+m.length-1;let k=m.slice(-1)[0].length;if(A==J.params.position.line)k+=J.params.position.character;return{label:Z.split(\"\\n\")[0],kind:1,preselect:!0,detail:Z,insertText:Z,insertTextFormat:1,additionalTextEdits:[{newText:\"\",range:{start:{line:A,character:k},end:{line:A,character:200}}}]}});j.send({id:J.id,result:{isIncomplete:!0,items:B}}),j.resetDiagnostics()};await $.start()};try{await t()}catch($){R(\"main error\",$)}\n"
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- " ^\n"
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- "TypeError: undefined is not an object (evaluating 'z.substring')\n"
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- " at positionalUpdate (/home/xou/helix-gpt.js:2:10299)\n"
2024-01-26T23:34:12.827 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:9645\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at forEach (:1:21)\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:9574\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:9678\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:10856\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:10930\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at emit (node:events:154:95)\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at /home/xou/helix-gpt.js:2:12470\n"
2024-01-26T23:34:12.828 helix_lsp::transport [ERROR] gpt err <- " at receiveLine (/home/xou/helix-gpt.js:2:12546)\n"
2024-01-26T23:34:13.612 helix_lsp::transport [ERROR] gpt err <- "1 | // @bun\n"
2024-01-26T23:34:13.612 helix_lsp::transport [ERROR] gpt err <- "2 | import i from\"events\";import{appendFileSync as a} from\"fs\";import{parseArgs as c} from\"util\";var D={openai:\"Continue the input code from the language <languageId>. Only respond with code.\",copilot:\"<languageId> completions. Only respond with code.\"};var b=[{key:\"generateDocs\",label:\"Generate documentation\",query:\"Add documentation to this code.\"},{key:\"improveCode\",label:\"Improve code\",query:\"Improve this code.\"},{key:\"refactorFromComment\",label:\"Refactor code from a comment\",query:\"Refactor this code based on the comment.\"}];var f=($)=>{const N=new URLSearchParams($);return Object.fromEntries(N.entries())},g=async()=>{const $=await fetch(\"https://github.com/login/device/code?client_id=Iv1.b507a08c87ecfe98&scope=read:user\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"}});if(!$.ok)throw new Error(`fetchDeviceCode failed: ${$.status} ${await $.text()}`);return f(await $.text())},E=async()=>{const $=await g();console.log(`Visit: ${$.verification_uri} in your browser and enter: ${$.user_code}`);while(!0){await new Promise((J)=>setTimeout(J,5000));const N=await fetch(`https://github.com/login/oauth/access_token?client_id=Iv1.b507a08c87ecfe98&device_code=${$.device_code}&grant_type=urn:ietf:params:oauth:grant-type:device_code`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"}}),j=f(await N.text());if(j?.access_token?.length){console.log(\"\\n\\nGot token:\",j.access_token,\"\\n\\n\",\"Store this in the COPILOT_API_KEY environment variable\");break}console.log(\"Waiting for user authorization...\")}};var{values:Q}=c({args:Bun.argv,options:{logFile:{type:\"string\",default:Bun.env.LOG_FILE},handler:{type:\"string\",default:Bun.env.HANDLER??\"openai\"},openaiKey:{type:\"string\",default:Bun.env.OPENAI_API_KEY},openaiContext:{type:\"string\",default:Bun.env.OPENAI_CONTEXT?.length?Bun.env.OPENAI_CONTEXT:D.openai},openaiModel:{type:\"string\",default:Bun.env.OPENAI_MODEL??\"gpt-3.5-turbo-16k\"},openaiMaxTokens:{type:\"string\",default:Bun.env.OPENAI_MAX_TOKENS??\"7000\"},openaiEndpoint:{type:\"string\",default:Bun.env.OPENAI_ENDPOINT??\"https://api.openai.com/v1/chat/completions\"},copilotEndpoint:{type:\"string\",default:Bun.env.GITHUB_ENDPOINT??\"https://api.githubcopilot.com\"},copilotContext:{type:\"string\",default:Bun.env.COPILOT_CONTEXT?.length?Bun.env.COPILOT_CONTEXT:D.copilot},copilotModel:{type:\"string\",default:Bun.env.COPILOT_MODEL??\"gpt-3.5-turbo\"},copilotApiKey:{type:\"string\",default:Bun.env.COPILOT_API_KEY},authCopilot:{type:\"boolean\",default:!1}},strict:!0,allowPositionals:!0});if(Q.authCopilot)await E(),process.exit(0);if(!Q.openaiKey?.length&&!Q.copilotApiKey?.length)throw R(\"no handler key provided\"),new Error(\"no handler key provided\");var K=Q;import o from\"crypto\";var T={},S=($,N,j)=>{if(T[$])clearTimeout(T[$]);T[$]=setTimeout(N,j)};var G=($)=>{return o.randomBytes($/2).toString(\"hex\")},h=async($,N,j)=>{const J=$?.split(\"\\n\").slice(0,N+1);J[J.length-1]=J[J.length-1].split(\"\").slice(0,j).join(\"\");const O=J[J.length-1],z=J.join(\"\\n\"),_=$?.split(\"\\n\").slice(N+1).join(\"\\n\"),W=z.slice(-1),I=`${z}<BEGIN_COMPLETION>\\n${_}`;return{contentBefore:z,contentAfter:_,lastCharacter:W,templatedContent:I,lastLine:O}},R=(...$)=>{if(!K.logFile)return;if(Bun.env.TEST_RUNNER)console.log(y(...$));else a(K.logFile,y(...$)+\"\\n\\n\")},y=(...$)=>{let N=[];return $.forEach((j)=>{N.push(j),N.push(\"|\")}),N=N.slice(0,N.length-1),[\"APP\",(new Date()).toISOString(),\"-->\",...N].join(\" \")},v=($)=>{return Array.from(new Set($))},C=($)=>{if(!$?.length)return{};const N={},j=$.split(\";\");for(let J of j){const[O,z]=J.split(\"=\");N[O]=z}return N},L=()=>{return Math.floor(Date.now()/1000)};var P;(function(F){F[\"DidOpen\"]=\"textDocument/didOpen\";F[\"DidChange\"]=\"textDocument/didChange\";F[\"Completion\"]=\"textDocument/completion\";F[\"CodeAction\"]=\"textDocument/codeAction\";F[\"ApplyEdit\"]=\"workspace/applyEdit\";F[\"ExecuteCommand\"]=\"workspace/executeCommand\";F[\"Initialize\"]=\"initialize\";F[\"Shutdown\"]=\"shutdown\";F[\"Exit\"]=\"exit\";F[\"PublishDiagnostics\"]=\"textDocument/publishDiagnostics\"})(P||(P={}));var H;(function(O){O[O[\"Error\"]=1]=\"Error\";O[O[\"Warning\"]=2]=\"Warning\";O[O[\"Information\"]=3]=\"Information\";O[O[\"Hint\"]=4]=\"Hint\"})(H||(H={}));class d{emitter;capabilities;currentUri;contentVersion;language;contents;constructor({capabilities:$}){this.emitter=new i,this.capabilities=$,this.contentVersion=0,this.contents=\"\",this.registerDefault()}registerDefault(){this.on(P.Initialize,async({ctx:$})=>{$.send({method:P.Initialize,id:0,result:{capabilities:this.capabilities}})}),this.on(P.DidOpen,({ctx:$,request:N})=>{$.currentUri=N.params.textDocument.uri,$.contents=N.params.textDocument.text,$.language=N.params.textDocument.languageId,$.contentVersion=0}),this.on(P.Shutdown,()=>{R(\"received shutdown request\"),process.exit(0)}),this.on(P.DidChange,async({ctx:$,request:N})=>{N.params.contentChanges.forEach((j)=>{this.positionalUpdate(j.text,j.range)}),$.contentVersion=N.params.textDocument.version})}getContentFromRange($){R(\"getting content from range\",JSON.stringify($),this.contents);const{start:N,end:j}=$;return this.contents.split(\"\\n\").slice(N.line,j.line+1).join(\"\\n\")}positionalUpdate($,N){const j=this.contents.split(\"\\n\"),J=N.start.line,O=N.end.line,z=j[J],_=j[O],W=z.substring(0,N.start.character),I=_.substring(N.end.character),Y=[W+$+I],F=j.reduce((M,V,B)=>{if(B<J||B>O)M.push(V);else if(B===J)M.push(Y[0]);return M},[]);this.contents=F.join(\"\\n\")}on($,N){const j=this;this.emitter.on($,async(J)=>{try{N({ctx:j,request:J})}catch(O){R(\"error in event\",JSON.stringify(J),O.message)}})}send({method:$,id:N,result:j,params:J}){if(j===null)return;const O=JSON.stringify({jsonrpc:\"2.0\",method:$,id:N,result:j,params:J});console.log(`Content-Length: ${O.length}\\r\\n\\r\\n${O}`),R(\"sent request\",O)}sendDiagnostics($,N=0){R(\"sending diagnostics\",JSON.stringify($));const j={uri:this.currentUri,diagnostics:$.map((J)=>{return J.source=\"helix-gpt\",J})};if(this.send({method:P.PublishDiagnostics,params:j}),N>0)setTimeout(()=>{this.send({method:P.PublishDiagnostics,params:{uri:this.currentUri,diagnostics:[]}})},N)}resetDiagnostics(){this.send({method:P.PublishDiagnostics,params:{uri:this.currentUri,diagnostics:[]}})}async receiveLine($){try{const N=JSON.parse($.split(\"\\r\\n\")[2].split(\"Content-Length\")[0]);if(![P.DidChange,P.DidOpen].includes(N.method))R(\"received request:\",JSON.stringify(N));this.emitter.emit(N.method,N)}catch(N){R(\"failed to parse line:\",N.message,$)}}async start(){for await(let $ of Bun.stdin.stream()){const N=Buffer.from($).toString();this.receiveLine(N)}}}var X={Service:d,Event:P,DiagnosticSeverity:H};var q=async($,N,j)=>{R(\"sending completion request\",JSON.stringify(j));const J=await fetch($,{method:\"POST\",headers:N,body:JSON.stringify(j)});if(!J.ok)throw R(\"completion error\",J.status,await J.text()),new Error(\"request error with status code \"+J.status);return J},r=async($,N,j)=>{return(await(await q($,N,j)).json())?.choices?.map((z)=>z.message?.content)},s=async($,N,j)=>{const z=(await(await q($,N,j)).text()).split(\"\\n\").map((_)=>_.slice(5)).map((_)=>{try{return JSON.parse(_).choices[0]}catch(W){return null}}).filter((_)=>_).reduce(function(_,W){return _[W.index]=_[W.index]||[],_[W.index].push(W),_},Object.create(null));return Object.values(z).map((_)=>_.map((W)=>W.text).join(\"\"))},w={stream:s,standard:r};var U,n=($,N,j)=>{const J=new RegExp(`\\`\\`\\`${j}([\\\\s\\\\S]*?)\\`\\`\\``,\"g\");let O;const z=[];while((O=J.exec(N))!==null)z.push(O[0]);const W=z[0].replace(`// FILEPATH: ${$.replace(\"file://\",\"\")}\\n`,\"\").split(\"\\n\");return W.slice(1,W.length-1).join(\"\\n\")+\"\\n\"},p={openai:async($,N,j,J=3)=>{const O=[{role:\"system\",content:K.openaiContext.replace(\"<languageId>\",j)+\"\\n\\n\"+`End of file context:\\n\\n${$.contentAfter}`},{role:\"user\",content:`Start of file context:\\n\\n${$.contentBefore}`}],z={model:K.openaiModel,max_tokens:parseInt(K.openaiMaxTokens),n:J,temperature:1,top_p:0.7,frequency_penalty:1,presence_penalty:2,messages:O},_={Authorization:`Bearer ${K.openaiKey}`,\"Content-Type\":\"application/json\"};return await w.standard(K.openaiEndpoint,_,z)},copilot:async($,N,j,J=3)=>{const O=C(U);if(!O?.exp||parseInt(O.exp)<=L()){R(\"refreshing copilot token\");const W=await fetch(\"https://api.github.com/copilot_internal/v2/token\",{headers:{Authorization:`Bearer ${K.copilotApiKey}`}});if(!W.ok)throw R(\"failed to refresh copilot token\",W.status,await W.text()),new Error(\"failed to refresh copilot token: \"+W.status);const{token:I}=await W.json();U=I,R(\"updated token\",I)}const z={\"Content-Type\":\"application/json; charset=utf-8\",\"User-Agent\":\"GithubCopilot/1.155.0\",Authorization:`Bearer ${U}`,\"Editor-Plugin-Version\":\"copilot/1.155.0\",\"Editor-Version\":\"vscode/1.85.1\",\"Openai-Intent\":\"copilot-ghost\",\"Openai-Organization\":\"github-copilot\",\"VScode-MachineId\":G(64),\"VScode-SessionId\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(25),\"X-Request-Id\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(12),\"Accept-Encoding\":\"gzip,deflate,br\",Accept:\"*/*\"},_={extra:{language:j,next_indent:0,prompt_tokens:500,suffix_tokens:400,trim_by_indentation:!0},max_tokens:500,n:J,nwo:\"app\",prompt:`// Path: ${N.replace(\"file://\",\"\")}\\n${$.contentBefore}`,stop:[\"\\n\\n\"],stream:!0,suffix:$.contentAfter,temperature:J>1?0.4:0,top_p:1};try{return await w.stream(\"https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions\",z,_)}catch(W){throw R(\"copilot request failed: \"+W.message),W}}},x={copilot:async($,N,j,J)=>{const O=C(U);if(!O?.exp||parseInt(O.exp)<=L()){R(\"refreshing copilot token\");const I=await fetch(\"https://api.github.com/copilot_internal/v2/token\",{headers:{Authorization:`Bearer ${K.copilotApiKey}`}});if(!I.ok)throw R(\"failed to refresh copilot token\",I.status,await I.text()),new Error(\"failed to refresh copilot token: \"+I.status);const{token:Y}=await I.json();U=Y,R(\"updated token\",Y)}const _={intent:!0,max_tokens:7909,model:\"gpt-3.5-turbo\",n:1,stream:!1,temperature:0.1,top_p:1,messages:[{content:`You are an AI programming assistant.\\nWhen asked for your name, you must respond with \\\"GitHub Copilot\\\".\\nFollow the user's requirements carefully & to the letter.\\n- Each code block starts with \\`\\`\\` and // FILEPATH.\\n- You always answer with ${J} code.\\n- When the user asks you to document something, you must answer in the form of a ${J} code block.\\nYour expertise is strictly limited to software development topics.\\nFor questions not related to software development, simply give a reminder that you are an AI programming assistant.\\nKeep your answers short and impersonal.`,role:\"system\"},{content:`I have the following code in the selection:\\n\\`\\`\\`${J}\\n// FILEPATH: ${j.replace(\"file://\",\"\")}\\n${N}`,role:\"user\"},{content:$,role:\"user\"}]},W={\"Content-Type\":\"application/json; charset=utf-8\",\"User-Agent\":\"GitHubCopilotChat/0.8.0\",Authorization:`Bearer ${U}`,\"Editor-Plugin-Version\":\"copilot-chat/0.8.0\",\"Editor-Version\":\"vscode/1.83.1\",\"Openai-Intent\":\"conversation-panel\",\"Openai-Organization\":\"github-copilot\",\"VScode-MachineId\":G(64),\"VScode-SessionId\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(25),\"X-Request-Id\":G(8)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(4)+\"-\"+G(12),\"Accept-Encoding\":\"gzip,deflate,br\",Accept:\"*/*\",Connection:\"close\"};try{const I=await w.standard(K.copilotEndpoint+\"/chat/completions\",W,_);return R(\"got copilot chat result:\",I),n(j,I,J)}catch(I){throw R(\"copilot request failed: \"+I.message),I}}},u=async($,N,j,J)=>{if(!x[K.handler])throw R(\"chat handler does not exist\"),new Error(`chat handler: ${K.handler} does not exist`);try{return R(\"running chat handler:\",K.handler),await x[K.handler]($,N,j,J)}catch(O){throw R(\"chat failed\",O.message),new Error(\"Chat failed: \"+O.message)}},l=async($,N,j=3)=>{if(!p[K.handler])throw R(\"completion handler does not exist\"),new Error(`completion handler: ${K.handler} does not exist`);try{return R(\"running completion handler:\",K.handler),v(await p[K.handler]($,N,j))}catch(J){throw R(\"completion failed\",J.message),new Error(\"Completion failed: \"+J.message)}};var t=async()=>{const $=new X.Service({capabilities:{codeActionProvider:!0,executeCommandProvider:{commands:b.map((j)=>j.key)},completionProvider:{resolveProvider:!1,triggerCharacters:[\"{\",\"(\",\")\",\"=\",\">\",\" \",\",\",\":\",\".\",\"<\",\"/\"]},textDocumentSync:{change:2}}});$.on(X.Event.ExecuteCommand,async({ctx:j,request:J})=>{const{command:O}=J.params,{range:z,query:_}=J.params.arguments[0];j.sendDiagnostics([{message:`Executing ${O}...`,range:z,severity:X.DiagnosticSeverity.Information}],1e4);const W=j.getContentFromRange(z);try{var I=await u(_,W,j.currentUri,j.language)}catch(Y){return R(\"chat failed\",Y.message),j.sendDiagnostics([{message:Y.message,severity:X.DiagnosticSeverity.Error,range:z}],1e4)}R(\"received chat result:\",I),j.send({method:X.Event.ApplyEdit,id:J.id,params:{label:O,edit:{changes:{[j.currentUri]:[{range:z,newText:I}]}}}}),j.resetDiagnostics()}),$.on(X.Event.CodeAction,({ctx:j,request:J})=>{j.send({id:J.id,result:b.map((O)=>({title:O.label,kind:\"quickfix\",diagnostics:[],command:{title:O.label,command:O.key,arguments:[{range:J.params.range,query:O.query}]}}))})}),$.on(X.Event.Completion,async({ctx:j,request:J})=>{const O=j.contentVersion;S(\"completion\",()=>{N({ctx:j,request:J,lastContentVersion:O})},200)});const N=async({ctx:j,request:J,lastContentVersion:O})=>{const z=()=>{j.resetDiagnostics(),j.send({id:J.id,result:{isIncomplete:!1,items:[]}})};if(j.contentVersion>O)return R(\"skipping because content is stale\",j.contentVersion,\">\",O),z();const{lastCharacter:_,lastLine:W,templatedContent:I,contentBefore:Y,contentAfter:F}=await h(j.contents,J.params.position.line,J.params.position.character),{triggerCharacters:M}=j.capabilities.completionProvider;if(!M.includes(_))return R(\"skipping\",_,\"not in\",M),z();R(\"calling completion event\",j.contentVersion,\"<\",O),j.sendDiagnostics([{message:\"Fetching completion...\",severity:X.DiagnosticSeverity.Information,range:{start:{line:J.params.position.line,character:0},end:{line:J.params.position.line+1,character:0}}}],1e4);try{var V=await l({contentBefore:Y,contentAfter:F},j.currentUri,j.language)}catch(Z){return j.sendDiagnostics([{message:Z.message,severity:X.DiagnosticSeverity.Error,range:{start:{line:J.params.position.line,character:0},end:{line:J.params.position.line+1,character:0}}}],1e4)}const B=V?.map((Z)=>{if(Z.startsWith(W.trim()))Z=Z.slice(W.trim().length);const m=Z.split(\"\\n\"),A=J.params.position.line+m.length-1;let k=m.slice(-1)[0].length;if(A==J.params.position.line)k+=J.params.position.character;return{label:Z.split(\"\\n\")[0],kind:1,preselect:!0,detail:Z,insertText:Z,insertTextFormat:1,additionalTextEdits:[{newText:\"\",range:{start:{line:A,character:k},end:{line:A,character:200}}}]}});j.send({id:J.id,result:{isIncomplete:!0,items:B}}),j.resetDiagnostics()};await $.start()};try{await t()}catch($){R(\"main error\",$)}\n"
2024-01-26T23:34:13.612 helix_lsp::transport [ERROR] gpt err <- " ^\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment