XiHan.Framework.Hosting.CommandLine
5.0.0-preview.1
Prefix Reserved
See the version list below for details.
dotnet add package XiHan.Framework.Hosting.CommandLine --version 5.0.0-preview.1
NuGet\Install-Package XiHan.Framework.Hosting.CommandLine -Version 5.0.0-preview.1
<PackageReference Include="XiHan.Framework.Hosting.CommandLine" Version="5.0.0-preview.1" />
<PackageVersion Include="XiHan.Framework.Hosting.CommandLine" Version="5.0.0-preview.1" />
<PackageReference Include="XiHan.Framework.Hosting.CommandLine" />
paket add XiHan.Framework.Hosting.CommandLine --version 5.0.0-preview.1
#r "nuget: XiHan.Framework.Hosting.CommandLine, 5.0.0-preview.1"
#:package XiHan.Framework.Hosting.CommandLine@5.0.0-preview.1
#addin nuget:?package=XiHan.Framework.Hosting.CommandLine&version=5.0.0-preview.1&prerelease
#tool nuget:?package=XiHan.Framework.Hosting.CommandLine&version=5.0.0-preview.1&prerelease
XiHan.Framework.Hosting.CommandLine
命令行宿主(Ring 4)。在通用宿主(Host.CreateApplicationBuilder)里把命令行参数翻译为内核调用:一份操作契约在命令行上也能服务(RFC-0011,spec/protocol/commandline.md)。
var builder = Host.CreateApplicationBuilder(args);
builder.AddXiHan(xihan => xihan.UseMinimalProfile().UseFeature<McpProtocolFeature>().UseFeature<GreetingsFeature>());
builder.Services.AddXiHanCommandLine();
return await builder.Build().RunXiHanCommandLineAsync(args);
app help # 用法与命令列表
app graph # 能力图谱(App.DescribeGraph)
app pipeline # 管道阶段与中间件(App.DescribePipeline)
app operations # 登记表:ID、稳定性、暴露的协议、权限或策略
app invoke greetings.create --name Ada # 字段选项拼成载荷;或 --json '{"name":"Ada"}'、--data request.json
app greetings create --name Ada --times 2 # <resource> <verb> 是 invoke 的简写
app mcp --tenant acme # Protocols.Mcp 注册的 stdio 传输,上下文选项同 invoke
规则
- 解析:第一个非选项记号是命令名;
--name value、--name=value、无值的--flag记为true;--之后全是位置参数;值不做类型转换。 invoke:只接受Expose含CommandLine且非Stability.Internal的操作。载荷按--json(须为对象)>--data <file>(可写@file)> 其余--<field> <value>选项(字符串,重复成数组)的顺序取;请求类型从字符串读数字需启用NumberHandling = AllowReadingFromString。- 上下文:
--tenant、--correlation、--locale进 Baggage;--timeout <秒>换算为截止时间;--authorization '<scheme> <value>'(或环境变量XIHAN_AUTHORIZATION)进入凭据由 Authenticate 阶段解释;调用来源记cli与操作 ID(ADR-0043)。调用经完整内核管道,Authorize 阶段按契约判定。 - 输出:成功把响应 JSON 写到 stdout;失败把
{"code","detail","traceId"}写到 stderr(detail按--locale或默认区域翻译),退出码按错误 KIND:VALIDATION 2、NOTFOUND 3、DENIED 4、CONFLICT 5、UNAVAILABLE 6、TIMEOUT 7、CANCELLED 8、其他 1;用法错误 64。 - 日志:
AddXiHanCommandLine()把日志改为只写 stderr,stdout 只承载命令输出。 - 扩展:实现
ICommand(名字、说明的消息键、执行)并AddXiHanCommand<T>();命令名重复在启动时失败。
AddXiHan(this HostApplicationBuilder, …) 与 ASP.NET Core 宿主一样先装载 XIHAN_CONFIG_PATH 目录里的 JSON 文件(可重载),紧接 appsettings.{环境}.json 插入:覆盖 appsettings,环境变量与命令行参数覆盖它(RFC-0016)。
依赖方向
依赖 XiHan.Framework.Kernel、XiHan.Framework.Security.Abstractions、XiHan.Framework.Localization.Abstractions,以及 Microsoft.Extensions.Hosting、Microsoft.Extensions.Configuration.Json 与 Microsoft.Extensions.Logging.Console。被 Protocols.Mcp(mcp 命令)引用。
状态
P3:可用。xihan graph / xihan pipeline(P1-19)由本宿主的 graph / pipeline 命令提供,xihan 工具转发到应用。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Json (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Console (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- System.Threading.RateLimiting (>= 10.0.14)
- XiHan.Framework.Kernel (>= 5.0.0-preview.1)
- XiHan.Framework.Localization.Abstractions (>= 5.0.0-preview.1)
- XiHan.Framework.Security.Abstractions (>= 5.0.0-preview.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XiHan.Framework.Hosting.CommandLine:
| Package | Downloads |
|---|---|
|
XiHan.Framework.Protocols.Mcp
曦寒框架 MCP 协议适配器 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0-preview.2 | 45 | 11/6/2026 |
| 5.0.0-preview.1 | 48 | 11/4/2026 |