Skip to content

Commit 2c5305a

Browse files
feature: cmd() to perform custom task
1 parent 588e938 commit 2c5305a

File tree

7 files changed

+39
-1817
lines changed

7 files changed

+39
-1817
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ CodeCharm is your intelligent VS Code extension that generates **inline code com
3232
4. `gemini-2.5-pro`
3333
- 🔐 **Secure API Key Storage** in VS Code settings.
3434
- 🧠 Uses your **API key**, no sharing required.
35+
- 🆕 **Execute `cmd()` instructions inside your code**
36+
- Add a line like: `cmd(import pandas)` at the top of your code block.
37+
- CodeCharm will first apply your instruction (e.g., add imports, modify setup)
38+
and then generate inline comments or refactor the code.
39+
> **Tip:** You can add a `cmd()` instruction before running CodeCharm
40+
> Example:
41+
> ```js
42+
> cmd(import pandas)
43+
> df = pd.DataFrame({...})
44+
> ```
45+
> This will automatically insert the required import before processing.
46+
3547
3648
---
3749
@@ -45,6 +57,14 @@ To use CodeCharm, you'll need your **own Google Gemini API key**:
4557
4. Press `Ctrl + Win + J` or `Ctrl + Win + G` for the first time.
4658
5. A secure input box will appear → paste your key there.
4759
6. It will be saved automatically in:
60+
> **Tip:** You can add a `cmd()` instruction before running CodeCharm
61+
> Example:
62+
> ```js
63+
> cmd(import pandas)
64+
> df = pd.DataFrame({...})
65+
> ```
66+
> This will automatically insert the required import before processing.
67+
4868
**`CodeCharm.zetaFlux`** in your VS Code settings.
4969
5070
> 🔐 Your key stays local & secure — not shared or stored remotely.
@@ -58,6 +78,14 @@ To use CodeCharm, you'll need your **own Google Gemini API key**:
5878
- `Ctrl + Win + J` → for inline comments
5979
- `Ctrl + Win + G` → to refactor code
6080
3. CodeCharm will generate and replace your selection with an improved version.
81+
> **Tip:** You can add a `cmd()` instruction before running CodeCharm
82+
> Example:
83+
> ```js
84+
> cmd(import pandas)
85+
> df = pd.DataFrame({...})
86+
> ```
87+
> This will automatically insert the required import before processing.
88+
6189
6290
---
6391

SHOWCASE/showcase.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import random # Import random module 💯
2+
import pandas as pd # Use pandas, as requested 🧐
23
numbers = [random.randint(1, 100) for _ in range(300)]
34
even_numbers = [] # Initialize even list 👍
45
odd_numbers = [] # Initialize odd list 🤔
@@ -9,5 +10,5 @@
910
else:
1011
odd_numbers.append(number) # Add to odd list 💯
1112

12-
print(even_numbers) # Print even numbers 😎
13-
print(odd_numbers) # Print odd numbers 😮
13+
print(pd.Series(even_numbers)) # Print even series 😎
14+
print(pd.Series(odd_numbers)) # Print odd series 😮

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "CodeCharm",
33
"displayName": "CodeCharm",
44
"description": "AI-powered code comment generator for VS Code using Gemini",
5-
"version": "0.4.2",
5+
"version": "0.4.5",
66
"publisher": "DeveloperPuneet",
77
"icon": "images/Icon.png",
88
"engines": {

src/extension.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,16 @@ async function activate(context) {
9999
vscode.window.showInformationMessage("💫 CodeCharm loaded!"); // Show startup message
100100
}
101101

102+
Additional_functionalies = `Before doing anything, check if the provided code contains a pattern like cmd(...).
103+
If found, treat the text inside cmd() as an instruction for modifying the code first.
104+
Example: cmd(import pandas library in this code)
105+
→ Then you have to Add "import pandas as pd" at the beginning of the code, then continue.`
106+
102107
// 🧠 Get Gemini Comment or Refactor
103108
async function getCommentFromGemini(code, mode = "comment") {
104109
let prompt = mode === "comment"
105-
? `You are a strict code-commenting assistant. Only add inline comments (4–5 words max) using emojis. Do NOT explain or return markdown. Return ONLY the modified code.\n\n${code}`
106-
: `Refactor this code for readability. Rename unclear variables, break down complex parts. DO NOT return explanation. ONLY the cleaned code.\n\n${code}`;
110+
? `You are a strict code-commenting assistant. Only add inline comments (4–5 words max) using emojis. Do NOT explain or return markdown. Return ONLY the modified code. ${Additional_functionalies} \n\n${code}`
111+
: `Refactor this code for readability. Rename unclear variables, break down complex parts. DO NOT return explanation. ONLY the cleaned code. ${Additional_functionalies} \n\n${code}`;
107112

108113
const apiKey = await getOrPromptAPIKey();
109114
if (!apiKey) return null;

webapp/Icon.png

-1020 KB
Binary file not shown.

0 commit comments

Comments
 (0)