feat: add plan mode with enter/exit tools (#8281)

This commit is contained in:
Dax
2026-01-13 15:55:48 -05:00
committed by GitHub
parent 66b7a4991e
commit 0a3c72d678
16 changed files with 824 additions and 46 deletions

View File

@@ -1,3 +1,5 @@
import { Slug } from "@opencode-ai/util/slug"
import pat from "path"
import { BusEvent } from "@/bus/bus-event"
import { Bus } from "@/bus"
import { Decimal } from "decimal.js"
@@ -19,6 +21,7 @@ import { Snapshot } from "@/snapshot"
import type { Provider } from "@/provider/provider"
import { PermissionNext } from "@/permission/next"
import path from "path"
export namespace Session {
const log = Log.create({ service: "session" })
@@ -39,6 +42,7 @@ export namespace Session {
export const Info = z
.object({
id: Identifier.schema("session"),
slug: z.string(),
projectID: z.string(),
directory: z.string(),
parentID: Identifier.schema("session").optional(),
@@ -194,6 +198,7 @@ export namespace Session {
}) {
const result: Info = {
id: Identifier.descending("session", input.id),
slug: Slug.create(),
version: Installation.VERSION,
projectID: Instance.project.id,
directory: input.directory,
@@ -227,6 +232,10 @@ export namespace Session {
return result
}
export function plan(input: { slug: string; time: { created: number } }) {
return path.join(Instance.worktree, ".opencode", "plans", [input.time.created, input.slug].join("-") + ".md")
}
export const get = fn(Identifier.schema("session"), async (id) => {
const read = await Storage.read<Info>(["session", Instance.project.id, id])
return read as Info