导入主机

人工智能 社区

技能解读

当前原文的自动摘译,尚未人工审校。

1. 检测候选人

步行已知地点并报告存在的情况。在两个范围内搜索:home ($HOME) 和当前的存储库根目录(包含.git的目录,从 cwd 向上)。将匹配列表报告给用户。如果没有匹配的内容,则退出并显示:“未找到主机 AI 上下文文件 - 从头开始​​运行 /second-brain:setup 来搭建脚手架。”

2. 对每个文件进行分类

对于每个检测到的文件,读取前约 60 行。确定内容是否主要是:用户级偏好 - 全局行为规则(语气、风格、“永远不要做 X”、语言偏好、格式默认值)。目标USER.md。项目级事实——特定于回购协议的目标、状态、惯例、决策、阻碍因素。目标是活动存储库的PROJECT.md。混合——建议分拆;建议使用 USER.md 切片和 PROJECT.md 切片。

3.提出USER.md内容

对于分类为用户级别的文件(或切片):将内容提炼为 ≤15 个跨项目首选项的短项目符号行。放弃冗长的散文、特定于存储库的事实以及任何陈旧的内容。将建议的 USER.md 内容显示为单个块。提示:Append these <N> preferences to USER.md? (Y / N / edit) 打开Y:对于每个首选项,请致电pin_to_user(text: "<preference>")。 MCP 工具对 USER.md 强制执行 15 行上限,并添加了一个带日期的 - [YYYY-MM-DD] … 条目;溢出时,它返回{ok: false},并且该技能必须显示拒绝。

4.提出PROJECT.md内容

对于分类为项目级别的文件(或切片),解析活动项目 slug:如果 ~/.second-brain/projects/$SLUG/PROJECT.md 不存在,则指示用户首先运行 /second-brain:setup - 此技能填充内容但不构建文件。如果存在,请逐节提出: 目标(≤3 行):展示您的蒸馏草稿并提示Replace existing Goal? (Y/N/edit)。通过Edit工具应用——仅替换## Goal部分的主体。

5. 跳过重复项

在每个 pin_to_user 或 pin_to_project 提案之前,grep 候选文本的目标文件。如果存在模糊匹配,则提示:<text> already present (or close); skip / replace?并进行相应操作。

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
人工智能
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@tomevault-io · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

<!-- user instruction verbatim: "1" -->

# Import host

Bootstrap the v1.0 hot tier (`USER.md` + `PROJECT.md`) from AI-context files you've already written for Claude Code, Aider, Cursor, Continue, Windsurf, or AGENTS.md (the OpenCode/agent-rules standard). The skill is read-only against your host files and explicit-confirm against second-brain writes.

## Steps

### 1. Detect candidates

Walk known locations and report what exists. Search at two scopes: home (`$HOME`) and the current repo root (the directory containing `.git`, walking up from cwd).

```bash
declare -a CANDIDATES=(
  "$HOME/CLAUDE.md"
  "$HOME/AGENTS.md"
  "$HOME/.cursorrules"
  "$HOME/.windsurfrules"
  "$HOME/.continuerules"
  "$HOME/.aider.conf.yml"
  "$HOME/.claude/CLAUDE.md"
  "$HOME/.claude/instructions.md"
)

GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -n "$GIT_ROOT" ]; then
  for f in CLAUDE.md AGENTS.md .cursorrules .windsurfrules .continuerules .aider.conf.yml instructions.md; do
    [ -f "$GIT_ROOT/$f" ] && CANDIDATES+=("$GIT_ROOT/$f")
  done
fi

for c in "${CANDIDATES[@]}"; do
  if [ -f "$c" ]; then
    LINES=$(wc -l < "$c" | tr -d ' ')
    printf '  %s (%s lines)\n' "$c" "$LINES"
  fi
done
```

Report the matched list to the user. If nothing matches, exit with: "No host AI-context files found — run `/second-brain:setup` to scaffold from scratch."

### 2. Categorize each file

For each detected file, read the first ~60 lines. Decide whether the content is primarily:

