SuperAPI AI 工具集

bonfire-start

编程与开发

查看项目

更新于 10-16 06:10

技能介绍

用途

bonfire-start 是 Bonfire 工作流中的会话启动技能,用于在开始新会话时读取项目上下文并设置任务。它面向使用 Claude Code 等支持技能/命令的 AI 编程环境、并希望跨会话保留项目上下文的开发者。

主要能力

  • 检查 Git 根目录下是否存在 .bonfire/index.md。
  • 若 .bonfire/ 不存在,则引导用户完成初始化配置并搭建目录结构。
  • 创建或更新 CLAUDE.md,使其引用 .bonfire/index.md。
  • 设置跨会话持久化的项目任务列表。
  • 读取并汇总会话上下文(当前状态、近期工作、下一步优先级)。
  • 在 index.md 过大时给出归档警告。
  • 可选地拉取 GitHub 或 Linear 的外部 issue 上下文。

使用方式

初始化配置

当 .bonfire/ 不存在时,技能会通过 AskUserQuestion 询问以下设置:

第一轮(4 个问题):

  • Specs 保存位置:.bonfire/specs/(默认)或 specs/
  • Docs 保存位置:.bonfire/docs/(默认)或 docs/
  • .bonfire/ 的 Git 处理方式:ignore-all(默认,保持会话私有/本地)、hybrid(提交 docs/specs,保持笔记私有)、commit-all(与团队共享全部内容)
  • 是否启用 Linear 集成:No(默认)或 Yes(需要 linear-cli)

第二轮(1 个问题):

  • 是否设置 bonfire hooks:Yes(推荐,上下文保留 + 归档建议)或 No

随后根据用户选择创建目录结构。始终在 .bonfire/ 中创建:index.md、config.json、archive/、.gitignore。根据 specsLocation 与 docsLocation 创建对应目录。项目名称从 package.json 的 name、git remote 或目录名中检测。

config.json 示例:

{
  "specsLocation": "<user-answer>",
  "docsLocation": "<user-answer>",
  "gitStrategy": "<user-answer>",
  "linearEnabled": <true-or-false>
}

index.md 使用模板创建,包含:Session Context 标题、日期、状态、分支、Current State、Recent Sessions、Next Session Priorities、Key Resources、Codemap、Archived Sessions、Notes 等部分。

.gitignore 根据策略生成:

  • ignore-all:
*
!.gitignore
  • hybrid(仅包含 .bonfire/ 内的目录):
*
!.gitignore

若 docsLocation 为 .bonfire/docs/,追加:

!docs/
!docs/**

若 specsLocation 为 .bonfire/specs/,追加:

!specs/
!specs/**
  • commit-all:
data/
scratch/

Hooks 设置

若用户选择 Yes,则创建 <git-root>/.claude/ 目录(如不存在),并创建或合并 <git-root>/.claude/settings.json:

{
  "hooks": {
    "PreCompact": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "echo '## Session Context (preserved before compaction)' && head -100 \"$(git rev-parse --show-toplevel)/.bonfire/index.md\" 2>/dev/null || echo 'No session context found'"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "if echo \"$TOOL_INPUT\" | grep -qE 'gh pr (merge|close)'; then echo 'PR merged/closed! Run /bonfire-archive to archive this session.'; fi"
          }
        ]
      }
    ]
  }
}

若 settings.json 已存在,则小心合并 hooks(保留已有 hooks)。

CLAUDE.md 检查/更新

若 <git-root>/CLAUDE.md 不存在,则创建,包含 Quick Context 与 Bonfire Commands 列表:

  • /bonfire-start - Start a session (reads context)
  • /bonfire-end - End session (updates context)
  • /bonfire-spec - Create implementation spec
  • /bonfire-document <topic> - Document a topic
  • /bonfire-review - Review work for blindspots and improvements
  • /bonfire-archive - Archive completed work
  • /bonfire-configure - Change project settings

若已存在,检查是否引用 .bonfire/index.md,若未引用则追加 Session Context 段落。

任务集成

设置项目任务列表以实现跨会话持久化。项目名称使用 package.json 的 name、git remote 或目录名。任务列表 ID 为 bonfire-<project-name>(例如 bonfire-my-app)。若任务已存在,显示“Continuing work from previous session. Active tasks: [summary]”。任务与 index.md 互补:Tasks 是活动清单(做什么),index.md 是叙述性上下文(为什么、决策、历史)。

读取会话上下文

读取 <git-root>/.bonfire/index.md 并汇总当前状态、近期工作、下一步优先级。

大小警告

读取 index.md 后估算大小(字符数 / 4)。若估算 token 超过 20,000,显示警告:

=== SESSION CONTEXT TOO LARGE ===

Your .bonfire/index.md is ~[N]K tokens, which may cause read errors.

Run /bonfire-archive to clean up old sessions.

然后通过 AskUserQuestion 确认如何处理:“I'll archive now”或“Continue anyway”。若估算 token 不超过 20,000,则直接继续。

拉取外部上下文(可选)

仅在用户提供新 URL 或 issue ID 时拉取。

识别 issue 类型:

  • GitHub:以 # 开头、包含 github.com,或不匹配 Linear 模式
  • Linear:匹配 [A-Z]+-[0-9]+ 模式(如 ENG-123、ABC-456)或包含 linear.app

GitHub Issues/PRs 使用 gh CLI:

gh pr view [URL] --json title,body,state,labels
gh issue view [URL] --json title,body,state,labels

Linear Issues:先读取 <git-root>/.bonfire/config.json 检查 linearEnabled。若为 false 或未设置,跳过 Linear,按临时任务处理。若为 true,使用 linear-cli 拉取:

linear issue view ENG-123

提取 title、description、state、priority、labels、assignee。成功则汇总 issue 上下文;失败则警告用户:“Couldn't fetch Linear issue. Is linear-cli installed and authenticated? Continue without issue context?”

若成功拉取 issue,则在 index.md 的 Current State 下添加引用,包含 issue ID、标题和链接,并注明 issue 跟踪器类型(GitHub/Linear)。

若无 URL/issue ID 提供(继续工作、临时任务),则使用现有会话上下文继续。

最后询问:“What do you want to work on this session?”

适用场景

  • 使用 Bonfire 工作流管理跨会话项目上下文的开发者。
  • 需要在会话开始时快速恢复项目状态、近期工作和优先级的场景。
  • 需要将 GitHub 或 Linear issue 上下文引入会话的场景。
  • 需要跨会话持久化任务清单的场景。

限制

  • Linear 集成需要安装并认证 linear-cli。
  • GitHub 集成依赖 gh CLI。
  • 当 index.md 估算超过 20,000 token 时可能产生读取错误,需要归档清理。
  • 具体收费、价格、平台支持范围等资料暂未提供。