leona / helix-gpt

Code assistant language server for Helix with support for Copilot/OpenAI/Codeium/Ollama
MIT License
287 stars 19 forks source link

Not getting completions #6

Closed leo-mangold closed 5 months ago

leo-mangold commented 5 months ago

Hey this is amazing, I just can't get it to work. I'm a helix noob tho so please excuse my incompetence. This is what I did:

When i run bun run ~/bin/helix-gpt.js a process is running without errors and no output.

I also tried to run :lsp-workspace-commands in helix to see if its running but I only see this:

Screenshot 2024-01-26 at 15 15 03

Here are my files:

~/.config/helix/languages.toml

[language-server.gpt]
command = "bun"
args = ["run", "~/bin/helix-gpt.js --handler "]

[language-server.ts]
command = "typescript-language-server"
args = ["--stdio"]
language-id = "javascript"

[language-server.efm-lsp-prettier]
command = "efm-langserver"

[language-server.efm-lsp-prettier.config]
documentFormatting = true
languages = { typescript = [ { formatCommand ="prettier --stdin-filepath ${INPUT}", formatStdin = true } ] }

[[language]]
name = "typescript"
language-servers = [
    { name = "efm-lsp-prettier", only-features = [ "format" ] },
    "ts",
    "gpt"
]

~/.config/helix/config.toml

theme = "amberwood"

[editor]
line-number = "relative"
auto-save = true
color-modes = true

[editor.cursor-shape]
insert = "bar"
normal = "block"
select = "underline"

[editor.file-picker]
hidden = true

[keys.normal]
"ret" = "expand_selection"
"backspace" = "shrink_selection"

~/bin/.env

COPILOT_API_KEY=...
HANDLER=copilot

What am I missing here? Do you know some good ways to check if a lsp is connected and running, or to test the lsp directly?

Thanks in advance!

leona commented 5 months ago

Hey so I think the problem is with the args below

[language-server.gpt]
command = "bun"
args = ["run", "~/bin/helix-gpt.js --handler "]

It should be

[language-server.gpt]
command = "bun"
args = ["run", "~/bin/helix-gpt.js", "--handler", "copilot", "--copilotApiKey", "123"]

But if your env vars are setup correctly you can leave them out entirely. Also just placing that .env file in the same directory as helix-gpt.js won't do it, they need to be exported in .bashrc or something.

And completions are triggered automatically by one of the triggerCharacters below. A dropdown should come up you can scroll through. triggerCharacters: ["{", "(", ")", "=", ">", " ", ",", ":", ".", "<", "/"]

TiLopes commented 5 months ago

I also can't seem to get it working. In my case i want to use it in rust.

here's languages.toml

[language-server.gpt]
command = "bun"
args = ["run", "~/helix-gpt.js", "--handler", "copilot", "--copilotApiKey", "copilot_key"]

[[language]]
name = "rust"
language-servers = [ "rust-analyzer", "gpt" ]

my .zshenv:

export COPILOT_API_KEY="copilot_key"

there are no completions whatsoever regardless of the trigger characters. I noticed this error appearing in the status line: Async job failed: protocol error: ServerError(-32801): content modified

leona commented 5 months ago

I also can't seem to get it working. In my case i want to use it in rust.

here's languages.toml

[language-server.gpt]
command = "bun"
args = ["run", "~/helix-gpt.js", "--handler", "copilot", "--copilotApiKey", "copilot_key"]

[[language]]
name = "rust"
language-servers = [ "rust-analyzer", "gpt" ]

my .zshenv:

export COPILOT_API_KEY="copilot_key"

there are no completions whatsoever regardless of the trigger characters. I noticed this error appearing in the status line: Async job failed: protocol error: ServerError(-32801): content modified

Config looks good. Could you run helix in verbose mode with -v and set the helix-gpt arg --logFile. Then post the outputs of those 2 files.

TiLopes commented 5 months ago

I looked at the log and it seems it can't find the file for some reason? But I have it in my home directory image

The lines in question in helix.log:

