-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b2d1eb9
Showing
21 changed files
with
2,722 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/naming-convention": "warn", | ||
"@typescript-eslint/semi": "warn", | ||
"curly": "warn", | ||
"eqeqeq": "warn", | ||
"no-throw-literal": "warn", | ||
"semi": "off" | ||
}, | ||
"ignorePatterns": [ | ||
"out", | ||
"dist", | ||
"**/*.d.ts" | ||
] | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
out | ||
dist | ||
node_modules | ||
.vscode-test/ | ||
*.vsix |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"] | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/dist/**/*.js" | ||
], | ||
"preLaunchTask": "${defaultBuildTask}" | ||
}, | ||
{ | ||
"name": "Extension Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}", | ||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/**/*.js", | ||
"${workspaceFolder}/dist/**/*.js" | ||
], | ||
"preLaunchTask": "tasks: watch-tests" | ||
} | ||
] | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false, // set this to true to hide the "out" folder with the compiled JS files | ||
"dist": false // set this to true to hide the "dist" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true, // set this to false to include "out" folder in search results | ||
"dist": true // set this to false to include "dist" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off" | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$ts-webpack-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never", | ||
"group": "watchers" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"type": "npm", | ||
"script": "watch-tests", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never", | ||
"group": "watchers" | ||
}, | ||
"group": "build" | ||
}, | ||
{ | ||
"label": "tasks: watch-tests", | ||
"dependsOn": [ | ||
"npm: watch", | ||
"npm: watch-tests" | ||
], | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/** | ||
node_modules/** | ||
src/** | ||
.gitignore | ||
.yarnrc | ||
webpack.config.js | ||
vsc-extension-quickstart.md | ||
**/tsconfig.json | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
--ignore-engines true |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Change Log | ||
|
||
All notable changes to the "chatgpt" extension will be documented in this file. | ||
|
||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||
|
||
## [Unreleased] | ||
|
||
- Initial release |
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ChatGPT for VSCode | ||
|
||
This is a VSCode extension that allows you to use ChatGPT right within VSCode. | ||
|
||
**Warning:** Right now, this is more of a proof of concept! | ||
|
||
## How it works | ||
|
||
The extension makes use of this [ChatGPT package](https://github.com/transitive-bullshit/chatgpt-api), which uses Playwright/a headless chrome in order to login and communicate with ChatGPT. | ||
|
||
In order to use this with VSCode, it's best to run the extension in debug mode once. | ||
On the initial start, you will need to authenticate with OpenAI - this requires you to login via the headless Chrome. | ||
|
||
When you are successfully authenticated, you can turn on headless mode so that the browser won't be visible. |
This file contains 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//@ts-check | ||
|
||
// This script will be run within the webview itself | ||
// It cannot access the main VS Code APIs directly. | ||
(function () { | ||
const vscode = acquireVsCodeApi(); | ||
|
||
let response = ''; | ||
|
||
// Handle messages sent from the extension to the webview | ||
window.addEventListener("message", (event) => { | ||
const message = event.data; | ||
switch (message.type) { | ||
case "addResponse": { | ||
response = message.value; | ||
setResponse(); | ||
break; | ||
} | ||
case "clearResponse": { | ||
response = ''; | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
function setResponse() { | ||
var converter = new showdown.Converter(); | ||
html = converter.makeHtml(response); | ||
document.getElementById("response").innerHTML = html; | ||
|
||
var preCodeBlocks = document.querySelectorAll("pre code"); | ||
for (var i = 0; i < preCodeBlocks.length; i++) { | ||
preCodeBlocks[i].classList.add( | ||
"p-4", | ||
"my-4", | ||
"block" | ||
); | ||
} | ||
var codeBlocks = document.querySelectorAll('code'); | ||
for (var i = 0; i < codeBlocks.length; i++) { | ||
// Check if innertext starts with "Copy code" | ||
if (codeBlocks[i].innerText.startsWith("Copy code")) { | ||
codeBlocks[i].innerText = codeBlocks[i].innerText.replace("Copy code", ""); | ||
} | ||
|
||
codeBlocks[i].classList.add("p-1", "inline-flex", "max-w-full", "overflow-hidden", "border", "rounded-sm", "cursor-pointer"); | ||
|
||
codeBlocks[i].addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
vscode.postMessage({ | ||
type: 'codeSelected', | ||
value: this.innerText | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
document.getElementById('prompt-input').addEventListener('keyup', function (e) { | ||
if (e.keyCode === 13) { | ||
vscode.postMessage({ | ||
type: 'prompt', | ||
value: this.value | ||
}); | ||
} | ||
}); | ||
})(); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"name": "chatgpt", | ||
"displayName": "chatgpt", | ||
"description": "", | ||
"version": "0.0.1", | ||
"engines": { | ||
"vscode": "^1.73.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onCommand:chatgpt.ask", | ||
"onView:chatgpt.chatView" | ||
], | ||
"main": "./dist/extension.js", | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "chatgpt.ask", | ||
"title": "Ask ChatGPT" | ||
} | ||
], | ||
"viewsContainers": { | ||
"activitybar": [ | ||
{ | ||
"id": "chatgpt", | ||
"title": "ChatGPT", | ||
"icon": "resources/icon.png" | ||
} | ||
] | ||
}, | ||
"views": { | ||
"chatgpt": [ | ||
{ | ||
"type": "webview", | ||
"id": "chatgpt.chatView", | ||
"name": "ChatGPT" | ||
} | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "yarn run package", | ||
"compile": "webpack", | ||
"watch": "webpack --watch", | ||
"package": "webpack --mode production --devtool hidden-source-map", | ||
"compile-tests": "tsc -p . --outDir out", | ||
"watch-tests": "tsc -p . -w --outDir out", | ||
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint", | ||
"lint": "eslint src --ext ts", | ||
"test": "node ./out/test/runTest.js" | ||
}, | ||
"devDependencies": { | ||
"@types/glob": "^8.0.0", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "16.x", | ||
"@types/vscode": "^1.73.0", | ||
"@typescript-eslint/eslint-plugin": "^5.45.0", | ||
"@typescript-eslint/parser": "^5.45.0", | ||
"@vscode/test-electron": "^2.2.0", | ||
"eslint": "^8.28.0", | ||
"glob": "^8.0.3", | ||
"mocha": "^10.1.0", | ||
"ts-loader": "^9.4.1", | ||
"typescript": "^4.9.3", | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"chatgpt": "^0.4.1" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.