kata-add-milestone

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<objective> Add a milestone to the project through unified flow: questioning → research (optional) → requirements → roadmap.
This works for both first milestone (after /kata-new-project) and subsequent milestones (after completing a milestone).
Creates/Updates:
  • .planning/PROJECT.md
    — updated with new milestone goals
  • .planning/research/
    — domain research (optional, focuses on NEW features)
  • .planning/REQUIREMENTS.md
    — scoped requirements for this milestone
  • .planning/ROADMAP.md
    — phase structure (creates if first, continues if subsequent)
  • .planning/STATE.md
    — reset for new milestone (creates if first)
After this command: Run
/kata-plan-phase [N]
to start execution. </objective>
<execution_context> @./references/questioning.md @./references/ui-brand.md @./references/project-template.md @./references/requirements-template.md @./references/github-mapping.md </execution_context>
<context> Milestone name: $ARGUMENTS (optional - will prompt if not provided)
Load project context: @.planning/PROJECT.md @.planning/STATE.md @.planning/MILESTONES.md @.planning/config.json
Load milestone context (if exists): @.planning/MILESTONE-CONTEXT.md </context>
<process>
<目标> 通过统一流程为项目添加里程碑:提问→调研(可选)→需求定义→路线规划。
此流程适用于首个里程碑(在/kata-new-project之后)及后续里程碑(在完成一个里程碑之后)。
创建/更新的文件:
  • .planning/PROJECT.md
    — 更新为包含新的里程碑目标
  • .planning/research/
    — 领域调研文件(可选,聚焦于新功能)
  • .planning/REQUIREMENTS.md
    — 此里程碑的限定范围需求
  • .planning/ROADMAP.md
    — 阶段结构(首次创建时生成,后续里程碑则延续)
  • .planning/STATE.md
    — 为新里程碑重置状态(首次创建时生成)
执行此命令后: 运行
/kata-plan-phase [N]
以启动执行阶段。 </目标>
<执行上下文> @./references/questioning.md @./references/ui-brand.md @./references/project-template.md @./references/requirements-template.md @./references/github-mapping.md </执行上下文>
<上下文> 里程碑名称:$ARGUMENTS(可选 - 若未提供则会提示输入)
加载项目上下文: @.planning/PROJECT.md @.planning/STATE.md @.planning/MILESTONES.md @.planning/config.json
加载里程碑上下文(若存在): @.planning/MILESTONE-CONTEXT.md </上下文>
<流程>

Phase 1: Load Context

阶段1:加载上下文

  • Read PROJECT.md (existing project, Validated requirements, decisions)
  • Read MILESTONES.md (what shipped previously)
  • Read STATE.md (pending todos, blockers)
  • Check for MILESTONE-CONTEXT.md (if exists)
  • 读取PROJECT.md(现有项目、已验证的需求、决策记录)
  • 读取MILESTONES.md(已交付的过往内容)
  • 读取STATE.md(待办事项、阻塞问题)
  • 检查是否存在MILESTONE-CONTEXT.md(若有)

Phase 2: Gather Milestone Goals

阶段2:收集里程碑目标

If MILESTONE-CONTEXT.md exists:
  • Use features and scope from the context file
  • Present summary for confirmation
If no context file:
  • Present what shipped in last milestone
  • Ask: "What do you want to build next?"
  • Use AskUserQuestion to explore features
  • Probe for priorities, constraints, scope
若MILESTONE-CONTEXT.md存在:
  • 使用该上下文文件中的功能和范围
  • 展示摘要供用户确认
若不存在上下文文件:
  • 展示上一个里程碑已交付的内容
  • 询问:"接下来你想要开发什么?"
  • 使用AskUserQuestion工具探索功能细节
  • 探查优先级、约束条件和范围

Phase 3: Determine Milestone Version

阶段3:确定里程碑版本号

  • Parse last version from MILESTONES.md
  • Suggest next version (v1.0 → v1.1, or v2.0 for major)
  • Confirm with user
  • 从MILESTONES.md中解析上一个版本号
  • 建议下一个版本号(如v1.0 → v1.1,重大更新则为v2.0)
  • 请用户确认

Phase 4: Update PROJECT.md

阶段4:更新PROJECT.md

Add/update these sections:
markdown
undefined
添加/更新以下章节:
markdown
undefined

Current Milestone: v[X.Y] [Name]

当前里程碑:v[X.Y] [名称]

Goal: [One sentence describing milestone focus]
Target features:
  • [Feature 1]
  • [Feature 2]
  • [Feature 3]

Update Active requirements section with new goals.

Update "Last updated" footer.
目标: [一句话描述里程碑的核心聚焦点]
目标功能:
  • [功能1]
  • [功能2]
  • [功能3]

更新“活跃需求”章节,加入新目标。

更新“最后更新时间”页脚。

Phase 5: Update STATE.md

阶段5:更新STATE.md

markdown
undefined
markdown
undefined

Current Position

当前状态

Phase: Not started (defining requirements) Plan: — Status: Defining requirements Last activity: [today] — Milestone v[X.Y] started

Keep Accumulated Context section (decisions, blockers) from previous milestone.
阶段:未开始(正在定义需求) 规划:— 状态:正在定义需求 最后活动:[今日] — 里程碑v[X.Y]已启动

保留上一个里程碑的“累积上下文”章节(决策记录、阻塞问题)。

Phase 5.5: Create GitHub Milestone (if enabled)

阶段5.5:创建GitHub里程碑(若启用)

