Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>10.0.2</Version>
<Version>10.0.3</Version>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<SatelliteResourceLanguages>false</SatelliteResourceLanguages>
Expand Down
4 changes: 2 additions & 2 deletions tools/BootstrapBlazor.LLMsDocs.Cli/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static Command BuildInstructionsCommand()
private static Command BuildInstallCommand()
{
var client = new Option<string?>("--client") { Description = "Target client: claude | cursor | trae | codex | all (default all)." };
var scope = new Option<string?>("--scope") { Description = "Where to write: project (cwd, default) or user (home)." };
var scope = new Option<string?>("--scope") { Description = "Where to write: user (home, default) or project (cwd)." };
var target = new Option<string?>("--target") { Description = "Override base directory to write into." };
var force = new Option<bool>("--force") { Description = "Overwrite existing files." };
var cmd = new Command("install", "Install agent discovery artifacts (Claude Code skill / Cursor rules / Trae skill / Codex AGENTS.md).")
Expand All @@ -167,7 +167,7 @@ private static Command BuildInstallCommand()
{
return Task.FromResult(Scaffolder.Install(
result.GetValue(client) ?? "all",
result.GetValue(scope) ?? "project",
result.GetValue(scope),
result.GetValue(target),
result.GetValue(force)));
}
Expand Down
37 changes: 22 additions & 15 deletions tools/BootstrapBlazor.LLMsDocs.Cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,43 +130,50 @@ bb-llms get Button --base-url ./wwwroot/llms

```bash
bb-llms instructions # 打印可粘贴进 CLAUDE.md / AGENTS.md 的通用片段
bb-llms install --client claude # 写 .claude/skills/bootstrapblazor/SKILL.md
bb-llms install --client cursor # 写 .cursor/rules/bootstrapblazor.mdc
bb-llms install --client trae # 写 .trae/skills/bootstrapblazor/SKILL.md
bb-llms install --client codex # 写 AGENTS.md(user scope 为 ~/.codex/AGENTS.md
bb-llms install --client claude # 写 ~/.claude/skills/bootstrapblazor/SKILL.md
bb-llms install --client cursor # 写 ~/.cursor/rules/bootstrapblazor.mdc
bb-llms install --client trae # 写 ~/.trae/skills/bootstrapblazor/SKILL.md
bb-llms install --client codex # 写 ~/.codex/AGENTS.md
bb-llms install --client all # 四者都写(默认)
```

`install` 选项:

```
--client claude|cursor|trae|codex|all 目标客户端(默认 all)
--scope project|user project=当前目录(默认),user=用户主目录
--scope user|project user=用户主目录(默认),project=当前目录
--target <dir> 覆盖写入的根目录
--force 覆盖已存在的文件(默认存在则跳过)
```

> 默认 scope 为 **user(用户主目录)**:四个客户端的发现文件都装到用户主目录
> (`~/.claude/skills/`、`~/.cursor/rules/`、`~/.trae/skills/`、`~/.codex/AGENTS.md`),
> 配合全局安装的 `bb-llms`,在任意项目里都能被自动发现,装一次全局生效。
> 需要只对当前项目生效时,用 `--scope project` 显式覆盖
> (如 `bb-llms install --client codex --scope project` 写仓库根目录的 `AGENTS.md`)。

五套生态接入方式:

- **Claude Code**:`bb-llms install --client claude` 写入一个 skill,Claude Code 会根据其
`description` 在任务涉及 BootstrapBlazor 组件时**自动加载**并调用 `bb-llms`,
等效于 MCP server 的自动发现。
- **Cursor**:`bb-llms install --client cursor` 写入项目规则(匹配 `*.razor` / `*.razor.cs`)。
- **Trae**:`bb-llms install --client trae` 写入一个 skill(`.trae/skills/bootstrapblazor/SKILL.md`)。
- **Claude Code**:`bb-llms install --client claude` 在**用户主目录** `~/.claude/skills/`
写入一个 skill,Claude Code 会根据其 `description` 在任务涉及 BootstrapBlazor 组件时
**自动加载**并调用 `bb-llms`,等效于 MCP server 的自动发现。装一次即对所有项目生效。
- **Cursor**:`bb-llms install --client cursor` 在**用户主目录** `~/.cursor/rules/`
写入规则(匹配 `*.razor` / `*.razor.cs`),全局生效。
- **Trae**:`bb-llms install --client trae` 在**用户主目录** `~/.trae/skills/` 写入一个 skill。
Trae 的 skill 与 Claude 同构(同样的 `SKILL.md` + name/description frontmatter,按描述**自动匹配**),
因此复用同一套模板。
- **Codex**:`bb-llms install --client codex` 写入 `AGENTS.md`(project scope 为仓库根目录的
`AGENTS.md`,user scope 为 `~/.codex/AGENTS.md`)。Codex 没有独立的 skill/规则机制,统一读 `AGENTS.md`,
因此复用同一套模板,同样装一次全局生效
- **Codex**:`bb-llms install --client codex` 写入 `~/.codex/AGENTS.md`(用户主目录,默认;
`--scope project` 则写仓库根目录的 `AGENTS.md`)。Codex 没有独立的 skill/规则机制,统一读 `AGENTS.md`,
因此复用 `instructions` 的通用片段。
> ⚠️ `AGENTS.md` 是手工维护的共享文件,**默认存在则跳过**;`--force` 会整文件覆盖,原有内容会丢失。
> 已有 `AGENTS.md` 时,建议改用 `bb-llms instructions` 把片段手动粘进去。
- **通用 / 其他 agent**:把 `bb-llms instructions` 的输出粘进项目的 `CLAUDE.md` / `AGENTS.md`。

典型流程(在你的 Blazor 项目根目录)
典型流程:

```bash
dotnet tool install -g BootstrapBlazor.LLMsDocs.Cli # 1. 装工具
bb-llms install --client claude # 2. 装发现层
bb-llms install --client claude # 2. 装发现层(写入用户主目录,全局生效)
# 之后在 Claude Code 中让它写/改组件代码时,会自动用 bb-llms 查权威 API
```

Expand Down
11 changes: 9 additions & 2 deletions tools/BootstrapBlazor.LLMsDocs.Cli/Scaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ public static int Instructions()
}

/// <summary>Write discovery artifacts for the requested client(s).</summary>
public static int Install(string client, string scope, string? target, bool force)
/// <param name="scope">
/// <c>user</c> (home, the default) or <c>project</c> (cwd). Defaulting to the user
/// home keeps every client's discovery artifact alongside the globally-installed
/// tool, so it is auto-discovered in every project without re-running install per repo.
/// </param>
public static int Install(string client, string? scope, string? target, bool force)
{
var clients = client.ToLowerInvariant() switch
{
Expand All @@ -50,7 +55,9 @@ public static int Install(string client, string scope, string? target, bool forc
_ => throw new ArgumentException($"Unknown client: {client} (expected claude|cursor|trae|codex|all)")
};

var scopeKey = scope.ToLowerInvariant();
// No explicit --scope defaults to the user home: the tool is installed globally,
// so its discovery artifacts live in the user home and work in every project.
var scopeKey = (scope ?? "user").ToLowerInvariant();
if (scopeKey is not ("project" or "user"))
{
throw new ArgumentException($"Unknown scope: {scope} (expected project|user)");
Expand Down
Loading