goal-plan

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Goal Plan

目标计划

Create and execute intelligent plans using Goal-Oriented Action Planning (GOAP).
使用目标导向行动计划(GOAP)创建并执行智能计划。

When to use

适用场景

When you have a complex objective that requires multiple steps, has dependencies between steps, and may need adaptive replanning as conditions change.
当你有一个复杂目标,需要多个步骤、步骤间存在依赖关系,且可能需要根据条件变化进行自适应重规划时。

Steps

步骤

  1. Define goal state — what does "done" look like? List concrete success criteria
  2. Assess current state — what's true now? What assets, code, infrastructure exist?
  3. Identify gap — what must change between current and goal state?
  4. Inventory actions — list available actions with:
    • Preconditions (what must be true before this action)
    • Effects (what becomes true after this action)
    • Cost estimate (time, complexity, risk)
  5. Generate plan — find the optimal action sequence using A* through the state space
  6. Record trajectory — call
    mcp__claude-flow__hooks_intelligence_trajectory-start
    to begin tracking
  7. Create tasks — call
    mcp__claude-flow__task_create
    for each action in the plan
  8. Execute — work through tasks in dependency order:
    • Before each action: verify preconditions still hold
    • After each action: verify effects achieved
    • Record each step via
      mcp__claude-flow__hooks_intelligence_trajectory-step
  9. Monitor & replan — if an action fails or produces unexpected results:
    • Reassess current state
    • Recalculate optimal path from new state
    • Update remaining tasks
  10. Complete trajectory — call
    mcp__claude-flow__hooks_intelligence_trajectory-end
  11. Store successful plan — call
    mcp__claude-flow__memory_store
    with namespace
    goap-plans
  1. 定义目标状态 — “完成”是什么样子?列出具体的成功标准
  2. 评估当前状态 — 目前的实际情况是什么?已有的资产、代码、基础设施有哪些?
  3. 识别差距 — 当前状态与目标状态之间需要做出哪些改变?
  4. 盘点可用行动 — 列出所有可用行动,包含:
    • 前置条件(执行此行动前必须满足的条件)
    • 效果(执行此行动后会达成的结果)
    • 成本估算(时间、复杂度、风险)
  5. 生成计划 — 通过状态空间中的A*算法找到最优行动序列
  6. 记录轨迹 — 调用
    mcp__claude-flow__hooks_intelligence_trajectory-start
    开始追踪
  7. 创建任务 — 为计划中的每个行动调用
    mcp__claude-flow__task_create
  8. 执行计划 — 按照依赖顺序完成任务:
    • 执行每个行动前:验证前置条件是否仍然满足
    • 执行每个行动后:验证是否达成预期效果
    • 通过
      mcp__claude-flow__hooks_intelligence_trajectory-step
      记录每个步骤
  9. 监控与重规划 — 如果某个行动失败或产生意外结果:
    • 重新评估当前状态
    • 从新状态重新计算最优路径
    • 更新剩余任务
  10. 完成轨迹记录 — 调用
    mcp__claude-flow__hooks_intelligence_trajectory-end
  11. 存储成功计划 — 使用命名空间
    goap-plans
    调用
    mcp__claude-flow__memory_store

Plan output format

计划输出格式

Goal: [concrete objective]
Current State: [key facts]
Plan Cost: [estimated effort]
Steps:
  1. [action] — precondition: [X], effect: [Y], cost: [Z]
  2. [action] — precondition: [Y], effect: [W], cost: [Z]
  ...
Risk Factors: [what could force a replan]
Fallback: [alternative approach if primary path fails]
Goal: [concrete objective]
Current State: [key facts]
Plan Cost: [estimated effort]
Steps:
  1. [action] — precondition: [X], effect: [Y], cost: [Z]
  2. [action] — precondition: [Y], effect: [W], cost: [Z]
  ...
Risk Factors: [what could force a replan]
Fallback: [alternative approach if primary path fails]

Replanning triggers

重规划触发条件

  • Action fails (precondition no longer met)
  • Unexpected side effects detected
  • New information changes goal definition
  • Cost exceeds threshold
  • External dependency becomes unavailable
  • 行动失败(前置条件不再满足)
  • 检测到意外副作用
  • 新信息改变了目标定义
  • 成本超出阈值
  • 外部依赖不可用