mirror of
https://github.com/sst/opencode.git
synced 2025-07-08 00:25:00 +00:00
refactor: centralize todo status and priority enums
This commit is contained in:
parent
8c4b5e088b
commit
53b70ad94e
2 changed files with 18 additions and 11 deletions
|
@ -2,18 +2,8 @@ import { z } from "zod"
|
||||||
import { Tool } from "./tool"
|
import { Tool } from "./tool"
|
||||||
import DESCRIPTION_WRITE from "./todowrite.txt"
|
import DESCRIPTION_WRITE from "./todowrite.txt"
|
||||||
import { App } from "../app/app"
|
import { App } from "../app/app"
|
||||||
|
import { TodoInfo } from "../util/schema"
|
||||||
|
|
||||||
const TodoInfo = z.object({
|
|
||||||
content: z.string().min(1).describe("Brief description of the task"),
|
|
||||||
status: z
|
|
||||||
.enum(["pending", "in_progress", "completed"])
|
|
||||||
.describe("Current status of the task"),
|
|
||||||
priority: z
|
|
||||||
.enum(["high", "medium", "low"])
|
|
||||||
.describe("Priority level of the task"),
|
|
||||||
id: z.string().describe("Unique identifier for the todo item"),
|
|
||||||
})
|
|
||||||
type TodoInfo = z.infer<typeof TodoInfo>
|
|
||||||
|
|
||||||
const state = App.state("todo-tool", () => {
|
const state = App.state("todo-tool", () => {
|
||||||
const todos: {
|
const todos: {
|
||||||
|
|
17
packages/opencode/src/util/schema.ts
Normal file
17
packages/opencode/src/util/schema.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
// Enum status
|
||||||
|
export const StatusEnum = z.enum(["pending", "in_progress", "completed"])
|
||||||
|
// Enum priority
|
||||||
|
export const PriorityEnum = z.enum(["high", "medium", "low"])
|
||||||
|
|
||||||
|
// Schema for todo info
|
||||||
|
export const TodoInfo = z.object({
|
||||||
|
content: z.string().min(1).describe("Brief description of the task"),
|
||||||
|
status: StatusEnum.describe("Current status of the task"),
|
||||||
|
priority: PriorityEnum.describe("Priority level of the task"),
|
||||||
|
id: z.string().describe("Unique identifier for the todo item"),
|
||||||
|
})
|
||||||
|
export type StatusEnum = z.infer<typeof StatusEnum>
|
||||||
|
export type PriorityEnum = z.infer<typeof PriorityEnum>
|
||||||
|
export type TodoInfo = z.infer<typeof TodoInfo>
|
Loading…
Add table
Add a link
Reference in a new issue