Repository: VaibhavAcharya/code-gpt
Branch: master
Commit: f14d384a996e
Files: 12
Total size: 12.2 KB
Directory structure:
gitextract_24340zrr/
├── .eslintrc.js
├── .gitignore
├── .vscode/
│ ├── launch.json
│ └── tasks.json
├── .vscodeignore
├── README.md
├── package.json
├── src/
│ ├── extension.ts
│ └── utils/
│ ├── comments.ts
│ ├── email.ts
│ └── errors.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.js
================================================
/**@type {import('eslint').Linter.Config} */
// eslint-disable-next-line no-undef
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'semi': [2, "always"],
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
}
};
================================================
FILE: .gitignore
================================================
out
node_modules
.vscode-test/
*.vsix
vscode.d.ts
pnpm-lock.yaml
================================================
FILE: .vscode/launch.json
================================================
{
"version": "0.2.0",
"configurations": [{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
},
{
"name": "Run Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}
================================================
FILE: .vscode/tasks.json
================================================
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
================================================
FILE: .vscodeignore
================================================
.vscode/**
.vscode-test/**
out/test/**
out/**/*.map
src/**
.gitignore
tsconfig.json
vsc-extension-quickstart.md
tslint.json
================================================
FILE: README.md
================================================

# [Code-GPT](https://marketplace.visualstudio.com/items?itemName=vaibhavacharya.code-gpt-va) — Make sense of any code, anytime. 🚀
## Introduction 👋
Code-GPT is an extension for VS Code that provides you **instant explanations for your code** within the code editor using AI.
With Code-GPT, you can:
- 🧠 Get instant explanations for selected code in real-time
- 💡 Increase your coding understanding and efficiency
- ⏳ Save time and minimize frustration with clear code explanations
- 🔍 Improve your coding skills with in-depth code analysis
## Demo 📽
[](https://www.aiproducttools.com/images/codegpt/demo.mp4)
## Installation 📦
1. Open VS Code and click on the Extensions icon in the left sidebar
2. Search for "Code-GPT" in the Extensions Marketplace
3. Click on the Install button for "Code-GPT"
## How to Use Code-GPT 🛠
1. Select the code you want to understand in your VSCode editor
2. Open the Command Palette (press `Ctrl + Shift + P` or `Cmd + Shift + P` on Mac)
3. Type "Explain Selected Code" and select the command from the list
4. Enter your email address if prompted
5. Wait for the response and the explanation will be prepended to the selected code in your VSCode editor
Enjoy the instant and comprehensive code explanations with Code-GPT! 🎉
## Author ✏
- Twitter → [@VaibhavAcharya_](https://twitter.com/VaibhavAcharya_)
- Website → [vaibhavacharya.github.io](https://vaibhavacharya.github.io)
- GitHub → [VaibhavAcharya](https://github.com/VaibhavAcharya)
================================================
FILE: package.json
================================================
{
"name": "code-gpt-va",
"displayName": "Code-GPT — Make sense of any code, anytime. 🚀",
"description": "Provides you instant explanations for your code within the code editor using AI.",
"icon": "images/logo.png",
"galleryBanner": {
"color": "#000000",
"theme": "dark"
},
"version": "0.0.6",
"publisher": "vaibhavacharya",
"author": {
"name": "Vaibhav Acharya",
"email": "vaibhavacharya111@gmail.com",
"url": "https://www.twitter.com/VaibhavAcharya_"
},
"engines": {
"vscode": "^1.74.0"
},
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/VaibhavAcharya/code-gpt"
},
"bugs": {
"url": "https://github.com/VaibhavAcharya/code-gpt/issues"
},
"categories": [
"Machine Learning",
"Other"
],
"keywords": [
"ai",
"code",
"explanation",
"comments"
],
"activationEvents": [
"*"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "extension.commentSelectedCode",
"title": "Code-GPT → Comment Selected Code"
},
{
"command": "extension.explainSelectedCode",
"title": "Code-GPT → Explain Selected Code"
}
],
"menus": {
"editor/context": [
{
"command": "extension.commentSelectedCode",
"when": "editorHasSelection"
},
{
"command": "extension.explainSelectedCode",
"when": "editorHasSelection"
}
]
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint \"src/**/*.ts\"",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/vscode": "1.74.0",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"eslint": "^8.26.0",
"typescript": "^4.8.4"
},
"dependencies": {
"@octokit/rest": "^18.0.0",
"axios": "^1.3.2"
}
}
================================================
FILE: src/extension.ts
================================================
import { type ExtensionContext, window, commands } from "vscode";
import axios from "axios";
import { checkEmail } from "./utils/email";
import { displayError } from "./utils/errors";
import { languageSupportsComments, styleAsComment } from "./utils/comments";
// Function to handle the selected code
const commentSelectedCode = async (context: ExtensionContext) => {
// Check if the email has been saved or not
await checkEmail(context);
const email = await context.globalState.get("email");
if (!email) return displayError("noEmail");
// Grab the editor window
const editor = window.activeTextEditor;
if (!editor) return displayError("noEditor");
// Aquire the selected text
const selection = editor.selection;
const selectedText = editor.document.getText(selection);
if (!selectedText.length) return displayError("noSelection");
const lang = editor.document.languageId;
const isLanguageSupported = languageSupportsComments(lang);
if (!isLanguageSupported) return displayError("languageNotSupported");
// Send the selected code and email to the API
try {
const { data } = await axios.post("https://www.aiproducttools.com/api/codegpt", {
email,
input: selectedText,
lang,
});
if (!data.output) return displayError("serverSentNothing");
// Get the output from the API response
const output = data.output.trim();
// Wrap the output in a comment
const comment = styleAsComment(output, lang);
// Replace the selected text with the output
editor.edit((editBuilder) => {
editBuilder.insert(selection.start, `${comment}\n`);
});
} catch (error) {
console.error(error);
return displayError("unableToConnect");
}
};
// Function to handle the selected code
const explainSelectedCode = async (context: ExtensionContext) => {
// Check if the email has been saved or not
await checkEmail(context);
const email = await context.globalState.get("email");
if (!email) return displayError("noEmail");
// Grab the editor window
const editor = window.activeTextEditor;
if (!editor) return displayError("noEditor");
// Aquire the selected text
const selection = editor.selection;
const selectedText = editor.document.getText(selection);
if (!selectedText.length) return displayError("noSelection");
const lang = editor.document.languageId;
const isLanguageSupported = languageSupportsComments(lang);
if (!isLanguageSupported) return displayError("languageNotSupported");
// Send the selected code and email to the API
try {
const { data } = await axios.post("https://www.aiproducttools.com/api/codegpt", {
email,
input: selectedText,
lang,
});
if (!data.output) return displayError("serverSentNothing");
// Get the output from the API response
const output = data.output.trim();
// Show the output in a message
window.showInformationMessage(output)
} catch (error) {
console.error(error);
return displayError("unableToConnect");
}
};
// Register the "Explain Selected Code" command
export function activate(context: ExtensionContext) {
const registerComment = commands.registerCommand("extension.commentSelectedCode", () => commentSelectedCode(context));
const registerExplain = commands.registerCommand("extension.explainSelectedCode", () => explainSelectedCode(context));
context.subscriptions.push(registerComment);
context.subscriptions.push(registerExplain);
}
// Deactivate the extension
export function deactivate() {
return null;
}
================================================
FILE: src/utils/comments.ts
================================================
const singleLineCommentMap: Record<string, string> = {
abap: "--",
bat: "::",
bibtex: "%",
clojure: ";",
coffeescript: "#",
c: "//",
cpp: "//",
csharp: "//",
"cuda-cpp": "//",
diff: "//",
dockerfile: "#",
fsharp: "//",
"git-commit": "#",
"git-rebase": "#",
go: "//",
groovy: "//",
ini: ";",
java: "//",
javascript: "//",
javascriptreact: "//",
json: "//",
jsonc: "//",
latex: "%",
less: "/*",
lua: "--",
makefile: "#",
objectivec: "//",
objectivecpp: "//",
perl: "#",
perl6: "#",
php: "//",
plaintext: "//",
powershell: "#",
jade: "//",
pug: "//",
python: "#",
r: "#",
razor: "@*",
ruby: "#",
rust: "//",
sass: "//",
shaderlab: "//",
shellscript: "#",
sql: "--",
slim: "//",
stylus: "//",
swift: "//",
typescript: "//",
typescriptreact: "//",
tex: "%",
vb: "'",
yaml: "#",
};
const multiLineCommentMap: Record<string, [string, string]> = {
css: ["/*", "*/"],
handlebars: ["{{!--", "--}}"],
html: ["<!--", "-->"],
markdown: ["<!--", "-->"],
scss: ["/*", "*/"],
xml: ["<!--", "-->"],
xsl: ["<!--", "-->"],
};
export const styleAsComment = (text: string, lang: string) => {
const singleLineComment = singleLineCommentMap[lang];
const multiLineComment = multiLineCommentMap[lang];
if (!singleLineComment && !multiLineComment) return text;
if (singleLineComment) return `${singleLineComment} ${text}`;
if (multiLineComment) return `${multiLineComment[0]} ${text} ${multiLineComment[1]}`;
};
export const languageSupportsComments = (lang: string) => {
return !!singleLineCommentMap[lang] || !!multiLineCommentMap[lang];
};
================================================
FILE: src/utils/email.ts
================================================
import { type ExtensionContext, window } from "vscode";
export const checkEmail = async (context: ExtensionContext) => {
const email = await context.globalState.get("email");
// If the email has not been saved, ask the user for their email
if (!email) {
const newEmail = await window.showInputBox({
title: "Code-GPT",
placeHolder: "📧 Enter your email",
prompt: "To protect us from unlimited use. We won't spam your email, promise. 🤝",
validateInput: (value) => {
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!emailRegex.test(value)) {
return "Error: Invalid email. ☹";
}
return null;
},
});
await context.globalState.update("email", newEmail);
}
};
================================================
FILE: src/utils/errors.ts
================================================
import { window } from "vscode";
const errorMessages = {
noEditor: "Error: Editor not found! 😵",
noEmail: "Error: Email is required! It is to protect us from unlimited use. We won't spam your email, promise. 🤝",
noSelection: "Nothing selected. 😅",
languageNotSupported: "Error: Language not supported yet! 😵",
unableToConnect: "Error: Unable to connect to server! 💀",
serverSentNothing: "Server sent nothing! 🙃",
};
export const displayError = (error: keyof typeof errorMessages) => {
return window.showErrorMessage(errorMessages[error]);
};
================================================
FILE: tsconfig.json
================================================
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"outDir": "out",
"sourceMap": true,
"rootDir": "src",
"strict": true
},
"exclude": ["node_modules", ".vscode-test"]
}
gitextract_24340zrr/ ├── .eslintrc.js ├── .gitignore ├── .vscode/ │ ├── launch.json │ └── tasks.json ├── .vscodeignore ├── README.md ├── package.json ├── src/ │ ├── extension.ts │ └── utils/ │ ├── comments.ts │ ├── email.ts │ └── errors.ts └── tsconfig.json
SYMBOL INDEX (2 symbols across 1 files)
FILE: src/extension.ts
function activate (line 97) | function activate(context: ExtensionContext) {
function deactivate (line 105) | function deactivate() {
Condensed preview — 12 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (15K chars).
[
{
"path": ".eslintrc.js",
"chars": 507,
"preview": "/**@type {import('eslint').Linter.Config} */\n// eslint-disable-next-line no-undef\nmodule.exports = {\n\troot: true,\n\tparse"
},
{
"path": ".gitignore",
"chars": 65,
"preview": "out\nnode_modules\n.vscode-test/\n*.vsix\nvscode.d.ts\npnpm-lock.yaml\n"
},
{
"path": ".vscode/launch.json",
"chars": 696,
"preview": "{\n\t\"version\": \"0.2.0\",\n\t\"configurations\": [{\n\t\t\t\"name\": \"Run Extension\",\n\t\t\t\"type\": \"extensionHost\",\n\t\t\t\"request\": \"laun"
},
{
"path": ".vscode/tasks.json",
"chars": 258,
"preview": "{\n\t\"version\": \"2.0.0\",\n\t\"tasks\": [\n\t\t{\n\t\t\t\"type\": \"npm\",\n\t\t\t\"script\": \"watch\",\n\t\t\t\"problemMatcher\": \"$tsc-watch\",\n\t\t\t\"is"
},
{
"path": ".vscodeignore",
"chars": 123,
"preview": ".vscode/**\n.vscode-test/**\nout/test/**\nout/**/*.map\nsrc/**\n.gitignore\ntsconfig.json\nvsc-extension-quickstart.md\ntslint.j"
},
{
"path": "README.md",
"chars": 1620,
"preview": "\n\n# [Code-GPT](https://marketplace.visualstudio.com/i"
},
{
"path": "package.json",
"chars": 1854,
"preview": "{\n\t\"name\": \"code-gpt-va\",\n\t\"displayName\": \"Code-GPT — Make sense of any code, anytime. 🚀\",\n\t\"description\": \"Provides you"
},
{
"path": "src/extension.ts",
"chars": 3872,
"preview": "import { type ExtensionContext, window, commands } from \"vscode\";\r\nimport axios from \"axios\";\r\n\r\nimport { checkEmail } f"
},
{
"path": "src/utils/comments.ts",
"chars": 1782,
"preview": "const singleLineCommentMap: Record<string, string> = {\n abap: \"--\",\n bat: \"::\",\n bibtex: \"%\",\n clojure: \";\","
},
{
"path": "src/utils/email.ts",
"chars": 989,
"preview": "import { type ExtensionContext, window } from \"vscode\";\n\nexport const checkEmail = async (context: ExtensionContext) => "
},
{
"path": "src/utils/errors.ts",
"chars": 572,
"preview": "import { window } from \"vscode\";\n\nconst errorMessages = {\n noEditor: \"Error: Editor not found! 😵\",\n noEmail: \"Erro"
},
{
"path": "tsconfig.json",
"chars": 198,
"preview": "{\n\t\"compilerOptions\": {\n\t\t\"module\": \"commonjs\",\n\t\t\"target\": \"es2020\",\n\t\t\"outDir\": \"out\",\n\t\t\"sourceMap\": true,\n\t\t\"rootDir"
}
]
About this extraction
This page contains the full source code of the VaibhavAcharya/code-gpt GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 12 files (12.2 KB), approximately 3.7k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.