Commit graph

172 commits

Author SHA1 Message Date
shanevcantwell
c79e6489a7
fix: restrict terminal childProcess.spawn to local-only environments (#10538)
fix: restrict childProcess.spawn to local-only environments

childProcess.spawn executes on the extension host machine. With
extensionKind: ["ui", "workspace"], the extension host almost always
runs locally. For any remote workspace (SSH, WSL, Dev Container,
Codespaces, tunnel), spawning locally either runs commands on the wrong
machine or fails with ENOENT when the local shell doesn't exist in the
extension host context.

Replace ENABLED_FOR_REMOTES (which listed all remote types) with
LOCAL_ONLY (just "" and "local"). All remote types now fall through to
ide.runCommand() which delegates to VS Code's integrated terminal and
executes in the correct remote environment.

The isWindowsHostWithRemote guard is removed as it is now redundant —
the platform-agnostic check handles all cases.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 20:33:04 -07:00
Keita A.
5d19470aa9
fix: add default timeout for terminal command tool execution (#10550)
* fix: add default timeout for terminal command tool execution

Terminal commands with waitForCompletion=true had no timeout, risking
indefinite hangs. Adds a 2-minute default timeout with graceful
SIGTERM -> 5s grace period -> SIGKILL escalation. Both streaming
and non-streaming code paths are covered. The SIGKILL timer is
properly cleared if the process exits during the grace period.

* fix: correct process running check and clear SIGKILL timer

Replace `childProc.killed` with `exitCode === null && signalCode === null`
for accurate process-state detection, and clear sigkillTimeoutId in error
handlers to prevent delayed kills after rejection.

Applied to both streaming and non-streaming paths.

---------

Co-authored-by: amabito <192487536+amabito@users.noreply.github.com>
Co-authored-by: amabito <amabito@local>
2026-03-24 11:04:28 -07:00
zerone0x
b091f5184d
fix: preserve leading dot in ls tool path resolution (#10515)
The `resolveLsToolDirPath` function incorrectly stripped leading dots
from paths like `.continue/rules`, converting them to `continue/rules`
which doesn't exist. This broke the ls tool for any hidden directory.

Remove the faulty condition that matched paths starting with "." but
not "./" and stripped their first character. The path resolver handles
these paths correctly without preprocessing.

Fixes #10466

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-10 00:08:14 -07:00
Nate Sesti
faca87bbc8
fix: add security check to createNewFile tool (CWE-22) (#11238)
* fix: add security check to createNewFile tool (CWE-22)

The createNewFile tool was missing the throwIfFileIsSecurityConcern()
check that readFile already has, allowing path traversal to write
sensitive file types (e.g. .env, SSH keys) via prompt injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: upgrade tar-fs to patch CVE-2024-12905 and CVE-2025-59343

core/vendor had tar-fs@2.1.2 (via prebuild-install) and tar-fs@3.0.8,
both in vulnerable ranges. npm audit fix upgraded them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 12:27:47 -07:00
shanevcantwell
b7c2b4f074 fix: generalize Windows remote detection for terminal commands
Broadens the Windows-with-remote check from WSL-only to all non-local
remotes (Dev Container, SSH, Codespaces, etc.) so that terminal commands
fall back to ide.runCommand() instead of trying to spawn powershell.exe.

Fixes #10007

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 08:01:35 -07:00
shanevcantwell
c565bdc464 fix: use ide.runCommand when Windows host connects to WSL
When the VS Code extension runs on Windows but connects to WSL,
direct shell spawning fails because process.platform is "win32"
but commands should execute in the Linux WSL environment.

This caused: spawn powershell.exe ENOENT

The fix detects this scenario and falls back to ide.runCommand(),
letting VS Code handle the remote terminal execution properly.

Fixes #9661

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:55:16 -07:00
uinstinct
f5c345254d support relative path for workspace dirs 2026-01-15 19:00:09 +05:30
uinstinct
b9bcd33cce add supporting files for skill tool 2026-01-15 13:05:03 +05:30
uinstinct
2ecccb0fa5 Merge branch 'main' into agent-skills 2026-01-15 11:39:22 +05:30
Dallin Romney
e419333183
Merge pull request #9325 from shanevcantwell/fix/wsl2-terminal-command-uri
fix: handle non-file URI schemes in runTerminalCommand for WSL2
2026-01-14 13:26:24 -08:00
Volodymyr Bychkovyak
c078d772eb fix issue with lsTool listing fs root instead of current folder 2026-01-06 22:53:36 -06:00
shanevcantwell
8e5a7c2152 refactor: generalize remote URI handling and remove CLAUDE.md
- Remove WSL-specific check in favor of generic URI handling
- Support all vscode-remote:// URI schemes (WSL, SSH, dev-container)
- Prefer file:// URIs when available, fall back to remote URIs
- Add tests for various remote URI formats
- Remove CLAUDE.md per reviewer feedback (use AGENTS.md convention)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 19:08:33 -07:00
uinstinct
c219e3e5c9 read skill is a tool definition 2026-01-06 17:31:04 +05:30
uinstinct
b6eddec2f4 add read skill tool 2025-12-30 12:51:16 +05:30
shanevcantwell
6b30a88fb0 style: fix prettier formatting
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 06:27:00 -07:00
shanevcantwell
27adb1d677 fix: use try/finally for env cleanup in test
Ensures process.env.HOME is restored even if assertions fail,
preventing flaky behavior in subsequent tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:36:39 -07:00
shanevcantwell
3ef9f89e8f test: add comprehensive tests for WSL workspace path resolution
Tests cover:
- Basic WSL URI parsing
- URL-encoded spaces and special characters
- Unicode path handling
- Different WSL distro names
- Priority of WSL URIs over file:// URIs
- Fallback behavior
- Edge cases (plus signs, percent signs, mixed encoding)
- Comparison with fileURLToPath behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:30:02 -07:00
shanevcantwell
074a6c74ba fix: decode URI-encoded pathname for WSL workspace paths
Paths with spaces or special characters (e.g., /home/user/my%20project)
need decodeURIComponent() to match actual filesystem paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:14:40 -07:00
shanevcantwell
eab2ac1e04 fix: properly resolve WSL2 workspace paths in runTerminalCommand
Parse vscode-remote://wsl+distro/path URIs to extract the actual
workspace path instead of falling back to Windows HOME directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:10:13 -07:00
shanevcantwell
788e25338a fix: wrap fileURLToPath in try-catch for WSL2 compatibility
The fileURLToPath function can throw "The URL must be of scheme file"
in some WSL2/remote environments with malformed URIs. Wrap in try-catch
to fall through to HOME directory fallback.

Fixes #8091

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 02:57:06 -07:00
continue[bot]
d70bdbbf28
Fix readFileRange Kotlin Int overflow in IntelliJ plugin (#8976)
* Fix readFileRange Kotlin Int overflow in IntelliJ plugin

Replace Number.MAX_SAFE_INTEGER with Int.MAX_VALUE (2147483647) to prevent
JSON deserialization errors in IntelliJ plugins.

The issue occurred because JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1)
exceeds Kotlin's Int maximum value (2^31 - 1), causing the following error:
'java.lang.NumberFormatException: Expected an int but was 9007199254740991'

This change ensures compatibility with Kotlin's Int type while still reading
to the end of each line as intended.

Fixes #8517

Co-authored-by: dallin <dallin@continue.dev>
Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* Trigger CI re-run

The previous CI failure was a flaky test in the CLI extension, unrelated to our changes.

Co-authored-by: dallin <dallin@continue.dev>
Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* Extract magic number into MAX_CHAR_POSITION constant

Improve code maintainability by defining the Kotlin Int.MAX_VALUE as a
named constant with clear documentation.

Co-authored-by: dallin <dallin@continue.dev>
Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* Trigger CI re-run for flaky tests

Flaky UI tests failing intermittently on macOS (Node 18, 20) but passing
on all other platforms. Tests are unrelated to readFileRange changes.

Co-authored-by: dallin <dallin@continue.dev>
Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* Fix flaky CLI UI tests on macOS

Increase timeouts for UI rendering tests on macOS to prevent race conditions.
The tests were failing intermittently on macOS with Node 18/20 due to
insufficient wait times for UI stabilization.

Changes:
- Double timeouts on macOS in TUIChat.fileSearch.test.tsx
- Add extra 100ms wait on macOS in TUIChat.slashCommands.test.tsx
- Tests now pass consistently across all platforms

Co-authored-by: dallin <dallin@continue.dev>
Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

* fix: revert test changes

---------

Co-authored-by: continue[bot] <continue[bot]@users.noreply.github.com>
Co-authored-by: Continue <noreply@continue.dev>
Co-authored-by: Dallin Romney <dallinromney@gmail.com>
2025-12-05 12:13:39 -08:00
Dallin Romney
814cc205fb fix: unify cwd and add missing case 2025-11-27 02:29:13 -08:00
Dallin Romney
462e7168bd fix: terminal cwd tests 2025-11-24 15:12:20 -08:00
Continue Agent
857903aa5b Add test coverage for runTerminalCommand cwd handling with non-file URIs
Tests verify that the fix correctly:
- Filters for file:// URIs before calling fileURLToPath
- Falls back to HOME/USERPROFILE/cwd/tmpdir when no file URIs exist
- Handles various workspace configurations (empty, non-file URIs, mixed)
- Works across different remote environments (local, WSL, dev-container)

Co-authored-by: nate <nate@continue.dev>

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
2025-11-24 21:56:19 +00:00
Dallin Romney
4837ef1352 fix: only set cwd to file URI if file uri found 2025-11-24 13:49:29 -08:00
Dallin Romney
7c369e0ac9 fix: only set cwd to file URI if found 2025-11-24 13:49:10 -08:00
Dallin Romney
1d15c7c3df
Merge pull request #8298 from continuedev/pe/read-file-errs
feat: allow file reads outside IDE workspace (w/ permission)
2025-10-20 10:50:38 -07:00
Patrick Erichsen
ee439faa38 fix tests 2025-10-17 11:21:55 -07:00
Patrick Erichsen
0670852a15 Update viewSubdirectory.vitest.ts 2025-10-17 11:02:14 -07:00
Patrick Erichsen
9388bd251f update subdirectory logic 2025-10-17 10:25:37 -07:00
Patrick Erichsen
c6780c095f Update fetchUrlContent.vitest.ts 2025-10-17 10:18:30 -07:00
Patrick Erichsen
48cef4256d add vitest for fetchUrlContent 2025-10-17 10:00:17 -07:00
Patrick Erichsen
4d747796e0 feat: return fetch errors to agent 2025-10-16 19:00:24 -07:00
Patrick Erichsen
ad2fd48124 Merge main branch and resolve conflicts
- Combined resolveInputPath approach with new ContinueError system
- Updated error handling to use ContinueError with appropriate error reasons
- Maintained improved error messages from pe/read-file-errs branch
2025-10-16 16:00:29 -07:00
Patrick Erichsen
4903f3ab94 add tool call policy evaluation 2025-10-16 15:56:31 -07:00
Patrick Erichsen
9b908d8ecd prettier 2025-10-14 15:48:35 -07:00
Patrick Erichsen
77a8db7f63 use specific ConitnueError for tool calls 2025-10-14 14:55:00 -07:00
Patrick Erichsen
1d7da38a66 fix: log correct tool call error from gui 2025-10-14 14:40:09 -07:00
Dallin Romney
c75262e692 ruleFile -> sourceFile 2025-09-29 16:05:05 -07:00
Dallin Romney
11d84b3b16 feat: empty diff tool result message 2025-09-10 19:26:50 -07:00
chezsmithy
acbba9b7d0 fix: 🐛 Fixes based on reviewer comments 2025-09-09 10:14:09 -07:00
chezsmithy
58cb7815ca feat: Add ability to stop foreground terminal commands 2025-09-09 10:12:59 -07:00
Tomasz Stefaniak
5604b299b3 Merge branch 'main' into tomasz/con-3679 2025-09-03 15:35:37 -07:00
Tomasz Stefaniak
259cbc25f8
Merge pull request #7421 from continuedev/tomasz/con-3680
Create dynamic tool policies and implement dynamic policy for terminal tool
2025-09-03 14:13:25 -07:00
Tomasz Stefaniak
c00bbd78b1 improv: move terminal security to separate package 2025-09-03 12:47:08 -07:00
Tomasz Stefaniak
606df7e0b6 test: echo 2025-09-03 10:27:46 -07:00
Tomasz Stefaniak
5d2b4725a2 test: echo 2025-09-03 10:27:00 -07:00
chezsmithy
c596f8b872 fix: 🐛 Remove head tool and move range tool to experimental 2025-08-27 23:06:39 -07:00
chezsmithy
7ffc6fb67d fix: 🎨 Prettier and Linting 2025-08-27 22:27:15 -07:00
chezsmithy
820822196b feat: ✨ Add range and head tools for file operations 2025-08-27 22:27:15 -07:00