Read GitHub config:
bash
GITHUB_ENABLED=$(cat .planning/config.json 2>/dev/null | grep -o '"enabled"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "false")
If
GITHUB_ENABLED=true
:
Step 1: Validate GitHub remote exists
bash
HAS_GITHUB_REMOTE=$(git remote -v 2>/dev/null | grep -q 'github\.com' && echo "true" || echo "false")
If
HAS_GITHUB_REMOTE=false
:
Use AskUserQuestion to offer repo creation:
  • header: "GitHub Repository"
  • question: "GitHub tracking is enabled but no GitHub remote found. Create a repository now?"
  • options:
    • "Yes, create private repo (Recommended)" — Create private repository and push
    • "Yes, create public repo" — Create public repository and push
    • "Skip for now" — Continue without GitHub integration
If "Yes, create private repo":
bash
gh repo create --source=. --private --push
If successful, set
HAS_GITHUB_REMOTE=true
and continue to Step 2 (Check authentication).
If "Yes, create public repo":
bash
gh repo create --source=. --public --push
If successful, set
HAS_GITHUB_REMOTE=true
and continue to Step 2 (Check authentication).
If "Skip for now": Display brief note and continue with local milestone initialization:
Continuing without GitHub integration. Run `gh repo create` later to enable.
Do NOT set github.enabled=false in config - user may add remote later.
If
HAS_GITHUB_REMOTE=true
:
Step 2: Check authentication (non-blocking)
bash
if ! gh auth status &>/dev/null; then
  echo "Warning: GitHub CLI not authenticated. Run 'gh auth login' to enable GitHub integration."
  # Continue without GitHub operations - local milestone still created
else
  # Proceed with milestone creation
fi
Step 3: Check if milestone exists (idempotent)
bash
MILESTONE_EXISTS=$(gh api /repos/:owner/:repo/milestones 2>/dev/null | jq -r ".[] | select(.title==\"v${VERSION}\") | .number" 2>/dev/null)
Step 4: Create milestone if doesn't exist
bash
if [ -z "$MILESTONE_EXISTS" ]; then
  # Extract milestone description (first paragraph of goal, truncated to 500 chars)
  MILESTONE_DESC=$(echo "$MILESTONE_GOALS" | head -1 | cut -c1-500)

  gh api \
    --method POST \
    -H "Accept: application/vnd.github.v3+json" \
    /repos/:owner/:repo/milestones \
    -f title="v${VERSION}" \
    -f state='open' \
    -f description="${MILESTONE_DESC}" \
    2>/dev/null && echo "GitHub Milestone v${VERSION} created" || echo "Warning: Failed to create GitHub Milestone (continuing)"
else
  echo "GitHub Milestone v${VERSION} already exists (#${MILESTONE_EXISTS})"
fi
If
GITHUB_ENABLED=false
:
Skip GitHub operations silently (no warning needed - user opted out).
Error handling principle:
  • All GitHub operations are non-blocking
  • Missing remote warns but does not stop milestone initialization
  • Auth failures warn but do not stop milestone initialization
  • Planning files always persist locally regardless of GitHub status
读取GitHub配置:
bash
GITHUB_ENABLED=$(cat .planning/config.json 2>/dev/null | grep -o '"enabled"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "false")
GITHUB_ENABLED=true
步骤1:验证GitHub远程仓库是否存在
bash
HAS_GITHUB_REMOTE=$(git remote -v 2>/dev/null | grep -q 'github\.com' && echo "true" || echo "false")
HAS_GITHUB_REMOTE=false
使用AskUserQuestion工具询问用户是否创建仓库:
  • 标题:"GitHub Repository"
  • 问题:"GitHub追踪已启用,但未找到GitHub远程仓库。是否现在创建一个仓库?"
  • 选项:
    • "是,创建私有仓库(推荐)" — 创建私有仓库并推送
    • "是,创建公开仓库" — 创建公开仓库并推送
    • "暂时跳过" — 不启用GitHub集成,继续执行
若选择“是,创建私有仓库”:
bash
gh repo create --source=. --private --push
若创建成功,设置
HAS_GITHUB_REMOTE=true
并继续步骤2(检查认证状态)。
若选择“是,创建公开仓库”:
bash
gh repo create --source=. --public --push
若创建成功,设置
HAS_GITHUB_REMOTE=true
并继续步骤2(检查认证状态)。
若选择“暂时跳过”: 显示简短提示,继续本地里程碑初始化:
将不启用GitHub集成继续执行。后续可运行`gh repo create`来启用该功能。
不要在配置中设置github.enabled=false — 用户可能之后会添加远程仓库。
HAS_GITHUB_REMOTE=true
步骤2:检查认证状态(非阻塞)
bash
if ! gh auth status &>/dev/null; then
  echo "警告:GitHub CLI未认证。运行'gh auth login'以启用GitHub集成。"
  # 不执行GitHub操作,继续创建本地里程碑
else
  # 继续创建里程碑
fi
步骤3:检查里程碑是否已存在(幂等操作)
bash
MILESTONE_EXISTS=$(gh api /repos/:owner/:repo/milestones 2>/dev/null | jq -r ".[] | select(.title==\"v${VERSION}\") | .number" 2>/dev/null)
步骤4:若里程碑不存在则创建
bash
if [ -z "$MILESTONE_EXISTS" ]; then
  # 提取里程碑描述(目标的第一段,截断至500字符)
  MILESTONE_DESC=$(echo "$MILESTONE_GOALS" | head -1 | cut -c1-500)

  gh api \
    --method POST \
    -H "Accept: application/vnd.github.v3+json" \
    /repos/:owner/:repo/milestones \
    -f title="v${VERSION}" \
    -f state='open' \
    -f description="${MILESTONE_DESC}" \
    2>/dev/null && echo "GitHub Milestone v${VERSION}已创建" || echo "警告:创建GitHub Milestone失败(将继续执行)"
else
  echo "GitHub Milestone v${VERSION}已存在(#${MILESTONE_EXISTS})"
fi
GITHUB_ENABLED=false
静默跳过GitHub操作(无需提示警告 — 用户已选择关闭)。
错误处理原则:
  • 所有GitHub操作均为非阻塞
  • 缺少远程仓库会发出警告,但不会终止里程碑初始化
  • 认证失败会发出警告,但不会终止里程碑初始化
  • 无论GitHub状态如何,规划文件始终会在本地持久化保存

Phase 6: Cleanup and Commit

阶段6:清理与提交

Delete MILESTONE-CONTEXT.md if exists (consumed).
Check planning config:
bash
COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false
If
COMMIT_PLANNING_DOCS=false
: Skip git operations
If
COMMIT_PLANNING_DOCS=true
(default):
bash
git add .planning/PROJECT.md .planning/STATE.md
git commit -m "docs: start milestone v[X.Y] [Name]"
若MILESTONE-CONTEXT.md存在则删除(已被使用)。
检查规划配置:
bash
COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false
COMMIT_PLANNING_DOCS=false
:跳过git操作
COMMIT_PLANNING_DOCS=true
(默认设置):
bash
git add .planning/PROJECT.md .planning/STATE.md
git commit -m "docs: start milestone v[X.Y] [Name]"

Phase 6.5: Resolve Model Profile

阶段6.5:解析模型配置

Read model profile for agent spawning:
bash
MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
Default to "balanced" if not set.
Model lookup table:
Agentqualitybalancedbudget
kata-project-researcheropussonnethaiku
kata-research-synthesizersonnetsonnethaiku
kata-roadmapperopussonnetsonnet
Store resolved models for use in Task calls below.
读取用于生成Agent的模型配置:
bash
MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
若未设置则默认使用"balanced"。
模型对照表:
Agentqualitybalancedbudget
kata-project-researcheropussonnethaiku
kata-research-synthesizersonnetsonnethaiku
kata-roadmapperopussonnetsonnet
存储解析后的模型,供后续Task调用使用。

Phase 7: Research Decision

阶段7:调研决策

Use AskUserQuestion:
  • header: "Research"
  • question: "Research the domain ecosystem for new features before defining requirements?"
  • options:
    • "Research first (Recommended)" — Discover patterns, expected features, architecture for NEW capabilities
    • "Skip research" — I know what I need, go straight to requirements
If "Research first":
Display stage banner:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► RESEARCHING ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Researching [new features] ecosystem...
Create research directory:
bash
mkdir -p .planning/research
Display spawning indicator:
◆ Spawning 4 researchers in parallel...
  → Stack research (for new features)
  → Features research
  → Architecture research (integration)
  → Pitfalls research
Read agent instruction files for inlining into Task() prompts:
bash
project_researcher_instructions_content=$(cat ${SKILL_BASE_DIR}/references/project-researcher-instructions.md)
research_synthesizer_instructions_content=$(cat ${SKILL_BASE_DIR}/references/research-synthesizer-instructions.md)
roadmapper_instructions_content=$(cat ${SKILL_BASE_DIR}/references/roadmapper-instructions.md)
Spawn all 4 researchers in a single message containing 4 parallel Task tool calls. All 4 must be in the same response — do NOT wait for one to finish before spawning the next:
Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Stack dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing validated capabilities (DO NOT re-research):
[List from PROJECT.md Validated requirements]

Focus ONLY on what's needed for the NEW features.
</milestone_context>

<question>
What stack additions/changes are needed for [new features]?
</question>

<project_context>
[PROJECT.md summary - current state, new milestone goals]
</project_context>

<downstream_consumer>
Your STACK.md feeds into roadmap creation. Be prescriptive:
- Specific libraries with versions for NEW capabilities
- Integration points with existing stack
- What NOT to add and why
</downstream_consumer>

<quality_gate>
- [ ] Versions are current (verify with Context7/official docs, not training data)
- [ ] Rationale explains WHY, not just WHAT
- [ ] Integration with existing stack considered
</quality_gate>

<output>
Write to: .planning/research/STACK.md
Format: Standard research output forSTACK.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Stack research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Features dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing features (already built):
[List from PROJECT.md Validated requirements]

Focus on how [new features] typically work, expected behavior.
</milestone_context>

<question>
How do [target features] typically work? What's expected behavior?
</question>

<project_context>
[PROJECT.md summary - new milestone goals]
</project_context>

<downstream_consumer>
Your FEATURES.md feeds into requirements definition. Categorize clearly:
- Table stakes (must have for these features)
- Differentiators (competitive advantage)
- Anti-features (things to deliberately NOT build)
</downstream_consumer>

<quality_gate>
- [ ] Categories are clear (table stakes vs differentiators vs anti-features)
- [ ] Complexity noted for each feature
- [ ] Dependencies on existing features identified
</quality_gate>

<output>
Write to: .planning/research/FEATURES.md
Format: Standard research output forFEATURES.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Features research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Architecture dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing architecture:
[Summary from PROJECT.md or codebase map]

Focus on how [new features] integrate with existing architecture.
</milestone_context>

<question>
How do [target features] integrate with existing [domain] architecture?
</question>

<project_context>
[PROJECT.md summary - current architecture, new features]
</project_context>

<downstream_consumer>
Your ARCHITECTURE.md informs phase structure in roadmap. Include:
- Integration points with existing components
- New components needed
- Data flow changes
- Suggested build order
</downstream_consumer>

<quality_gate>
- [ ] Integration points clearly identified
- [ ] New vs modified components explicit
- [ ] Build order considers existing dependencies
</quality_gate>

<output>
Write to: .planning/research/ARCHITECTURE.md
Format: Standard research output forARCHITECTURE.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Architecture research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Pitfalls dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Focus on common mistakes when ADDING these features to an existing system.
</milestone_context>

<question>
What are common mistakes when adding [target features] to [domain]?
</question>

<project_context>
[PROJECT.md summary - current state, new features]
</project_context>

<downstream_consumer>
Your PITFALLS.md prevents mistakes in roadmap/planning. For each pitfall:
- Warning signs (how to detect early)
- Prevention strategy (how to avoid)
- Which phase should address it
</downstream_consumer>

<quality_gate>
- [ ] Pitfalls are specific to adding these features (not generic)
- [ ] Integration pitfalls with existing system covered
- [ ] Prevention strategies are actionable
</quality_gate>

<output>
Write to: .planning/research/PITFALLS.md
Format: Standard research output forPITFALLS.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Pitfalls research")
After all 4 agents complete, spawn synthesizer to create SUMMARY.md:
Task(prompt="
<agent-instructions>
{research_synthesizer_instructions_content}
</agent-instructions>

<task>
Synthesize research outputs into SUMMARY.md.
</task>

<research_files>
Read these files:
- .planning/research/STACK.md
- .planning/research/FEATURES.md
- .planning/research/ARCHITECTURE.md
- .planning/research/PITFALLS.md
</research_files>

<output>
Write to: .planning/research/SUMMARY.md
Format: Standard research output forSUMMARY.md
Commit after writing.
</output>
", subagent_type="general-purpose", model="{synthesizer_model}", description="Synthesize research")
Display research complete banner and key findings:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► RESEARCH COMPLETE ✓ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
使用AskUserQuestion工具:
  • 标题:"调研"
  • 问题:"在定义需求之前,是否需要针对新功能的领域生态进行调研?"
  • 选项:
    • "先进行调研(推荐)" — 探索新功能的模式、预期特性和架构
    • "跳过调研" — 我清楚需求,直接进入需求定义阶段
若选择“先进行调研”:
显示阶段横幅:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► 调研中 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
正在调研[新功能]的领域生态...
创建调研目录:
bash
mkdir -p .planning/research
显示Agent生成提示:
◆ 正在并行生成4个调研Agent...
  → 技术栈调研(针对新功能)
  → 功能调研
  → 架构调研(集成相关)
  → 风险调研
读取Agent指令文件,用于嵌入Task()提示:
bash
project_researcher_instructions_content=$(cat ${SKILL_BASE_DIR}/references/project-researcher-instructions.md)
research_synthesizer_instructions_content=$(cat ${SKILL_BASE_DIR}/references/research-synthesizer-instructions.md)
roadmapper_instructions_content=$(cat ${SKILL_BASE_DIR}/references/roadmapper-instructions.md)
同一条响应中生成4个并行的Task工具调用,所有4个Agent需同时生成 — 不要等待一个完成后再生成下一个:
Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Stack dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing validated capabilities (DO NOT re-research):
[List from PROJECT.md Validated requirements]

Focus ONLY on what's needed for the NEW features.
</milestone_context>

<question>
What stack additions/changes are needed for [new features]?
</question>

<project_context>
[PROJECT.md summary - current state, new milestone goals]
</project_context>

<downstream_consumer>
Your STACK.md feeds into roadmap creation. Be prescriptive:
- Specific libraries with versions for NEW capabilities
- Integration points with existing stack
- What NOT to add and why
</downstream_consumer>

<quality_gate>
- [ ] Versions are current (verify with Context7/official docs, not training data)
- [ ] Rationale explains WHY, not just WHAT
- [ ] Integration with existing stack considered
</quality_gate>

<output>
Write to: .planning/research/STACK.md
Format: Standard research output forSTACK.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Stack research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Features dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing features (already built):
[List from PROJECT.md Validated requirements]

Focus on how [new features] typically work, expected behavior.
</milestone_context>

<question>
How do [target features] typically work? What's expected behavior?
</question>

<project_context>
[PROJECT.md summary - new milestone goals]
</project_context>

<downstream_consumer>
Your FEATURES.md feeds into requirements definition. Categorize clearly:
- Table stakes (must have for these features)
- Differentiators (competitive advantage)
- Anti-features (things to deliberately NOT build)
</downstream_consumer>

<quality_gate>
- [ ] Categories are clear (table stakes vs differentiators vs anti-features)
- [ ] Complexity noted for each feature
- [ ] Dependencies on existing features identified
</quality_gate>

<output>
Write to: .planning/research/FEATURES.md
Format: Standard research output forFEATURES.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Features research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Architecture dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Existing architecture:
[Summary from PROJECT.md or codebase map]

Focus on how [new features] integrate with existing architecture.
</milestone_context>

<question>
How do [target features] integrate with existing [domain] architecture?
</question>

<project_context>
[PROJECT.md summary - current architecture, new features]
</project_context>

<downstream_consumer>
Your ARCHITECTURE.md informs phase structure in roadmap. Include:
- Integration points with existing components
- New components needed
- Data flow changes
- Suggested build order
</downstream_consumer>

<quality_gate>
- [ ] Integration points clearly identified
- [ ] New vs modified components explicit
- [ ] Build order considers existing dependencies
</quality_gate>

<output>
Write to: .planning/research/ARCHITECTURE.md
Format: Standard research output forARCHITECTURE.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Architecture research")

Task(prompt="
<agent-instructions>
{project_researcher_instructions_content}
</agent-instructions>

<research_type>
Project Research — Pitfalls dimension for [new features].
</research_type>

<milestone_context>
SUBSEQUENT MILESTONE — Adding [target features] to existing app.

Focus on common mistakes when ADDING these features to an existing system.
</milestone_context>

<question>
What are common mistakes when adding [target features] to [domain]?
</question>

<project_context>
[PROJECT.md summary - current state, new features]
</project_context>

<downstream_consumer>
Your PITFALLS.md prevents mistakes in roadmap/planning. For each pitfall:
- Warning signs (how to detect early)
- Prevention strategy (how to avoid)
- Which phase should address it
</downstream_consumer>

<quality_gate>
- [ ] Pitfalls are specific to adding these features (not generic)
- [ ] Integration pitfalls with existing system covered
- [ ] Prevention strategies are actionable
</quality_gate>

<output>
Write to: .planning/research/PITFALLS.md
Format: Standard research output forPITFALLS.md
</output>
", subagent_type="general-purpose", model="{researcher_model}", description="Pitfalls research")
所有4个Agent完成后,生成合成Agent以创建SUMMARY.md:
Task(prompt="
<agent-instructions>
{research_synthesizer_instructions_content}
</agent-instructions>

<task>
Synthesize research outputs into SUMMARY.md.
</task>

<research_files>
Read these files:
- .planning/research/STACK.md
- .planning/research/FEATURES.md
- .planning/research/ARCHITECTURE.md
- .planning/research/PITFALLS.md
</research_files>

<output>
Write to: .planning/research/SUMMARY.md
Format: Standard research output forSUMMARY.md
Commit after writing.
</output>
", subagent_type="general-purpose", model="{synthesizer_model}", description="Synthesize research")
显示调研完成横幅与关键发现:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► 调研完成 ✓ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Key Findings

关键发现

Stack additions: [from SUMMARY.md] New feature table stakes: [from SUMMARY.md] Watch Out For: [from SUMMARY.md]
Files:
.planning/research/
If "Skip research": Continue to Phase 7.5.
技术栈新增项: [来自SUMMARY.md] 新功能核心需求: [来自SUMMARY.md] 注意事项: [来自SUMMARY.md]
文件位置:
.planning/research/
若选择“跳过调研”: 直接进入阶段7.5。

Phase 7.5: Issue Selection

阶段7.5:待办问题选择

Check for backlog issues:
bash
BACKLOG_COUNT=$(find .planning/issues/open -maxdepth 1 -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
If BACKLOG_COUNT > 0:
Display: "Checking backlog for issues to include in this milestone..."
Build issue options dynamically:
bash
ISSUE_OPTIONS=""
for file in .planning/issues/open/*.md; do
  [ -f "$file" ] || continue
  created=$(grep "^created:" "$file" | cut -d' ' -f2)
  title=$(grep "^title:" "$file" | cut -d':' -f2- | xargs)
  area=$(grep "^area:" "$file" | cut -d' ' -f2)
  provenance=$(grep "^provenance:" "$file" | cut -d' ' -f2)

  # Calculate age
  created_date=$(echo "$created" | cut -dT -f1)
  days_ago=$(( ($(date +%s) - $(date -j -f "%Y-%m-%d" "$created_date" +%s 2>/dev/null || echo $(date +%s))) / 86400 ))
  if [ "$days_ago" -eq 0 ]; then
    age="today"
  elif [ "$days_ago" -eq 1 ]; then
    age="1d ago"
  else
    age="${days_ago}d ago"
  fi

  # Extract GitHub issue number if linked
  github_ref=""
  if echo "$provenance" | grep -q "^github:"; then
    github_ref=" (GitHub $(echo "$provenance" | grep -oE '#[0-9]+')"
  fi

  echo "$file|$title|$area|$age$github_ref"
done
Use AskUserQuestion:
  • header: "Backlog Issues"
  • question: "Include any backlog issues in this milestone's scope?"
  • multiSelect: true
  • options: Build from issue list above, format as
    "[title]" — [area], [age]
  • Include final option: "None — Start fresh"
For each selected issue (if not "None — Start fresh"):
Store as SELECTED_ISSUES variable for use in Phase 8.
Update STATE.md with milestone scope issues:
  1. Read STATE.md
  2. Find or create "### Milestone Scope Issues" section
  3. Add each selected issue:
markdown
undefined
检查待办问题数量:
bash
BACKLOG_COUNT=$(find .planning/issues/open -maxdepth 1 -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
若BACKLOG_COUNT > 0:
显示:"正在检查待办问题,看是否需要纳入此里程碑范围..."
动态生成问题选项:
bash
ISSUE_OPTIONS=""
for file in .planning/issues/open/*.md; do
  [ -f "$file" ] || continue
  created=$(grep "^created:" "$file" | cut -d' ' -f2)
  title=$(grep "^title:" "$file" | cut -d':' -f2- | xargs)
  area=$(grep "^area:" "$file" | cut -d' ' -f2)
  provenance=$(grep "^provenance:" "$file" | cut -d' ' -f2)

  # 计算问题存在时长
  created_date=$(echo "$created" | cut -dT -f1)
  days_ago=$(( ($(date +%s) - $(date -j -f "%Y-%m-%d" "$created_date" +%s 2>/dev/null || echo $(date +%s))) / 86400 ))
  if [ "$days_ago" -eq 0 ]; then
    age="今日"
  elif [ "$days_ago" -eq 1 ]; then
    age="1天前"
  else
    age="${days_ago}天前"
  fi

  # 提取关联的GitHub问题编号
  github_ref=""
  if echo "$provenance" | grep -q "^github:"; then
    github_ref=" (GitHub $(echo "$provenance" | grep -oE '#[0-9]+')"
  fi

  echo "$file|$title|$area|$age$github_ref"
done
使用AskUserQuestion工具:
  • 标题:"待办问题"
  • 问题:"是否将某些待办问题纳入此里程碑的范围?"
  • multiSelect: true
  • 选项:根据上述问题列表生成,格式为
    "[标题]" — [领域], [存在时长]
  • 最后加入选项:"无 — 从零开始"
对于每个选中的问题(若未选择“无 — 从零开始”):
将其存储为SELECTED_ISSUES变量,供阶段8使用。
更新STATE.md,加入里程碑范围问题:
  1. 读取STATE.md
  2. 查找或创建"### 里程碑范围问题"章节
  3. 添加每个选中的问题:
markdown
undefined

Milestone Scope Issues

里程碑范围问题

Issues pulled into current milestone scope:
  • "[issue-title]" (from: [issue-file-path], GitHub: #N if linked)

4. Write updated STATE.md

**Purpose of issue selection:**
- Selected issues become formally tracked as part of the milestone scope
- They appear in STATE.md under "### Milestone Scope Issues" for the current milestone
- They inform requirements generation in Phase 8 (planner should consider these issues when generating requirements)
- They will be visible in progress tracking commands like /kata-track-progress
- User still defines formal requirements through Phase 8, but selected issues provide explicit scope context

**If BACKLOG_COUNT = 0:**

Skip silently. Continue to Phase 8.
纳入当前里程碑范围的问题:
  • "[问题标题]"(来源:[问题文件路径],GitHub:#N(若关联))

4. 写入更新后的STATE.md

**问题选择的目的:**
- 选中的问题将正式作为里程碑范围的一部分被追踪
- 它们会出现在当前里程碑的STATE.md的"### 里程碑范围问题"章节中
- 它们会为阶段8的需求生成提供明确的范围上下文
- 它们会在`/kata-track-progress`等进度追踪命令中可见
- 用户仍需通过阶段8定义正式需求,但选中的问题会提供明确的范围参考

**若BACKLOG_COUNT = 0:**

静默跳过此阶段,直接进入阶段8。

Phase 8: Define Requirements

阶段8:定义需求

Display stage banner:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► DEFINING REQUIREMENTS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Load context:
Read PROJECT.md and extract:
  • Core value (the ONE thing that must work)
  • Current milestone goals
  • Validated requirements (what already exists)
If research exists: Read research/FEATURES.md and extract feature categories.
Present features by category:
Here are the features for [new capabilities]:
显示阶段横幅:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► 定义需求中 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
加载上下文:
读取PROJECT.md并提取:
  • 核心价值(必须确保正常工作的核心内容)
  • 当前里程碑目标
  • 已验证的需求(已完成的内容)
若存在调研文件: 读取research/FEATURES.md并提取功能分类。
按分类展示功能:
以下是[新功能]的相关特性:

[Category 1]

[分类1]

Table stakes:
  • Feature A
  • Feature B
Differentiators:
  • Feature C
  • Feature D
Research notes: [any relevant notes]

核心需求:
  • 功能A
  • 功能B
差异化特性:
  • 功能C
  • 功能D
调研笔记: [相关笔记]

[Next Category]

下一个分类

...

**If no research:** Gather requirements through conversation instead.

Ask: "What are the main things users need to be able to do with [new features]?"

For each capability mentioned:
- Ask clarifying questions to make it specific
- Probe for related capabilities
- Group into categories

**Scope each category:**

For each category, use AskUserQuestion:

- header: "[Category name]"
- question: "Which [category] features are in this milestone?"
- multiSelect: true
- options:
  - "[Feature 1]" — [brief description]
  - "[Feature 2]" — [brief description]
  - "[Feature 3]" — [brief description]
  - "None for this milestone" — Defer entire category

Track responses:
- Selected features → this milestone's requirements
- Unselected table stakes → future milestone
- Unselected differentiators → out of scope

**Identify gaps:**

Use AskUserQuestion:
- header: "Additions"
- question: "Any requirements research missed? (Features specific to your vision)"
- options:
  - "No, research covered it" — Proceed
  - "Yes, let me add some" — Capture additions

**Generate REQUIREMENTS.md:**

Create `.planning/REQUIREMENTS.md` with:
- v1 Requirements for THIS milestone grouped by category (checkboxes, REQ-IDs)
- Future Requirements (deferred to later milestones)
- Out of Scope (explicit exclusions with reasoning)
- Traceability section (empty, filled by roadmap)

**REQ-ID format:** `[CATEGORY]-[NUMBER]` (AUTH-01, NOTIF-02)

Continue numbering from existing requirements if applicable.

**Requirement quality criteria:**

Good requirements are:
- **Specific and testable:** "User can reset password via email link" (not "Handle password reset")
- **User-centric:** "User can X" (not "System does Y")
- **Atomic:** One capability per requirement (not "User can login and manage profile")
- **Independent:** Minimal dependencies on other requirements

**Present full requirements list:**

Show every requirement (not counts) for user confirmation:
...

**若不存在调研文件:** 通过对话收集需求。

询问:"用户使用[新功能]时,主要需要完成哪些操作?"

对于每个提到的功能:
- 提出澄清问题,使其更具体
- 探查相关的附属功能
- 进行分类分组

**为每个分类确定范围:**

针对每个分类,使用AskUserQuestion工具:

- 标题:"[分类名称]"
- 问题:"此里程碑包含哪些[分类]功能?"
- multiSelect: true
- 选项:
  - "[功能1]" — [简短描述]
  - "[功能2]" — [简短描述]
  - "[功能3]" — [简短描述]
  - "此里程碑不包含该分类下的功能" — 推迟至后续里程碑

记录用户响应:
- 选中的功能 → 纳入此里程碑的需求
- 未选中的核心需求 → 纳入未来里程碑
- 未选中的差异化特性 → 排除在范围外

**识别需求缺口:**

使用AskUserQuestion工具:
- 标题:"补充需求"
- 问题:"是否有调研未覆盖到的需求?(符合你的愿景的特定功能)"
- 选项:
  - "没有,调研已覆盖全部需求" — 继续执行
  - "有,我需要添加一些" — 记录补充需求

**生成REQUIREMENTS.md:**

创建`.planning/REQUIREMENTS.md`,包含:
- 此里程碑的v1需求,按分类分组(带复选框和REQ-ID)
- 未来需求(推迟至后续里程碑)
- 范围外内容(明确的排除项及原因)
- 可追溯性章节(为空,由路线图填充)

**REQ-ID格式:** `[分类缩写]-[编号]`(如AUTH-01、NOTIF-02)

若存在现有需求,需延续编号序列。

**需求质量标准:**

优质需求需满足:
- **具体且可测试:** "用户可通过邮件链接重置密码"(而非"处理密码重置")
- **以用户为中心:** "用户可完成X操作"(而非"系统执行Y操作")
- **原子性:** 每个需求对应一个功能(而非"用户可登录并管理个人资料")
- **独立性:** 与其他需求的依赖关系最小化

**展示完整需求列表:**

展示所有需求(而非仅数量)供用户确认:

Milestone v[X.Y] Requirements

里程碑v[X.Y]需求

[Category 1]

[分类1]

  • CAT1-01: User can do X
  • CAT1-02: User can do Y
  • CAT1-01: 用户可完成X操作
  • CAT1-02: 用户可完成Y操作

[Category 2]

[分类2]

  • CAT2-01: User can do Z
[... full list ...]

Does this capture what you're building? (yes / adjust)

If "adjust": Return to scoping.

**Commit requirements:**

Check planning config (same pattern as Phase 6).

If committing:
```bash
git add .planning/REQUIREMENTS.md
git commit -m "$(cat <<'EOF'
docs: define milestone v[X.Y] requirements

[X] requirements across [N] categories
EOF
)"
  • CAT2-01: 用户可完成Z操作
[...完整列表...]

此需求列表是否准确覆盖了你要开发的内容?(是 / 调整)

若用户选择"调整":返回范围确定阶段。

**提交需求:**

检查规划配置(与阶段6相同)。

若需提交:
```bash
git add .planning/REQUIREMENTS.md
git commit -m "$(cat <<'EOF'
docs: define milestone v[X.Y] requirements

[X] requirements across [N] categories
EOF
)"

Phase 8.5: Collision Check

阶段8.5:冲突检查

Check for duplicate phase numeric prefixes across all state directories. Collisions cause
find ... -name "01-*" | head -1
to return wrong directories.
bash
DUPES=$(for state in active pending completed; do
  ls .planning/phases/${state}/ 2>/dev/null
done | grep -oE '^[0-9]+' | sort -n | uniq -d)
检查所有状态目录中的阶段数字前缀是否重复。冲突会导致
find ... -name "01-*" | head -1
返回错误目录。
bash
DUPES=$(for state in active pending completed; do
  ls .planning/phases/${state}/ 2>/dev/null
done | grep -oE '^[0-9]+' | sort -n | uniq -d)

Include flat directories (unmigrated projects)

包含扁平目录(未迁移的项目)

FLAT_DUPES=$(ls .planning/phases/ 2>/dev/null | grep -E '^[0-9]' | grep -oE '^[0-9]+' | sort -n | uniq -d)
ALL_DUPES=$(echo -e "${DUPES}\n${FLAT_DUPES}" | sort -nu | grep -v '^$')

**If `ALL_DUPES` is empty:** Continue silently to Phase 9.

**If collisions found:**

Display:
⚠ Duplicate phase prefixes detected: [list]
Phase directories share numeric prefixes across milestones. This causes phase lookup commands to return wrong directories.

Use AskUserQuestion:
- header: "Collisions"
- question: "Duplicate phase prefixes found. Migrate to globally sequential numbering?"
- options:
  - "Migrate now" — Run inline migration, then recalculate NEXT_PHASE before continuing
  - "Skip" — Continue without fixing (phase lookups may return wrong results)

**If "Migrate now":**

Run the migration logic from `/kata-migrate-phases` inline:
1. Build chronology from ROADMAP.md (completed milestone `<details>` blocks + current milestone phases)
2. Map directories to globally sequential numbers
3. Execute two-pass rename (tmp- prefix, then final)
4. Update ROADMAP.md current milestone phase numbers
5. Recalculate `NEXT_PHASE` from the newly renumbered directories

**If "Skip":**

Display:
⚠ Skipping migration. Run
/kata-migrate-phases
to fix collisions later.

Continue to Phase 9.
FLAT_DUPES=$(ls .planning/phases/ 2>/dev/null | grep -E '^[0-9]' | grep -oE '^[0-9]+' | sort -n | uniq -d)
ALL_DUPES=$(echo -e "${DUPES}\n${FLAT_DUPES}" | sort -nu | grep -v '^$')

**若`ALL_DUPES`为空:** 静默进入阶段9。

**若发现冲突:**

显示:
⚠ 检测到重复的阶段前缀:[列表]
不同里程碑的阶段目录使用了相同的数字前缀,这会导致阶段查找命令返回错误目录。

使用AskUserQuestion工具:
- 标题:"冲突处理"
- 问题:"检测到重复的阶段前缀。是否迁移为全局连续编号?"
- 选项:
  - "立即迁移" — 执行内联迁移,然后重新计算NEXT_PHASE再继续
  - "跳过" — 不修复继续执行(阶段查找可能返回错误结果)

**若选择“立即迁移”:**

内联执行`/kata-migrate-phases`的迁移逻辑:
1. 从ROADMAP.md构建时间线(已完成里程碑的`<details>`块 + 当前里程碑阶段)
2. 将目录映射为全局连续编号
3. 执行两轮重命名(先添加tmp-前缀,再改为最终名称)
4. 更新ROADMAP.md中当前里程碑的阶段编号
5. 根据重新编号后的目录,重新计算`NEXT_PHASE`

**若选择“跳过”:**

显示:
⚠ 已跳过迁移。后续可运行
/kata-migrate-phases
来修复冲突。

继续进入阶段9。

Phase 9: Create Roadmap

阶段9:创建路线图

Display stage banner:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► CREATING ROADMAP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
◆ Spawning roadmapper...
Determine starting phase number:
Phase numbers are globally sequential across milestones. Scan all existing phase directories to find the highest phase number, then start this milestone's phases at highest + 1:
bash
ALL_PHASE_DIRS=""
for state in active pending completed; do
  [ -d ".planning/phases/${state}" ] && ALL_PHASE_DIRS="${ALL_PHASE_DIRS} $(find .planning/phases/${state} -maxdepth 1 -type d -not -name "${state}" 2>/dev/null)"
done
HIGHEST=$(echo "$ALL_PHASE_DIRS" | tr ' ' '\n' | grep -oE '/[0-9]+' | grep -oE '[0-9]+' | sort -n | tail -1)
NEXT_PHASE=$((HIGHEST + 1))
Pass
NEXT_PHASE
as the starting phase number to the roadmapper.
Spawn roadmapper agent with context:
Task(prompt="
<agent-instructions>
{roadmapper_instructions_content}
</agent-instructions>

<planning_context>

**Project:**
@.planning/PROJECT.md

**Requirements:**
@.planning/REQUIREMENTS.md

**Research (if exists):**
@.planning/research/SUMMARY.md

**Config:**
@.planning/config.json

**Previous milestones (shipped context):**
@.planning/MILESTONES.md

</planning_context>

<instructions>
Create roadmap for milestone v[X.Y]:
1. Continue phase numbering from the highest existing phase number + 1 (globally sequential across milestones). The starting phase number is provided as NEXT_PHASE.
2. Derive phases from THIS MILESTONE's requirements (don't include validated/existing)
3. Map every requirement to exactly one phase
4. Derive 2-5 success criteria per phase (observable user behaviors)
5. Validate 100% coverage of new requirements
6. Write files immediately (ROADMAP.md, STATE.md, update REQUIREMENTS.md traceability)
7. Include "Planned Milestones" section in ROADMAP.md if user mentioned future milestone ideas
8. Use ○ symbol for planned milestones in overview, 🔄 for current, ✅ for completed
9. Include planned milestones in Progress Summary table with "Planned" status
10. Return ROADMAP CREATED with summary

Write files first, then return. This ensures artifacts persist even if context is lost.
</instructions>

<format_conventions>
Milestones overview uses these symbols:
- ✅ for shipped milestones
- 🔄 for current/in-progress milestone
- ○ for planned milestones

Completed milestone details blocks MUST include:
- Summary line: ✅ v[X.Y] [Name] — SHIPPED [DATE]
- **Goal:** line
- Phase checkboxes with plan counts and dates
- [Full archive](milestones/v[X.Y]-ROADMAP.md) link

Progress Summary table includes planned milestones with "Planned" status and "—" for metrics.
</format_conventions>
", subagent_type="general-purpose", model="{roadmapper_model}", description="Create roadmap")
Handle roadmapper return:
If
## ROADMAP BLOCKED
:
  • Present blocker information
  • Work with user to resolve
  • Re-spawn when resolved
If
## ROADMAP CREATED
:
Read the created ROADMAP.md and present it nicely inline:
---
显示阶段横幅:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► 创建路线图中 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
◆ 正在生成路线图Agent...
确定起始阶段编号:
阶段编号在所有里程碑中是全局连续的。扫描所有现有阶段目录,找到最高的阶段编号,然后将此里程碑的起始阶段编号设为最高编号 + 1:
bash
ALL_PHASE_DIRS=""
for state in active pending completed; do
  [ -d ".planning/phases/${state}" ] && ALL_PHASE_DIRS="${ALL_PHASE_DIRS} $(find .planning/phases/${state} -maxdepth 1 -type d -not -name "${state}" 2>/dev/null)"
done
HIGHEST=$(echo "$ALL_PHASE_DIRS" | tr ' ' '\n' | grep -oE '/[0-9]+' | grep -oE '[0-9]+' | sort -n | tail -1)
NEXT_PHASE=$((HIGHEST + 1))
NEXT_PHASE
作为起始阶段编号传递给路线图Agent。
生成路线图Agent并传入上下文:
Task(prompt="
<agent-instructions>
{roadmapper_instructions_content}
</agent-instructions>

<planning_context>

**Project:**
@.planning/PROJECT.md

**Requirements:**
@.planning/REQUIREMENTS.md

**Research (if exists):**
@.planning/research/SUMMARY.md

**Config:**
@.planning/config.json

**Previous milestones (shipped context):**
@.planning/MILESTONES.md

</planning_context>

<instructions>
Create roadmap for milestone v[X.Y]:
1. Continue phase numbering from the highest existing phase number + 1 (globally sequential across milestones). The starting phase number is provided as NEXT_PHASE.
2. Derive phases from THIS MILESTONE's requirements (don't include validated/existing)
3. Map every requirement to exactly one phase
4. Derive 2-5 success criteria per phase (observable user behaviors)
5. Validate 100% coverage of new requirements
6. Write files immediately (ROADMAP.md, STATE.md, update REQUIREMENTS.md traceability)
7. Include "Planned Milestones" section in ROADMAP.md if user mentioned future milestone ideas
8. Use ○ symbol for planned milestones in overview, 🔄 for current, ✅ for completed
9. Include planned milestones in Progress Summary table with "Planned" status
10. Return ROADMAP CREATED with summary

Write files first, then return. This ensures artifacts persist even if context is lost.
</instructions>

<format_conventions>
Milestones overview uses these symbols:
- ✅ for shipped milestones
- 🔄 for current/in-progress milestone
- ○ for planned milestones

Completed milestone details blocks MUST include:
- Summary line: ✅ v[X.Y] [Name] — SHIPPED [DATE]
- **Goal:** line
- Phase checkboxes with plan counts and dates
- [Full archive](milestones/v[X.Y]-ROADMAP.md) link

Progress Summary table includes planned milestones with "Planned" status and "—" for metrics.
</format_conventions>
", subagent_type="general-purpose", model="{roadmapper_model}", description="Create roadmap")
处理路线图Agent的返回结果:
若返回
## ROADMAP BLOCKED
  • 展示阻塞信息
  • 与用户协作解决阻塞问题
  • 问题解决后重新生成Agent
若返回
## ROADMAP CREATED
读取已创建的ROADMAP.md,并以友好格式展示:
---

Proposed Roadmap

建议的路线图

[N] phases | [X] requirements mapped | All milestone requirements covered ✓
#PhaseGoalRequirementsSuccess Criteria
[N][Name][Goal][REQ-IDs][count]
[N+1][Name][Goal][REQ-IDs][count]
...
[N]个阶段 | [X]个需求已映射 | 所有里程碑需求已全部覆盖 ✓
编号阶段名称阶段目标关联需求成功标准数量
[N][名称][目标][REQ-ID列表][数量]
[N+1][名称][目标][REQ-ID列表][数量]
...

Phase Details

阶段详情

Phase [N]: [Name] Goal: [goal] Requirements: [REQ-IDs] Success criteria:
  1. [criterion]
  2. [criterion]
[... continue for all phases ...]


**CRITICAL: Ask for approval before committing:**

Use AskUserQuestion:
- header: "Roadmap"
- question: "Does this roadmap structure work for you?"
- options:
  - "Approve" — Commit and continue
  - "Adjust phases" — Tell me what to change
  - "Review full file" — Show raw ROADMAP.md

**If "Approve":** Continue to commit.

**If "Adjust phases":**
- Get user's adjustment notes
- Re-spawn roadmapper with revision context:
Task(prompt=" <agent-instructions> {roadmapper_instructions_content} </agent-instructions>
<revision> User feedback on roadmap: [user's notes]
Current ROADMAP.md: @.planning/ROADMAP.md
Update the roadmap based on feedback. Edit files in place. Return ROADMAP REVISED with changes made. </revision> ", subagent_type="general-purpose", model="{roadmapper_model}", description="Revise roadmap")
- Present revised roadmap
- Loop until user approves

**If "Review full file":** Display raw `cat .planning/ROADMAP.md`, then re-ask.

**Commit roadmap (after approval):**

Check planning config (same pattern as Phase 6).

If committing:
```bash
git add .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md
git commit -m "$(cat <<'EOF'
docs: create milestone v[X.Y] roadmap ([N] phases)

Phases:
[N]. [phase-name]: [requirements covered]
[N+1]. [phase-name]: [requirements covered]
...

All milestone requirements mapped to phases.
EOF
)"
阶段[N]:[名称] 目标:[目标描述] 关联需求:[REQ-ID列表] 成功标准:
  1. [标准1]
  2. [标准2]
[...所有阶段详情...]


**重要:提交前需获取用户批准:**

使用AskUserQuestion工具:
- 标题:"路线图"
- 问题:"此路线图结构是否符合你的需求?"
- 选项:
  - "批准" — 提交并继续
  - "调整阶段" — 告诉我需要修改的内容
  - "查看完整文件" — 展示原始ROADMAP.md

**若选择“批准”:** 继续提交。

**若选择“调整阶段”:**
- 获取用户的调整说明
- 传入修订上下文,重新生成路线图Agent:
Task(prompt=" <agent-instructions> {roadmapper_instructions_content} </agent-instructions>
<revision> User feedback on roadmap: [用户的调整说明]
Current ROADMAP.md: @.planning/ROADMAP.md
Update the roadmap based on feedback. Edit files in place. Return ROADMAP REVISED with changes made. </revision> ", subagent_type="general-purpose", model="{roadmapper_model}", description="Revise roadmap")
- 展示修订后的路线图
- 循环此过程直至用户批准

**若选择“查看完整文件”:** 展示原始`cat .planning/ROADMAP.md`内容,然后重新询问用户。

**提交路线图(获得批准后):**

检查规划配置(与阶段6相同)。

若需提交:
```bash
git add .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md
git commit -m "$(cat <<'EOF'
docs: create milestone v[X.Y] roadmap ([N] phases)

Phases:
[N]. [phase-name]: [requirements covered]
[N+1]. [phase-name]: [requirements covered]
...

All milestone requirements mapped to phases.
EOF
)"

Phase 9.5: Create Phase Issues (if enabled)

阶段9.5:创建阶段问题(若启用)

1. Check github.enabled - Skip silently if false
If
GITHUB_ENABLED=false
:
Skip to Phase 10.
2. Check github.issueMode (auto | ask | never):
bash
ISSUE_MODE=$(cat .planning/config.json 2>/dev/null | grep -o '"issueMode"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "auto")
  • If "never": Skip phase issue creation silently, continue to Phase 10
  • If "ask": Use AskUserQuestion to prompt:
    • header: "GitHub Phase Issues"
    • question: "Create GitHub Issues for each phase in this milestone?"
    • options:
      • "Yes" — Create issues for all phases
      • "No" — Skip issue creation for this milestone
  • If "auto" or user approved "Yes": Proceed with creation
3. Create phase label (idempotent):
bash
gh label create "phase" --color "0E8A16" --description "Kata phase tracking" --force 2>/dev/null || true
4. Get milestone number (from Phase 5.5):
bash
undefined
1. 检查github.enabled - 若为false则静默跳过
GITHUB_ENABLED=false
直接进入阶段10。
2. 检查github.issueMode(auto | ask | never):
bash
ISSUE_MODE=$(cat .planning/config.json 2>/dev/null | grep -o '"issueMode"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "auto")
  • 若为"never":静默跳过阶段问题创建,进入阶段10
  • 若为"ask":使用AskUserQuestion工具询问:
    • 标题:"GitHub阶段问题"
    • 问题:"是否为此里程碑的每个阶段创建GitHub Issue?"
    • 选项:
      • "是" — 为所有阶段创建Issue
      • "否" — 此里程碑跳过Issue创建
  • 若为"auto"或用户选择"是":继续执行创建操作
3. 创建阶段标签(幂等操作):
bash
gh label create "phase" --color "0E8A16" --description "Kata phase tracking" --force 2>/dev/null || true
4. 获取里程碑编号(来自阶段5.5):
bash
undefined

Extract VERSION from current milestone (the one marked "In Progress")

从当前里程碑(标记为"In Progress"的里程碑)中提取VERSION

VERSION=$(grep -E "^### v[0-9]+.[0-9]+.*(In Progress)" .planning/ROADMAP.md | grep -oE "v[0-9]+.[0-9]+(.[0-9]+)?" | head -1 | tr -d 'v') if [ -z "$VERSION" ]; then echo "Warning: Could not determine milestone version from ROADMAP.md. Skipping phase issue creation." exit 0 fi
MILESTONE_NUM=$(gh api /repos/:owner/:repo/milestones --jq ".[] | select(.title=="v${VERSION}") | .number" 2>/dev/null) if [ -z "$MILESTONE_NUM" ]; then echo "Warning: Could not find GitHub Milestone v${VERSION}. Skipping phase issue creation."

Continue without phase issues - skip to Phase 10

fi

**5. Parse phases from ROADMAP.md** (for this milestone only):

The ROADMAP.md structure uses:
- Milestone headers: `### v1.1.0 GitHub Integration (Planned)` or `### v{VERSION} {Name} (Status)`
- Phase headers: `#### Phase N: Phase Name`
- Goal line: `**Goal**: description text`
- Requirements line: `**Requirements**: REQ-01, REQ-02` (optional)
- Success criteria: `**Success Criteria** (what must be TRUE):` followed by numbered list

```bash
VERSION=$(grep -E "^### v[0-9]+.[0-9]+.*(In Progress)" .planning/ROADMAP.md | grep -oE "v[0-9]+.[0-9]+(.[0-9]+)?" | head -1 | tr -d 'v') if [ -z "$VERSION" ]; then echo "警告:无法从ROADMAP.md中确定里程碑版本号。跳过阶段Issue创建。" exit 0 fi
MILESTONE_NUM=$(gh api /repos/:owner/:repo/milestones --jq ".[] | select(.title=="v${VERSION}") | .number" 2>/dev/null) if [ -z "$MILESTONE_NUM" ]; then echo "警告:未找到GitHub Milestone v${VERSION}。跳过阶段Issue创建。"

不创建阶段Issue,直接进入阶段10

fi

**5. 从ROADMAP.md中解析当前里程碑的阶段:**

ROADMAP.md的结构如下:
- 里程碑标题:`### v1.1.0 GitHub Integration (Planned)` 或 `### v{VERSION} {Name} (Status)`
- 阶段标题:`#### Phase N: Phase Name`
- 目标行:`**Goal**: description text`
- 需求行:`**Requirements**: REQ-01, REQ-02`(可选)
- 成功标准:`**Success Criteria** (what must be TRUE):` 后跟编号列表

```bash

Find the milestone section and extract phases

查找里程碑章节并提取阶段

ROADMAP_FILE=".planning/ROADMAP.md"
ROADMAP_FILE=".planning/ROADMAP.md"

Extract VERSION from current milestone (the one marked "In Progress")

从当前里程碑(标记为"In Progress"的里程碑)中提取VERSION

VERSION=$(grep -E "^### v[0-9]+.[0-9]+.*(In Progress)" "$ROADMAP_FILE" | grep -oE "v[0-9]+.[0-9]+(.[0-9]+)?" | head -1 | tr -d 'v') if [ -z "$VERSION" ]; then echo "Warning: Could not determine milestone version. Skipping phase issue creation." exit 0 fi
VERSION=$(grep -E "^### v[0-9]+.[0-9]+.*(In Progress)" "$ROADMAP_FILE" | grep -oE "v[0-9]+.[0-9]+(.[0-9]+)?" | head -1 | tr -d 'v') if [ -z "$VERSION" ]; then echo "警告:无法确定里程碑版本号。跳过阶段Issue创建。" exit 0 fi

Get line numbers for milestone section boundaries

获取里程碑章节的行号范围

MILESTONE_START=$(grep -n "^### v${VERSION}" "$ROADMAP_FILE" | head -1 | cut -d: -f1) NEXT_MILESTONE=$(awk -v start="$MILESTONE_START" 'NR > start && /^### v[0-9]/ {print NR; exit}' "$ROADMAP_FILE")
MILESTONE_START=$(grep -n "^### v${VERSION}" "$ROADMAP_FILE" | head -1 | cut -d: -f1) NEXT_MILESTONE=$(awk -v start="$MILESTONE_START" 'NR > start && /^### v[0-9]/ {print NR; exit}' "$ROADMAP_FILE")

If no next milestone, use end of file

若没有下一个里程碑,则使用文件末尾

if [ -z "$NEXT_MILESTONE" ]; then NEXT_MILESTONE=$(wc -l < "$ROADMAP_FILE") fi
if [ -z "$NEXT_MILESTONE" ]; then NEXT_MILESTONE=$(wc -l < "$ROADMAP_FILE") fi

Extract phase blocks within this milestone section

提取此里程碑章节内的阶段块

Each phase starts with "#### Phase N:" and ends at next "#### Phase" or section boundary

每个阶段以"#### Phase N:"开头,以下一个"#### Phase"或章节边界结束

PHASE_HEADERS=$(sed -n "${MILESTONE_START},${NEXT_MILESTONE}p" "$ROADMAP_FILE" | grep -n "^#### Phase [0-9]")
PHASE_HEADERS=$(sed -n "${MILESTONE_START},${NEXT_MILESTONE}p" "$ROADMAP_FILE" | grep -n "^#### Phase [0-9]")

Process each phase

处理每个阶段

echo "$PHASE_HEADERS" | while IFS= read -r phase_line; do

Extract phase number and name from "#### Phase N: Name"

PHASE_NUM=$(echo "$phase_line" | sed -E 's/.Phase ([0-9.]+):./\1/') PHASE_NAME=$(echo "$phase_line" | sed -E 's/.Phase [0-9.]+: (.)/\1/')

Get relative line number within milestone section

PHASE_REL_LINE=$(echo "$phase_line" | cut -d: -f1) PHASE_ABS_LINE=$((MILESTONE_START + PHASE_REL_LINE - 1))

Find next phase or section end

NEXT_PHASE_LINE=$(sed -n "$((PHASE_ABS_LINE+1)),${NEXT_MILESTONE}p" "$ROADMAP_FILE" | grep -n "^#### Phase|^### |^## " | head -1 | cut -d: -f1) if [ -z "$NEXT_PHASE_LINE" ]; then PHASE_END=$NEXT_MILESTONE else PHASE_END=$((PHASE_ABS_LINE + NEXT_PHASE_LINE - 1)) fi

Extract phase block

PHASE_BLOCK=$(sed -n "${PHASE_ABS_LINE},${PHASE_END}p" "$ROADMAP_FILE")

Extract goal (line starting with Goal:)

PHASE_GOAL=$(echo "$PHASE_BLOCK" | grep "^**Goal**:" | sed 's/**Goal**: *//')

Extract requirements (line starting with Requirements:) - may not exist

REQUIREMENT_IDS=$(echo "$PHASE_BLOCK" | grep "^**Requirements**:" | sed 's/**Requirements**: *//')

Extract success criteria (numbered list after Success Criteria)

Convert to checklist format: " 1. item" -> "- [ ] item"

SUCCESS_CRITERIA_AS_CHECKLIST=$(echo "$PHASE_BLOCK" |
awk '/^**Success Criteria**/{found=1; next} found && /^ [0-9]+./{print} found && /^**/{exit}' |
sed -E 's/^ [0-9]+. /- [ ] /')

--- Issue creation code (step 6) ---

Check if issue already exists (idempotent)

EXISTING=$(gh issue list --label "phase" --milestone "v${VERSION}" --json number,title --jq ".[] | select(.title | startswith("Phase ${PHASE_NUM}:")) | .number" 2>/dev/null)
if [ -n "$EXISTING" ]; then echo "Phase ${PHASE_NUM} issue already exists: #${EXISTING}" else # Build issue body using temp file (handles special characters safely) cat > /tmp/phase-issue-body.md << PHASE_EOF
echo "$PHASE_HEADERS" | while IFS= read -r phase_line; do

从"#### Phase N: Name"中提取阶段编号和名称

PHASE_NUM=$(echo "$phase_line" | sed -E 's/.Phase ([0-9.]+):./\1/') PHASE_NAME=$(echo "$phase_line" | sed -E 's/.Phase [0-9.]+: (.)/\1/')

获取阶段在里程碑章节内的相对行号

PHASE_REL_LINE=$(echo "$phase_line" | cut -d: -f1) PHASE_ABS_LINE=$((MILESTONE_START + PHASE_REL_LINE - 1))

查找下一个阶段或章节结束位置

NEXT_PHASE_LINE=$(sed -n "$((PHASE_ABS_LINE+1)),${NEXT_MILESTONE}p" "$ROADMAP_FILE" | grep -n "^#### Phase|^### |^## " | head -1 | cut -d: -f1) if [ -z "$NEXT_PHASE_LINE" ]; then PHASE_END=$NEXT_MILESTONE else PHASE_END=$((PHASE_ABS_LINE + NEXT_PHASE_LINE - 1)) fi

提取阶段块

PHASE_BLOCK=$(sed -n "${PHASE_ABS_LINE},${PHASE_END}p" "$ROADMAP_FILE")

提取目标(以Goal:开头的行)

PHASE_GOAL=$(echo "$PHASE_BLOCK" | grep "^**Goal**:" | sed 's/**Goal**: *//')

提取需求(以Requirements:开头的行)- 可能不存在

REQUIREMENT_IDS=$(echo "$PHASE_BLOCK" | grep "^**Requirements**:" | sed 's/**Requirements**: *//')

提取成功标准(Success Criteria后的编号列表)

转换为复选框格式:" 1. item" -> "- [ ] item"

SUCCESS_CRITERIA_AS_CHECKLIST=$(echo "$PHASE_BLOCK" |
awk '/^**Success Criteria**/{found=1; next} found && /^ [0-9]+./{print} found && /^**/{exit}' |
sed -E 's/^ [0-9]+. /- [ ] /')

--- Issue创建代码(步骤6) ---

检查Issue是否已存在(幂等操作)

EXISTING=$(gh issue list --label "phase" --milestone "v${VERSION}" --json number,title --jq ".[] | select(.title | startswith("Phase ${PHASE_NUM}:")) | .number" 2>/dev/null)
if [ -n "$EXISTING" ]; then echo "阶段${PHASE_NUM}的Issue已存在:#${EXISTING}" else # 使用临时文件构建Issue内容(安全处理特殊字符) cat > /tmp/phase-issue-body.md << PHASE_EOF

Goal

目标

${PHASE_GOAL}
${PHASE_GOAL}

Success Criteria

成功标准

${SUCCESS_CRITERIA_AS_CHECKLIST} $([ -n "$REQUIREMENT_IDS" ] && echo "
${SUCCESS_CRITERIA_AS_CHECKLIST} $([ -n "$REQUIREMENT_IDS" ] && echo "

Requirements

关联需求

${REQUIREMENT_IDS}")
${REQUIREMENT_IDS}")

Plans

规划

<!-- Checklist added by /kata-plan-phase (Phase 4) -->
Plans will be added after phase planning completes.

<sub>Created by Kata | Phase ${PHASE_NUM} of milestone v${VERSION}</sub> PHASE_EOF
# Create issue
gh issue create \
  --title "Phase ${PHASE_NUM}: ${PHASE_NAME}" \
  --body-file /tmp/phase-issue-body.md \
  --label "phase" \
  --milestone "v${VERSION}" \
  2>/dev/null && echo "Created issue: Phase ${PHASE_NUM}: ${PHASE_NAME}" || echo "Warning: Failed to create issue for Phase ${PHASE_NUM}"
fi done

**6. Display summary** (after loop):
◆ GitHub Phase Issues: [N] created for milestone v${VERSION}

**Error handling principle:** All operations are non-blocking. Missing milestone, auth issues, or creation failures warn but do not stop the milestone flow.

**IMPORTANT:** Use temp file approach (--body-file) to handle special characters in phase goals. Direct --body strings break with quotes/backticks.
<!-- 规划内容将由/kata-plan-phase(阶段4)添加 -->
阶段规划完成后会添加此处内容。

<sub>由Kata创建 | 里程碑v${VERSION}的第${PHASE_NUM}阶段</sub> PHASE_EOF
# 创建Issue
gh issue create \
  --title "Phase ${PHASE_NUM}: ${PHASE_NAME}" \
  --body-file /tmp/phase-issue-body.md \
  --label "phase" \
  --milestone "v${VERSION}" \
  2>/dev/null && echo "已创建Issue:Phase ${PHASE_NUM}: ${PHASE_NAME}" || echo "警告:无法为阶段${PHASE_NUM}创建Issue"
fi done

**6. 显示摘要**(循环结束后):
◆ GitHub阶段Issue:已为里程碑v${VERSION}创建[N]个

**错误处理原则:** 所有操作均为非阻塞。缺少里程碑、认证问题或创建失败会发出警告,但不会终止里程碑流程。

**重要提示:** 使用临时文件(--body-file)来处理阶段目标中的特殊字符。直接使用--body字符串会因引号/反引号导致错误。

Phase 10: Done

阶段10:完成

Present completion with next steps:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► MILESTONE INITIALIZED ✓ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Milestone v[X.Y]: [Name]
ArtifactLocation
Project
.planning/PROJECT.md
Research
.planning/research/
Requirements
.planning/REQUIREMENTS.md
Roadmap
.planning/ROADMAP.md
If
GITHUB_ENABLED=true
and milestone created:
| GitHub | Milestone v${VERSION} created |
[N] phases | [X] requirements | Ready to build ✓
───────────────────────────────────────────────────────────────
展示完成信息与后续步骤:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Kata ► 里程碑初始化完成 ✓ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
里程碑v[X.Y]:[名称]
工件存储位置
项目文件
.planning/PROJECT.md
调研文件
.planning/research/
需求文件
.planning/REQUIREMENTS.md
路线图文件
.planning/ROADMAP.md
GITHUB_ENABLED=true
且已创建里程碑:
| GitHub | 已创建里程碑v${VERSION} |
[N]个阶段 | [X]个需求 | 已准备好开发 ✓
───────────────────────────────────────────────────────────────

▶ Next Up

▶ 下一步操作

Phase [N]: [Phase Name] — [Goal from ROADMAP.md]
/kata-discuss-phase [N]
— gather context and clarify approach
<sub>
/clear
first → fresh context window</sub>

Also available:
  • /kata-plan-phase [N]
    — skip discussion, plan directly
───────────────────────────────────────────────────────────────
</process>
<success_criteria>
  • PROJECT.md updated with Current Milestone section
  • STATE.md reset for new milestone
  • MILESTONE-CONTEXT.md consumed and deleted (if existed)
  • Research completed (if selected) — 4 parallel agents spawned, milestone-aware
  • Requirements gathered (from research or conversation)
  • User scoped each category
  • REQUIREMENTS.md created with REQ-IDs
  • kata-roadmapper spawned with phase numbering context
  • Roadmap files written immediately (not draft)
  • User feedback incorporated (if any)
  • ROADMAP.md created with globally sequential phase numbers (continuing from highest existing)
  • All commits made (if planning docs committed)
  • User knows next step is
    /kata-discuss-phase [N]
Atomic commits: Each phase commits its artifacts immediately. If context is lost, artifacts persist. </success_criteria>
阶段[N]:[阶段名称] — [来自ROADMAP.md的目标]
/kata-discuss-phase [N]
— 收集上下文并明确实现方案
<sub>建议先运行
/clear
→ 清空上下文窗口</sub>

其他可用命令:
  • /kata-plan-phase [N]
    — 跳过讨论,直接进入规划阶段
───────────────────────────────────────────────────────────────
</流程>
<成功标准>
  • PROJECT.md已更新,包含当前里程碑章节
  • STATE.md已为新里程碑重置
  • MILESTONE-CONTEXT.md已被使用并删除(若存在)
  • 已完成调研(若选择) — 已并行生成4个Agent,且感知里程碑上下文
  • 已收集需求(来自调研或对话)
  • 用户已确定每个分类的范围
  • 已创建带REQ-ID的REQUIREMENTS.md
  • 已生成带阶段编号上下文的kata-roadmapper Agent
  • 路线图文件已立即写入(而非草稿)
  • 已纳入用户反馈(若有)
  • 已创建带全局连续阶段编号的ROADMAP.md(延续自最高的现有编号)
  • 已完成所有提交(若规划文件需提交)
  • 用户知晓下一步操作是
    /kata-discuss-phase [N]
原子提交: 每个阶段会立即提交其工件。若上下文丢失,工件仍会持久化保存。 </成功标准>