[feat] init --agent 时创建工具目录并做一次初始同步,修正 pull 的虚报计数
Open
@Morrowga is already working on this.
Since Sep 16, 2026.
bug
help wanted
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 342
- Avg merge
- 13h 48m
- Merged PRs (30d)
- 211
Description
关联 #574
背景
#574 反映:init 不做初始同步,pull 在工具目录不存在时静默跳过却打印 Synced N rule(s),新成员按文档走完看到「成功」但磁盘上没有任何规则文件。
改动
1. init --agent 触发建目录 + 初始同步
teamai init <repo> --agent claude,codex 已明确声明要用哪些 agent,此时:
- 为
enabledAgents(排除disabledAgents)创建工具根目录,已存在则跳过; - 立即执行一次全量 pull,落盘 rules /
CLAUDE.md/AGENTS.md; - 收尾输出报告实际写盘内容,不再只说 "will auto-sync on each session start"。
user / project scope 均适用;--dry-run 只打印计划。
不带 --agent 时行为完全不变,不凭空建目录,仍由 SessionStart hook 驱动。
2. pull 不再虚报
Synced N 只计实际写盘数量;因工具目录不存在而跳过时,在默认日志级别可见并给出下一步。
3. --force 绕过 isToolInstalled
显式 --force 的语义是「无论如何都同步」。
实现要点
- 复用
seedSelfModeToolDirs(src/known-agents.ts),重命名为seedEnabledAgentDirs,在src/init.ts的 git / http 两条路径上,于 hooks + 内置 skill 之后调用。 - seeding 建的是 skills 目录,其根目录即
isToolInstalled的判定对象,无需逐资源建目录。 - pull 失败只 warn,不让 init 退出非 0。
验收
- 全新目录跑
init --agent claude,codex,不手工 mkdir,结束时.claude/.codex/AGENTS.mdCLAUDE.md均在位;git / gitlab / github 三种 provider 各验一遍。 - 不带
--agent的 init 不产生任何目录(回归守护)。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.