mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
refactor(schema): remove unused QuestionV1 contract (#52838)
This commit is contained in:
committed by
GitHub
Unverified
parent
0bef0eab67
commit
9277761af6
@@ -1 +0,0 @@
|
||||
export * from "./v1/question.js"
|
||||
@@ -1,66 +0,0 @@
|
||||
export * as QuestionV1 from "./question.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { ephemeral, inventory } from "../event.js"
|
||||
import { ascending } from "../identifier.js"
|
||||
import { statics } from "../schema.js"
|
||||
import { SessionID } from "../session-id.js"
|
||||
import { SessionV1 } from "./session.js"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
||||
Schema.brand("QuestionV1.ID"),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "que_" + ascending()) })),
|
||||
)
|
||||
|
||||
export const Option = Schema.Struct({
|
||||
label: Schema.String.annotate({ description: "Display text (1-5 words, concise)" }),
|
||||
description: Schema.String.annotate({ description: "Explanation of choice" }),
|
||||
}).annotate({ identifier: "QuestionV1.Option" })
|
||||
|
||||
const base = {
|
||||
question: Schema.String.annotate({ description: "Complete question" }),
|
||||
header: Schema.String.annotate({ description: "Very short label (max 30 chars)" }),
|
||||
options: Schema.Array(Option).annotate({ description: "Available choices" }),
|
||||
multiple: Schema.optional(Schema.Boolean).annotate({ description: "Allow selecting multiple choices" }),
|
||||
}
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
...base,
|
||||
custom: Schema.optional(Schema.Boolean).annotate({ description: "Allow typing a custom answer (default: true)" }),
|
||||
}).annotate({ identifier: "QuestionV1.Info" })
|
||||
export const Prompt = Schema.Struct(base).annotate({ identifier: "QuestionV1.Prompt" })
|
||||
export const Tool = Schema.Struct({ messageID: SessionV1.MessageID, callID: Schema.String }).annotate({
|
||||
identifier: "QuestionV1.Tool",
|
||||
})
|
||||
export const Request = Schema.Struct({
|
||||
id: ID,
|
||||
sessionID: SessionID,
|
||||
questions: Schema.Array(Info).annotate({ description: "Questions to ask" }),
|
||||
tool: Schema.optional(Tool),
|
||||
}).annotate({ identifier: "QuestionV1.Request" })
|
||||
export const Answer = Schema.Array(Schema.String).annotate({ identifier: "QuestionV1.Answer" })
|
||||
export const Reply = Schema.Struct({
|
||||
answers: Schema.Array(Answer).annotate({
|
||||
description: "User answers in order of questions (each answer is an array of selected labels)",
|
||||
}),
|
||||
}).annotate({ identifier: "QuestionV1.Reply" })
|
||||
export const Replied = Schema.Struct({
|
||||
sessionID: SessionID,
|
||||
requestID: ID,
|
||||
answers: Schema.Array(Answer),
|
||||
}).annotate({
|
||||
identifier: "QuestionV1.Replied",
|
||||
})
|
||||
export const Rejected = Schema.Struct({ sessionID: SessionID, requestID: ID }).annotate({
|
||||
identifier: "QuestionV1.Rejected",
|
||||
})
|
||||
|
||||
const Asked = ephemeral({ type: "question.asked", schema: Request.fields })
|
||||
const RepliedEvent = ephemeral({ type: "question.replied", schema: Replied.fields })
|
||||
const RejectedEvent = ephemeral({ type: "question.rejected", schema: Rejected.fields })
|
||||
export const Event = {
|
||||
Asked,
|
||||
Replied: RepliedEvent,
|
||||
Rejected: RejectedEvent,
|
||||
Definitions: inventory(Asked, RepliedEvent, RejectedEvent),
|
||||
}
|
||||
@@ -42,9 +42,6 @@ describe("public event manifest", () => {
|
||||
expect(EventManifest.Server.get("session.deleted")).toBe(SessionEvent.Deleted)
|
||||
expect(EventManifest.Server.get("project.updated")).toBe(Project.Event.Updated)
|
||||
expect(EventManifest.Server.has("mcp.tools.changed")).toBe(false)
|
||||
expect(EventManifest.Server.has("question.asked")).toBe(false)
|
||||
expect(EventManifest.Server.has("question.replied")).toBe(false)
|
||||
expect(EventManifest.Server.has("question.rejected")).toBe(false)
|
||||
expect(Agent.Event.Updated.durable).toBeUndefined()
|
||||
expect(EventManifest.Durable.has("agent.updated")).toBe(false)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { LegacyEventV1 } from "../src/legacy-event.js"
|
||||
import { PermissionV1 } from "../src/permission-v1.js"
|
||||
import { QuestionV1 } from "../src/question-v1.js"
|
||||
import { Project } from "../src/project.js"
|
||||
import { SessionV1 } from "../src/session-v1.js"
|
||||
|
||||
@@ -32,9 +31,6 @@ describe("legacy public event schemas", () => {
|
||||
SessionV1.Error.type,
|
||||
PermissionV1.Event.Asked.type,
|
||||
PermissionV1.Event.Replied.type,
|
||||
QuestionV1.Event.Asked.type,
|
||||
QuestionV1.Event.Replied.type,
|
||||
QuestionV1.Event.Rejected.type,
|
||||
Project.Event.Updated.type,
|
||||
LegacyEventV1.CommandExecuted.type,
|
||||
]).toEqual([
|
||||
@@ -43,9 +39,6 @@ describe("legacy public event schemas", () => {
|
||||
"session.error",
|
||||
"permission.asked",
|
||||
"permission.replied",
|
||||
"question.asked",
|
||||
"question.replied",
|
||||
"question.rejected",
|
||||
"project.updated",
|
||||
"command.executed",
|
||||
])
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { LegacyEventV1 } from "../src/legacy-event.js"
|
||||
import { PermissionV1 } from "../src/permission-v1.js"
|
||||
import { QuestionV1 } from "../src/question-v1.js"
|
||||
import { SessionV1 } from "../src/session-v1.js"
|
||||
const isolatedLegacyEvent = await import("../src/v1/legacy-event.js")
|
||||
const isolatedPermission = await import("../src/v1/permission.js")
|
||||
const isolatedQuestion = await import("../src/v1/question.js")
|
||||
const isolatedSession = await import("../src/v1/session.js")
|
||||
|
||||
test("compatibility entrypoints preserve isolated V1 schema identity", () => {
|
||||
expect(LegacyEventV1).toBe(isolatedLegacyEvent.LegacyEventV1)
|
||||
expect(PermissionV1).toBe(isolatedPermission.PermissionV1)
|
||||
expect(QuestionV1).toBe(isolatedQuestion.QuestionV1)
|
||||
expect(SessionV1).toBe(isolatedSession.SessionV1)
|
||||
})
|
||||
|
||||
@@ -20,7 +17,6 @@ test("current source does not import the V1 subtree directly", async () => {
|
||||
"filesystem-v1.ts",
|
||||
"legacy-event.ts",
|
||||
"permission-v1.ts",
|
||||
"question-v1.ts",
|
||||
"session-v1.ts",
|
||||
])
|
||||
const files = [...new Bun.Glob("*.ts").scanSync(new URL("../src", import.meta.url).pathname)].filter(
|
||||
|
||||
Reference in New Issue
Block a user