2024-01-26T22:50:22.798 helix_lsp::transport [INFO] gpt -> {"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":28575,"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}
2024-01-26T22:50:22.803 helix_lsp::transport [ERROR] gpt err <- "error: Script not found \"~/helix-gpt.js\"\n"
2024-01-26T22:50:22.803 helix_lsp::transport [ERROR] gpt err: <- StreamClosed

The --logFile does not do anything for some reason.

TiLopes commented 5 months ago

I got more info! It seems it does not work if I use a relative file path and I must use an absolute one like /home/user/helix-gpt.js.

helix.log:

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"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "TypeError: undefined is not an object (evaluating 'z.substring')\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at positionalUpdate (/home/xou/helix-gpt.js:2:10299)\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:9645\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at forEach (:1:21)\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:9574\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:9678\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10856\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10930\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at emit (node:events:154:95)\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:12470\n"
2024-01-26T23:34:13.613 helix_lsp::transport [ERROR] gpt err <- "      at receiveLine (/home/xou/helix-gpt.js:2:12546)\n"

helix-gpt.log:

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
leona commented 5 months ago

I looked at the log and it seems it can't find the file for some reason? But I have it in my home directory image

The lines in question in helix.log:

2024-01-26T22:50:22.798 helix_lsp::transport [INFO] gpt -> {"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":28575,"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}
2024-01-26T22:50:22.803 helix_lsp::transport [ERROR] gpt err <- "error: Script not found \"~/helix-gpt.js\"\n"
2024-01-26T22:50:22.803 helix_lsp::transport [ERROR] gpt err: <- StreamClosed

The --logFile does not do anything for some reason.

Yea the home directory is probably different because of the user it's under. Is it working now?

TiLopes commented 5 months ago

@leona Using an absolute path gives me the following errors:

Here are the logs: https://gist.github.com/TiLopes/80d6c19a0ac85e73005987f507399594

It seems parsing of something is causing an error though I can't tell why/what since the code has been minified.

TiLopes commented 5 months ago

If I call lsp-workspace-command I get the following: image Though they do not work. I get the following error when I select generateDocs:

2024-01-27T11:58:59.892 helix_lsp::transport [ERROR] gpt err <- "1 | // @bun\n"
2024-01-27T11:58:59.892 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-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ^\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "TypeError: Right side of assignment cannot be destructured\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:24454\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:24936\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10856\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10930\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at emit (node:events:154:95)\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:12470\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at receiveLine (/home/xou/helix-gpt.js:2:12546)\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:12887\n"
leona commented 5 months ago

If I call lsp-workspace-command I get the following: image Though they do not work. I get the following error when I select generateDocs:

2024-01-27T11:58:59.892 helix_lsp::transport [ERROR] gpt err <- "1 | // @bun\n"
2024-01-27T11:58:59.892 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-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ^\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "TypeError: Right side of assignment cannot be destructured\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:24454\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:24936\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10856\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:10930\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at emit (node:events:154:95)\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:12470\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at receiveLine (/home/xou/helix-gpt.js:2:12546)\n"
2024-01-27T11:58:59.893 helix_lsp::transport [ERROR] gpt err <- "      at /home/xou/helix-gpt.js:2:12887\n"

That error doesn't say much alright. You could try clone the repo and build it without minifying to see what's happening maybe.

leo-mangold commented 5 months ago

I updated the file path to be absolute and added logging.

Here are my helix logs:

2024-01-27T22:01:03.280 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2024-01-27T22:01:42.110 helix_view::editor [ERROR] Failed to initialize the language servers for `source.ts` - `efm-lsp-prettier` { cannot find binary path }
2024-01-27T22:01:42.199 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2024-01-27T22:03:20.967 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2024-01-27T22:04:01.401 helix_lsp::transport [ERROR] ts err: <- StreamClosed
2024-01-27T22:04:01.405 helix_lsp::transport [ERROR] gpt err: <- StreamClosed
2024-01-27T22:04:01.405 helix_lsp::client [WARN] language server failed to terminate gracefully - server closed the stream
2024-01-27T22:04:01.405 helix_lsp::transport [ERROR] gpt err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })
2024-01-27T22:04:07.038 helix_view::editor [ERROR] editor error: no such command: 'log'

And here my helix logs:

APP 2024-01-27T21:01:42.214Z --> 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":11789,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}

APP 2024-01-27T21:01:42.216Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-27T21:01:42.217Z --> failed to parse line: | JSON Parse error: Unable to parse JSON string | Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 2926

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}

APP 2024-01-27T21:04:01.400Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":1}

APP 2024-01-27T21:04:01.403Z --> received shutdown request

Does this say anything useful?

leona commented 5 months ago

I updated the file path to be absolute and added logging.

Here are my helix logs:

