mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-24 06:45:22 +00:00
fix(id): restore original prefixes for permission, question, and tool IDs
The branded-remaining-ids PR changed these prefixes from their original values (per, que, tool) to shortened versions (prm, qst, tol). This would break validation of any existing IDs already persisted in the database, since the Zod .startsWith() validators would reject them.
This commit is contained in:
@@ -5,12 +5,12 @@ export namespace Identifier {
|
||||
const prefixes = {
|
||||
session: "ses",
|
||||
message: "msg",
|
||||
permission: "prm",
|
||||
question: "qst",
|
||||
permission: "per",
|
||||
question: "que",
|
||||
user: "usr",
|
||||
part: "prt",
|
||||
pty: "pty",
|
||||
tool: "tol",
|
||||
tool: "tool",
|
||||
workspace: "wrk",
|
||||
} as const
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ export const PermissionID = permissionIdSchema.pipe(
|
||||
withStatics((schema: typeof permissionIdSchema) => ({
|
||||
make: (id: string) => schema.makeUnsafe(id),
|
||||
ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("permission", id)),
|
||||
zod: z.string().startsWith("prm").pipe(z.custom<PermissionID>()),
|
||||
zod: z.string().startsWith("per").pipe(z.custom<PermissionID>()),
|
||||
})),
|
||||
)
|
||||
|
||||
@@ -12,6 +12,6 @@ export const QuestionID = questionIdSchema.pipe(
|
||||
withStatics((schema: typeof questionIdSchema) => ({
|
||||
make: (id: string) => schema.makeUnsafe(id),
|
||||
ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("question", id)),
|
||||
zod: z.string().startsWith("qst").pipe(z.custom<QuestionID>()),
|
||||
zod: z.string().startsWith("que").pipe(z.custom<QuestionID>()),
|
||||
})),
|
||||
)
|
||||
|
||||
@@ -12,6 +12,6 @@ export const ToolID = toolIdSchema.pipe(
|
||||
withStatics((schema: typeof toolIdSchema) => ({
|
||||
make: (id: string) => schema.makeUnsafe(id),
|
||||
ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("tool", id)),
|
||||
zod: z.string().startsWith("tol").pipe(z.custom<ToolID>()),
|
||||
zod: z.string().startsWith("tool").pipe(z.custom<ToolID>()),
|
||||
})),
|
||||
)
|
||||
|
||||
@@ -87,7 +87,7 @@ describe("Truncate", () => {
|
||||
expect(result.content).toContain("Grep")
|
||||
if (!result.truncated) throw new Error("expected truncated")
|
||||
expect(result.outputPath).toBeDefined()
|
||||
expect(result.outputPath).toContain("tol_")
|
||||
expect(result.outputPath).toContain("tool_")
|
||||
|
||||
const written = await Filesystem.readText(result.outputPath!)
|
||||
expect(written).toBe(lines)
|
||||
|
||||
Reference in New Issue
Block a user