cursor-feedback 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ import * as vscode from 'vscode';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+
5
+ export type I18nMessages = {
6
+ checkingConnection: string;
7
+ waitingForAI: string;
8
+ waitingHint: string;
9
+ aiSummary: string;
10
+ yourFeedback: string;
11
+ feedbackPlaceholder: string;
12
+ uploadImage: string;
13
+ selectFilesOrFolders: string;
14
+ submitFeedback: string;
15
+ toggleKeyMode: string;
16
+ remainingTime: string;
17
+ timeout: string;
18
+ enterSubmitMode: string;
19
+ ctrlEnterSubmitMode: string;
20
+ switchToCtrlEnter: string;
21
+ switchToEnter: string;
22
+ mcpServerConnected: string;
23
+ mcpServerDisconnected: string;
24
+ debugInfo: string;
25
+ scanPort: string;
26
+ workspace: string;
27
+ currentPort: string;
28
+ connected: string;
29
+ none: string;
30
+ status: string;
31
+ startListening: string;
32
+ stopListening: string;
33
+ aiWaitingFeedback: string;
34
+ feedbackSubmitted: string;
35
+ submitFailed: string;
36
+ cannotConnectMCP: string;
37
+ select: string;
38
+ };
39
+
40
+ let cachedMessages: I18nMessages | null = null;
41
+ let cachedLanguage: string | null = null;
42
+
43
+ /**
44
+ * 获取当前配置的语言
45
+ */
46
+ export function getLanguage(): string {
47
+ const config = vscode.workspace.getConfiguration('cursorFeedback');
48
+ const configuredLang = config.get<string>('language') || 'auto';
49
+
50
+ if (configuredLang === 'auto') {
51
+ // 根据系统语言自动检测
52
+ const vscodeLang = vscode.env.language; // 例如 'zh-cn', 'en', 'zh-tw'
53
+ if (vscodeLang.startsWith('zh')) {
54
+ return 'zh-CN';
55
+ }
56
+ return 'en';
57
+ }
58
+
59
+ return configuredLang;
60
+ }
61
+
62
+ /**
63
+ * 加载语言消息
64
+ */
65
+ export function loadMessages(extensionPath: string, language?: string): I18nMessages {
66
+ const lang = language || getLanguage();
67
+
68
+ // 如果语言没变,返回缓存
69
+ if (cachedMessages && cachedLanguage === lang) {
70
+ return cachedMessages;
71
+ }
72
+
73
+ // 尝试加载指定语言
74
+ const langFile = path.join(extensionPath, 'dist', 'i18n', `${lang}.json`);
75
+ const defaultFile = path.join(extensionPath, 'dist', 'i18n', 'zh-CN.json');
76
+
77
+ try {
78
+ if (fs.existsSync(langFile)) {
79
+ cachedMessages = JSON.parse(fs.readFileSync(langFile, 'utf-8'));
80
+ } else {
81
+ // 回退到默认语言
82
+ cachedMessages = JSON.parse(fs.readFileSync(defaultFile, 'utf-8'));
83
+ }
84
+ cachedLanguage = lang;
85
+ return cachedMessages!;
86
+ } catch (error) {
87
+ console.error('Failed to load i18n messages:', error);
88
+ // 返回硬编码的默认值
89
+ return getDefaultMessages();
90
+ }
91
+ }
92
+
93
+ /**
94
+ * 默认消息(兜底)
95
+ */
96
+ function getDefaultMessages(): I18nMessages {
97
+ return {
98
+ checkingConnection: "Checking connection...",
99
+ waitingForAI: "Waiting for AI feedback request...",
100
+ waitingHint: "The input interface will appear here when AI needs your feedback",
101
+ aiSummary: "AI Summary",
102
+ yourFeedback: "Your Feedback",
103
+ feedbackPlaceholder: "Enter your feedback...",
104
+ uploadImage: "Upload image",
105
+ selectFilesOrFolders: "Select files/folders",
106
+ submitFeedback: "Submit Feedback",
107
+ toggleKeyMode: "Toggle key mode",
108
+ remainingTime: "Remaining time",
109
+ timeout: "Timeout",
110
+ enterSubmitMode: "Enter to submit · Shift+Enter for newline",
111
+ ctrlEnterSubmitMode: "Ctrl+Enter to submit · Enter for newline",
112
+ switchToCtrlEnter: "Click to switch to Ctrl+Enter submit",
113
+ switchToEnter: "Click to switch to Enter submit",
114
+ mcpServerConnected: "MCP Server connected",
115
+ mcpServerDisconnected: "MCP Server disconnected",
116
+ debugInfo: "Debug Info",
117
+ scanPort: "Scan port",
118
+ workspace: "Workspace",
119
+ currentPort: "Current port",
120
+ connected: "Connected",
121
+ none: "None",
122
+ status: "Status",
123
+ startListening: "Started listening for MCP feedback requests",
124
+ stopListening: "Stopped listening",
125
+ aiWaitingFeedback: "AI is waiting for your feedback",
126
+ feedbackSubmitted: "Feedback submitted",
127
+ submitFailed: "Submit failed",
128
+ cannotConnectMCP: "Cannot connect to MCP Server",
129
+ select: "Select"
130
+ };
131
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "checkingConnection": "检查连接...",
3
+ "waitingForAI": "等待 AI 请求反馈...",
4
+ "waitingHint": "当 AI 需要您的反馈时,这里会显示输入界面",
5
+ "aiSummary": "AI 工作摘要",
6
+ "yourFeedback": "您的反馈",
7
+ "feedbackPlaceholder": "请输入您的反馈...",
8
+ "uploadImage": "上传图片",
9
+ "selectFilesOrFolders": "选择文件/文件夹",
10
+ "submitFeedback": "提交反馈",
11
+ "toggleKeyMode": "切换快捷键模式",
12
+ "remainingTime": "剩余时间",
13
+ "timeout": "已超时",
14
+ "enterSubmitMode": "Enter 提交 · Shift+Enter 换行",
15
+ "ctrlEnterSubmitMode": "Ctrl+Enter 提交 · Enter 换行",
16
+ "switchToCtrlEnter": "点击切换为 Ctrl+Enter 提交",
17
+ "switchToEnter": "点击切换为 Enter 提交",
18
+ "mcpServerConnected": "MCP Server 已连接",
19
+ "mcpServerDisconnected": "MCP Server 未连接",
20
+ "debugInfo": "调试信息",
21
+ "scanPort": "扫描端口",
22
+ "workspace": "工作区",
23
+ "currentPort": "当前端口",
24
+ "connected": "已连接",
25
+ "none": "无",
26
+ "status": "状态",
27
+ "startListening": "开始监听 MCP 反馈请求",
28
+ "stopListening": "已停止监听",
29
+ "aiWaitingFeedback": "AI 正在等待您的反馈",
30
+ "feedbackSubmitted": "反馈已提交",
31
+ "submitFailed": "提交失败",
32
+ "cannotConnectMCP": "无法连接到 MCP Server",
33
+ "select": "选择"
34
+ }
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html lang="zh-CN">
2
+ <html lang="{{LANG}}">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -13,7 +13,8 @@
13
13
  <!-- 服务器状态 -->
