#69 Phase 1c: 注册 18 个 @output/* schema + 默认 template + wrapEnvelope 函数 #75

Closed
opened 2026-05-31 12:46:02 +00:00 by xiaoju · 0 comments
Owner

Parent: #69 (Phase 1 of #67)

Depends: Phase 1b

Scope

1. 在 bootstrap() 中注册 18 个 @output/* schema

每个 schema 带 title 和 description:

@output/put          — { type: "string", format: "cas_ref", title: "ucas put result" }
@output/get          — { type: "object", properties: { type: cas_ref, payload: any, timestamp: number }, title: "ucas get result" }
@output/has          — { type: "boolean", title: "ucas has result" }
@output/hash         — { type: "string", format: "cas_ref", title: "ucas hash result" }
@output/verify       — { type: "string", enum: ["ok","corrupted","invalid"], title: "ucas verify result" }
@output/refs         — { type: "array", items: { type: "string", format: "cas_ref" }, title: "ucas refs result" }
@output/walk         — { type: "array", items: { type: "string" }, title: "ucas walk result" }
@output/list         — { type: "array", items: { type: "string", format: "cas_ref" }, title: "ucas list result" }
@output/var-set      — 当前 var set 的输出结构 schema, title: "ucas var set result"
@output/var-get      — 当前 var get 的输出结构 schema, title: "ucas var get result"
@output/var-delete   — 当前 var delete 的输出结构 schema, title: "ucas var delete result"
@output/var-tag      — 当前 var tag 的输出结构 schema, title: "ucas var tag result"
@output/var-list     — 当前 var list 的输出结构 schema, title: "ucas var list result"
@output/template-set — { type: "object", properties: { schemaHash, contentHash }, title: "ucas template set result" }
@output/template-get — { type: "string", title: "ucas template get result" }
@output/template-list — { type: "array", items: ..., title: "ucas template list result" }
@output/template-delete — { type: "object", properties: { deleted: boolean }, title: "ucas template delete result" }
@output/gc           — { type: "object", properties: { collected, remaining, ... }, title: "ucas gc result" }

2. 注册别名

每个 schema 注册 @output/<name> 别名到内置别名表(和 @string/@number 一样)。

3. 注册默认 template

为每个 @output/* schema 注册默认 LiquidJS template 到 @ucas/template/text/<schema-hash>

4. 抽取 wrapEnvelope()

async function wrapEnvelope(store: Store, schemaAlias: string, value: unknown): Promise<{ type: Hash; value: unknown }>

从别名解析 schema hash,返回 { type, value }

关键约束

  • bootstrap() 返回的别名表要包含所有新增的 @output/ 别名*
  • 现有测试中检查 bootstrap 返回值的,需要更新期望(schema 数量从 6 变成 24)
  • 不改任何命令的输出格式(那是 Phase 2-4 的事)

Verification

  • bun test 通过(更新 bootstrap 相关测试的期望值)
  • bun run build 通过
  • bootstrap 后 store 能查到所有 @output/* schema
  • 每个 @output/* 都有对应的 template
  • wrapEnvelope("@output/put", "XXXXX") 返回正确信封
## Parent: #69 (Phase 1 of #67) ## Depends: Phase 1b ## Scope ### 1. 在 bootstrap() 中注册 18 个 @output/* schema 每个 schema 带 title 和 description: ``` @output/put — { type: "string", format: "cas_ref", title: "ucas put result" } @output/get — { type: "object", properties: { type: cas_ref, payload: any, timestamp: number }, title: "ucas get result" } @output/has — { type: "boolean", title: "ucas has result" } @output/hash — { type: "string", format: "cas_ref", title: "ucas hash result" } @output/verify — { type: "string", enum: ["ok","corrupted","invalid"], title: "ucas verify result" } @output/refs — { type: "array", items: { type: "string", format: "cas_ref" }, title: "ucas refs result" } @output/walk — { type: "array", items: { type: "string" }, title: "ucas walk result" } @output/list — { type: "array", items: { type: "string", format: "cas_ref" }, title: "ucas list result" } @output/var-set — 当前 var set 的输出结构 schema, title: "ucas var set result" @output/var-get — 当前 var get 的输出结构 schema, title: "ucas var get result" @output/var-delete — 当前 var delete 的输出结构 schema, title: "ucas var delete result" @output/var-tag — 当前 var tag 的输出结构 schema, title: "ucas var tag result" @output/var-list — 当前 var list 的输出结构 schema, title: "ucas var list result" @output/template-set — { type: "object", properties: { schemaHash, contentHash }, title: "ucas template set result" } @output/template-get — { type: "string", title: "ucas template get result" } @output/template-list — { type: "array", items: ..., title: "ucas template list result" } @output/template-delete — { type: "object", properties: { deleted: boolean }, title: "ucas template delete result" } @output/gc — { type: "object", properties: { collected, remaining, ... }, title: "ucas gc result" } ``` ### 2. 注册别名 每个 schema 注册 `@output/<name>` 别名到内置别名表(和 @string/@number 一样)。 ### 3. 注册默认 template 为每个 @output/* schema 注册默认 LiquidJS template 到 `@ucas/template/text/<schema-hash>`。 ### 4. 抽取 wrapEnvelope() ```typescript async function wrapEnvelope(store: Store, schemaAlias: string, value: unknown): Promise<{ type: Hash; value: unknown }> ``` 从别名解析 schema hash,返回 `{ type, value }`。 ### 关键约束 - **bootstrap() 返回的别名表要包含所有新增的 @output/* 别名** - **现有测试中检查 bootstrap 返回值的,需要更新期望**(schema 数量从 6 变成 24) - **不改任何命令的输出格式**(那是 Phase 2-4 的事) ### Verification - `bun test` 通过(更新 bootstrap 相关测试的期望值) - `bun run build` 通过 - bootstrap 后 store 能查到所有 @output/* schema - 每个 @output/* 都有对应的 template - wrapEnvelope("@output/put", "XXXXX") 返回正确信封
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#75