From bb9e92bb842f2595efb75be1613be07b681fbe8e Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 7 May 2026 14:18:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=20=20=E7=9C=9F=E6=AD=A3?= =?UTF-8?q?=E8=90=BD=E5=9C=B0:=20=E4=BA=A7=E7=89=A9=E6=94=B6=E6=95=9B?= =?UTF-8?q?=E5=88=B0=20workspace/tasks//?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 SKILL.md 反复说 /spec_lock.md / /sections/,但代码里没把 task_dir 暴露给 agent,只给了 cwd——导致 spec_lock.md 落到 skills/proposal/、 sections/ 落到 repo 根。两者被 .gitignore 通配规则盖住,问题被掩盖。 - main.py system prompt 里显式注入 task_dir 绝对路径 + 强约束(只写 task_dir,不写 cwd / skills/ / repo 根)。SKILL 里的 占位符明确指向这个值。 - skills/proposal/SKILL.md + skills/ppt/SKILL.md 的「工作目录约定」前面加一句解释 来自 system prompt。 - .gitignore 删掉 sections/ slides/ spec_lock.md 这三条无锚 bandaid——workspace/ 已经覆盖正确路径下的产物;repo 根再写错了要靠 git status 立刻报红,不再靠 ignore 兜底。 Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 6 +++--- main.py | 12 +++++++++++- skills/ppt/SKILL.md | 3 +++ skills/proposal/SKILL.md | 2 ++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 82359aa..eaba2a7 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,10 @@ venv/ env/ # 用户运行产物 / 临时文件 +# task 内产物(sections/ slides/ spec_lock.md/ *.docx/*.pptx)都在 workspace/tasks// 下, +# 由上面这条 workspace/ 一并忽略。repo 根级别的 sections/ / slides/ / spec_lock.md +# **故意不忽略**——如果 agent 又写错位置,要靠 git status 立刻暴露,不再用 .gitignore 兜底。 workspace/ -slides/ -sections/ *.log # Claude Code 本地状态 @@ -41,7 +42,6 @@ desktop.ini *.tmp.pptx output.pptx untitled*.pptx -spec_lock.md /*.pptx /*.docx diff --git a/main.py b/main.py index cbda6e1..7c80927 100644 --- a/main.py +++ b/main.py @@ -126,7 +126,17 @@ def build_agent( system_prompt = (ROOT / cfg["system_prompt"]).read_text(encoding="utf-8") if skills.skills: system_prompt += f"\n\n## 可用 skill (用 load_skill 加载完整指引)\n{skills.discovery_block()}" - system_prompt += f"\n\n## 当前工作目录\n{tool_base}" + task_dir_abs = task_dir.resolve() + system_prompt += ( + f"\n\n## 工作目录\n" + f"- cwd(用户启动时所在目录,只读用): `{tool_base}`\n" + f"- **task_dir(所有产物写到这里)**: `{task_dir_abs}`\n\n" + f"SKILL 文档里出现的 `` 占位符,一律指上面这个绝对路径。" + f"产物示例: `{task_dir_abs}/spec_lock.md`、" + f"`{task_dir_abs}/sections/01_summary.md`、" + f"`{task_dir_abs}/slides/`、最终 .docx/.pptx。\n" + f"⛔ 不要把产物写到 cwd / `skills/` / repo 根 —— 只写到 task_dir。" + ) now_iso = datetime.now().isoformat(timespec="seconds") meta = { "id": sid, diff --git a/skills/ppt/SKILL.md b/skills/ppt/SKILL.md index 7a176a7..a00b495 100644 --- a/skills/ppt/SKILL.md +++ b/skills/ppt/SKILL.md @@ -89,6 +89,9 @@ python scripts/quality_check.py --spec spec_lock.md - 详细规则见 `references/design_principles.md` ## 工作目录约定 + +下文 `` = system prompt 里「task_dir」给的**绝对路径**(形如 `…/workspace/tasks//`)。**所有产物都写到 task_dir 下**,不要写到 cwd / `skills/` / repo 根;`assets/icons/` 是 skill 自带的图标缓存,继续走 `skills/ppt/assets/icons/`。 + ``` / ├── source.md # source_to_md.py 转出的素材 diff --git a/skills/proposal/SKILL.md b/skills/proposal/SKILL.md index 4d47fba..490efa7 100644 --- a/skills/proposal/SKILL.md +++ b/skills/proposal/SKILL.md @@ -67,6 +67,8 @@ python skills/proposal/scripts/render_docx.py /sections/ --fund-type k ## 工作目录约定 +下文 `` = system prompt 里「task_dir」给的**绝对路径**(形如 `…/workspace/tasks//`)。**所有产物都写到 task_dir 下**,不要写到 cwd / `skills/` / repo 根。 + ``` / ├── source/ # 用户给的素材 (指南 PDF / 前期成果 / 团队介绍)