@@ -125,6 +125,17 @@ indentation offset."
125
125
(defvar copilot--opened-buffers nil
126
126
" List of buffers that have been opened in Copilot." )
127
127
128
+ ; ;
129
+ ; ; jsonrpc
130
+ ; ;
131
+
132
+ (defun copilot--jsonrpc-version ()
133
+ " Return the jsonrpc version."
134
+ (let* ((desc (package-get-descriptor 'jsonrpc ))
135
+ (vlist (package-desc-version desc))
136
+ (version (package-version-join vlist)))
137
+ version))
138
+
128
139
; ;
129
140
; ; agent
130
141
; ;
@@ -174,22 +185,27 @@ indentation offset."
174
185
(call-process copilot-node-executable nil standard-output nil " --version" ))
175
186
(s-trim)
176
187
(s-chop-prefix " v" )
177
- (string-to-number ))))
188
+ (string-to-number )))
189
+ (old-jsonrpc (version< (copilot--jsonrpc-version) " 1.0.23" )))
178
190
(cond ((< node-version 18 )
179
191
(user-error " Node 18+ is required but found %s" node-version))
180
192
(t
181
193
(setq copilot--connection
182
- (make-instance 'jsonrpc-process-connection
183
- :name " copilot"
184
- :events-buffer-config `(:size , copilot-log-max )
185
- :notification-dispatcher #'copilot--handle-notification
186
- :process (make-process :name " copilot agent"
187
- :command (list copilot-node-executable
188
- (concat copilot--base-dir " /dist/agent.js" ))
189
- :coding 'utf-8-emacs-unix
190
- :connection-type 'pipe
191
- :stderr (get-buffer-create " *copilot stderr*" )
192
- :noquery t )))
194
+ (funcall #'make-instance
195
+ 'jsonrpc-process-connection
196
+ :name " copilot"
197
+ (if old-jsonrpc :events-buffer-scrollback-size
198
+ :events-buffer-config )
199
+ (if old-jsonrpc copilot-log-max
200
+ `(:size , copilot-log-max ))
201
+ :notification-dispatcher #'copilot--handle-notification
202
+ :process (make-process :name " copilot agent"
203
+ :command (list copilot-node-executable
204
+ (concat copilot--base-dir " /dist/agent.js" ))
205
+ :coding 'utf-8-emacs-unix
206
+ :connection-type 'pipe
207
+ :stderr (get-buffer-create " *copilot stderr*" )
208
+ :noquery t )))
193
209
(message " Copilot agent started. " )
194
210
(copilot--request 'initialize '(:capabilities (:workspace (:workspaceFolders t ))))
195
211
(copilot--async-request 'setEditorInfo
0 commit comments