Skip to content

Commit a97f83f

Browse files
authored
feat(LLMsDocs.Cli): default skill installation to user scope (#1116)
* feat: 所有 skill 作用域更改为系统级别 * doc: 更新 readme 文档 * chore: bump version 10.0.3
1 parent 8f0855e commit a97f83f

4 files changed

Lines changed: 34 additions & 20 deletions

File tree

tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>10.0.2</Version>
4+
<Version>10.0.3</Version>
55
<OutputType>Exe</OutputType>
66
<TargetFramework>net10.0</TargetFramework>
77
<SatelliteResourceLanguages>false</SatelliteResourceLanguages>

tools/BootstrapBlazor.LLMsDocs.Cli/CommandFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static Command BuildInstructionsCommand()
154154
private static Command BuildInstallCommand()
155155
{
156156
var client = new Option<string?>("--client") { Description = "Target client: claude | cursor | trae | codex | all (default all)." };
157-
var scope = new Option<string?>("--scope") { Description = "Where to write: project (cwd, default) or user (home)." };
157+
var scope = new Option<string?>("--scope") { Description = "Where to write: user (home, default) or project (cwd)." };
158158
var target = new Option<string?>("--target") { Description = "Override base directory to write into." };
159159
var force = new Option<bool>("--force") { Description = "Overwrite existing files." };
160160
var cmd = new Command("install", "Install agent discovery artifacts (Claude Code skill / Cursor rules / Trae skill / Codex AGENTS.md).")
@@ -167,7 +167,7 @@ private static Command BuildInstallCommand()
167167
{
168168
return Task.FromResult(Scaffolder.Install(
169169
result.GetValue(client) ?? "all",
170-
result.GetValue(scope) ?? "project",
170+
result.GetValue(scope),
171171
result.GetValue(target),
172172
result.GetValue(force)));
173173
}

tools/BootstrapBlazor.LLMsDocs.Cli/README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,43 +130,50 @@ bb-llms get Button --base-url ./wwwroot/llms
130130

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

140140
`install` 选项:
141141

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

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

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

165-
典型流程(在你的 Blazor 项目根目录)
172+
典型流程:
166173

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

tools/BootstrapBlazor.LLMsDocs.Cli/Scaffolder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ public static int Instructions()
3838
}
3939

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

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

0 commit comments

Comments
 (0)