14
14
  <div id="serverStatus" class="server-status">
15
15
  <span class="dot"></span>
16
- <span id="serverStatusText">检查连接...</span>
16
+ <span id="serverStatusText">{{i18n.checkingConnection}}</span>
17
+ <button id="langSwitchBtn" class="lang-switch-btn" title="Switch Language / 切换语言">🌐</button>
17
18
  <span id="debugIcon" class="debug-icon">🔍</span>
18
19
  <div id="debugTooltip" class="debug-tooltip"></div>
19
20
  </div>
@@ -21,29 +22,29 @@
21
22
  <!-- 等待状态 -->
22
23
  <div id="waitingStatus" class="status waiting">
23
24
  <div class="status-icon">⏳</div>
24
- <p>等待 AI 请求反馈...</p>
25
- <p style="font-size: 11px; margin-top: 10px; opacity: 0.8;">当 AI 需要您的反馈时,这里会显示输入界面</p>
25
+ <p>{{i18n.waitingForAI}}</p>
26
+ <p style="font-size: 11px; margin-top: 10px; opacity: 0.8;">{{i18n.waitingHint}}</p>
26
27
  </div>
27
28
 
28
29
  <!-- 反馈表单 -->
29
30
  <div id="feedbackForm" class="hidden">
30
31
  <!-- AI 摘要 -->
31
32
  <div class="section">
32
- <div class="section-title">📋 AI 工作摘要</div>
33
+ <div class="section-title">📋 {{i18n.aiSummary}}</div>
33
34
  <div id="summaryContent" class="summary-content"></div>
