Changesets · Branches · Tags · Compare
| Changeset | c5a6b31f551809a6f1eb7792698e66e407d5e532838e723e4f0a117effbbca76 |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-08-11 08:27 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-08-11 08:27 +05:30 |
| Parents | 7283be5297d6, 5b736d3312e9 |
15 files changed
added .github/workflows/similar-issues.yml +342 −0
| @@ -0,0 +1,342 @@ | ||
| 1 | +name: Similar Issue Search & Discussion Suggestion | |
| 2 | +on: | |
| 3 | + issues: | |
| 4 | + types: [opened] | |
| 5 | + pull_request: | |
| 6 | + types: [opened] | |
| 7 | + | |
| 8 | +jobs: | |
| 9 | + analyze: | |
| 10 | + runs-on: ubuntu-latest | |
| 11 | + permissions: | |
| 12 | + issues: write | |
| 13 | + pull-requests: write | |
| 14 | + | |
| 15 | + steps: | |
| 16 | + - name: Checkout deja-view | |
| 17 | + uses: actions/checkout@v4 | |
| 18 | + with: | |
| 19 | + repository: 'bdougie/deja-view' | |
| 20 | + # Option 1: Pin to specific commit (most secure) | |
| 21 | + ref: '45e7696' # Pin to specific commit for stability | |
| 22 | + | |
| 23 | + # Option 2: Use a tag (recommended after creating releases) | |
| 24 | + # ref: 'v1.0.0' | |
| 25 | + | |
| 26 | + # Option 3: Use main branch (least secure, gets latest changes) | |
| 27 | + # ref: 'main' | |
| 28 | + | |
| 29 | + path: deja-view | |
| 30 | + | |
| 31 | + - name: Setup Python | |
| 32 | + uses: actions/setup-python@v5 | |
| 33 | + with: | |
| 34 | + python-version: '3.11' | |
| 35 | + | |
| 36 | + - name: Install dependencies | |
| 37 | + run: | | |
| 38 | + cd deja-view | |
| 39 | + pip install -r requirements.txt | |
| 40 | + | |
| 41 | + - name: Index repository if needed | |
| 42 | + env: | |
| 43 | + CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }} | |
| 44 | + CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }} | |
| 45 | + CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }} | |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 47 | + run: | | |
| 48 | + cd deja-view | |
| 49 | + | |
| 50 | + # Index the repository (this will update existing index) | |
| 51 | + python cli.py index "${{ github.repository }}" --max-issues 200 || true | |
| 52 | + | |
| 53 | + - name: Search for similar issues | |
| 54 | + id: search | |
| 55 | + env: | |
| 56 | + CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }} | |
| 57 | + CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }} | |
| 58 | + CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }} | |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 60 | + run: | | |
| 61 | + cd deja-view | |
| 62 | + | |
| 63 | + # Determine if this is an issue or PR | |
| 64 | + if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| 65 | + ISSUE_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" | |
| 66 | + THRESHOLD="0.85" | |
| 67 | + TOP_K="5" | |
| 68 | + else | |
| 69 | + ISSUE_URL="https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}" | |
| 70 | + THRESHOLD="0.7" | |
| 71 | + TOP_K="5" | |
| 72 | + fi | |
| 73 | + | |
| 74 | + # Create a Python script to search and format as JSON | |
| 75 | + cat << 'PYTHON_SCRIPT' > search_similar.py | |
| 76 | + import sys | |
| 77 | + import json | |
| 78 | + import os | |
| 79 | + from github_similarity_service import SimilarityService | |
| 80 | + | |
| 81 | + issue_url = sys.argv[1] | |
| 82 | + threshold = float(sys.argv[2]) | |
| 83 | + top_k = int(sys.argv[3]) | |
| 84 | + | |
| 85 | + # Parse issue number from URL | |
| 86 | + issue_number = int(issue_url.split('/')[-1]) | |
| 87 | + repo_parts = issue_url.split('/') | |
| 88 | + owner = repo_parts[3] | |
| 89 | + repo = repo_parts[4] | |
| 90 | + | |
| 91 | + service = SimilarityService() | |
| 92 | + | |
| 93 | + # Find similar issues | |
| 94 | + similar = service.find_similar_issues( | |
| 95 | + owner=owner, | |
| 96 | + repo=repo, | |
| 97 | + issue_number=issue_number, | |
| 98 | + top_k=top_k, | |
| 99 | + min_similarity=threshold | |
| 100 | + ) | |
| 101 | + | |
| 102 | + # Format as JSON | |
| 103 | + print(json.dumps(similar)) | |
| 104 | + PYTHON_SCRIPT | |
| 105 | + | |
| 106 | + # Search for similar issues | |
| 107 | + SIMILAR_ISSUES=$(python search_similar.py "$ISSUE_URL" "$THRESHOLD" "$TOP_K") | |
| 108 | + | |
| 109 | + # Save to output | |
| 110 | + echo "similar_issues<<EOF" >> $GITHUB_OUTPUT | |
| 111 | + echo "$SIMILAR_ISSUES" >> $GITHUB_OUTPUT | |
| 112 | + echo "EOF" >> $GITHUB_OUTPUT | |
| 113 | + | |
| 114 | + # Check if any similar issues found | |
| 115 | + if [ "$(echo "$SIMILAR_ISSUES" | jq '. | length')" -gt 0 ]; then | |
| 116 | + echo "has_similar=true" >> $GITHUB_OUTPUT | |
| 117 | + else | |
| 118 | + echo "has_similar=false" >> $GITHUB_OUTPUT | |
| 119 | + fi | |
| 120 | + | |
| 121 | + - name: Check if issue should be a discussion | |
| 122 | + id: discussion_check | |
| 123 | + if: github.event_name == 'issues' | |
| 124 | + env: | |
| 125 | + CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }} | |
| 126 | + CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }} | |
| 127 | + CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }} | |
| 128 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 129 | + run: | | |
| 130 | + cd deja-view | |
| 131 | + | |
| 132 | + # Create a Python script to analyze the issue | |
| 133 | + cat << 'PYTHON_SCRIPT' > check_discussion.py | |
| 134 | + import os | |
| 135 | + import json | |
| 136 | + import re | |
| 137 | + from github_similarity_service import SimilarityService | |
| 138 | + | |
| 139 | + # Get issue details from environment | |
| 140 | + issue_title = os.environ.get('ISSUE_TITLE', '') | |
| 141 | + issue_body = os.environ.get('ISSUE_BODY', '') | |
| 142 | + issue_labels = json.loads(os.environ.get('ISSUE_LABELS', '[]')) | |
| 143 | + | |
| 144 | + # Mock Issue object for analysis | |
| 145 | + class MockIssue: | |
| 146 | + def __init__(self): | |
| 147 | + self.title = issue_title | |
| 148 | + self.body = issue_body | |
| 149 | + self.labels = issue_labels | |
| 150 | + self.state = 'open' | |
| 151 | + self.number = int(os.environ.get('ISSUE_NUMBER', 0)) | |
| 152 | + self.created_at = '' | |
| 153 | + self.updated_at = '' | |
| 154 | + self.url = '' | |
| 155 | + | |
| 156 | + service = SimilarityService() | |
| 157 | + issue = MockIssue() | |
| 158 | + | |
| 159 | + score, reasons = service._calculate_discussion_score(issue) | |
| 160 | + | |
| 161 | + result = { | |
| 162 | + 'score': score, | |
| 163 | + 'reasons': reasons, | |
| 164 | + 'should_be_discussion': score >= 0.5, | |
| 165 | + 'confidence': 'high' if score >= 0.7 else 'medium' if score >= 0.5 else 'low' | |
| 166 | + } | |
| 167 | + | |
| 168 | + print(json.dumps(result)) | |
| 169 | + PYTHON_SCRIPT | |
| 170 | + | |
| 171 | + # Run the analysis | |
| 172 | + DISCUSSION_ANALYSIS=$(ISSUE_TITLE="${{ github.event.issue.title }}" \ | |
| 173 | + ISSUE_BODY='${{ github.event.issue.body }}' \ | |
| 174 | + ISSUE_LABELS='${{ toJson(github.event.issue.labels.*.name) }}' \ | |
| 175 | + ISSUE_NUMBER="${{ github.event.issue.number }}" \ | |
| 176 | + python check_discussion.py) | |
| 177 | + | |
| 178 | + echo "analysis<<EOF" >> $GITHUB_OUTPUT | |
| 179 | + echo "$DISCUSSION_ANALYSIS" >> $GITHUB_OUTPUT | |
| 180 | + echo "EOF" >> $GITHUB_OUTPUT | |
| 181 | + | |
| 182 | + # Extract whether it should be a discussion | |
| 183 | + SHOULD_BE_DISCUSSION=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.should_be_discussion') | |
| 184 | + echo "should_be_discussion=$SHOULD_BE_DISCUSSION" >> $GITHUB_OUTPUT | |
| 185 | + | |
| 186 | + # Extract confidence level | |
| 187 | + CONFIDENCE=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.confidence') | |
| 188 | + echo "confidence=$CONFIDENCE" >> $GITHUB_OUTPUT | |
| 189 | + | |
| 190 | + - name: Comment with analysis | |
| 191 | + uses: actions/github-script@v7 | |
| 192 | + with: | |
| 193 | + script: | | |
| 194 | + let comment = ''; | |
| 195 | + const hasSimilar = '${{ steps.search.outputs.has_similar }}' === 'true'; | |
| 196 | + const isPR = '${{ github.event_name }}' === 'pull_request'; | |
| 197 | + const shouldBeDiscussion = !isPR && '${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true'; | |
| 198 | + | |
| 199 | + // Add similar issues section if found | |
| 200 | + if (hasSimilar) { | |
| 201 | + const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`); | |
| 202 | + | |
| 203 | + if (isPR) { | |
| 204 | + // Filter only open issues for PRs | |
| 205 | + const openIssues = similarIssues.filter(issue => issue.state === 'open'); | |
| 206 | + | |
| 207 | + if (openIssues.length > 0) { | |
| 208 | + // Simple table format for PRs | |
| 209 | + comment += '## 📋 Related Open Issues\n\n'; | |
| 210 | + comment += 'These open issues appear to be related to this PR (≥85% similarity):\n\n'; | |
| 211 | + comment += '| # | Title | Similarity |\n'; | |
| 212 | + comment += '|---|-------|------------|\n'; | |
| 213 | + | |
| 214 | + openIssues.forEach(issue => { | |
| 215 | + const similarity = (issue.similarity * 100).toFixed(0); | |
| 216 | + const title = issue.title.length > 50 ? issue.title.substring(0, 47) + '...' : issue.title; | |
| 217 | + comment += `| [#${issue.number}](${issue.url}) | ${title} | ${similarity}% |\n`; | |
| 218 | + }); | |
| 219 | + | |
| 220 | + comment += '\n'; | |
| 221 | + comment += '_Consider closing related issues if this PR addresses them._\n'; | |
| 222 | + } else { | |
| 223 | + // Don't add any comment if no open issues found | |
| 224 | + return; | |
| 225 | + } | |
| 226 | + } else { | |
| 227 | + // Original format for issues | |
| 228 | + comment += '## 🔍 Similar Issues Found\n\n'; | |
| 229 | + comment += 'I found some existing issues that might be related:\n\n'; | |
| 230 | + | |
| 231 | + similarIssues.forEach((issue, index) => { | |
| 232 | + const similarity = (issue.similarity * 100).toFixed(1); | |
| 233 | + const state = issue.state === 'open' ? '🟢' : '🔴'; | |
| 234 | + | |
| 235 | + comment += `${index + 1}. ${state} [#${issue.number}: ${issue.title}](${issue.url}) (${similarity}% similar)\n`; | |
| 236 | + | |
| 237 | + if (issue.summary) { | |
| 238 | + comment += ` > ${issue.summary.substring(0, 150)}${issue.summary.length > 150 ? '...' : ''}\n`; | |
| 239 | + } | |
| 240 | + comment += '\n'; | |
| 241 | + }); | |
| 242 | + | |
| 243 | + comment += '\n'; | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + // Add discussion suggestion if applicable | |
| 248 | + if (shouldBeDiscussion) { | |
| 249 | + const analysis = JSON.parse(`${{ steps.discussion_check.outputs.analysis }}`); | |
| 250 | + const confidence = '${{ steps.discussion_check.outputs.confidence }}'; | |
| 251 | + | |
| 252 | + if (hasSimilar) { | |
| 253 | + comment += '---\n\n'; | |
| 254 | + } | |
| 255 | + | |
| 256 | + comment += '## 💬 Discussion Suggestion\n\n'; | |
| 257 | + | |
| 258 | + const confidenceEmoji = { | |
| 259 | + 'high': '🟢', | |
| 260 | + 'medium': '🟡', | |
| 261 | + 'low': '🔴' | |
| 262 | + }; | |
| 263 | + | |
| 264 | + comment += `This issue might be better suited as a **GitHub Discussion** ${confidenceEmoji[confidence] || ''}\n\n`; | |
| 265 | + comment += `**Confidence**: ${confidence.charAt(0).toUpperCase() + confidence.slice(1)} (${(analysis.score * 100).toFixed(0)}%)\n\n`; | |
| 266 | + | |
| 267 | + if (analysis.reasons && analysis.reasons.length > 0) { | |
| 268 | + comment += '**Reasons**:\n'; | |
| 269 | + analysis.reasons.forEach(reason => { | |
| 270 | + comment += `- ${reason}\n`; | |
| 271 | + }); | |
| 272 | + comment += '\n'; | |
| 273 | + } | |
| 274 | + | |
| 275 | + comment += 'GitHub Discussions are great for:\n'; | |
| 276 | + comment += '- Questions and help requests\n'; | |
| 277 | + comment += '- Feature requests and ideas\n'; | |
| 278 | + comment += '- General feedback and brainstorming\n'; | |
| 279 | + comment += '- Community conversations\n\n'; | |
| 280 | + | |
| 281 | + comment += '_Consider converting this to a discussion if it\'s not a bug report or actionable task._\n'; | |
| 282 | + } | |
| 283 | + | |
| 284 | + // Only comment if we have something to say | |
| 285 | + if (comment) { | |
| 286 | + comment += '\n---\n'; | |
| 287 | + comment += '_This analysis was automatically generated by [deja-view](https://github.com/bdougie/deja-view)._'; | |
| 288 | + | |
| 289 | + if ('${{ github.event_name }}' === 'pull_request') { | |
| 290 | + await github.rest.issues.createComment({ | |
| 291 | + owner: context.repo.owner, | |
| 292 | + repo: context.repo.repo, | |
| 293 | + issue_number: context.payload.pull_request.number, | |
| 294 | + body: comment | |
| 295 | + }); | |
| 296 | + } else { | |
| 297 | + await github.rest.issues.createComment({ | |
| 298 | + owner: context.repo.owner, | |
| 299 | + repo: context.repo.repo, | |
| 300 | + issue_number: context.issue.number, | |
| 301 | + body: comment | |
| 302 | + }); | |
| 303 | + } | |
| 304 | + } | |
| 305 | + | |
| 306 | + - name: Add labels | |
| 307 | + if: github.event_name == 'issues' | |
| 308 | + uses: actions/github-script@v7 | |
| 309 | + with: | |
| 310 | + script: | | |
| 311 | + const labels = []; | |
| 312 | + | |
| 313 | + // Check for duplicate | |
| 314 | + if ('${{ steps.search.outputs.has_similar }}' === 'true') { | |
| 315 | + const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`); | |
| 316 | + const hasDuplicate = similarIssues.some(issue => issue.similarity > 0.9); | |
| 317 | + | |
| 318 | + if (hasDuplicate) { | |
| 319 | + labels.push('potential-duplicate'); | |
| 320 | + } | |
| 321 | + } | |
| 322 | + | |
| 323 | + // Check for discussion suggestion | |
| 324 | + if ('${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true') { | |
| 325 | + const confidence = '${{ steps.discussion_check.outputs.confidence }}'; | |
| 326 | + | |
| 327 | + if (confidence === 'high') { | |
| 328 | + labels.push('should-be-discussion'); | |
| 329 | + } else if (confidence === 'medium') { | |
| 330 | + labels.push('discussion'); | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 334 | + // Add labels if any | |
| 335 | + if (labels.length > 0) { | |
| 336 | + await github.rest.issues.addLabels({ | |
| 337 | + owner: context.repo.owner, | |
| 338 | + repo: context.repo.repo, | |
| 339 | + issue_number: context.issue.number, | |
| 340 | + labels: labels | |
| 341 | + }); | |
| 342 | + } |
modified core/llm/toolSupport.ts +12 −0
| @@ -63,13 +63,22 @@ | ||
| 63 | 63 | ) { |
| 64 | 64 | return true; |
| 65 | 65 | } |
| 66 | + | |
| 67 | + // LGAI EXAONE models expose an OpenAI-compatible API with tool | |
| 68 | + // calling support when served via frameworks like vLLM | |
| 69 | + if (lower.includes("exaone")) { | |
| 70 | + return true; | |
| 71 | + } | |
| 72 | + | |
| 66 | 73 | if (lower.includes("gpt-oss")) { |
| 67 | 74 | return true; |
| 68 | 75 | } |
| 76 | + | |
| 69 | 77 | // https://ai.google.dev/gemma/docs/capabilities/function-calling |
| 70 | 78 | if (lower.startsWith("gemma")) { |
| 71 | 79 | return true; |
| 72 | 80 | } |
| 81 | + | |
| 73 | 82 | // firworks-ai https://docs.fireworks.ai/guides/function-calling |
| 74 | 83 | if (model.startsWith("accounts/fireworks/models/")) { |
| 75 | 84 | switch (model.substring(26)) { |
| @@ -179,6 +188,7 @@ | ||
| 179 | 188 | "firefunction-v2", |
| 180 | 189 | "mistral", |
| 181 | 190 | "devstral", |
| 191 | + "exaone", | |
| 182 | 192 | "gpt-oss", |
| 183 | 193 | ].some((part) => modelName.toLowerCase().includes(part)) |
| 184 | 194 | ) { |
| @@ -269,6 +279,7 @@ | ||
| 269 | 279 | "deepseek/deepseek-chat", |
| 270 | 280 | "meta-llama/llama-4", |
| 271 | 281 | "all-hands/openhands-lm-32b", |
| 282 | + "lgai-exaone/exaone", | |
| 272 | 283 | ]; |
| 273 | 284 | for (const prefix of supportedPrefixes) { |
| 274 | 285 | if (model.toLowerCase().startsWith(prefix)) { |
| @@ -339,6 +350,7 @@ | ||
| 339 | 350 | if (modelDescription.capabilities?.tools !== undefined) { |
| 340 | 351 | return modelDescription.capabilities.tools; |
| 341 | 352 | } |
| 353 | + | |
| 342 | 354 | const providerSupport = PROVIDER_TOOL_SUPPORT[modelDescription.provider]; |
| 343 | 355 | if (!providerSupport) { |
| 344 | 356 | return false; |
modified core/tools/implementations/runTerminalCommand.test.ts +119 −0
| @@ -352,4 +352,123 @@ | ||
| 352 | 352 | expect(result[0].content).toBe("Command is running in the background..."); |
| 353 | 353 | expect(result[0].status).toBe("Command is running in the background..."); |
| 354 | 354 | }); |
| 355 | + | |
| 356 | + it("should handle missing workspace directory gracefully", async () => { | |
| 357 | + // Mock IDE to return empty workspace directories | |
| 358 | + const mockEmptyWorkspace = jest.fn().mockReturnValue(Promise.resolve([])); | |
| 359 | + | |
| 360 | + // Create IDE mock with empty workspace | |
| 361 | + const mockIde = { | |
| 362 | + getIdeInfo: jest | |
| 363 | + .fn() | |
| 364 | + .mockReturnValue(Promise.resolve({ remoteName: "local" })), | |
| 365 | + getWorkspaceDirs: mockEmptyWorkspace, | |
| 366 | + runCommand: jest.fn(), | |
| 367 | + getIdeSettings: jest.fn(), | |
| 368 | + getDiff: jest.fn(), | |
| 369 | + getClipboardContent: jest.fn(), | |
| 370 | + isTelemetryEnabled: jest.fn(), | |
| 371 | + readFile: jest.fn(), | |
| 372 | + writeFile: jest.fn(), | |
| 373 | + renameFile: jest.fn(), | |
| 374 | + deleteFile: jest.fn(), | |
| 375 | + globFiles: jest.fn(), | |
| 376 | + ls: jest.fn(), | |
| 377 | + }; | |
| 378 | + | |
| 379 | + const extras = { | |
| 380 | + ide: mockIde as unknown as IDE, | |
| 381 | + llm: {} as any, | |
| 382 | + fetch: {} as any, | |
| 383 | + tool: {} as any, | |
| 384 | + toolCallId: "test-tool-call", | |
| 385 | + } as ToolExtras; | |
| 386 | + | |
| 387 | + const command = `node -e "console.log('no workspace test')"`; | |
| 388 | + const args = { command, waitForCompletion: true }; | |
| 389 | + | |
| 390 | + const result = await runTerminalCommandImpl(args, extras); | |
| 391 | + | |
| 392 | + // Should still work - falling back to HOME or cwd | |
| 393 | + expect(result).toHaveLength(1); | |
| 394 | + expect(result[0].name).toBe("Terminal"); | |
| 395 | + expect(result[0].description).toBe("Terminal command output"); | |
| 396 | + expect(result[0].content).toContain("no workspace test"); | |
| 397 | + expect(result[0].status).toBe("Command completed"); | |
| 398 | + | |
| 399 | + // Verify workspace dirs was called but returned empty | |
| 400 | + expect(mockEmptyWorkspace).toHaveBeenCalled(); | |
| 401 | + }); | |
| 402 | + | |
| 403 | + it("should handle case where cwd fallbacks all fail", async () => { | |
| 404 | + // Mock IDE to return empty workspace directories | |
| 405 | + const mockEmptyWorkspace = jest.fn().mockReturnValue(Promise.resolve([])); | |
| 406 | + | |
| 407 | + // Save original environment variables and process.cwd | |
| 408 | + const originalHome = process.env.HOME; | |
| 409 | + const originalUserProfile = process.env.USERPROFILE; | |
| 410 | + const originalCwd = process.cwd; | |
| 411 | + | |
| 412 | + try { | |
| 413 | + // Mock all fallbacks to fail | |
| 414 | + delete process.env.HOME; | |
| 415 | + delete process.env.USERPROFILE; | |
| 416 | + process.cwd = jest.fn().mockImplementation(() => { | |
| 417 | + throw new Error("Current directory unavailable"); | |
| 418 | + }) as jest.MockedFunction<() => string>; | |
| 419 | + | |
| 420 | + // Create IDE mock with empty workspace | |
| 421 | + const mockIde = { | |
| 422 | + getIdeInfo: jest | |
| 423 | + .fn() | |
| 424 | + .mockReturnValue(Promise.resolve({ remoteName: "local" })), | |
| 425 | + getWorkspaceDirs: mockEmptyWorkspace, | |
| 426 | + runCommand: jest.fn(), | |
| 427 | + getIdeSettings: jest.fn(), | |
| 428 | + getDiff: jest.fn(), | |
| 429 | + getClipboardContent: jest.fn(), | |
| 430 | + isTelemetryEnabled: jest.fn(), | |
| 431 | + readFile: jest.fn(), | |
| 432 | + writeFile: jest.fn(), | |
| 433 | + renameFile: jest.fn(), | |
| 434 | + deleteFile: jest.fn(), | |
| 435 | + globFiles: jest.fn(), | |
| 436 | + ls: jest.fn(), | |
| 437 | + }; | |
| 438 | + | |
| 439 | + const extras = { | |
| 440 | + ide: mockIde as unknown as IDE, | |
| 441 | + llm: {} as any, | |
| 442 | + fetch: {} as any, | |
| 443 | + tool: {} as any, | |
| 444 | + toolCallId: "test-tool-call", | |
| 445 | + } as ToolExtras; | |
| 446 | + | |
| 447 | + const command = `node -e "console.log('fallback test')"`; | |
| 448 | + const args = { command, waitForCompletion: true }; | |
| 449 | + | |
| 450 | + // This should now handle the case gracefully by falling back to temp directory | |
| 451 | + const result = await runTerminalCommandImpl(args, extras); | |
| 452 | + | |
| 453 | + // Should work using the temp directory as fallback | |
| 454 | + expect(result).toHaveLength(1); | |
| 455 | + expect(result[0].name).toBe("Terminal"); | |
| 456 | + expect(result[0].content).toContain("fallback test"); | |
| 457 | + expect(result[0].status).toBe("Command completed"); | |
| 458 | + | |
| 459 | + console.log( | |
| 460 | + "Successfully handled cwd fallback to temp directory:", | |
| 461 | + result[0].status, | |
| 462 | + ); | |
| 463 | + } finally { | |
| 464 | + // Always restore original values | |
| 465 | + if (originalHome !== undefined) { | |
| 466 | + process.env.HOME = originalHome; | |
| 467 | + } | |
| 468 | + if (originalUserProfile !== undefined) { | |
| 469 | + process.env.USERPROFILE = originalUserProfile; | |
| 470 | + } | |
| 471 | + process.cwd = originalCwd; | |
| 472 | + } | |
| 473 | + }); | |
| 355 | 474 | }); |
modified core/tools/implementations/runTerminalCommand.ts +172 −150
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import iconv from "iconv-lite"; |
| 2 | 2 | import childProcess from "node:child_process"; |
| 3 | +import os from "node:os"; | |
| 3 | 4 | import util from "node:util"; |
| 4 | 5 | // Automatically decode the buffer according to the platform to avoid garbled Chinese |
| 5 | 6 | function getDecodedOutput(data: Buffer): string { |
| @@ -75,89 +76,132 @@ | ||
| 75 | 76 | if (ENABLED_FOR_REMOTES.includes(ideInfo.remoteName)) { |
| 76 | 77 | // For streaming output |
| 77 | 78 | if (extras.onPartialOutput) { |
| 78 | - return new Promise((resolve, reject) => { | |
| 79 | - try { | |
| 80 | - const getWorkspaceDirsPromise = extras.ide.getWorkspaceDirs(); | |
| 81 | - getWorkspaceDirsPromise | |
| 82 | - .then((workspaceDirs) => { | |
| 83 | - const cwd = fileURLToPath(workspaceDirs[0]); | |
| 84 | - let terminalOutput = ""; | |
| 85 | - | |
| 86 | - if (!waitForCompletion) { | |
| 87 | - const status = "Command is running in the background..."; | |
| 88 | - if (extras.onPartialOutput) { | |
| 89 | - extras.onPartialOutput({ | |
| 90 | - toolCallId, | |
| 91 | - contextItems: [ | |
| 92 | - { | |
| 93 | - name: "Terminal", | |
| 94 | - description: "Terminal command output", | |
| 95 | - content: "", | |
| 96 | - status: status, | |
| 97 | - }, | |
| 98 | - ], | |
| 99 | - }); | |
| 100 | - } | |
| 101 | - } | |
| 79 | + try { | |
| 80 | + const workspaceDirs = await extras.ide.getWorkspaceDirs(); | |
| 81 | + | |
| 82 | + // Handle case where no workspace is available | |
| 83 | + let cwd: string; | |
| 84 | + if (workspaceDirs.length > 0) { | |
| 85 | + cwd = fileURLToPath(workspaceDirs[0]); | |
| 86 | + } else { | |
| 87 | + // Default to user's home directory with fallbacks | |
| 88 | + try { | |
| 89 | + cwd = process.env.HOME || process.env.USERPROFILE || process.cwd(); | |
| 90 | + } catch (error) { | |
| 91 | + // Final fallback if even process.cwd() fails - use system temp directory | |
| 92 | + cwd = os.tmpdir(); | |
| 93 | + } | |
| 94 | + } | |
| 102 | 95 | |
| 103 | - // Use spawn with color environment | |
| 104 | - const { shell, args } = getShellCommand(command); | |
| 105 | - const childProc = childProcess.spawn(shell, args, { | |
| 106 | - cwd, | |
| 107 | - env: getColorEnv(), // Add enhanced environment for colors | |
| 96 | + return new Promise((resolve, reject) => { | |
| 97 | + let terminalOutput = ""; | |
| 98 | + | |
| 99 | + if (!waitForCompletion) { | |
| 100 | + const status = "Command is running in the background..."; | |
| 101 | + if (extras.onPartialOutput) { | |
| 102 | + extras.onPartialOutput({ | |
| 103 | + toolCallId, | |
| 104 | + contextItems: [ | |
| 105 | + { | |
| 106 | + name: "Terminal", | |
| 107 | + description: "Terminal command output", | |
| 108 | + content: "", | |
| 109 | + status: status, | |
| 110 | + }, | |
| 111 | + ], | |
| 108 | 112 | }); |
| 109 | - | |
| 110 | - childProc.stdout?.on("data", (data) => { | |
| 111 | - // Skip if this process has been backgrounded | |
| 112 | - if (isProcessBackgrounded(toolCallId)) return; | |
| 113 | - | |
| 114 | - const newOutput = getDecodedOutput(data); | |
| 115 | - terminalOutput += newOutput; | |
| 116 | - | |
| 117 | - // Send partial output to UI | |
| 118 | - if (extras.onPartialOutput) { | |
| 119 | - const status = waitForCompletion | |
| 120 | - ? "" | |
| 121 | - : "Command is running in the background..."; | |
| 122 | - extras.onPartialOutput({ | |
| 123 | - toolCallId, | |
| 124 | - contextItems: [ | |
| 125 | - { | |
| 126 | - name: "Terminal", | |
| 127 | - description: "Terminal command output", | |
| 128 | - content: terminalOutput, | |
| 129 | - status: status, | |
| 130 | - }, | |
| 131 | - ], | |
| 132 | - }); | |
| 133 | - } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + // Use spawn with color environment | |
| 117 | + const { shell, args } = getShellCommand(command); | |
| 118 | + const childProc = childProcess.spawn(shell, args, { | |
| 119 | + cwd, | |
| 120 | + env: getColorEnv(), // Add enhanced environment for colors | |
| 121 | + }); | |
| 122 | + | |
| 123 | + childProc.stdout?.on("data", (data) => { | |
| 124 | + // Skip if this process has been backgrounded | |
| 125 | + if (isProcessBackgrounded(toolCallId)) return; | |
| 126 | + | |
| 127 | + const newOutput = getDecodedOutput(data); | |
| 128 | + terminalOutput += newOutput; | |
| 129 | + | |
| 130 | + // Send partial output to UI | |
| 131 | + if (extras.onPartialOutput) { | |
| 132 | + const status = waitForCompletion | |
| 133 | + ? "" | |
| 134 | + : "Command is running in the background..."; | |
| 135 | + extras.onPartialOutput({ | |
| 136 | + toolCallId, | |
| 137 | + contextItems: [ | |
| 138 | + { | |
| 139 | + name: "Terminal", | |
| 140 | + description: "Terminal command output", | |
| 141 | + content: terminalOutput, | |
| 142 | + status: status, | |
| 143 | + }, | |
| 144 | + ], | |
| 134 | 145 | }); |
| 135 | - | |
| 136 | - childProc.stderr?.on("data", (data) => { | |
| 137 | - // Skip if this process has been backgrounded | |
| 138 | - if (isProcessBackgrounded(toolCallId)) return; | |
| 139 | - | |
| 140 | - const newOutput = getDecodedOutput(data); | |
| 141 | - terminalOutput += newOutput; | |
| 142 | - | |
| 143 | - // Send partial output to UI, status is not required | |
| 144 | - if (extras.onPartialOutput) { | |
| 145 | - extras.onPartialOutput({ | |
| 146 | - toolCallId, | |
| 147 | - contextItems: [ | |
| 148 | - { | |
| 149 | - name: "Terminal", | |
| 150 | - description: "Terminal command output", | |
| 151 | - content: terminalOutput, | |
| 152 | - }, | |
| 153 | - ], | |
| 154 | - }); | |
| 155 | - } | |
| 146 | + } | |
| 147 | + }); | |
| 148 | + | |
| 149 | + childProc.stderr?.on("data", (data) => { | |
| 150 | + // Skip if this process has been backgrounded | |
| 151 | + if (isProcessBackgrounded(toolCallId)) return; | |
| 152 | + | |
| 153 | + const newOutput = getDecodedOutput(data); | |
| 154 | + terminalOutput += newOutput; | |
| 155 | + | |
| 156 | + // Send partial output to UI, status is not required | |
| 157 | + if (extras.onPartialOutput) { | |
| 158 | + extras.onPartialOutput({ | |
| 159 | + toolCallId, | |
| 160 | + contextItems: [ | |
| 161 | + { | |
| 162 | + name: "Terminal", | |
| 163 | + description: "Terminal command output", | |
| 164 | + content: terminalOutput, | |
| 165 | + }, | |
| 166 | + ], | |
| 156 | 167 | }); |
| 157 | - | |
| 158 | - // If we don't need to wait for completion, resolve immediately | |
| 159 | - if (!waitForCompletion) { | |
| 160 | - const status = "Command is running in the background..."; | |
| 168 | + } | |
| 169 | + }); | |
| 170 | + | |
| 171 | + // If we don't need to wait for completion, resolve immediately | |
| 172 | + if (!waitForCompletion) { | |
| 173 | + const status = "Command is running in the background..."; | |
| 174 | + resolve([ | |
| 175 | + { | |
| 176 | + name: "Terminal", | |
| 177 | + description: "Terminal command output", | |
| 178 | + content: terminalOutput, | |
| 179 | + status: status, | |
| 180 | + }, | |
| 181 | + ]); | |
| 182 | + } | |
| 183 | + | |
| 184 | + childProc.on("close", (code) => { | |
| 185 | + // If this process has been backgrounded, clean it up from the map and return | |
| 186 | + if (isProcessBackgrounded(toolCallId)) { | |
| 187 | + removeBackgroundedProcess(toolCallId); | |
| 188 | + return; | |
| 189 | + } | |
| 190 | + | |
| 191 | + if (waitForCompletion) { | |
| 192 | + // Normal completion, resolve now | |
| 193 | + if (code === 0) { | |
| 194 | + const status = "Command completed"; | |
| 195 | + resolve([ | |
| 196 | + { | |
| 197 | + name: "Terminal", | |
| 198 | + description: "Terminal command output", | |
| 199 | + content: terminalOutput, | |
| 200 | + status: status, | |
| 201 | + }, | |
| 202 | + ]); | |
| 203 | + } else { | |
| 204 | + const status = `Command failed with exit code ${code}`; | |
| 161 | 205 | resolve([ |
| 162 | 206 | { |
| 163 | 207 | name: "Terminal", |
| @@ -167,80 +211,58 @@ | ||
| 167 | 211 | }, |
| 168 | 212 | ]); |
| 169 | 213 | } |
| 170 | - | |
| 171 | - childProc.on("close", (code) => { | |
| 172 | - // If this process has been backgrounded, clean it up from the map and return | |
| 173 | - if (isProcessBackgrounded(toolCallId)) { | |
| 174 | - removeBackgroundedProcess(toolCallId); | |
| 175 | - return; | |
| 176 | - } | |
| 177 | - | |
| 178 | - if (waitForCompletion) { | |
| 179 | - // Normal completion, resolve now | |
| 180 | - if (code === 0) { | |
| 181 | - const status = "Command completed"; | |
| 182 | - resolve([ | |
| 183 | - { | |
| 184 | - name: "Terminal", | |
| 185 | - description: "Terminal command output", | |
| 186 | - content: terminalOutput, | |
| 187 | - status: status, | |
| 188 | - }, | |
| 189 | - ]); | |
| 190 | - } else { | |
| 191 | - const status = `Command failed with exit code ${code}`; | |
| 192 | - resolve([ | |
| 193 | - { | |
| 194 | - name: "Terminal", | |
| 195 | - description: "Terminal command output", | |
| 196 | - content: terminalOutput, | |
| 197 | - status: status, | |
| 198 | - }, | |
| 199 | - ]); | |
| 200 | - } | |
| 201 | - } else { | |
| 202 | - // Already resolved, just update the UI with final output | |
| 203 | - if (extras.onPartialOutput) { | |
| 204 | - const status = | |
| 205 | - code === 0 || !code | |
| 206 | - ? "\nBackground command completed" | |
| 207 | - : `\nBackground command failed with exit code ${code}`; | |
| 208 | - extras.onPartialOutput({ | |
| 209 | - toolCallId, | |
| 210 | - contextItems: [ | |
| 211 | - { | |
| 212 | - name: "Terminal", | |
| 213 | - description: "Terminal command output", | |
| 214 | - content: terminalOutput, | |
| 215 | - status: status, | |
| 216 | - }, | |
| 217 | - ], | |
| 218 | - }); | |
| 219 | - } | |
| 220 | - } | |
| 221 | - }); | |
| 222 | - | |
| 223 | - childProc.on("error", (error) => { | |
| 224 | - // If this process has been backgrounded, clean it up from the map and return | |
| 225 | - if (isProcessBackgrounded(toolCallId)) { | |
| 226 | - removeBackgroundedProcess(toolCallId); | |
| 227 | - return; | |
| 228 | - } | |
| 229 | - | |
| 230 | - reject(error); | |
| 231 | - }); | |
| 232 | - }) | |
| 233 | - .catch((error) => { | |
| 234 | - reject(error); | |
| 235 | - }); | |
| 236 | - } catch (error: any) { | |
| 237 | - reject(error); | |
| 238 | - } | |
| 239 | - }); | |
| 214 | + } else { | |
| 215 | + // Already resolved, just update the UI with final output | |
| 216 | + if (extras.onPartialOutput) { | |
| 217 | + const status = | |
| 218 | + code === 0 || !code | |
| 219 | + ? "\nBackground command completed" | |
| 220 | + : `\nBackground command failed with exit code ${code}`; | |
| 221 | + extras.onPartialOutput({ | |
| 222 | + toolCallId, | |
| 223 | + contextItems: [ | |
| 224 | + { | |
| 225 | + name: "Terminal", | |
| 226 | + description: "Terminal command output", | |
| 227 | + content: terminalOutput, | |
| 228 | + status: status, | |
| 229 | + }, | |
| 230 | + ], | |
| 231 | + }); | |
| 232 | + } | |
| 233 | + } | |
| 234 | + }); | |
| 235 | + | |
| 236 | + childProc.on("error", (error) => { | |
| 237 | + // If this process has been backgrounded, clean it up from the map and return | |
| 238 | + if (isProcessBackgrounded(toolCallId)) { | |
| 239 | + removeBackgroundedProcess(toolCallId); | |
| 240 | + return; | |
| 241 | + } | |
| 242 | + | |
| 243 | + reject(error); | |
| 244 | + }); | |
| 245 | + }); | |
| 246 | + } catch (error: any) { | |
| 247 | + throw error; | |
| 248 | + } | |
| 240 | 249 | } else { |
| 241 | 250 | // Fallback to non-streaming for older clients |
| 242 | 251 | const workspaceDirs = await extras.ide.getWorkspaceDirs(); |
| 243 | - const cwd = fileURLToPath(workspaceDirs[0]); | |
| 252 | + | |
| 253 | + // Handle case where no workspace is available | |
| 254 | + let cwd: string; | |
| 255 | + if (workspaceDirs.length > 0) { | |
| 256 | + cwd = fileURLToPath(workspaceDirs[0]); | |
| 257 | + } else { | |
| 258 | + // Default to user's home directory with fallbacks | |
| 259 | + try { | |
| 260 | + cwd = process.env.HOME || process.env.USERPROFILE || process.cwd(); | |
| 261 | + } catch (error) { | |
| 262 | + // Final fallback if even process.cwd() fails - use system temp directory | |
| 263 | + cwd = os.tmpdir(); | |
| 264 | + } | |
| 265 | + } | |
| 244 | 266 | |
| 245 | 267 | if (waitForCompletion) { |
| 246 | 268 | // Standard execution, waiting for completion |
modified core/util/parameters.ts +1 −0
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | useImports: true, |
| 21 | 21 | transform: true, |
| 22 | 22 | showWhateverWeHaveAtXMs: 300, |
| 23 | + // Experimental options: true = enabled, false = disabled, number = enabled w priority | |
| 23 | 24 | experimental_includeClipboard: true, |
| 24 | 25 | experimental_includeRecentlyVisitedRanges: true, |
| 25 | 26 | experimental_includeRecentlyEditedRanges: true, |
modified docs/customize/deep-dives/autocomplete.mdx +28 −5
| @@ -84,7 +84,7 @@ | ||
| 84 | 84 | |
| 85 | 85 | Once the model has been downloaded, you should begin to see completions in VS Code. |
| 86 | 86 | |
| 87 | -NOTE: Typically, thinking-type models are not recommended as they generate more slowly and are not suitable for scenarios that require speed. | |
| 87 | +NOTE: Typically, thinking-type models are not recommended as they generate more slowly and are not suitable for scenarios that require speed. | |
| 88 | 88 | |
| 89 | 89 | However, if you use any thinking-switchable models, you can configure these models for autocomplete functions by turning off the thinking mode. |
| 90 | 90 | |
| @@ -92,7 +92,7 @@ | ||
| 92 | 92 | |
| 93 | 93 | <Tabs> |
| 94 | 94 | <Tab title="YAML"> |
| 95 | - ```yaml title="config.yaml" | |
| 95 | +```yaml title="config.yaml" | |
| 96 | 96 | models: |
| 97 | 97 | - name: Qwen3 without Thinking for Autocomplete |
| 98 | 98 | provider: ollama |
| @@ -122,9 +122,32 @@ | ||
| 122 | 122 | - `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto` |
| 123 | 123 | - `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt" |
| 124 | 124 | |
| 125 | -### `config.json` Configuration | |
| 126 | - | |
| 127 | -The `config.json` configuration format (deprecated) offers further configuration options through `tabAutocompleteOptions`. See the [JSON Reference](/reference) for more details. | |
| 125 | +### Autocomplete Configuration | |
| 126 | + | |
| 127 | +#### YAML Configuration | |
| 128 | + | |
| 129 | +The `config.yaml` format offers model-level configuration using the `autocompleteOptions` field. See the [YAML Reference](/reference#models) for more details. | |
| 130 | + | |
| 131 | +```yaml | |
| 132 | +models: | |
| 133 | + - name: Codestral | |
| 134 | + provider: mistral | |
| 135 | + model: codestral-latest | |
| 136 | + roles: | |
| 137 | + - autocomplete | |
| 138 | + autocompleteOptions: | |
| 139 | + disable: false | |
| 140 | + maxPromptTokens: 1024 | |
| 141 | + debounceDelay: 250 | |
| 142 | + modelTimeout: 150 | |
| 143 | + maxSuffixPercentage: 0.2 | |
| 144 | + prefixPercentage: 0.3 | |
| 145 | + onlyMyCode: true | |
| 146 | +``` | |
| 147 | + | |
| 148 | +#### JSON Configuration (Deprecated) | |
| 149 | + | |
| 150 | +The `config.json` configuration format offers configuration options through `tabAutocompleteOptions`. See the [JSON Reference](/reference/json-reference#tabautocomplete-options) for more details. | |
| 128 | 151 | |
| 129 | 152 | ## FAQs |
| 130 | 153 |
modified docs/reference.mdx +28 −0
| @@ -175,6 +175,7 @@ | ||
| 175 | 175 | |
| 176 | 176 | - `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used. |
| 177 | 177 | |
| 178 | + | |
| 178 | 179 | - `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. See the [Model Capabilities guide](/customize/deep-dives/model-capabilities) for detailed information. Supported capabilities include: |
| 179 | 180 | - `tool_use`: Enables function/tool calling support (required for Agent mode) |
| 180 | 181 | - `image_input`: Enables image upload and processing support |
| @@ -228,6 +229,21 @@ | ||
| 228 | 229 | - `key`: Path to the client certificate key file. |
| 229 | 230 | - `passphrase`: Optional passphrase for the client certificate key file. |
| 230 | 231 | |
| 232 | +- `autocompleteOptions`: If the model includes role `autocomplete`, these settings apply for tab autocompletion: | |
| 233 | + | |
| 234 | + - `disable`: If `true`, disables autocomplete for this model. | |
| 235 | + - `maxPromptTokens`: Maximum number of tokens for the autocomplete prompt. | |
| 236 | + - `debounceDelay`: Delay before triggering autocomplete in milliseconds. | |
| 237 | + - `modelTimeout`: Model timeout for autocomplete requests in milliseconds. | |
| 238 | + - `maxSuffixPercentage`: Maximum percentage of prompt allocated for suffix. | |
| 239 | + - `prefixPercentage`: Percentage of input allocated for prefix. | |
| 240 | + - `template`: Custom template for autocomplete using Mustache syntax. You can use the `{{{ prefix }}}`, `{{{ suffix }}}`, `{{{ filename }}}`, `{{{ reponame }}}`, and `{{{ language }}}` variables. | |
| 241 | + - `onlyMyCode`: Only includes code within the repository for context. | |
| 242 | + - `useCache`: If `true`, enables caching for completions. | |
| 243 | + - `useImports`: If `true`, includes imports in context. | |
| 244 | + - `useRecentlyEdited`: If `true`, includes recently edited files in context. | |
| 245 | + - `useRecentlyOpened`: If `true`, includes recently opened files in context. | |
| 246 | + | |
| 231 | 247 | **Example:** |
| 232 | 248 | |
| 233 | 249 | ```yaml title="config.yaml" |
| @@ -247,6 +263,10 @@ | ||
| 247 | 263 | model: codestral-latest |
| 248 | 264 | roles: |
| 249 | 265 | - autocomplete |
| 266 | + autocompleteOptions: | |
| 267 | + debounceDelay: 250 | |
| 268 | + maxPromptTokens: 1024 | |
| 269 | + onlyMyCode: true | |
| 250 | 270 | - name: My Model - OpenAI-Compatible |
| 251 | 271 | provider: openai |
| 252 | 272 | apiBase: http://my-endpoint/v1 |
| @@ -456,6 +476,10 @@ | ||
| 456 | 476 | model: starcoder |
| 457 | 477 | roles: |
| 458 | 478 | - autocomplete |
| 479 | + autocompleteOptions: | |
| 480 | + debounceDelay: 350 | |
| 481 | + maxPromptTokens: 1024 | |
| 482 | + onlyMyCode: true | |
| 459 | 483 | defaultCompletionOptions: |
| 460 | 484 | temperature: 0.3 |
| 461 | 485 | stop: |
| @@ -531,4 +555,8 @@ | ||
| 531 | 555 | useLegacyCompletionsEndpoint: false |
| 532 | 556 | roles: |
| 533 | 557 | - autocomplete |
| 558 | + autocompleteOptions: | |
| 559 | + debounceDelay: 350 | |
| 560 | + maxPromptTokens: 1024 | |
| 561 | + onlyMyCode: true | |
| 534 | 562 | ``` |
modified docs/reference/json-reference.mdx +6 −0
| @@ -107,6 +107,12 @@ | ||
| 107 | 107 | |
| 108 | 108 | Specifies options for tab autocompletion behavior. |
| 109 | 109 | |
| 110 | +<Info> | |
| 111 | + **Note**: Many of these parameters can also be configured per-model using the | |
| 112 | + `autocompleteOptions` field in `config.yaml`. See the [YAML | |
| 113 | + Reference](/reference#models) for more details. | |
| 114 | +</Info> | |
| 115 | + | |
| 110 | 116 | **Properties:** |
| 111 | 117 | |
| 112 | 118 | - `disable`: If `true`, disables tab autocomplete (default: `false`). |
modified extensions/intellij/gradle.properties +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | pluginGroup=com.github.continuedev.continueintellijextension |
| 2 | 2 | pluginRepositoryUrl=https://github.com/continuedev/continue |
| 3 | -pluginVersion=1.0.34 | |
| 3 | +pluginVersion=1.0.35 | |
| 4 | 4 | pluginSinceBuild=223 |
| 5 | 5 | platformType=IC |
| 6 | 6 | platformVersion=2022.3.3 |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/listeners/ContinuePluginSelectionListener.kt +5 −9
| @@ -1,29 +1,27 @@ | ||
| 1 | 1 | package com.github.continuedev.continueintellijextension.listeners |
| 2 | 2 | |
| 3 | 3 | import ToolTipComponent |
| 4 | -import com.github.continuedev.continueintellijextension.editor.EditorUtils | |
| 5 | 4 | import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings |
| 6 | 5 | import com.github.continuedev.continueintellijextension.utils.Debouncer |
| 7 | 6 | import com.intellij.openapi.application.ApplicationManager |
| 8 | 7 | import com.intellij.openapi.components.service |
| 8 | +import com.intellij.openapi.editor.Document | |
| 9 | 9 | import com.intellij.openapi.editor.Editor |
| 10 | 10 | import com.intellij.openapi.editor.LogicalPosition |
| 11 | 11 | import com.intellij.openapi.editor.SelectionModel |
| 12 | 12 | import com.intellij.openapi.editor.event.SelectionEvent |
| 13 | 13 | import com.intellij.openapi.editor.event.SelectionListener |
| 14 | -import com.intellij.openapi.project.DumbAware | |
| 15 | -import com.intellij.openapi.util.TextRange | |
| 16 | -import kotlinx.coroutines.CoroutineScope | |
| 17 | -import com.intellij.openapi.editor.Document | |
| 18 | -import com.intellij.openapi.editor.ex.util.EditorUtil | |
| 19 | 14 | import com.intellij.openapi.fileEditor.FileDocumentManager |
| 20 | 15 | import com.intellij.openapi.fileEditor.FileEditorManager |
| 21 | 16 | import com.intellij.openapi.fileEditor.TextEditor |
| 17 | +import com.intellij.openapi.project.DumbAware | |
| 18 | +import com.intellij.openapi.util.TextRange | |
| 19 | +import kotlinx.coroutines.CoroutineScope | |
| 22 | 20 | |
| 23 | 21 | class ContinuePluginSelectionListener( |
| 24 | 22 | coroutineScope: CoroutineScope, |
| 25 | 23 | ) : SelectionListener, DumbAware { |
| 26 | - private val debouncer = Debouncer(100, coroutineScope) | |
| 24 | + private val debouncer = Debouncer(200, coroutineScope) | |
| 27 | 25 | private var toolTipComponents: ArrayList<ToolTipComponent> = ArrayList() |
| 28 | 26 | private var lastActiveEditor: Editor? = null |
| 29 | 27 | |
| @@ -228,5 +226,3 @@ | ||
| 228 | 226 | editor.contentComponent.repaint() |
| 229 | 227 | } |
| 230 | 228 | } |
| 231 | - | |
| 232 | - |
modified gui/src/components/mainInput/AtMentionDropdown/index.tsx +51 −29
| @@ -32,6 +32,7 @@ | ||
| 32 | 32 | import SafeImg from "../../SafeImg"; |
| 33 | 33 | import AddDocsDialog from "../../dialogs/AddDocsDialog"; |
| 34 | 34 | import HeaderButtonWithToolTip from "../../gui/HeaderButtonWithToolTip"; |
| 35 | +import { Button } from "../../ui"; | |
| 35 | 36 | import { NAMED_ICONS } from "../icons"; |
| 36 | 37 | import type { ComboBoxItem, ComboBoxItemType } from "../types"; |
| 37 | 38 | |
| @@ -117,6 +118,7 @@ | ||
| 117 | 118 | background-color: #fff1; |
| 118 | 119 | border: 1px solid ${lightGray}; |
| 119 | 120 | border-radius: ${defaultBorderRadius}; |
| 121 | + overflow: hidden; | |
| 120 | 122 | |
| 121 | 123 | padding: 0.2rem 0.4rem; |
| 122 | 124 | width: 240px; |
| @@ -243,7 +245,7 @@ | ||
| 243 | 245 | .run(); |
| 244 | 246 | |
| 245 | 247 | // Trigger warning message |
| 246 | - ideMessenger.ide.showToast( | |
| 248 | + void ideMessenger.ide.showToast( | |
| 247 | 249 | "warning", |
| 248 | 250 | fileSize > 0 |
| 249 | 251 | ? "File exceeds model's context length" |
| @@ -368,8 +370,9 @@ | ||
| 368 | 370 | |
| 369 | 371 | if (item) { |
| 370 | 372 | if (item.type === "file" && item.query) { |
| 371 | - isItemTooBig(item.type, item.query).then(([fileExceeds, fileSize]) => | |
| 372 | - handleItemTooBig(fileExceeds, fileSize, item), | |
| 373 | + void isItemTooBig(item.type, item.query).then( | |
| 374 | + ([fileExceeds, fileSize]) => | |
| 375 | + handleItemTooBig(fileExceeds, fileSize, item), | |
| 373 | 376 | ); |
| 374 | 377 | } else { |
| 375 | 378 | props.command({ ...item, itemType: item.type }); |
| @@ -456,34 +459,53 @@ | ||
| 456 | 459 | return ( |
| 457 | 460 | <ItemsDiv> |
| 458 | 461 | {querySubmenuItem ? ( |
| 459 | - <QueryInput | |
| 460 | - onClick={(e) => { | |
| 461 | - e.stopPropagation(); | |
| 462 | - }} | |
| 463 | - rows={1} | |
| 464 | - ref={queryInputRef} | |
| 465 | - placeholder={querySubmenuItem.description} | |
| 466 | - onKeyDown={(e) => { | |
| 467 | - if (!queryInputRef.current) { | |
| 468 | - return; | |
| 469 | - } | |
| 470 | - if (e.key === "Enter") { | |
| 471 | - if (e.shiftKey) { | |
| 472 | - queryInputRef.current.innerText += "\n"; | |
| 473 | - } else { | |
| 474 | - props.command({ | |
| 475 | - ...querySubmenuItem, | |
| 476 | - itemType: querySubmenuItem.type, | |
| 477 | - query: queryInputRef.current.value, | |
| 478 | - label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`, | |
| 479 | - }); | |
| 462 | + <span className="flex items-center gap-x-1"> | |
| 463 | + <QueryInput | |
| 464 | + wrap="off" | |
| 465 | + onClick={(e) => { | |
| 466 | + e.stopPropagation(); | |
| 467 | + }} | |
| 468 | + rows={1} | |
| 469 | + ref={queryInputRef} | |
| 470 | + placeholder={querySubmenuItem.description} | |
| 471 | + onKeyDown={(e) => { | |
| 472 | + if (!queryInputRef.current) { | |
| 473 | + return; | |
| 474 | + } | |
| 475 | + if (e.key === "Enter") { | |
| 476 | + if (e.shiftKey) { | |
| 477 | + queryInputRef.current.innerText += "\n"; | |
| 478 | + } else { | |
| 479 | + props.command({ | |
| 480 | + ...querySubmenuItem, | |
| 481 | + itemType: querySubmenuItem.type, | |
| 482 | + query: queryInputRef.current.value, | |
| 483 | + label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`, | |
| 484 | + }); | |
| 485 | + } | |
| 486 | + } else if (e.key === "Escape") { | |
| 487 | + setQuerySubmenuItem(undefined); | |
| 488 | + setSubMenuTitle(undefined); | |
| 480 | 489 | } |
| 481 | - } else if (e.key === "Escape") { | |
| 482 | - setQuerySubmenuItem(undefined); | |
| 483 | - setSubMenuTitle(undefined); | |
| 490 | + }} | |
| 491 | + /> | |
| 492 | + <Button | |
| 493 | + variant="secondary" | |
| 494 | + size="sm" | |
| 495 | + className="m-0" | |
| 496 | + disabled={!queryInputRef.current} | |
| 497 | + onClick={() => | |
| 498 | + props.command({ | |
| 499 | + ...querySubmenuItem, | |
| 500 | + itemType: querySubmenuItem.type, | |
| 501 | + query: queryInputRef.current!.value, | |
| 502 | + label: `${querySubmenuItem.label}: ${queryInputRef.current!.value}`, | |
| 503 | + }) | |
| 484 | 504 | } |
| 485 | - }} | |
| 486 | - /> | |
| 505 | + > | |
| 506 | + ⏎ | |
| 507 | + </Button> | |
| 508 | + </span> | |
| 487 | 509 | ) : ( |
| 488 | 510 | <> |
| 489 | 511 | {subMenuTitle && <ItemDiv className="mb-2">{subMenuTitle}</ItemDiv>} |
modified gui/src/pages/AddNewModel/configs/models.ts +26 −0
| @@ -330,6 +330,32 @@ | ||
| 330 | 330 | providerOptions: ["nebius"], |
| 331 | 331 | isOpenSource: true, |
| 332 | 332 | }, |
| 333 | + exaone32B: { | |
| 334 | + title: "EXAONE 4.0.1-32B", | |
| 335 | + description: | |
| 336 | + "LG AI Research's 32B model with integrated reasoning and agentic tool use capabilities.", | |
| 337 | + refUrl: "https://huggingface.co/LGAI-EXAONE/EXAONE-4.0.1-32B", | |
| 338 | + params: { | |
| 339 | + title: "EXAONE-4.0.1-32B", | |
| 340 | + model: "LGAI-EXAONE/EXAONE-4.0.1-32B", | |
| 341 | + contextLength: 131072, | |
| 342 | + }, | |
| 343 | + providerOptions: ["openai"], | |
| 344 | + isOpenSource: true, | |
| 345 | + }, | |
| 346 | + exaone12B: { | |
| 347 | + title: "EXAONE 4.0-1.2B", | |
| 348 | + description: | |
| 349 | + "Compact EXAONE 4.0 model suitable for on-device use while retaining tool calling support.", | |
| 350 | + refUrl: "https://huggingface.co/LGAI-EXAONE/EXAONE-4.0-1.2B", | |
| 351 | + params: { | |
| 352 | + title: "EXAONE-4.0-1.2B", | |
| 353 | + model: "LGAI-EXAONE/EXAONE-4.0-1.2B", | |
| 354 | + contextLength: 65536, | |
| 355 | + }, | |
| 356 | + providerOptions: ["openai"], | |
| 357 | + isOpenSource: true, | |
| 358 | + }, | |
| 333 | 359 | moonshotChat: { |
| 334 | 360 | title: "Moonshot Chat", |
| 335 | 361 | description: "Moonshot AI provides high-performance large language models", |
modified gui/src/pages/config/IndexingSettingsSection.tsx +1 −1
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | <div className="pb-2 pt-5"> |
| 16 | 16 | <p className="py-1 text-center font-semibold">Indexing is disabled</p> |
| 17 | 17 | <p className="text-lightgray cursor-pointer text-center text-xs"> |
| 18 | - Open settings and toggle <code>Disable Indexing</code> to re-enable | |
| 18 | + Open settings and toggle <code>Enable Indexing</code> to re-enable | |
| 19 | 19 | </p> |
| 20 | 20 | </div> |
| 21 | 21 | ) : ( |
modified packages/config-types/src/index.ts +10 −0
| @@ -151,6 +151,16 @@ | ||
| 151 | 151 | useRecentlyEdited: z.boolean(), |
| 152 | 152 | disableInFiles: z.array(z.string()).optional(), |
| 153 | 153 | useImports: z.boolean().optional(), |
| 154 | + // Experimental options: true = enabled, false = disabled, number = enabled w priority | |
| 155 | + experimental_includeClipboard: z.union([z.boolean(), z.number()]).optional(), | |
| 156 | + experimental_includeRecentlyVisitedRanges: z | |
| 157 | + .union([z.boolean(), z.number()]) | |
| 158 | + .optional(), | |
| 159 | + experimental_includeRecentlyEditedRanges: z | |
| 160 | + .union([z.boolean(), z.number()]) | |
| 161 | + .optional(), | |
| 162 | + experimental_includeDiff: z.union([z.boolean(), z.number()]).optional(), | |
| 163 | + experimental_enableStaticContextualization: z.boolean().optional(), | |
| 154 | 164 | }); |
| 155 | 165 | export type TabAutocompleteOptions = z.infer< |
| 156 | 166 | typeof tabAutocompleteOptionsSchema |
modified packages/config-yaml/src/schemas/models.ts +10 −0
| @@ -120,6 +120,16 @@ | ||
| 120 | 120 | prefixPercentage: z.number().optional(), |
| 121 | 121 | template: z.string().optional(), |
| 122 | 122 | onlyMyCode: z.boolean().optional(), |
| 123 | + useCache: z.boolean().optional(), | |
| 124 | + useImports: z.boolean().optional(), | |
| 125 | + useRecentlyEdited: z.boolean().optional(), | |
| 126 | + useRecentlyOpened: z.boolean().optional(), | |
| 127 | + // Experimental options: true = enabled, false = disabled, number = enabled w priority | |
| 128 | + experimental_includeClipboard: z.boolean().optional(), | |
| 129 | + experimental_includeRecentlyVisitedRanges: z.boolean().optional(), | |
| 130 | + experimental_includeRecentlyEditedRanges: z.boolean().optional(), | |
| 131 | + experimental_includeDiff: z.boolean().optional(), | |
| 132 | + experimental_enableStaticContextualization: z.boolean().optional(), | |
| 123 | 133 | }); |
| 124 | 134 | |
| 125 | 135 | /** Prompt templates use Handlebars syntax */ |