Focus Tree
Session content focus tree with checklist tracking. Extracts decisions, TODOs, constraints, and context into a single-root hierarchical structure for better conversation alignment and task management.
Core Principles
- 1. Alignment — Maintain synchronized understanding between agent and user. The FOCUS.md serves as a shared source of truth that both parties can reference.
- 2. Focus — Keep the agent anchored to the current task. Prevents drifting between topics or losing track after session compactions.
- 3. Planning — Enable structured, step-by-step task execution. Break down complex work into manageable hierarchical sub-tasks with clear progress tracking.
When to Read FOCUS.md
- - Every session start (before responding to first message)
- After every compaction (if context feels thin, read it)
- When the user asks about current work ("what are we doing?", "where were we?")
When to Write/Update FOCUS.md
Agents update FOCUS.md directly using file tools when:
| Trigger | Action | Example |
|---|
| userrequest | User says "start new project" | Write new FOCUS.md with Focus Point and TODOs |
| taskcomplete |
User says "task done" | Edit TODO line:
☐ →
✅ |
|
priority_shift | User changes priorities | Edit Focus Point line |
|
new_project | Starting new focused project | Write new FOCUS.md, archive old if exists |
|
heartbeat | Heartbeat check reveals blockers | Edit Status line, add Blockers section |
Additional actions:
- - When work is DONE — append to
FOCUS-LOG.md and clear/write new FOCUS.md - Before compaction memory flushes — ensure FOCUS.md reflects current state
Rules
- 1. One focus at a time. If the user pivots, archive the old focus first.
- Keep it short. FOCUS.md should be <50 lines. It's a resume point, not a journal.
- 📖 Context is sacred. Always update it before stopping work. Future-you reads this first.
- Don't duplicate memory files. FOCUS.md tracks what we're doing now. Daily memory files track what happened. Different jobs.
- Archive when done. Append completed focuses to
FOCUS-LOG.md with completion date and outcome, then clear FOCUS.md. - Read it, don't ask. If FOCUS.md exists, read it and resume. Don't ask "what were we working on?" when the answer is in the file.
File Roles
Focus Tree uses three distinct files for different purposes:
| File | Purpose | When to Update |
|---|
| FOCUS.md | Current work state — What we're doing NOW | Every task change, status change, or context shift |
| FOCUS-LOG.md |
Completed work history — Archive of finished focuses | Only when archiving a completed/blocked focus |
|
MEMORY.md |
Long-term curated memory — Important insights, lessons, preferences | Periodically distill from daily notes |
Key principle: FOCUS.md tracks what we're doing now. Daily memory files track what happened. FOCUS-LOG tracks what we finished. Different jobs.
FOCUS.md Structure
Focus Tree uses a hierarchical tree structure. Here's the complete format:
CODEBLOCK0
Tree View
Hierarchical structure showing nesting levels:
CODEBLOCK1
Field Reference
| Field | Prefix | Required | Description |
|---|
| Focus Point | INLINECODE4 | ✅ Yes | Root task name |
| TODOs |
☐/⏳/✅ | ✅ Yes | Task checklist |
|
Context |
📖 | ✅ Yes | Active state + blockers |
| Decisions |
📌 | ❌ No | Key decisions made |
| Constraints |
⚠️ | ❌ No | Limitations/requirements |
| Sub-Agents |
🤖 | ❌ No | Spawned agents status |
| Started | - | ❌ No | Start date |
| Status | - | ❌ No | active/paused/blocked |
Usage
Focus Tree operates on FOCUS.md and FOCUS-LOG.md directly.
Option 1: CLI Script (recommended)
CODEBLOCK2
Option 2: Direct File Operations
CODEBLOCK3
Context Section Details
The 📖 Context section serves as the "Active State" — it's the resume point after compaction.
What to include:
- - What was the last thing done
- What's the next action
- Any blockers or waiting
Always update Context before stopping work. Future-you will read this first.
Content Parsing
When editing FOCUS.md, agents should use these section prefixes:
| Section | Prefix | Example | Placement |
|---|
| Decisions | INLINECODE12 | INLINECODE13 | Optional section after TODOs |
| TODOs |
☐/⏳/✅ |
☐ Implement feature | Required section |
| Constraints |
⚠️ |
⚠️ Must use TypeScript | Optional section after TODOs |
| Blockers |
🚧 |
🚧 Waiting for API key | Inside 📖 Context section |
| Context |
📖 |
📖 Current status... | Required section (last) |
| Sub-Agents |
🤖 |
🤖 label — task — status | Optional section before Context |
Display Format
- - TODOs Level 1: Icon prefix
-
✅ = completed
-
⏳ = in progress
-
☐ = pending
- - TODOs Level 2: Plain list, no icon prefix
- Decisions: prefix INLINECODE27
- Constraints: prefix INLINECODE28
- Context: prefix INLINECODE29
FOCUS-LOG.md Format
Append-only log of completed focuses:
CODEBLOCK4
Integration with AGENTS.md
Add to your session-start routine, after reading SOUL.md and USER.md:
- - Read
FOCUS.md if it exists → resume work or acknowledge status - If no
FOCUS.md exists → check MEMORY.md for recent context - Proceed with current focus or start new
Integration with HEARTBEAT.md
Focus Tree provides dedicated heartbeat integration:
Heartbeat triggers:
- - Check current FOCUS.md status
- Detect blockers → edit 📖 Context section, add INLINECODE33
- Update Status line if needed
HEARTBEAT.md format:
CODEBLOCK5
焦点树
带清单追踪的会话内容焦点树。将决策、待办事项、约束和上下文提取到单一根层级结构中,以实现更好的对话对齐和任务管理。
核心原则
- 1. 对齐 — 保持代理与用户之间的同步理解。FOCUS.md作为双方均可参考的共享事实来源。
- 2. 聚焦 — 让代理锚定在当前任务上。防止在主题间漂移或在会话压缩后丢失进度。
- 3. 规划 — 实现结构化、逐步的任务执行。将复杂工作分解为可管理的层级子任务,并带有清晰的进度追踪。
何时读取FOCUS.md
- - 每次会话开始时(在回复第一条消息之前)
- 每次压缩之后(如果上下文感觉单薄,请阅读)
- 当用户询问当前工作时(我们在做什么?、我们进行到哪了?)
何时写入/更新FOCUS.md
代理使用文件工具直接更新FOCUS.md,当:
| 触发条件 | 操作 | 示例 |
|---|
| 用户请求 | 用户说开始新项目 | 写入新的FOCUS.md,包含焦点点和待办事项 |
| 任务完成 |
用户说任务完成 | 编辑待办事项行:☐ → ✅ |
|
优先级变更 | 用户改变优先级 | 编辑焦点点行 |
|
新项目 | 开始新的聚焦项目 | 写入新的FOCUS.md,如果存在旧文件则归档 |
|
心跳检查 | 心跳检查发现阻塞项 | 编辑状态行,添加阻塞项部分 |
额外操作:
- - 当工作完成时 — 追加到FOCUS-LOG.md并清空/写入新的FOCUS.md
- 在压缩内存刷新之前 — 确保FOCUS.md反映当前状态
规则
- 1. 一次只聚焦一个点。 如果用户转向,先归档旧焦点。
- 保持简短。 FOCUS.md应少于50行。它是恢复点,不是日记。
- 📖 上下文是神圣的。 在停止工作前务必更新它。未来的你会首先阅读这个。
- 不要重复记忆文件。 FOCUS.md追踪我们正在做什么。日常记忆文件追踪发生了什么。不同的职责。
- 完成后归档。 将完成的焦点追加到FOCUS-LOG.md,包含完成日期和结果,然后清空FOCUS.md。
- 阅读它,不要询问。 如果FOCUS.md存在,阅读并恢复。当答案在文件中时,不要问我们在做什么?
文件角色
焦点树使用三个不同的文件用于不同目的:
| 文件 | 目的 | 何时更新 |
|---|
| FOCUS.md | 当前工作状态 — 我们现在正在做什么 | 每次任务变更、状态变更或上下文切换 |
| FOCUS-LOG.md |
已完成工作历史 — 已完成焦点的归档 | 仅在归档已完成/被阻塞的焦点时 |
|
MEMORY.md |
长期策划记忆 — 重要见解、经验、偏好 | 定期从日常笔记中提炼 |
关键原则: FOCUS.md追踪我们现在正在做什么。日常记忆文件追踪发生了什么。FOCUS-LOG追踪我们完成了什么。不同的职责。
FOCUS.md结构
焦点树使用层级树结构。以下是完整格式:
markdown
FOCUS.md - 当前焦点
🎯 焦点点:[任务名称]
开始时间:[日期]
状态:[活跃/暂停/阻塞]
📝 待办事项
☐ [任务1]
☐ [任务2]
📖 上下文
[当前上下文/笔记]
🚧 [阻塞项(如有)]
树视图
显示嵌套层级的层级结构:
🎯 焦点点(根)
├── 📌 决策
├── 📝 待办事项(最多2层)
│ ├── ✅ 第1层任务
│ │ ├── 第2层子任务(无图标)
│ │ └── 第2层子任务
│ └── ⏳ 第1层任务
├── ⚠️ 约束
├── 🤖 子代理
└── 📖 上下文
└── 🚧 阻塞项
字段参考
☐/⏳/✅ | ✅ 是 | 任务清单 |
|
上下文 | 📖 | ✅ 是 | 活跃状态 + 阻塞项 |
| 决策 | 📌 | ❌ 否 | 做出的关键决策 |
| 约束 | ⚠️ | ❌ 否 | 限制/要求 |
| 子代理 | 🤖 | ❌ 否 | 衍生代理的状态 |
| 开始时间 | - | ❌ 否 | 开始日期 |
| 状态 | - | ❌ 否 | 活跃/暂停/阻塞 |
使用方法
焦点树直接操作FOCUS.md和FOCUS-LOG.md。
选项1:CLI脚本(推荐)
bash
node scripts/focus.mjs init 项目名称 # 初始化
node scripts/focus.mjs add-todo 任务 # 添加任务
node scripts/focus.mjs done 1 # 标记完成
node scripts/focus.mjs status active # 更新状态
node scripts/focus.mjs archive 结果 # 归档
选项2:直接文件操作
bash
read /path/to/workspace/FOCUS.md
edit /path/to/workspace/FOCUS.md
old: ☐ 未完成任务
new: ✅ 已完成任务
上下文部分详情
📖 上下文部分作为活跃状态——它是压缩后的恢复点。
包含内容:
- - 最后做了什么
- 下一步行动是什么
- 任何阻塞项或等待项
在停止工作前务必更新上下文。未来的你会首先阅读这个。
内容解析
当编辑FOCUS.md时,代理应使用这些部分前缀:
| 部分 | 前缀 | 示例 | 位置 |
|---|
| 决策 | 📌 | 📌 决定使用Node.js | 待办事项后的可选部分 |
| 待办事项 |
☐/⏳/✅ | ☐ 实现功能 | 必需部分 |
| 约束 | ⚠️ | ⚠️ 必须使用TypeScript | 待办事项后的可选部分 |
| 阻塞项 | 🚧 | 🚧 等待API密钥 | 在📖上下文部分内 |
| 上下文 | 📖 | 📖 当前状态... | 必需部分(最后) |
| 子代理 | 🤖 | 🤖 标签 — 任务 — 状态 | 上下文前的可选部分 |
显示格式
- ✅ = 已完成
- ⏳ = 进行中
- ☐ = 待处理
- - 待办事项第2层:纯列表,无图标前缀
- 决策:前缀 📌
- 约束:前缀 ⚠️
- 上下文:前缀 📖
FOCUS-LOG.md格式
仅追加的已完成焦点日志:
markdown
焦点日志
[项目名称] — 已完成 YYYY-MM-DD
持续时间: X小时/天
结果: 一行结果
[项目名称] — 已归档 YYYY-MM-DD
持续时间: X小时/天
结果: 部分完成备注
状态: 未完成
与AGENTS.md的集成
添加到会话开始例程中,在读取SOUL.md和USER.md之后:
- - 如果存在则读取FOCUS.md → 恢复工作或确认状态
- 如果不存在FOCUS.md → 检查MEMORY.md获取最近上下文
- 继续当前焦点或开始新焦点
与HEARTBEAT.md的集成
焦点树提供专用的心跳集成:
心跳触发条件:
- - 检查当前FOCUS.md状态
- 检测阻塞项 → 编辑📖上下文部分,添加🚧 [阻塞项描述]
- 如果需要则更新状态行
HEARTBEAT.md格式:
markdown
HEARTBEAT.md
基于触发条件的焦点树更新
触发条件
- 1. 用户请求 — 用户明确说