34
35
  <div id="projectInfo" class="project-info"></div>
35
36
  </div>
36
37
 
37
38
  <!-- 反馈输入 -->
38
39
  <div class="section">
39
- <div class="section-title">💬 您的反馈</div>
40
- <textarea id="feedbackInput" class="feedback-input" placeholder="请输入您的反馈..."></textarea>
40
+ <div class="section-title">💬 {{i18n.yourFeedback}}</div>
41
+ <textarea id="feedbackInput" class="feedback-input" placeholder="{{i18n.feedbackPlaceholder}}"></textarea>
41
42
 
42
43
  <!-- 附件区域 -->
43
44
  <div class="attachments-area">
44
45
  <div class="attachment-buttons">
45
- <button id="uploadBtn" class="attachment-btn" data-tooltip="上传图片">🖼️</button>
46
- <button id="selectPathBtn" class="attachment-btn" data-tooltip="选择文件/文件夹">📁</button>
46
+ <button id="uploadBtn" class="attachment-btn" data-tooltip="{{i18n.uploadImage}}">🖼️</button>
47
+ <button id="selectPathBtn" class="attachment-btn" data-tooltip="{{i18n.selectFilesOrFolders}}">📁</button>
47
48
  </div>
48
49
  <input type="file" id="imageInput" accept="image/*" multiple class="hidden">
49
50
  <div id="imagePreview" class="image-preview"></div>
@@ -55,12 +56,14 @@
55
56
 
56
57
  <!-- 提交按钮组 -->
57
58
  <div class="submit-group">
58
- <button id="submitBtn" class="submit-btn">提交反馈 (Ctrl+Enter)</button>
59
- <button id="toggleKeyModeBtn" class="toggle-key-mode-btn" title="切换快捷键模式">⌨️</button>
59
+ <button id="submitBtn" class="submit-btn">{{i18n.ctrlEnterSubmitMode}}</button>
60
+ <button id="toggleKeyModeBtn" class="toggle-key-mode-btn" title="{{i18n.toggleKeyMode}}">⌨️</button>
60
61
  </div>
61
62
  </div>
62
63
  </div>
63
64
 
65
+ <!-- 注入 i18n 数据 -->
66
+ <script>window.i18n = {{I18N_JSON}};</script>
64
67
  <script src="{{SCRIPT_JS_URI}}"></script>
65
68
  </body>
66
69
  </html>
@@ -1,6 +1,7 @@
1
1
  // WebView 脚本
