mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
refactor(core): tighten pty, plugin, question, and snapshot types and checks (#57889)
This commit is contained in:
committed by
GitHub
Unverified
parent
a7a508b898
commit
2e5a4deea8
@@ -260,7 +260,7 @@ const layer = Layer.effect(
|
||||
// `plugin` is the requested definition; `activation` is its last activation, which may have
|
||||
// failed or be an older fallback while the requested revision keeps failing setup.
|
||||
type Slot = {
|
||||
readonly plugin: Generation
|
||||
readonly plugin: Generation & { readonly id: Plugin.ID }
|
||||
readonly activation?: Activation
|
||||
readonly error?: string
|
||||
}
|
||||
@@ -285,7 +285,7 @@ type PendingFailure = {
|
||||
function slotInfo(slot: Slot): Plugin.Info {
|
||||
const failure = slot.activation?.failure ?? (slot.error === undefined ? undefined : { error: slot.error })
|
||||
return {
|
||||
id: Plugin.ID.make(slot.plugin.id),
|
||||
id: slot.plugin.id,
|
||||
source: slot.plugin.source ?? { type: "builtin" },
|
||||
state: failure === undefined ? { status: "active" } : { status: "failed", ...failure },
|
||||
features: { server: true, ...slot.plugin.features },
|
||||
|
||||
@@ -42,11 +42,11 @@ export type Info = Types.DeepMutable<typeof Info.Type>
|
||||
|
||||
export const CreateInput = Pty.CreateInput
|
||||
|
||||
export type CreateInput = Types.DeepMutable<typeof CreateInput.Type>
|
||||
export type CreateInput = typeof CreateInput.Type
|
||||
|
||||
export const UpdateInput = Pty.UpdateInput
|
||||
|
||||
export type UpdateInput = Types.DeepMutable<typeof UpdateInput.Type>
|
||||
export type UpdateInput = typeof UpdateInput.Type
|
||||
|
||||
export { Event } from "@opencode/schema/pty"
|
||||
|
||||
@@ -275,7 +275,7 @@ const layer = Layer.effect(
|
||||
const from =
|
||||
input.cursor === -1
|
||||
? end
|
||||
: typeof input.cursor === "number" && Number.isSafeInteger(input.cursor)
|
||||
: input.cursor !== undefined && Number.isSafeInteger(input.cursor)
|
||||
? Math.max(0, input.cursor)
|
||||
: 0
|
||||
const replay = (() => {
|
||||
|
||||
@@ -168,6 +168,7 @@ const layer = Layer.effect(
|
||||
const changed = yield* git.tree
|
||||
.files({ repository: compared.repository, from: compared.from, to: compared.to })
|
||||
.pipe(Effect.mapError((cause) => failure("files", cause)))
|
||||
if (changed.length === 0) return []
|
||||
const skipped = yield* ignored("files", compared.source, changed)
|
||||
return changed.filter((file) => !skipped.has(file))
|
||||
})
|
||||
@@ -185,12 +186,10 @@ const layer = Layer.effect(
|
||||
paths: input.paths,
|
||||
})
|
||||
.pipe(Effect.mapError((cause) => failure("diff", cause)))
|
||||
const skipped = yield* ignored(
|
||||
"diff",
|
||||
compared.source,
|
||||
diffs.map((file) => RelativePath.make(file.file)),
|
||||
)
|
||||
return diffs.filter((file) => !skipped.has(RelativePath.make(file.file)))
|
||||
if (diffs.length === 0) return []
|
||||
const paths = diffs.map((file) => RelativePath.make(file.file))
|
||||
const skipped = yield* ignored("diff", compared.source, paths)
|
||||
return diffs.filter((_, index) => !skipped.has(paths[index]!))
|
||||
})
|
||||
|
||||
const plan = Effect.fnUntraced(function* (worktree: AbsolutePath, input: RestoreInput) {
|
||||
|
||||
@@ -99,7 +99,7 @@ export const Plugin = {
|
||||
answers: input.questions.map((_, index): Question.Answer => {
|
||||
const value = state.answer[`q${index}`]
|
||||
if (value === undefined) return []
|
||||
if (typeof value === "object") return Array.from(value)
|
||||
if (Array.isArray(value)) return Array.from(value)
|
||||
return [String(value)]
|
||||
}),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user