-
Notifications
You must be signed in to change notification settings - Fork 164
feat: Install server #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Install server #247
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8496da5
feat: Install server
jcs090218 0c35139
resolve conflict
jcs090218 388130b
Prompt to install server
jcs090218 ac30026
fix metadata
jcs090218 90a9051
check mismatch
jcs090218 683e27e
improve documentation a bit
jcs090218 56e8df5
Use warn instaed
jcs090218 82ef49d
Use straight up name
jcs090218 9a5791d
fix: Work on Unix systems
jcs090218 6c8a3fb
docs: Document copilot-version
jcs090218 228be50
Fix agent executable path for Linux
emil-vdw 32a7861
Improve formatting
emil-vdw 3fb251c
Only call callbacks when non-nil
emil-vdw 055f8f1
Merge branch 'main' of github.com:copilot-emacs/copilot.el into feat/…
emil-vdw 8379e61
Fix wrong copilot-installed-version Linux path
emil-vdw 25e683f
Merge pull request #2 from emil-vdw/install-server
jcs090218 57ab87b
Use bin instead
jcs090218 a4e4f43
Merge branch 'main' into feat/install-server
jcs090218 37259ea
fix: merge conflict
jcs090218 27dd6cc
Update readme.md
jcs090218 62f0d7a
Update readme.md
jcs090218 d7ab8df
Merge branch 'main' into feat/install-server
jcs090218 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,8 @@ indentation offset." | |
|
||
(defconst copilot--server-executable | ||
(if (eq system-type 'windows-nt) | ||
(f-join copilot-install-dir "node_modules" "copilot-node-server" "copilot" "dist" "agent.js") | ||
(f-join copilot-install-dir "node_modules" "copilot-node-server" "copilot" | ||
"bin" "copilot-node-server") | ||
(f-join copilot-install-dir "bin" "copilot-node-server")) | ||
"The dist directory containing agent.js file.") | ||
|
||
|
@@ -245,27 +246,27 @@ Please upgrade the server via `M-x copilot-reinstall-server`")) | |
"Login to Copilot." | ||
(interactive) | ||
(copilot--dbind | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest are indentation errors. |
||
(:status :user :userCode user-code :verificationUri verification-uri) | ||
(copilot--request 'signInInitiate '(:dummy "signInInitiate")) | ||
(when (s-equals-p status "AlreadySignedIn") | ||
(user-error "Already signed in as %s" user)) | ||
(if (display-graphic-p) | ||
(progn | ||
(gui-set-selection 'CLIPBOARD user-code) | ||
(read-from-minibuffer (format "Your one-time code %s is copied. Press \ | ||
(:status :user :userCode user-code :verificationUri verification-uri) | ||
(copilot--request 'signInInitiate '(:dummy "signInInitiate")) | ||
(when (s-equals-p status "AlreadySignedIn") | ||
(user-error "Already signed in as %s" user)) | ||
(if (display-graphic-p) | ||
(progn | ||
(gui-set-selection 'CLIPBOARD user-code) | ||
(read-from-minibuffer (format "Your one-time code %s is copied. Press \ | ||
ENTER to open GitHub in your browser. If your browser does not open \ | ||
automatically, browse to %s." user-code verification-uri)) | ||
(browse-url verification-uri) | ||
(read-from-minibuffer "Press ENTER if you finish authorizing.")) | ||
(read-from-minibuffer (format "First copy your one-time code: %s. Press ENTER to continue." user-code)) | ||
(read-from-minibuffer (format "Please open %s in your browser. Press ENTER if you finish authorizing." verification-uri))) | ||
(message "Verifying...") | ||
(condition-case err | ||
(copilot--request 'signInConfirm (list :userCode user-code)) | ||
(jsonrpc-error | ||
(user-error "Authentication failure: %s" (alist-get 'jsonrpc-error-message (cddr err))))) | ||
(copilot--dbind (:user) (copilot--request 'checkStatus '(:dummy "checkStatus")) | ||
(message "Authenticated as GitHub user %s." user)))) | ||
(browse-url verification-uri) | ||
(read-from-minibuffer "Press ENTER if you finish authorizing.")) | ||
(read-from-minibuffer (format "First copy your one-time code: %s. Press ENTER to continue." user-code)) | ||
(read-from-minibuffer (format "Please open %s in your browser. Press ENTER if you finish authorizing." verification-uri))) | ||
(message "Verifying...") | ||
(condition-case err | ||
(copilot--request 'signInConfirm (list :userCode user-code)) | ||
(jsonrpc-error | ||
(user-error "Authentication failure: %s" (alist-get 'jsonrpc-error-message (cddr err))))) | ||
(copilot--dbind (:user) (copilot--request 'checkStatus '(:dummy "checkStatus")) | ||
(message "Authenticated as GitHub user %s." user)))) | ||
|
||
(defun copilot-logout () | ||
"Logout from Copilot." | ||
|
@@ -489,20 +490,20 @@ automatically, browse to %s." user-code verification-uri)) | |
"Handle MSG of type METHOD." | ||
(when (eql method 'PanelSolution) | ||
(copilot--dbind (:completionText completion-text :score completion-score) msg | ||
(with-current-buffer "*copilot-panel*" | ||
(unless (member (secure-hash 'sha256 completion-text) | ||
(org-map-entries (lambda () (org-entry-get nil "SHA")))) | ||
(save-excursion | ||
(goto-char (point-max)) | ||
(insert "* Solution\n" | ||
" :PROPERTIES:\n" | ||
" :SCORE: " (number-to-string completion-score) "\n" | ||
" :SHA: " (secure-hash 'sha256 completion-text) "\n" | ||
" :END:\n" | ||
"#+BEGIN_SRC " copilot--panel-lang "\n" | ||
completion-text "\n#+END_SRC\n\n") | ||
(mark-whole-buffer) | ||
(org-sort-entries nil ?R nil nil "SCORE")))))) | ||
(with-current-buffer "*copilot-panel*" | ||
(unless (member (secure-hash 'sha256 completion-text) | ||
(org-map-entries (lambda () (org-entry-get nil "SHA")))) | ||
(save-excursion | ||
(goto-char (point-max)) | ||
(insert "* Solution\n" | ||
" :PROPERTIES:\n" | ||
" :SCORE: " (number-to-string completion-score) "\n" | ||
" :SHA: " (secure-hash 'sha256 completion-text) "\n" | ||
" :END:\n" | ||
"#+BEGIN_SRC " copilot--panel-lang "\n" | ||
completion-text "\n#+END_SRC\n\n") | ||
(mark-whole-buffer) | ||
(org-sort-entries nil ?R nil nil "SCORE")))))) | ||
(when (eql method 'PanelSolutionsDone) | ||
(message "Copilot: Finish synthesizing solutions.") | ||
(display-buffer "*copilot-panel*") | ||
|
@@ -677,34 +678,34 @@ Use TRANSFORM-FN to transform completion if provided." | |
"Show COMPLETION-DATA." | ||
(when (copilot--satisfy-display-predicates) | ||
(copilot--dbind | ||
(:text :uuid :docVersion doc-version | ||
:range (:start (:line :character start-char) | ||
:end (:character end-char))) | ||
completion-data | ||
(when (= doc-version copilot--doc-version) | ||
(save-excursion | ||
(save-restriction | ||
(widen) | ||
(let* ((p (point)) | ||
(goto-line! (lambda () | ||
(goto-char (point-min)) | ||
(forward-line (1- (+ line copilot--line-bias))))) | ||
(start (progn | ||
(funcall goto-line!) | ||
(forward-char start-char) | ||
(let* ((cur-line (buffer-substring-no-properties (point) (line-end-position))) | ||
(common-prefix-len (length (s-shared-start text cur-line)))) | ||
(setq text (substring text common-prefix-len)) | ||
(forward-char common-prefix-len) | ||
(point)))) | ||
(end (progn | ||
(funcall goto-line!) | ||
(forward-char end-char) | ||
(point))) | ||
(fixed-completion (copilot-balancer-fix-completion start end text))) | ||
(goto-char p) | ||
(pcase-let ((`(,start ,end ,balanced-text) fixed-completion)) | ||
(copilot--display-overlay-completion balanced-text uuid start end))))))))) | ||
(:text :uuid :docVersion doc-version | ||
:range (:start (:line :character start-char) | ||
:end (:character end-char))) | ||
completion-data | ||
(when (= doc-version copilot--doc-version) | ||
(save-excursion | ||
(save-restriction | ||
(widen) | ||
(let* ((p (point)) | ||
(goto-line! (lambda () | ||
(goto-char (point-min)) | ||
(forward-line (1- (+ line copilot--line-bias))))) | ||
(start (progn | ||
(funcall goto-line!) | ||
(forward-char start-char) | ||
(let* ((cur-line (buffer-substring-no-properties (point) (line-end-position))) | ||
(common-prefix-len (length (s-shared-start text cur-line)))) | ||
(setq text (substring text common-prefix-len)) | ||
(forward-char common-prefix-len) | ||
(point)))) | ||
(end (progn | ||
(funcall goto-line!) | ||
(forward-char end-char) | ||
(point))) | ||
(fixed-completion (copilot-balancer-fix-completion start end text))) | ||
(goto-char p) | ||
(pcase-let ((`(,start ,end ,balanced-text) fixed-completion)) | ||
(copilot--display-overlay-completion balanced-text uuid start end))))))))) | ||
|
||
(defun copilot--on-doc-focus (window) | ||
"Notify that the document has been focussed or opened." | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.