2
2
  (function() {
3
3
  const vscode = acquireVsCodeApi();
4
+ const i18n = window.i18n || {};
4
5
 
5
6
  // 恢复之前保存的文本
6
7
  const previousState = vscode.getState();
@@ -23,6 +24,7 @@
23
24
  const serverStatus = document.getElementById('serverStatus');
24
25
  const serverStatusText = document.getElementById('serverStatusText');
25
26
  const debugTooltip = document.getElementById('debugTooltip');
27
+ const langSwitchBtn = document.getElementById('langSwitchBtn');
26
28
  const waitingStatus = document.getElementById('waitingStatus');
27
29
  const feedbackForm = document.getElementById('feedbackForm');
28
30
  const summaryContent = document.getElementById('summaryContent');
@@ -37,6 +39,11 @@
37
39
  const timeoutInfo = document.getElementById('timeoutInfo');
38
40
  const toggleKeyModeBtn = document.getElementById('toggleKeyModeBtn');
39
41
 
42
+ // 语言切换按钮
43
+ langSwitchBtn.addEventListener('click', () => {
44
+ vscode.postMessage({ type: 'switchLanguage' });
45
+ });
46
+
40
47
  let uploadedImages = [];
41
48
  let attachedFiles = [];
42
49
  let currentRequestId = '';
@@ -51,13 +58,13 @@
51
58
  // 更新快捷键模式 UI
52
59
  function updateKeyModeUI() {
53
60
  if (enterToSubmit) {
54
- submitBtn.textContent = 'Enter 提交 · Shift+Enter 换行';
61
+ submitBtn.textContent = i18n.enterSubmitMode || 'Enter to submit · Shift+Enter for newline';
55
62
  toggleKeyModeBtn.classList.add('enter-mode');
56
- toggleKeyModeBtn.title = '点击切换为 Ctrl+Enter 提交';
63
+ toggleKeyModeBtn.title = i18n.switchToCtrlEnter || 'Click to switch to Ctrl+Enter submit';
57
64
  } else {
58
- submitBtn.textContent = 'Ctrl+Enter 提交 · Enter 换行';
65
+ submitBtn.textContent = i18n.ctrlEnterSubmitMode || 'Ctrl+Enter to submit · Enter for newline';
59
66
  toggleKeyModeBtn.classList.remove('enter-mode');
60
- toggleKeyModeBtn.title = '点击切换为 Enter 提交';
67
+ toggleKeyModeBtn.title = i18n.switchToEnter || 'Click to switch to Enter submit';
61
68
  }
62
69
  }
63
70
 
@@ -184,10 +191,11 @@
184
191
  const remaining = Math.max(0, requestTimeout - elapsed);
185
192
  const minutes = Math.floor(remaining / 60);
186
193
  const seconds = remaining % 60;
187
- timeoutInfo.textContent = '剩余时间: ' + minutes + ':' + seconds.toString().padStart(2, '0');
194
+ const remainingLabel = i18n.remainingTime || 'Remaining time';
195
+ timeoutInfo.textContent = remainingLabel + ': ' + minutes + ':' + seconds.toString().padStart(2, '0');
188
196
  if (remaining <= 0) {
189
197
  clearInterval(countdownInterval);
190
- timeoutInfo.textContent = '已超时';
198
+ timeoutInfo.textContent = i18n.timeout || 'Timeout';
191
199
  }
192
200
  }
193
201
 
@@ -276,16 +284,23 @@
276
284
  case 'serverStatus':
277
285
  if (message.payload.connected) {
278
286
  serverStatus.classList.add('connected');
279
- serverStatusText.textContent = 'MCP Server 已连接';
287
+ serverStatusText.textContent = i18n.mcpServerConnected || 'MCP Server connected';
280
288
  } else {
281
289
  serverStatus.classList.remove('connected');
282
- serverStatusText.textContent = 'MCP Server 未连接';
290
+ serverStatusText.textContent = i18n.mcpServerDisconnected || 'MCP Server disconnected';
283
291
  }
284
292
  break;
285
293
 
286
294
  case 'updateDebugInfo':
287
295
  const d = message.payload;
288
- debugTooltip.textContent = `🔍 调试信息\n━━━━━━━━━━━━\n扫描端口: ${d.portRange}\n工作区: ${d.workspacePath}\n当前端口: ${d.activePort || '-'}\n已连接: ${d.connectedPorts.length > 0 ? d.connectedPorts.join(', ') : '无'}\n状态: ${d.lastStatus}`;
296
+ const debugLabel = i18n.debugInfo || 'Debug Info';
297
+ const scanPortLabel = i18n.scanPort || 'Scan port';
298
+ const workspaceLabel = i18n.workspace || 'Workspace';
299
+ const currentPortLabel = i18n.currentPort || 'Current port';
300
+ const connectedLabel = i18n.connected || 'Connected';
301
+ const noneLabel = i18n.none || 'None';
302
+ const statusLabel = i18n.status || 'Status';
303
+ debugTooltip.textContent = `🔍 ${debugLabel}\n━━━━━━━━━━━━\n${scanPortLabel}: ${d.portRange}\n${workspaceLabel}: ${d.workspacePath}\n${currentPortLabel}: ${d.activePort || '-'}\n${connectedLabel}: ${d.connectedPorts.length > 0 ? d.connectedPorts.join(', ') : noneLabel}\n${statusLabel}: ${d.lastStatus}`;
289
304
  break;
290
305
 
291
306
  case 'filesSelected':
@@ -224,8 +224,24 @@ body {
224
224
  background: var(--vscode-notificationsInfoIcon-foreground);
225
225
  }
226
226
 
227
- .debug-icon {
227
+ .lang-switch-btn {
228
228
  margin-left: auto;
229
+ padding: 2px 6px;
230
+ background: transparent;
231
+ border: 1px solid var(--vscode-input-border);
232
+ border-radius: 3px;
233
+ cursor: pointer;
234
+ font-size: 12px;
235
+ opacity: 0.7;
236
+ transition: opacity 0.15s, background 0.15s;
237
+ }
238
+
239
+ .lang-switch-btn:hover {
240
+ opacity: 1;
241
+ background: var(--vscode-button-secondaryBackground);
242
+ }
243
+
244
+ .debug-icon {
229
245
  cursor: pointer;
230
246
  opacity: 0.6;
231
247
  font-size: 12px;