Init

From Chanw-research/claude-code-paper-writing · View interactive version

Init is an AI agent skill from the GitHub repository Chanw-research/claude-code-paper-writing. 基于用户素材与可选外部发现搭建 ΩmegaWiki,并用并行 `/ingest` 完成最终论文集的消化

How to use this skill

Skill file

/init

从 raw/ 搭建 wiki:先做确定性 prepare,再跑 planner-guided discovery;raw/notes/ 与 raw/web/ 可种下 provisional scaffold;论文消化仍走并行 /ingest fan-out / fan-in。

按需打开这些本地参考文件:

Inputs

Outputs

Wiki Interaction

Reads

Writes

Graph edges created

Workflow

前置条件:当前目录为项目根,且包含 wiki/、raw/、tools/。设 WIKI_ROOT=wiki/。先解析一次 PYTHON_BIN,并在整个 /init 流程里复用它,确保运行时使用与 setup.sh 安装依赖时相同的解释器:

# 通过 git 找到项目根,让 worktree 中的 subagent 也能定位 .venv。
# .venv 被 gitignore,subagent 的 cwd 在 ../.worktrees/<branch>/ 时本地没有
# .venv——若不解析项目根,PYTHON_BIN 会回退到系统 python3,既丢失 .env 里的
# API key,也丢失安装的依赖(deepxiv-sdk 等)。
# git rev-parse --git-common-dir 无论 cwd 位于哪个 worktree 都返回主仓库的
# .git 目录;其父目录即项目根。
GIT_COMMON_DIR=$(git rev-parse --git-common-dir 2>/dev/null || true)
PROJECT_ROOT=""
if [ -n "$GIT_COMMON_DIR" ]; then
  PROJECT_ROOT=$(cd "$(dirname "$GIT_COMMON_DIR")" 2>/dev/null && pwd)
fi

if   [ -x "$PROJECT_ROOT/.venv/bin/python" ];         then PYTHON_BIN="$PROJECT_ROOT/.venv/bin/python"
elif [ -x "$PROJECT_ROOT/.venv/Scripts/python.exe" ]; then PYTHON_BIN="$PROJECT_ROOT/.venv/Scripts/python.exe"
elif [ -x .venv/bin/python ];                         then PYTHON_BIN=.venv/bin/python
elif [ -x .venv/Scripts/python.exe ];                 then PYTHON_BIN=.venv/Scripts/python.exe
else                                                       PYTHON_BIN=python3
fi
export PYTHON_BIN

Step 1: 初始化 wiki 结构

"$PYTHON_BIN" tools/research_wiki.py init wiki/

创建标准目录、graph/、outputs/、index.md 与 log.md。这里不要重复写第二条 init 日志。

Step 2: 把本地输入 prepare 到 `raw/tmp/`

"$PYTHON_BIN" tools/init_discovery.py prepare --raw-root raw --pdf-titles-json .checkpoints/init-pdf-titles.json --output-manifest .checkpoints/init-prepare.json

Step 3: 生成 discovery plan、裁剪最终论文集,并写出 source manifest

"$PYTHON_BIN" tools/init_discovery.py plan [--topic "<topic>"] --mode auto --raw-root raw --wiki-root wiki --prepared-manifest .checkpoints/init-prepare.json --allow-introduction <true|false> --output-plan .checkpoints/init-plan.json

然后执行:

"$PYTHON_BIN" tools/init_discovery.py fetch --raw-root raw --plan-json .checkpoints/init-plan.json --prepared-manifest .checkpoints/init-prepare.json --output-sources .checkpoints/init-sources.json --id <candidate-id> --id <candidate-id>

Step 4: 在论文 ingest 前建立 scaffold 页面

创建一篇 wiki/Summary/{area}.md、若干 wiki/topics/{slug}.md,以及来自 notes/web 的 provisional ideas/、concepts/、claims/。

规则:

Provisional note: seeded from raw/notes or raw/web during /init; pending validation from ingested papers.

Step 5: 通过 worktree 隔离并行 ingest 论文

本步骤的论文来源只能来自 .checkpoints/init-sources.json:

并行 ingest 合同:

Step 6: fan-in、rebuild 与最终报告

全部子代理完成后:

"$PYTHON_BIN" tools/research_wiki.py dedup-edges wiki/
"$PYTHON_BIN" tools/research_wiki.py dedup-citations wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-index wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-context-brief wiki/
"$PYTHON_BIN" tools/research_wiki.py rebuild-open-questions wiki/
"$PYTHON_BIN" tools/lint.py --wiki-dir wiki/ --fix

报告中必须分开列出:

若 stash_ref 存在,在最后再 pop。若 stash pop 失败,保留 checkpoint 并在报告中说明。

Constraints

Error Handling

Dependencies

Tools(via Bash)

Skills

`init_discovery.py` 内部使用的外部 API

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.