Delegate file generation to shell_agent when direct tools fail, with systematic file location and retrieval
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-shell-agent-file-workflow-293ac83a6396 ,按照其中的说明把「shell-agent-file-workflow」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
When direct document or file generation approaches fail, delegate the task to shell_agent which can autonomously write code, execute it, and retry on errors. Generated files may appear in nested workspace directories.
create_file functions fail for complex formatsUse shell_agent with a clear, specific task description:
shell_agent(task="Create a [file type] with [specific content/structure requirements]")
The agent will:
Files may be created in nested directories within the workspace. Use find to locate them:
find . -name "*.extension" -type f
For multiple file types:
find . -type f \( -name "*.pptx" -o -name "*.docx" -o -name "*.pdf" \)
For recently modified files (last 10 minutes):
find . -name "*.extension" -type f -mmin -10
Once located, copy the file to your working directory:
cp /path/to/found/file.extension ./
# Step 1: Delegate to shell_agent
shell_agent(task="Create a 10-slide PowerPoint presentation covering: topic A, topic B, topic C")
# Step 2: Find the generated file
find . -name "*.pptx" -type f
# Output might show: ./workspace/nested/path/presentation.pptx
# Step 3: Copy to working directory
cp ./workspace/nested/path/presentation.pptx ./
# Step 1: Delegate generation
shell_agent(task="Generate a PDF report with charts and tables from the provided data")
# Step 2: Locate output
find . -name "*.pdf" -type f -mmin -5
# Step 3: Retrieve file
cp ./generated/reports/output.pdf ./
| Issue | Solution |
|---|---|
| No files found | Expand search: remove extension filter, increase time window |
| Multiple files found | Sort by modification time: find . -name "*.ext" -type f -printf '%T@ %p\n' | sort -n |
| File is corrupted | Re-run shell_agent with more specific requirements |
| Permission errors | Use sudo or check directory permissions |