mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-16 12:59:37 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0abfab72a8 | ||
|
|
1eacc6ff74 | ||
|
|
031a2c5fc3 | ||
|
|
73c4a38da1 | ||
|
|
53acc0a79f | ||
|
|
62163dbc32 | ||
|
|
d225ff2596 | ||
|
|
ab5c393253 | ||
|
|
d6a73a1a7f | ||
|
|
5abb1fedd9 | ||
|
|
3b534cfce2 | ||
|
|
6bd906981b | ||
|
|
4f126641e4 | ||
|
|
2d63eaac58 | ||
|
|
f44dc28763 | ||
|
|
2c47349282 | ||
|
|
43c1c85efb |
@@ -10,4 +10,5 @@ vsc-extension-quickstart.md
|
|||||||
**/*.ts
|
**/*.ts
|
||||||
**/.vscode-test.*
|
**/.vscode-test.*
|
||||||
backup
|
backup
|
||||||
.claude
|
.claude
|
||||||
|
claude-code-chat-permissions-mcp/**
|
||||||
40
CHANGELOG.md
40
CHANGELOG.md
@@ -4,6 +4,46 @@ All notable changes to the "claude-code-chat" extension will be documented in th
|
|||||||
|
|
||||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||||
|
|
||||||
|
## [1.0.6] - 2025-08-26
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
- Fixed typo in codebase
|
||||||
|
- Removed priority settings that were no longer needed
|
||||||
|
|
||||||
|
### 🔧 Technical Improvements
|
||||||
|
- Moved script to separate file for better code organization
|
||||||
|
|
||||||
|
## [1.0.5] - 2025-07-30
|
||||||
|
|
||||||
|
### 🚀 Features Added
|
||||||
|
- **MCP Integration**: Added claude-code-chat-permissions-mcp folder for enhanced permission management
|
||||||
|
- **Message Persistence**: Save message in text box for better user experience
|
||||||
|
- **UI Improvements**: Always display history and new chat options
|
||||||
|
- **Input Enhancement**: Removed maxlength limit for custom command prompt textarea
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
- Fixed new chat functionality
|
||||||
|
- Fixed request start time isProcessing issue
|
||||||
|
- Fixed close and open conversation behavior
|
||||||
|
|
||||||
|
### 🔄 Merged Pull Requests
|
||||||
|
- Merged PR #87 from horatio-sans-serif/main
|
||||||
|
|
||||||
|
## [1.0.4] - 2025-01-22
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
- Fixed input text area overflow issue by adding `box-sizing: border-box` to prevent padding from extending beyond container width
|
||||||
|
- Fixed command parameter handling for `claude-code-chat.openChat` to properly handle both ViewColumn and Uri parameters from different invocation contexts
|
||||||
|
|
||||||
|
### 🔧 Technical Improvements
|
||||||
|
- Enhanced `show()` method to accept optional ViewColumn parameter with ViewColumn.Two as default
|
||||||
|
- Added proper type checking for command parameters to handle context menu invocations
|
||||||
|
- Improved webview panel positioning with flexible column parameter support
|
||||||
|
|
||||||
|
### 🎨 UI/UX Improvements
|
||||||
|
- Resolved text input container sizing issues that caused visual overflow
|
||||||
|
- Better input field styling consistency across different VS Code themes
|
||||||
|
|
||||||
## [1.0.0] - 2025-01-15
|
## [1.0.0] - 2025-01-15
|
||||||
|
|
||||||
### 🚀 Major Features Added
|
### 🚀 Major Features Added
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ Ditch the command line and experience Claude Code like never before. This extens
|
|||||||
💾 **Conversation History** - Automatic conversation history and session management
|
💾 **Conversation History** - Automatic conversation history and session management
|
||||||
🎨 **VS Code Native** - Claude Code integrated directly into VS Code with native theming and sidebar support
|
🎨 **VS Code Native** - Claude Code integrated directly into VS Code with native theming and sidebar support
|
||||||
🧠 **Plan and Thinking modes** - Plan First and configurable Thinking modes for better results
|
🧠 **Plan and Thinking modes** - Plan First and configurable Thinking modes for better results
|
||||||
⚡ **Smart File/Image Context and Custom Commands** - Reference any file, copy images or screenshots, and create custom commands
|
⚡ **Smart File/Image Context and Custom Commands** - Reference any file, paste images or screenshots and create custom commands
|
||||||
🤖 **Model Selection** - Choose between Opus, Sonnet, or Default based on your needs
|
🤖 **Model Selection** - Choose between Opus, Sonnet, or Default based on your needs
|
||||||
🐧 **WSL Support** - Full Windows Subsystem for Linux integration and compatibility
|
🐧 **Windows/WSL Support** - Full native Windows and WSL support
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
13954
claude-code-chat-permissions-mcp/mcp-permissions.js
Normal file
13954
claude-code-chat-permissions-mcp/mcp-permissions.js
Normal file
File diff suppressed because one or more lines are too long
212
claude-code-chat-permissions-mcp/mcp-permissions.ts
Normal file
212
claude-code-chat-permissions-mcp/mcp-permissions.ts
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||||
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
|
import { z } from "zod";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
|
const server = new McpServer({
|
||||||
|
name: "Claude Code Permissions MCP Server",
|
||||||
|
version: "0.0.1",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get permissions directory from environment
|
||||||
|
const PERMISSIONS_PATH = process.env.CLAUDE_PERMISSIONS_PATH;
|
||||||
|
if (!PERMISSIONS_PATH) {
|
||||||
|
console.error("CLAUDE_PERMISSIONS_PATH environment variable not set");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface WorkspacePermissions {
|
||||||
|
alwaysAllow: {
|
||||||
|
[toolName: string]: boolean | string[]; // true for all, or array of allowed commands/patterns
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWorkspacePermissionsPath(): string | null {
|
||||||
|
if (!PERMISSIONS_PATH) return null;
|
||||||
|
return path.join(PERMISSIONS_PATH, 'permissions.json');
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadWorkspacePermissions(): WorkspacePermissions {
|
||||||
|
const permissionsPath = getWorkspacePermissionsPath();
|
||||||
|
if (!permissionsPath || !fs.existsSync(permissionsPath)) {
|
||||||
|
return { alwaysAllow: {} };
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const content = fs.readFileSync(permissionsPath, 'utf8');
|
||||||
|
return JSON.parse(content);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error loading workspace permissions: ${error}`);
|
||||||
|
return { alwaysAllow: {} };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isAlwaysAllowed(toolName: string, input: any): boolean {
|
||||||
|
const permissions = loadWorkspacePermissions();
|
||||||
|
const toolPermission = permissions.alwaysAllow[toolName];
|
||||||
|
|
||||||
|
if (!toolPermission) return false;
|
||||||
|
|
||||||
|
// If it's true, always allow
|
||||||
|
if (toolPermission === true) return true;
|
||||||
|
|
||||||
|
// If it's an array, check for specific commands (mainly for Bash)
|
||||||
|
if (Array.isArray(toolPermission)) {
|
||||||
|
if (toolName === 'Bash' && input.command) {
|
||||||
|
const command = input.command.trim();
|
||||||
|
return toolPermission.some(allowedCmd => {
|
||||||
|
// Support exact match or pattern matching
|
||||||
|
if (allowedCmd.includes('*')) {
|
||||||
|
// Handle patterns like "npm i *" to match both "npm i" and "npm i something"
|
||||||
|
const baseCommand = allowedCmd.replace(' *', '');
|
||||||
|
if (command === baseCommand) {
|
||||||
|
return true; // Exact match for base command
|
||||||
|
}
|
||||||
|
// Pattern match for command with arguments
|
||||||
|
const pattern = allowedCmd.replace(/\*/g, '.*');
|
||||||
|
return new RegExp(`^${pattern}$`).test(command);
|
||||||
|
}
|
||||||
|
return command.startsWith(allowedCmd);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateRequestId(): string {
|
||||||
|
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestPermission(tool_name: string, input: any): Promise<{approved: boolean, reason?: string}> {
|
||||||
|
if (!PERMISSIONS_PATH) {
|
||||||
|
console.error("Permissions path not available");
|
||||||
|
return { approved: false, reason: "Permissions path not configured" };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this tool/command is always allowed for this workspace
|
||||||
|
if (isAlwaysAllowed(tool_name, input)) {
|
||||||
|
console.error(`Tool ${tool_name} is always allowed for this workspace`);
|
||||||
|
return { approved: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestId = generateRequestId();
|
||||||
|
const requestFile = path.join(PERMISSIONS_PATH, `${requestId}.request`);
|
||||||
|
const responseFile = path.join(PERMISSIONS_PATH, `${requestId}.response`);
|
||||||
|
|
||||||
|
// Write request file
|
||||||
|
const request = {
|
||||||
|
id: requestId,
|
||||||
|
tool: tool_name,
|
||||||
|
input: input,
|
||||||
|
timestamp: new Date().toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(requestFile, JSON.stringify(request, null, 2));
|
||||||
|
|
||||||
|
// Use fs.watch to wait for response file
|
||||||
|
return new Promise<{approved: boolean, reason?: string}>((resolve) => {
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
watcher.close();
|
||||||
|
// Clean up request file on timeout
|
||||||
|
if (fs.existsSync(requestFile)) {
|
||||||
|
fs.unlinkSync(requestFile);
|
||||||
|
}
|
||||||
|
console.error(`Permission request ${requestId} timed out`);
|
||||||
|
resolve({ approved: false, reason: "Permission request timed out" });
|
||||||
|
}, 3600000); // 1 hour timeout
|
||||||
|
|
||||||
|
const watcher = fs.watch(PERMISSIONS_PATH, (eventType, filename) => {
|
||||||
|
if (eventType === 'rename' && filename === path.basename(responseFile)) {
|
||||||
|
// Check if file exists (rename event can be for creation or deletion)
|
||||||
|
if (fs.existsSync(responseFile)) {
|
||||||
|
try {
|
||||||
|
const responseContent = fs.readFileSync(responseFile, 'utf8');
|
||||||
|
const response = JSON.parse(responseContent);
|
||||||
|
|
||||||
|
// Clean up response file
|
||||||
|
fs.unlinkSync(responseFile);
|
||||||
|
|
||||||
|
// Clear timeout and close watcher
|
||||||
|
clearTimeout(timeout);
|
||||||
|
watcher.close();
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
approved: response.approved,
|
||||||
|
reason: response.approved ? undefined : "User rejected the request"
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error reading response file: ${error}`);
|
||||||
|
// Continue watching in case of read error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle watcher errors
|
||||||
|
watcher.on('error', (error) => {
|
||||||
|
console.error(`File watcher error: ${error}`);
|
||||||
|
clearTimeout(timeout);
|
||||||
|
watcher.close();
|
||||||
|
resolve({ approved: false, reason: "File watcher error" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error requesting permission: ${error}`);
|
||||||
|
return { approved: false, reason: `Error processing permission request: ${error}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server.tool(
|
||||||
|
"approval_prompt",
|
||||||
|
'Request user permission to execute a tool via VS Code dialog',
|
||||||
|
{
|
||||||
|
tool_name: z.string().describe("The name of the tool requesting permission"),
|
||||||
|
input: z.object({}).passthrough().describe("The input for the tool"),
|
||||||
|
tool_use_id: z.string().optional().describe("The unique tool use request ID"),
|
||||||
|
},
|
||||||
|
async ({ tool_name, input }) => {
|
||||||
|
console.error(`Requesting permission for tool: ${tool_name}`);
|
||||||
|
|
||||||
|
const permissionResult = await requestPermission(tool_name, input);
|
||||||
|
|
||||||
|
const behavior = permissionResult.approved ? "allow" : "deny";
|
||||||
|
console.error(`Permission ${behavior}ed for tool: ${tool_name}`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: behavior === "allow" ?
|
||||||
|
JSON.stringify({
|
||||||
|
behavior: behavior,
|
||||||
|
updatedInput: input,
|
||||||
|
})
|
||||||
|
:
|
||||||
|
JSON.stringify({
|
||||||
|
behavior: behavior,
|
||||||
|
message: permissionResult.reason || "Permission denied",
|
||||||
|
})
|
||||||
|
,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const transport = new StdioServerTransport();
|
||||||
|
await server.connect(transport);
|
||||||
|
console.error(`Permissions MCP Server running on stdio`);
|
||||||
|
console.error(`Using permissions directory: ${PERMISSIONS_PATH}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error("Fatal error in main():", error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
1086
claude-code-chat-permissions-mcp/package-lock.json
generated
Normal file
1086
claude-code-chat-permissions-mcp/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
claude-code-chat-permissions-mcp/package.json
Normal file
21
claude-code-chat-permissions-mcp/package.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "claude-code-chat-permissions-mcp",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "dist/mcp-permissions.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "tsc && node dist/mcp-permissions.js",
|
||||||
|
"lint": "eslint . --ext .ts",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": "",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.0.13",
|
||||||
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
||||||
|
"zod": "^3.25.76"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
claude-code-chat-permissions-mcp/tsconfig.json
Normal file
11
claude-code-chat-permissions-mcp/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"target": "es6",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "dist"
|
||||||
|
},
|
||||||
|
"lib": ["es2015"]
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "claude-code-chat",
|
"name": "claude-code-chat",
|
||||||
"displayName": "Claude Code Chat",
|
"displayName": "Claude Code Chat",
|
||||||
"description": "Beautiful Claude Code Chat Interface for VS Code",
|
"description": "Beautiful Claude Code Chat Interface for VS Code",
|
||||||
"version": "1.0.0",
|
"version": "1.0.6",
|
||||||
"publisher": "AndrePimenta",
|
"publisher": "AndrePimenta",
|
||||||
"author": "Andre Pimenta",
|
"author": "Andre Pimenta",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
413
src/extension.ts
413
src/extension.ts
File diff suppressed because it is too large
Load Diff
2964
src/script.ts
Normal file
2964
src/script.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -86,8 +86,8 @@ const styles = `
|
|||||||
/* Permission Request */
|
/* Permission Request */
|
||||||
.permission-request {
|
.permission-request {
|
||||||
margin: 4px 12px 20px 12px;
|
margin: 4px 12px 20px 12px;
|
||||||
background-color: var(--vscode-inputValidation-warningBackground);
|
background-color: rgba(252, 188, 0, 0.1);
|
||||||
border: 1px solid var(--vscode-inputValidation-warningBorder);
|
border: 1px solid rgba(252, 188, 0, 0.3);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
@@ -1350,13 +1350,14 @@ const styles = `
|
|||||||
|
|
||||||
.input-field {
|
.input-field {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
color: var(--vscode-input-foreground);
|
color: var(--vscode-input-foreground);
|
||||||
border: none;
|
border: none;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
outline: none;
|
outline: none;
|
||||||
font-family: var(--vscode-editor-font-family);
|
font-family: var(--vscode-editor-font-family);
|
||||||
min-height: 20px;
|
min-height: 68px;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
resize: none;
|
resize: none;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"mcp-permissions.js"
|
"mcp-permissions.js",
|
||||||
|
"claude-code-chat-permissions-mcp"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user