2024-01-27T22:01:03.280 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2024-01-27T22:01:42.110 helix_view::editor [ERROR] Failed to initialize the language servers for `source.ts` - `efm-lsp-prettier` { cannot find binary path }
2024-01-27T22:01:42.199 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2024-01-27T22:03:20.967 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2024-01-27T22:04:01.401 helix_lsp::transport [ERROR] ts err: <- StreamClosed
2024-01-27T22:04:01.405 helix_lsp::transport [ERROR] gpt err: <- StreamClosed
2024-01-27T22:04:01.405 helix_lsp::client [WARN] language server failed to terminate gracefully - server closed the stream
2024-01-27T22:04:01.405 helix_lsp::transport [ERROR] gpt err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })
2024-01-27T22:04:07.038 helix_view::editor [ERROR] editor error: no such command: 'log'

And here my helix logs:

APP 2024-01-27T21:01:42.214Z --> 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":11789,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}

APP 2024-01-27T21:01:42.216Z --> sent request | {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}

APP 2024-01-27T21:01:42.217Z --> failed to parse line: | JSON Parse error: Unable to parse JSON string | Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 2926

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}

APP 2024-01-27T21:04:01.400Z --> received request: | {"jsonrpc":"2.0","method":"shutdown","id":1}

APP 2024-01-27T21:04:01.403Z --> received shutdown request

Does this say anything useful?

Is that definitely the helix log file with verbose mode hx -v example.file? Seems like helix-gpt is exiting, and it only shows why in verbose mode.

leo-mangold commented 5 months ago

My bad I used the helix log-open command, since I couldn't find the file. The command you should use is hx -v --log helix.log

Here is the log file

2024-01-27T22:32:14.807 helix_lsp::transport [INFO] ts -> {"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":15497,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}
2024-01-27T22:32:14.808 helix_lsp::transport [INFO] gpt -> {"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":15497,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}
2024-01-27T22:32:14.908 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt <- {"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using Typescript version (bundled) 5.3.3 from path \"/Users/leo/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js\""}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"triggerCharacters":[".","\"","'","/","@","<"],"resolveProvider":true},"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"codeLensProvider":{"resolveProvider":true},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"hoverProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":false,"renameProvider":{"prepareProvider":true},"referencesProvider":true,"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]},"workspaceSymbolProvider":true,"implementationProvider":true,"typeDefinitionProvider":true,"foldingRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"legend":{"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"],"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"]},"full":true,"range":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"}},{"scheme":"file","pattern":{"glob":"**","matches":"folder"}}]}}}}}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","/","@","<"]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":false,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"full":true,"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"]},"range":true},"signatureHelpProvider":{"retriggerCharacters":[")"],"triggerCharacters":["(",",","<"]},"textDocumentSync":2,"typeDefinitionProvider":true,"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"},"scheme":"file"},{"pattern":{"glob":"**","matches":"folder"},"scheme":"file"}]}}},"workspaceSymbolProvider":true}}
2024-01-27T22:32:14.968 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Using Typescript version (bundled) 5.3.3 from path \"/Users/leo/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js\"" }
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}
2024-01-27T22:32:14.969 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/typescriptVersion","params":{"version":"5.3.3","source":"bundled"}}
2024-01-27T22:32:14.969 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2024-01-27T22:32:15.137 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","id":0,"method":"window/workDoneProgress/create","params":{"token":"d8460e61-5556-4630-b1af-025f62166591"}}
2024-01-27T22:32:15.137 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","result":null,"id":0}
2024-01-27T22:32:15.138 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"d8460e61-5556-4630-b1af-025f62166591","value":{"kind":"begin","title":"Initializing JS/TS language features…"}}}
2024-01-27T22:32:16.931 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"d8460e61-5556-4630-b1af-025f62166591","value":{"kind":"end"}}}
2024-01-27T22:32:16.989 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","diagnostics":[]}}
2024-01-27T22:32:17.042 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","diagnostics":[]}}
leona commented 5 months ago

My bad I used the helix log-open command, since I couldn't find the file. The command you should use is hx -v --log helix.log

Here is the log file