- **User-level preferences** — global how-to-behave rules (tone, style, "never do X", language preferences, formatting defaults). Targets `USER.md`.
- **Project-level facts** — repo-specific Goal, State, Conventions, decisions, blockers. Targets the active repo's `PROJECT.md`.
- **Mixed** — recommend splitting; propose a USER.md slice and a PROJECT.md slice.

Files at `$HOME` are usually user-level. Files at `$GIT_ROOT` are usually project-level. The first ~60-line read confirms.

Report the categorisation to the user before any writes.

### 3. Propose USER.md content

For files (or slices) categorized as user-level:

1. Distill the content into ≤15 short bullet lines of cross-project preferences. Drop verbose prose, repo-specific facts, and anything stale.
2. Show the proposed USER.md content as a single block.
3. Prompt: `Append these <N> preferences to USER.md? (Y / N / edit)`
4. On `Y`: for each preference, call `pin_to_user(text: "<preference>")`. The MCP tool enforces a 15-line cap on USER.md and adds a dated `- [YYYY-MM-DD] …` entry; on overflow it returns `{ok: false}` and the skill must surface the rejection.
5. On `edit`: let the user revise the block, then re-prompt.
6. On `N`: skip.

If `~/.second-brain/USER.md` does not exist yet, the first `pin_to_user` call will create it with the standard header.

### 4. Propose PROJECT.md content

For files (or slices) categorized as project-level, resolve the active project slug:

```bash
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
```

If `~/.second-brain/projects/$SLUG/PROJECT.md` does not exist, instruct the user to run `/second-brain:setup` first — this skill fills in content but does not scaffold the file.

If it exists, propose section-by-section:

- **Goal** (≤3 lines): show your distilled draft and prompt `Replace existing Goal? (Y/N/edit)`. Apply via `Edit` tool — replace the body of the `## Goal` section only.
- **Conventions** (≤5 lines): same flow, target `## Conventions`.
- **Recent decisions** (≤3 entries): for each, prompt and call `pin_to_project(text: "<decision text>", slug: "$SLUG", section: "decisions")` on accept. The tool prefixes `- [decision] ` automatically.
- **Open blockers** (≤15 lines): for each, prompt and call `pin_to_project(text: "<blocker text>", slug: "$SLUG", section: "blockers")` on accept. The tool prefixes `- [active] ` automatically.

Skip `## State` and `## Cross-references` — those are runtime-maintained, not import targets.

### 5. Skip duplicates

Before each `pin_to_user` or `pin_to_project` proposal, grep the destination file for the candidate text. If a fuzzy match exists, prompt: `<text> already present (or close); skip / replace?` and act accordingly.

### 6. Done

Report a one-block summary:

```
# Import summary
- USER.md: 4 preferences appended (skipped 1 duplicate)
- PROJECT.md (my-repo):
  - Goal updated
  - Conventions updated
  - 2 [active] blockers added
  - 1 [decision] decision added
- Source files left untouched.
```

Suggest follow-ups: `/second-brain:lint` (catch any orphan or dead references introduced by the import) and `/second-brain:status` (sanity-check hot-tier byte counts stay under cap).

## Notes

- This is a **bootstrap** skill — it is most useful right after `/second-brain:setup`. Re-running it later is safe but will mostly hit the duplicate-skip path.
- The skill never deletes or modifies your host files (`~/CLAUDE.md`, `.cursorrules`, etc.). They stay where they are.
- All writes go through the v1.0 MCP tools (`pin_to_user`, `pin_to_project`) or direct `Edit`s on `PROJECT.md`. There is no critic-gate, no persona/quality-rules file, no `archive_to_wiki` invocation here — those are explicit user actions handled by `/second-brain:improve`.
- Hot-tier cap reminder: USER.md ≤ 15 lines (enforced by `pin_to_user`); USER.md + PROJECT.md combined ~3200 bytes target. If a proposed import would push over, distill harder before re-trying.

---
> Source: [Cain-Ish/claude-code-plugin](https://github.com/Cain-Ish/claude-code-plugin) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。