makecindy / makecindy/cindy

文件写入只能走 shell 字符串拼接,缺少不经 shell 的安全写入方式(建议 write_file / 放开 exec 的 require / shell_command 支持数组)

Open
#3,463 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

**提交人**: youyoucn
**客户端版本**: 0.1.61

---

## 反馈类型
Bug 报告(文件写入体验缺陷)

## 现象 / 当前痛点
通过 shell_command 写文件必须走 shell 字符串拼接,路径含空格或中文时转义成本高、容易出错。当前缺少「不经过 shell 解析」的安全写入原语,写文件只能依赖手工转义。

## 复现步骤
1. 在 exec 单元格确认运行时环境:
- `typeof require` → `"undefined"`
- `typeof process` → `"undefined"`
说明 exec 是纯 JS 沙箱,不暴露任何 Node API,无法用 `require("fs")` 直接写文件。
2. 尝试用数组形式调用 shell_command(execFile 语义,参数不经 shell 解析):
- `await tools.shell_command({ command: ["echo", "hello world"] })`
- 实际报错:`failed to parse function arguments: invalid type: sequence, expected a string at line 1 column N`

## 期望行为
至少提供以下之一,使文件写入无需手工处理 shell 转义:
- 方案 1(推荐):原生 `write_file(path, content)` 工具,与 `read` 对应,不依赖 shell;
- 方案 2:exec 沙箱放开 `require("fs")`,至少允许写入白名单目录(工作区 / 系统临时目录);
- 方案 3:shell_command 支持数组参数,按 execFile 语义传参,不经过 shell 解析。

## 实际行为
- exec 内 `require` / `process` 不可用,无 Node 文件系统 API;
- shell_command 的 `command` 仅接受字符串,传入数组直接参数解析失败。

## 复现频率
稳定复现(确定性行为,100%)。

## 已尝试的方法 / 当前可用的 workaround
shell_command 的字符串形式可以正常读写工作区与系统临时目录,功能上「能写」,但每次都需手动转义,路径含空格 / 中文时尤其繁琐且易错。

## 补充(建议范围)
以上三条合并提出,方案 1 为首选,方案 2、3 为备选;任一落地都可明显改善文件写入体验。

## 环境信息
由系统自动附加(客户端版本 / 版本区域 / OS / 界面语言)。
---
**版本区域**: CN
**OS**: win32 x64 (10.0.26200)
**界面语言**: zh-CN

Contributor guide

Open the contributing guide

Research direction

Start by locating the tools.shell_command argument schema and the exec sandbox setup, then compare the existing read capability. The issue offers three alternative designs rather than one defined change; done means agreeing on one safe non-shell file-writing path or argument-passing behavior and verifying the reported reproduction no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, shell, typescript
Domain
developer-experience, security, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.