2024-01-27T22:32:14.807 helix_lsp::transport [INFO] ts -> {"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":15497,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}
2024-01-27T22:32:14.808 helix_lsp::transport [INFO] gpt -> {"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":15497,"rootPath":"/Users/leo/dev/lean/dexter","rootUri":"file:///Users/leo/dev/lean/dexter","workspaceFolders":[{"name":"dexter","uri":"file:///Users/leo/dev/lean/dexter"}]},"id":0}
2024-01-27T22:32:14.908 helix_lsp::transport [INFO] gpt <- {"jsonrpc":"2.0","method":"initialize","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt <- {"capabilities":{"completionProvider":{"resolveProvider":false,"triggerCharacters":["{","(",")","=",">"," ",",",":",".","<","/"]},"textDocumentSync":{"change":2}}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-27T22:32:14.909 helix_lsp::transport [INFO] gpt -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using Typescript version (bundled) 5.3.3 from path \"/Users/leo/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js\""}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"triggerCharacters":[".","\"","'","/","@","<"],"resolveProvider":true},"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"codeLensProvider":{"resolveProvider":true},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"hoverProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":false,"renameProvider":{"prepareProvider":true},"referencesProvider":true,"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]},"workspaceSymbolProvider":true,"implementationProvider":true,"typeDefinitionProvider":true,"foldingRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"legend":{"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"],"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"]},"full":true,"range":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"}},{"scheme":"file","pattern":{"glob":"**","matches":"folder"}}]}}}}}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","/","@","<"]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":false,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"full":true,"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"]},"range":true},"signatureHelpProvider":{"retriggerCharacters":[")"],"triggerCharacters":["(",",","<"]},"textDocumentSync":2,"typeDefinitionProvider":true,"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"},"scheme":"file"},{"pattern":{"glob":"**","matches":"folder"},"scheme":"file"}]}}},"workspaceSymbolProvider":true}}
2024-01-27T22:32:14.968 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Using Typescript version (bundled) 5.3.3 from path \"/Users/leo/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js\"" }
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-01-27T22:32:14.968 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"import { clsx, type ClassValue } from \"clsx\";\nimport { cubicOut } from \"svelte/easing\";\nimport type { TransitionConfig } from \"svelte/transition\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n\tclassGroups: {\n\t\ttext: [\"text-xxs\", \"text-xs\", \"text-sm\", \"text-md\", \"text-lg\", \"text-lg\"],\n\t},\n});\n\n\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn customTwMerge(clsx(inputs));\n}\n\n/**\n * A utility function to easily build conditional lists\n *\n * @example\n * list(\"a\", \"b\", false && [\"x\", \"y\"], \"c\", [\"d\", \"e\"], true && \"f\") // [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n */\nexport function list<T>(...arraysOrBooleans: (T[] | false | T)[]): T[] {\n\tconst result: T[] = [];\n\n\tfor (const item of arraysOrBooleans) {\n\t\tif (Array.isArray(item)) {\n\t\t\tresult.push(...item);\n\t\t} else if (item !== false) {\n\t\t\tresult.push(item);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// thanks copilot!\nexport function debounce(fn: (...args: any[]) => any, delay: number) {\n\tlet timeoutID: ReturnType<typeof setTimeout> | null = null;\n\treturn function (this: any, ...args: any[]) {\n\t\tclearTimeout(timeoutID!);\n\t\ttimeoutID = setTimeout(() => fn.apply(this, args), delay);\n\t};\n}\ntype FlyAndScaleParams = {\n\ty?: number;\n\tx?: number;\n\tstart?: number;\n\tduration?: number;\n};\n\nexport const flyAndScale = (\n\tnode: Element,\n\tparams: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },\n): TransitionConfig => {\n\tconst style = getComputedStyle(node);\n\tconst transform = style.transform === \"none\" ? \"\" : style.transform;\n\n\tconst scaleConversion = (valueA: number, scaleA: [number, number], scaleB: [number, number]) => {\n\t\tconst [minA, maxA] = scaleA;\n\t\tconst [minB, maxB] = scaleB;\n\n\t\tconst percentage = (valueA - minA) / (maxA - minA);\n\t\tconst valueB = percentage * (maxB - minB) + minB;\n\n\t\treturn valueB;\n\t};\n\n\tconst styleToString = (style: Record<string, number | string | undefined>): string => {\n\t\treturn Object.keys(style).reduce((str, key) => {\n\t\t\tif (style[key] === undefined) return str;\n\t\t\treturn str + `${key}:${style[key]};`;\n\t\t}, \"\");\n\t};\n\n\treturn {\n\t\tduration: params.duration ?? 200,\n\t\tdelay: 0,\n\t\tcss: (t) => {\n\t\t\tconst y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);\n\t\t\tconst x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);\n\t\t\tconst scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);\n\n\t\t\treturn styleToString({\n\t\t\t\ttransform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,\n\t\t\t\topacity: t,\n\t\t\t});\n\t\t},\n\t\teasing: cubicOut,\n\t};\n};\n","uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","version":0}}}
2024-01-27T22:32:14.969 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/typescriptVersion","params":{"version":"5.3.3","source":"bundled"}}
2024-01-27T22:32:14.969 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2024-01-27T22:32:15.137 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","id":0,"method":"window/workDoneProgress/create","params":{"token":"d8460e61-5556-4630-b1af-025f62166591"}}
2024-01-27T22:32:15.137 helix_lsp::transport [INFO] ts -> {"jsonrpc":"2.0","result":null,"id":0}
2024-01-27T22:32:15.138 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"d8460e61-5556-4630-b1af-025f62166591","value":{"kind":"begin","title":"Initializing JS/TS language features…"}}}
2024-01-27T22:32:16.931 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"d8460e61-5556-4630-b1af-025f62166591","value":{"kind":"end"}}}
2024-01-27T22:32:16.989 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","diagnostics":[]}}
2024-01-27T22:32:17.042 helix_lsp::transport [INFO] ts <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/leo/dev/lean/dexter/frontend/src/lib/utils.ts","diagnostics":[]}}

