dsh-git-ui 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-git-ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "DeepSeek Harness (dsh) plugin: visualize Git status in the Web UI — current branch, HEAD, staged/modified/untracked counts, ahead/behind, recent commits and changed files.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,6 +24,12 @@ export interface DshClientContext {
24
24
  on(event: string, listener: (...args: never[]) => void): (() => void) | void
25
25
  /** 注册副作用(自动在 fiber 卸载时清理)。 */
26
26
  effect(callback: () => void | (() => void | Promise<void>), label?: string): void
27
+ /** 启动一个嵌套插件 fiber(子上下文)。 */
28
+ plugin(definition: {
29
+ readonly name: string
30
+ readonly inject: readonly string[]
31
+ apply: (ctx: DshClientContext) => void | Promise<void>
32
+ }): Promise<unknown>
27
33
  /** Remote 服务:挂载贡献 + 访问已挂载的命名空间。 */
28
34
  remote: {
29
35
  $mount(contribution: TypertRemoteContribution): Promise<() => Promise<void>>
@@ -62,10 +68,11 @@ function toTypertContribution(ours: RemoteContribution): TypertRemoteContributio
62
68
  /**
63
69
  * 将 Cordis Context 适配为 `ClientPlatform`。
64
70
  *
65
- * 注意:`mountRemoteAndGetService` 的实现利用了 Cordis 的特性——
66
- * 挂载完成后,`ctx.remote.gitInfo` 立即可用。无需 child fiber 模式
67
- * (该模式是 Cordis 内部为避免 inject 死锁的优化,此处我们在 mount
68
- * 完成后直接访问,效果等价)。
71
+ * `mountRemoteAndGetService` 必须通过 child fiber 访问命名空间服务:
72
+ * Cordis 的访问控制要求读取 `remote.gitInfo` 前必须在 inject 中声明它,
73
+ * 而主 fiber 不能声明(服务由我们自己的 apply 挂载,声明会死锁——
74
+ * cordis 会等待 apply 执行后才存在的服务)。child fiber 在 mount 之后
75
+ * 激活,声明 `remote.gitInfo` 时服务已存在——无等待、无访问违规。
69
76
  */
70
77
  export function adaptDshClientContext(ctx: DshClientContext): ClientPlatform {
71
78
  return {
@@ -74,14 +81,24 @@ export function adaptDshClientContext(ctx: DshClientContext): ClientPlatform {
74
81
  },
75
82
 
76
83
  async mountRemoteAndGetService(contribution, namespace) {
77
- // 挂载 Remote 贡献
84
+ // 挂载 Remote 贡献(主 fiber 内执行,仅调用 $mount 方法本身)
78
85
  await ctx.remote.$mount(toTypertContribution(contribution))
79
- // 挂载完成后,命名空间服务立即可用
80
- // 当前只有 'gitInfo' 命名空间,直接返回
81
- if (namespace === 'gitInfo') {
82
- return ctx.remote.gitInfo
86
+ if (namespace !== 'gitInfo') {
87
+ throw new Error(`adaptDshClientContext: 未知命名空间 "${namespace}"`)
83
88
  }
84
- throw new Error(`adaptDshClientContext: 未知命名空间 "${namespace}"`)
89
+ // child fiber:inject 声明 remote.gitInfo,apply 内读取合法
90
+ let service: GitRemoteLike | undefined
91
+ await ctx.plugin({
92
+ name: 'dsh-git-ui:git',
93
+ inject: ['remote.gitInfo'],
94
+ apply: (sub) => {
95
+ service = sub.remote.gitInfo
96
+ },
97
+ })
98
+ if (service === undefined) {
99
+ throw new Error('adaptDshClientContext: gitInfo 服务未就绪')
100
+ }
101
+ return service
85
102
  },
86
103
 
87
104
  registerSlotEntry(options, component) {