SKILL.md 的輸出路徑指令不夠明確,Gemini CLI 把 output/ 解讀為相對於 Skill安裝目錄(.gemini/skills/blog-pro-max/output/),而非使用者的工作目錄

◐ The user is reporting that when Gemini CLI executes the skill, it saves files to .gemini/skills/blog-pro-max/output/
instead of output/ (relative to the user’s working directory). This is a path problem in the SKILL.md instructions.

The issue is that Gemini CLI is running the script from the skill directory (.gemini/skills/blog-pro-max/), so when
the script outputs to output/, it creates output/ relative to the script’s location, which is
.gemini/skills/blog-pro-max/output/.

The fix is to make the SKILL.md instructions more explicit about where to save files.

I need to update the SKILL.md to clarify that files should be saved to the user’s current working directory rather
than relative to the skill’s location, or provide absolute path guidance so the output goes where the user expects.
The real issue is that when Gemini CLI runs the script from the project root, the SKILL.md instructions reference
output/關鍵字.md as if it’s relative to the skill directory, but it should be relative to where the user is actually
working. I need to update the script execution instruction to use the correct path that accounts for the skill being
installed in .gemini/skills/blog-pro-max/. The real problem is that Gemini CLI is executing the scripts correctly,
but the SKILL.md documentation needs to be clearer about where output files should go. I need to update the
instructions to explicitly state that all output paths should be relative to the user’s current working directory, not
the skill installation directory. The scripts themselves are already using Path.cwd() / "output", so they should
work fine as long as the working directory is set correctly—the issue is just making sure the documentation is
unambiguous about this. The real issue is that the working directory gets set to the skill directory when Gemini CLI
runs the scripts, so output files end up in the wrong place. I need to update SKILL.md to explicitly instruct users to
save output to the project root output/ directory using absolute or relative paths, then check how script_prefix
is being used in blogpro.py to understand the exact execution context.

● Search (grep)
│ “script_prefix|output/|CWD|工作目錄|當前目錄” (blog_pro_max\blogpro.py)
└ 88 lines found

◐ Now I understand the issue. The problem is:

  1. When Gemini CLI executes content_research.py, it uses the script at
    .gemini/skills/blog-pro-max/scripts/content_research.py
  2. The script uses Path.cwd() / "output" for its output directory
  3. But Gemini CLI appears to be changing the working directory to the skill installation directory before running the
    script Looking at the log:
  Shell python .gemini/skills/blog-pro-max/scripts/output_md2html.py 
  .gemini/skills/blog-pro-max/output/resolve-ai-jumping-thoughts.md 
  .gemini/skills/blog-pro-max/output/resolve-ai-jumping-thoughts.html

This shows that Gemini CLI ran content_research.py and created the file in .gemini/skills/blog-pro-max/output/,
which means the script’s working directory was set to the skill directory when executed. So when the script calls
Path.cwd() / "output", it’s resolving relative to that skill directory rather than the project root.

  I think the issue is that Gemini CLI runs scripts from the skill directory as the working directory, not the project 
  root. So when `content_research.py` uses `Path.cwd() / "output"`, it's resolving to 
  `.gemini/skills/blog-pro-max/output/` instead of the intended project root output folder. The fix would be to either 
  have Gemini always run scripts from the project root, or explicitly pass the full output path as a command-line 
  argument to avoid this path resolution confusion.

I’m considering three approaches to fix this: explicitly passing an output path parameter to the script,
prepending a directory change command before execution, or adding a clear warning in the SKILL.md documentation that
specifies the project root as the working directory and clarifies where output files should be saved versus where the
skill is installed. I need to update the script execution instructions in the SKILL.md file to clarify that scripts
should run from the user’s project root, with output going to ./output/ relative to that directory, not the skill
installation folder. I need to clarify that users should reference the project root’s output folder, not any nested
skill directory output, to avoid confusion about where files are actually being written.

● 問題根源清楚了:Gemini CLI 執行腳本時,它把 output/ 路徑解讀為相對於 Skill
安裝目錄(.gemini/skills/blog-pro-max/output/),而非使用者的工作目錄。

解法:在 SKILL.md 的腳本執行指令中,明確說明輸出路徑要用使用者工作目錄,並加入 –output 參數明確指定。需要同時更新
blog_pro_max/blogpro.py 和 scripts/blogpro.py:

修改內容(blog_pro_max/blogpro.py + scripts/blogpro.py):

 1. 新增 ⚠️ 輸出路徑規則(所有模式通用):
  - 明確說明所有 .md/.html 必須存到使用者工作目錄的 output/
  - 明確禁止:不能存到 Skill 安裝目錄
 2. 腳本執行步驟新增: mkdir -p output  # 確保 output/ 存在於使用者工作目錄

 並加上備注:腳本以 CWD 為基準,必須在使用者專案根目錄執行
 3. Gemini CLI 歸類修正:Gemini CLI 其實可執行腳本,已從「不具備執行腳本能力」類別移除
 4. output_md2html.py 呼叫使用一致的 {script_prefix},避免路徑混淆

 提醒:已安裝的舊版 SKILL.md 需執行 blogpro update 才能套用修正。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *