This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-07 07:04:05 +01:00
1 parent 977d3960b0
commit b74a03a02d
2 files changed
+25 -17

No files matched your search

@@ -360,28 +360,14 @@
}
}}
>
<div class="flex items-center gap-1.5 px-3 pt-2 pb-0.5">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="size-3.5 text-gray-400 dark:text-gray-500 shrink-0"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
/>
</svg>
<span class="text-sm font-medium text-gray-800 dark:text-gray-100"
<div class="flex items-center px-3 pt-2.5 pb-0.5">
<span class="text-xs font-medium text-gray-800 dark:text-gray-100"
>{artifact.title || 'Artifact'}</span
>
</div>
{#if preview}
<p
class="px-3 pb-2 pt-0.5 text-xs text-gray-500 dark:text-gray-400 line-clamp-2 leading-relaxed"
class="px-3 pb-2.5 text-[10px] text-gray-400 dark:text-gray-500 line-clamp-2 leading-relaxed"
>
{preview}{preview.length >= 200 ? '...' : ''}
</p>
+22
View File
@@ -49,6 +49,14 @@ async def _collect_bg_output(task_id: str, proc: asyncio.subprocess.Process):
# ── Helper ──────────────────────────────────────────────────
def _is_dotenv(path: Path) -> bool:
"""Return True if the path refers to a .env file (e.g. .env, .env.local)."""
return path.name == ".env" or path.name.startswith(".env.")
_DOTENV_ERROR = "Error: access to .env files is not allowed for security reasons."
def _human_size(size: int) -> str:
"""Format byte size for display."""
for unit in ("B", "KB", "MB", "GB"):
@@ -83,6 +91,8 @@ async def read_file(
:param end_line: Last line to read (inclusive, 0 = to end of file).
"""
full = _resolve_path(path, workspace)
if _is_dotenv(full):
return _DOTENV_ERROR
if not full.is_file():
return f"Error: file not found: {path}"
@@ -213,6 +223,8 @@ async def _search_rg(
) -> str:
"""Search using ripgrep."""
args = ["rg", "--no-heading", "--max-count=50", "--color=never"]
# Never search .env files
args.extend(["--glob", "!.env", "--glob", "!.env.*"])
if not regex:
args.append("--fixed-strings")
if case_insensitive:
@@ -277,6 +289,8 @@ async def _search_python(query: str, full: Path, case_insensitive: bool) -> str:
dirs[:] = [d for d in dirs if d not in ignore]
for fname in files:
fpath = Path(root) / fname
if _is_dotenv(fpath):
continue
text = _read_text_for_search(fpath)
if text is None:
continue
@@ -317,6 +331,8 @@ async def create_file(
return "Error: path is required when artifact_type is not set."
full = _resolve_path(path, workspace)
if _is_dotenv(full):
return _DOTENV_ERROR
if full.is_file() and not overwrite:
return f"Error: file already exists: {path}. Use overwrite=true or edit_file to modify."
@@ -334,6 +350,8 @@ async def write_file(path: str, content: str, *, workspace: str) -> str:
:param content: File contents to write.
"""
full = _resolve_path(path, workspace)
if _is_dotenv(full):
return _DOTENV_ERROR
def _write():
full.parent.mkdir(parents=True, exist_ok=True)
@@ -360,6 +378,8 @@ async def edit_file(
:param end_line: Narrow search to lines ending here (0 = to end).
"""
full = _resolve_path(path, workspace)
if _is_dotenv(full):
return _DOTENV_ERROR
if not full.is_file():
return f"Error: file not found: {path}"
@@ -422,6 +442,8 @@ async def multi_edit_file(
:param edits: JSON array of edit objects, each with 'target' and 'replacement' strings, and optional 'start_line'/'end_line' integers.
"""
full = _resolve_path(path, workspace)
if _is_dotenv(full):
return _DOTENV_ERROR
if not full.is_file():
return f"Error: file not found: {path}"