feat(packages): 内置 SDK 包并完善 ContextLoader 集成

- 将 ShrinkEventBus、ShrinkDataSaver 及其 EventBus 集成从 gitlink 转为仓库直接维护的完整 UPM 包,补齐运行时、编辑器工具、测试与文档
- 新增 Command 和 Network 的 App 集成组件,支持 ContextLoader 服务发布、可逆注销及 Network Loopback 生命周期管理
- 更新 Starter 与演示组合逻辑,缺失模块时可注册、已有兼容安装器时可覆盖,并补充宿主启动断言
- 升级内部包依赖与 Shared CodeGen 包定义,放宽 Integration.App 包的 Git 忽略规则
- 将独立服务器生成器改为基于已编译程序集的语义扫描,支持 partial、复杂泛型、命名冲突检测及模板 SHA-256 覆写保护
- 新增 Network 语义扫描、模板保护和 App 组件生命周期测试
- 新增真实 UPM 消费工程验证脚本,校验内部版本一致性、程序集加载及 EditMode 测试
- 重构当前架构文档并归档已完成的 Cordis 迁移与旧代码地图
This commit is contained in:
2026-08-18 18:06:34 +08:00
parent 517c4cf46e
commit d74c2f08ca
240 changed files with 13647 additions and 545 deletions
@@ -0,0 +1,11 @@
# Changelog
本文件记录 `ShrinkCommand.Integration.App` 的包内变更。
## [0.1.0] - 2026-05-18
### Added
- 新增 `ShrinkCommand``ShrinkApp.Core` 的桥接包。
- 新增 `ShrinkCommandAppInstaller`,把默认命令服务挂入宿主服务容器。
- 新增 `ShrinkCommandAppService` 作为宿主侧命令门面。
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1754b3bc0377768409187131b594bda6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
# ShrinkCommand.Integration.App
`ShrinkCommand.Integration.App``ShrinkCommand``ShrinkApp.Core` 的桥接层。它的职责很简单:把默认命令服务挂进 `ShrinkApp` 的服务容器里,让项目在进入统一宿主模式后,仍能用熟悉的命令系统,而不需要到处手动拿 `ShrinkCommandRuntime.Default`
## 当前能力
- 提供原生 `ShrinkCommandAppComponent`,发布 `shrink.service.command`
-`ShrinkCommandRuntime.Default` 包装为 `ShrinkCommandAppService`
- ContextLoader 下由 Starter 组合根装配,服务门面随组件停用可逆注销
- `ShrinkCommandAppInstaller` 仅保留给 ClassicHost 兼容路径,已标记过时
## 使用示例
```csharp
var command = ShrinkApp.ShrinkApp.Services.GetRequired<ShrinkCommand.Integration.App.ShrinkCommandAppService>();
var result = await command.ExecuteAsync(source, "help");
```
## 说明
- 本包不改变 `ShrinkCommand` 的原有 API。
- 静态命令的默认注册仍由 `ShrinkCommandRuntime.Default` 完成。
- 运行时实例命令仍然走 `RegisterCommands(object target)`
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: da6f74ed70ed86e48bc9309983a690b9
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 79640806d61572d44b10ae9bbb0ace79
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
{
"name": "ShrinkCommand.Integration.App",
"rootNamespace": "ShrinkCommand.Integration.App",
"references": [
"ShrinkCommand.Runtime",
"ShrinkApp.Core.Runtime",
"ShrinkContext.Core.Runtime",
"UniTask"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e5805c0a2f81e6f47818b1dac7d15e6c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
#nullable enable
using System;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using ShrinkApp;
using ShrinkContext;
using ShrinkCommand;
namespace ShrinkCommand.Integration.App
{
/// <summary>
/// ShrinkCommand 的原生 Cordis 组件(阶段 3):
/// 提供 <c>shrink.service.command</c> 余效应键(默认命令服务),依赖者按键注入;
/// 与经典 ShrinkCommandAppInstallerModuleId "shrink.command")二选一使用(同键供给冲突保护)。
/// </summary>
public sealed class ShrinkCommandAppComponent : IShrinkComponent
{
public const string ServiceKey = "shrink.service.command";
public const string ModuleKey = "app.module.shrink.command";
private static readonly string[] ProvideKeys = { ModuleKey, ServiceKey };
public string Name => "shrink.command";
public IReadOnlyList<string> Inject => Array.Empty<string>();
public IReadOnlyList<string> Provide => ProvideKeys;
public UniTask ApplyAsync(ShrinkCtx ctx, object? config)
{
var service = ShrinkCommandRuntime.Default;
ctx.Set(ServiceKey, service);
ctx.Set(ModuleKey, Name);
if (config is ShrinkAppServices appServices)
{
var facade = new ShrinkCommandAppService(service);
appServices.Register(facade);
ctx.EffectInverse(() =>
{
appServices.TryUnregister(facade);
return UniTask.CompletedTask;
});
}
return UniTask.CompletedTask;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 507e23e02986281488456a63dc8ffdbe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
#nullable enable
using System;
using Cysharp.Threading.Tasks;
using ShrinkApp;
namespace ShrinkCommand.Integration.App
{
[ShrinkAppModuleInstaller]
[Obsolete("ClassicHost compatibility only. ContextLoader projects should use ShrinkCommandAppComponent from a composition root.")]
public sealed class ShrinkCommandAppInstaller : IShrinkAppModuleInstaller
{
public string ModuleId => "shrink.command";
public int Order => -1500;
public System.Collections.Generic.IReadOnlyList<string> DependsOn => Array.Empty<string>();
public void RegisterServices(ShrinkAppContext context)
{
context.Services.Register(new ShrinkCommandAppService(ShrinkCommandRuntime.Default));
}
public UniTask InitializeAsync(ShrinkAppContext context)
{
return UniTask.CompletedTask;
}
}
public sealed class ShrinkCommandAppService
{
public ShrinkCommandAppService(ShrinkCommandService service)
{
Service = service ?? throw new ArgumentNullException(nameof(service));
}
public ShrinkCommandService Service { get; }
public UniTask<ShrinkCommandExecutionResult> ExecuteAsync(
IShrinkCommandSource source,
string rawInput,
System.Threading.CancellationToken cancellationToken = default)
=> Service.ExecuteAsync(source, rawInput, cancellationToken);
public string BuildHelp(IShrinkCommandSource? source, string? prefix = null)
=> Service.BuildHelp(source, prefix);
public System.Collections.Generic.IReadOnlyList<ShrinkCommandDescriptor> Commands => Service.Commands;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a71473a2ecd04c3459903841fee6da7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
{
"name": "com.cneicy.shrink-command-integration-app",
"version": "0.1.0",
"displayName": "ShrinkCommand - App Integration",
"description": "ShrinkCommand 与 ShrinkApp 的桥接层,把默认命令服务纳入统一宿主服务容器。",
"unity": "2022.3",
"dependencies": {
"com.cneicy.shrink-command": "0.2.0",
"com.cneicy.shrink-app-core": "0.1.1",
"com.cysharp.unitask": "2.5.10",
"com.cneicy.shrink-context-core": "0.1.0"
},
"keywords": [
"command",
"integration",
"app",
"console"
],
"author": {
"name": "cneicy",
"url": "https://github.com/cneicy"
}
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 126abcc047b44714593c2f94aa587c75
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: