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>11.0.0</Version>
<Version>11.0.1</Version>
<OutputType>Exe</OutputType>
<SatelliteResourceLanguages>false</SatelliteResourceLanguages>
</PropertyGroup>
Expand Down
51 changes: 30 additions & 21 deletions tools/BootstrapBlazor.LLMsDocs.Cli/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ internal static class CommandFactory

private static Command BuildIndexCommand()
{
var (baseUrl, refresh, noCache) = SourceOptions();
var cmd = new Command("index", "Print the raw llms.txt index.") { baseUrl, refresh, noCache };
var (baseUrl, refresh, noCache, project, framework) = SourceOptions();
var cmd = new Command("index", "Print the documentation index.") { baseUrl, refresh, noCache, project, framework };
cmd.SetAction(async (result, ct) =>
{
try
{
using var client = CreateClient(result, baseUrl, refresh, noCache);
Console.Out.Write(await client.GetIndexAsync(ct));
using var client = CreateClient(result, baseUrl, refresh, noCache, project, framework);
Console.Out.Write(await client.IndexAsync(ct));
return 0;
}
catch (Exception ex)
Expand All @@ -57,16 +57,16 @@ private static Command BuildListCommand()
{
var query = new Option<string?>("--query") { Description = "Optional name/description filter." };
var format = FormatOption();
var (baseUrl, refresh, noCache) = SourceOptions();
var (baseUrl, refresh, noCache, project, framework) = SourceOptions();
var cmd = new Command("list", "List components from the index (default JSON).")
{
query, format, baseUrl, refresh, noCache
query, format, baseUrl, refresh, noCache, project, framework
};
cmd.SetAction(async (result, ct) =>
{
try
{
using var client = CreateClient(result, baseUrl, refresh, noCache);
using var client = CreateClient(result, baseUrl, refresh, noCache, project, framework);
var entries = await client.ListAsync(result.GetValue(query), ct);
WriteEntries(entries, result.GetValue(format));
return 0;
Expand All @@ -84,16 +84,16 @@ private static Command BuildSearchCommand()
var query = new Argument<string>("query") { Description = "Search term." };
var limit = new Option<int>("--limit") { Description = "Maximum results (default 20)." };
var format = FormatOption();
var (baseUrl, refresh, noCache) = SourceOptions();
var (baseUrl, refresh, noCache, project, framework) = SourceOptions();
var cmd = new Command("search", "Search components by name or description (default JSON).")
{
query, limit, format, baseUrl, refresh, noCache
query, limit, format, baseUrl, refresh, noCache, project, framework
};
cmd.SetAction(async (result, ct) =>
{
try
{
using var client = CreateClient(result, baseUrl, refresh, noCache);
using var client = CreateClient(result, baseUrl, refresh, noCache, project, framework);
var max = result.GetValue(limit);
if (max <= 0)
{
Expand All @@ -115,18 +115,18 @@ private static Command BuildSearchCommand()
private static Command BuildGetCommand()
{
var component = new Argument<string>("component") { Description = "Component name, e.g. Button." };
var (baseUrl, refresh, noCache) = SourceOptions();
var (baseUrl, refresh, noCache, project, framework) = SourceOptions();
var cmd = new Command("get", "Fetch one component's API doc (the core command).")
{
component, baseUrl, refresh, noCache
component, baseUrl, refresh, noCache, project, framework
};
cmd.SetAction(async (result, ct) =>
{
var name = result.GetValue(component)!;
try
{
using var client = CreateClient(result, baseUrl, refresh, noCache);
Console.Out.Write(await client.GetComponentAsync(name, ct));
using var client = CreateClient(result, baseUrl, refresh, noCache, project, framework);
Console.Out.Write(await client.GetAsync(name, ct));
return 0;
}
catch (FileNotFoundException ex)
Expand All @@ -153,11 +153,11 @@ 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 client = new Option<string?>("--client") { Description = "Target client: copilot | claude | cursor | trae | codex | all (default all)." };
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).")
var cmd = new Command("install", "Install agent discovery artifacts (Copilot / Claude Code / Cursor / Trae / Codex).")
{
client, scope, target, force
};
Expand All @@ -181,23 +181,32 @@ private static Command BuildInstallCommand()

// ---- helpers ----------------------------------------------------------

private static (Option<string?> baseUrl, Option<bool> refresh, Option<bool> noCache) SourceOptions()
private static (Option<string?> baseUrl, Option<bool> refresh, Option<bool> noCache, Option<string?> project, Option<string?> framework) SourceOptions()
{
var baseUrl = new Option<string?>("--base-url")
{
Description = $"Docs source: HTTP(S) URL or local directory. Overrides {LlmsDocsClient.BaseUrlEnvVar}. Default: {LlmsDocsClient.DefaultBaseUrl}"
};
var refresh = new Option<bool>("--refresh") { Description = "Ignore cache TTL and re-fetch from the source." };
var noCache = new Option<bool>("--no-cache") { Description = "Do not read or write the local cache." };
return (baseUrl, refresh, noCache);
var project = new Option<string?>("--project") { Description = "Project file or directory to resolve package documentation." };
var framework = new Option<string?>("--framework") { Description = "Target framework from project.assets.json." };
return (baseUrl, refresh, noCache, project, framework);
}

private static Option<string?> FormatOption() =>
new("--format") { Description = "Output format: json (default) or text." };

private static LlmsDocsClient CreateClient(
ParseResult result, Option<string?> baseUrl, Option<bool> refresh, Option<bool> noCache) =>
new(result.GetValue(baseUrl), result.GetValue(refresh), result.GetValue(noCache));
private static ProjectDocsClient CreateClient(
ParseResult result, Option<string?> baseUrl, Option<bool> refresh, Option<bool> noCache,
Option<string?> project, Option<string?> framework)
{
var source = result.GetValue(baseUrl);
var automatic = string.IsNullOrWhiteSpace(source)
&& string.IsNullOrEmpty(Environment.GetEnvironmentVariable(LlmsDocsClient.BaseUrlEnvVar));
var packages = automatic ? ProjectDocsResolver.Resolve(result.GetValue(project), result.GetValue(framework)) : [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Low · Help advertises the wrong default

When restored project package documentation is available and a caller consults CLI help to determine the default source, --help still describes the official URL as the default, although automatic mode resolves restored project packages first; callers who rely on the help output are misled about which documentation source will answer their query.

Update the root and source-option help descriptions to explain that project package docs take precedence over the official site in automatic mode.

Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocs.Cli/CommandFactory.cs` at line 207:

**Help advertises the wrong default**

When restored project package documentation is available and a caller consults CLI help to determine the default source, `--help` still describes the official URL as the default, although automatic mode resolves restored project packages first; callers who rely on the help output are misled about which documentation source will answer their query.

Update the root and source-option help descriptions to explain that project package docs take precedence over the official site in automatic mode.

return new ProjectDocsClient(new LlmsDocsClient(source, result.GetValue(refresh), result.GetValue(noCache), automatic), packages, automatic);
}

private static void WriteEntries(IReadOnlyList<ComponentEntry> entries, string? format)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/BootstrapBlazor.LLMsDocs.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
// Output is redirected and the encoding can't be set; ignore.
}

return await CommandFactory.Build().Parse(args).InvokeAsync();
return await CommandFactory.Build().Parse(args.Length == 0 ? ["--help"] : args).InvokeAsync();
Loading
Loading