Everything looks fine in those logs. I don't see any completion requests or didChange events though. Did you try edit anything? Or manually trigger it wiith ctrl+x

leo-mangold commented 5 months ago

Okey now it works. Just had to turn it off and on again and press try some more changes in the code. Your lsp is amazing thank you!!

leona commented 5 months ago

Okey now it works. Just had to turn it off and on again and press try some more changes in the code. Your lsp is amazing thank you!!

Ok great! I'll leave this open for another day, so if there's any other issues just pop them in here.

LeeeSe commented 5 months ago

2024-01-29T03:16:08.045 helix_lsp::transport [ERROR] gpt err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }) 2024-01-29T03:16:16.978 helix_lsp::transport [ERROR] rust-analyzer <- ServerError(-32801): content modified 2024-01-29T03:16:16.978 helix_lsp::transport [ERROR] rust-analyzer <- ServerError(-32801): content modified 2024-01-29T03:16:20.033 helix_lsp::transport [ERROR] Exiting gpt after unexpected error: Parse(Error("EOF while parsing a string", line: 1, column: 827)) 2024-01-29T03:23:36.061 helix_lsp::transport [ERROR] gpt err: <- StreamClosed 2024-01-29T03:24:00.336 helix_lsp::transport [ERROR] Exiting gpt after unexpected error: Parse(Error("EOF while parsing a string", line: 1, column: 570))

It looks like it's not getting the correct output from the copilot server and just exits the lsp. Could it be a problem with my network? I'm using a VPN

leona commented 5 months ago

2024-01-29T03:16:08.045 helix_lsp::transport [ERROR] gpt err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }) 2024-01-29T03:16:16.978 helix_lsp::transport [ERROR] rust-analyzer <- ServerError(-32801): content modified 2024-01-29T03:16:16.978 helix_lsp::transport [ERROR] rust-analyzer <- ServerError(-32801): content modified 2024-01-29T03:16:20.033 helix_lsp::transport [ERROR] Exiting gpt after unexpected error: Parse(Error("EOF while parsing a string", line: 1, column: 827)) 2024-01-29T03:23:36.061 helix_lsp::transport [ERROR] gpt err: <- StreamClosed 2024-01-29T03:24:00.336 helix_lsp::transport [ERROR] Exiting gpt after unexpected error: Parse(Error("EOF while parsing a string", line: 1, column: 570))

It looks like it's not getting the correct output from the copilot server and just exits the lsp. Could it be a problem with my network? I'm using a VPN

Could you try with 0.15 please

LeeeSe commented 5 months ago

The helix I just used was the latest version I compiled myself yesterday in the official repositories, just now I switched to version 23.10 and found that any problems are gone, I'm now using helix-gpt 0.14 , it's working fine, very much like it!

I'm going to switch to 0.15 and keep testing it, I'll come back with feedback if I have any problems!

Thank you so much for taking the time to do this, it has been a great motivation for me to migrate from neovim to helix!

leona commented 5 months ago

The helix I just used was the latest version I compiled myself yesterday in the official repositories, just now I switched to version 23.10 and found that any problems are gone, I'm now using helix-gpt 0.14 , it's working fine, very much like it!

I'm going to switch to 0.15 and keep testing it, I'll come back with feedback if I have any problems!

Thank you so much for taking the time to do this, it has been a great motivation for me to migrate from neovim to helix!

Awesome, glad to hear it's working! And yea any feedback is welcome.

Interesting the latest source compiled one didn't work, I'll keep that in mind.