Files
stanp-opencode/src/config.ts
T
StanPonomarev 80728e7d75
CI / verify (pull_request) Successful in 9s
feat: better config
2026-09-19 13:12:03 +02:00

76 lines
2.4 KiB
TypeScript

import { z } from "zod";
export const workerNames = [
"fast-lo",
"fast-hi",
"good-lo",
"good-hi",
"deep-lo",
"deep-hi",
] as const;
const gptAssignment = z.strictObject({
model: z.string().trim().min(1),
effort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]),
});
const customAssignment = gptAssignment.extend({
model: z
.string()
.trim()
.refine((model) => {
const slash = model.indexOf("/");
return slash > 0 && slash < model.length - 1;
}, "model must use the provider/model convention"),
});
const common = {
playwright: z.boolean().default(false),
};
export const settings = z.discriminatedUnion("mode", [
z
.strictObject({
...common,
mode: z.literal("gpt"),
provider: z.string().trim().min(1).default("openai"),
lunaPriority: z.boolean().optional(),
})
.transform((value, context) => {
if (value.provider !== "openai" && value.lunaPriority !== undefined) {
context.addIssue({
code: "custom",
path: ["lunaPriority"],
message: "lunaPriority is only supported by the openai provider",
});
return z.NEVER;
}
return value.provider === "openai"
? { ...value, lunaPriority: value.lunaPriority ?? true }
: value;
}),
z.strictObject({
...common,
mode: z.literal("custom"),
agents: z.strictObject({
"fast-lo": customAssignment,
"fast-hi": customAssignment,
"good-lo": customAssignment,
"good-hi": customAssignment,
"deep-lo": customAssignment,
"deep-hi": customAssignment,
// Deprecated compatibility field. Coordinate is derived from deep-lo/good-lo.
coordinate: customAssignment.optional(),
}),
}),
]);
export const gptAgents = {
"fast-lo": { model: "gpt-5.6-luna", effort: "low" },
"fast-hi": { model: "gpt-5.6-luna", effort: "high" },
"good-lo": { model: "gpt-5.6-sol", effort: "low" },
"good-hi": { model: "gpt-5.6-sol", effort: "high" },
"deep-lo": { model: "gpt-6-astra", effort: "low" },
"deep-hi": { model: "gpt-6-astra", effort: "high" },
} satisfies Record<(typeof workerNames)[number], z.infer<typeof gptAssignment>>;