XiHan.Framework.Hosting.CommandLine 5.0.0-preview.1

Prefix Reserved
This is a prerelease version of XiHan.Framework.Hosting.CommandLine.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XiHan.Framework.Hosting.CommandLine" Version="5.0.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Hosting.CommandLine" Version="5.0.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="XiHan.Framework.Hosting.CommandLine" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XiHan.Framework.Hosting.CommandLine --version 5.0.0-preview.1
                    
#r "nuget: XiHan.Framework.Hosting.CommandLine, 5.0.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XiHan.Framework.Hosting.CommandLine@5.0.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XiHan.Framework.Hosting.CommandLine&version=5.0.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=XiHan.Framework.Hosting.CommandLine&version=5.0.0-preview.1&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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