mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
fix(sdk): stabilize generated event ordering
This commit is contained in:
@@ -17,8 +17,11 @@ export function define<Type extends string, Properties extends Schema.Top>(
|
||||
}
|
||||
|
||||
export function effectPayloads() {
|
||||
// kilocode_change start - keep generated schemas stable across module evaluation orders
|
||||
return registry
|
||||
.entries()
|
||||
.toArray()
|
||||
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
||||
.map(([type, def]) =>
|
||||
Schema.Struct({
|
||||
id: Schema.String,
|
||||
@@ -26,7 +29,7 @@ export function effectPayloads() {
|
||||
properties: def.properties,
|
||||
}).annotate({ identifier: `Event.${type}` }),
|
||||
)
|
||||
.toArray()
|
||||
// kilocode_change end
|
||||
}
|
||||
|
||||
export * as BusEvent from "./bus-event"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { Schema, SchemaAST } from "effect"
|
||||
import { BusEvent } from "../../../src/bus/bus-event"
|
||||
|
||||
test("event payload schemas use stable event type order", () => {
|
||||
BusEvent.define("test.order.z", Schema.Struct({}))
|
||||
BusEvent.define("test.order.a", Schema.Struct({}))
|
||||
|
||||
const ids = BusEvent.effectPayloads()
|
||||
.map((schema) => SchemaAST.resolveIdentifier(schema.ast))
|
||||
.filter((id) => id?.startsWith("Event.test.order."))
|
||||
|
||||
expect(ids).toEqual(["Event.test.order.a", "Event.test.order.z"])
|
||||
})
|
||||
@@ -9,14 +9,6 @@ import path from "path"
|
||||
|
||||
import { createClient } from "@hey-api/openapi-ts"
|
||||
|
||||
// kilocode_change start - prevent runtime-dependent generated SDK ordering
|
||||
const pkg = await Bun.file(path.resolve(dir, "../../../package.json")).json()
|
||||
const manager = pkg.packageManager ?? ""
|
||||
const version = manager.startsWith("bun@") ? manager.slice(4) : ""
|
||||
if (!version) throw new Error("Root packageManager must specify bun@<version>")
|
||||
if (Bun.version !== version) throw new Error(`SDK generation requires Bun ${version}, but is running Bun ${Bun.version}`)
|
||||
// kilocode_change end
|
||||
|
||||
const opencode = path.resolve(dir, "../../opencode")
|
||||
|
||||
await $`bun dev generate > ${dir}/openapi.json`.cwd(opencode)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+2624
-2624
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user