fix plan mode when not in git worktree
This commit is contained in:
@@ -13,6 +13,8 @@ import PROMPT_SUMMARY from "./prompt/summary.txt"
|
|||||||
import PROMPT_TITLE from "./prompt/title.txt"
|
import PROMPT_TITLE from "./prompt/title.txt"
|
||||||
import { PermissionNext } from "@/permission/next"
|
import { PermissionNext } from "@/permission/next"
|
||||||
import { mergeDeep, pipe, sortBy, values } from "remeda"
|
import { mergeDeep, pipe, sortBy, values } from "remeda"
|
||||||
|
import { Global } from "@/global"
|
||||||
|
import path from "path"
|
||||||
|
|
||||||
export namespace Agent {
|
export namespace Agent {
|
||||||
export const Info = z
|
export const Info = z
|
||||||
@@ -88,9 +90,13 @@ export namespace Agent {
|
|||||||
PermissionNext.fromConfig({
|
PermissionNext.fromConfig({
|
||||||
question: "allow",
|
question: "allow",
|
||||||
plan_exit: "allow",
|
plan_exit: "allow",
|
||||||
|
external_directory: {
|
||||||
|
[path.join(Global.Path.data, "plans", "*")]: "allow",
|
||||||
|
},
|
||||||
edit: {
|
edit: {
|
||||||
"*": "deny",
|
"*": "deny",
|
||||||
".opencode/plans/*.md": "allow",
|
".opencode/plans/*.md": "allow",
|
||||||
|
[path.relative(Instance.worktree, path.join(Global.Path.data, "plans/*.md"))]: "allow",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
user,
|
user,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { Snapshot } from "@/snapshot"
|
|||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider/provider"
|
||||||
import { PermissionNext } from "@/permission/next"
|
import { PermissionNext } from "@/permission/next"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { Global } from "@/global"
|
||||||
|
|
||||||
export namespace Session {
|
export namespace Session {
|
||||||
const log = Log.create({ service: "session" })
|
const log = Log.create({ service: "session" })
|
||||||
@@ -233,7 +234,10 @@ export namespace Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function plan(input: { slug: string; time: { created: number } }) {
|
export function plan(input: { slug: string; time: { created: number } }) {
|
||||||
return path.join(Instance.worktree, ".opencode", "plans", [input.time.created, input.slug].join("-") + ".md")
|
const base = Instance.project.vcs
|
||||||
|
? path.join(Instance.worktree, ".opencode", "plans")
|
||||||
|
: path.join(Global.Path.data, "plans")
|
||||||
|
return path.join(base, [input.time.created, input.slug].join("-") + ".md")
|
||||||
}
|
}
|
||||||
|
|
||||||
export const get = fn(Identifier.schema("session"), async (id) => {
|
export const get = fn(Identifier.schema("session"), async (id) => {
|
||||||
|
|||||||
@@ -1229,11 +1229,13 @@ export namespace SessionPrompt {
|
|||||||
messageID: userMessage.info.id,
|
messageID: userMessage.info.id,
|
||||||
sessionID: userMessage.info.sessionID,
|
sessionID: userMessage.info.sessionID,
|
||||||
type: "text",
|
type: "text",
|
||||||
text: BUILD_SWITCH.replace("{{plan}}", plan),
|
text:
|
||||||
|
BUILD_SWITCH + "\n\n" + `A plan file exists at ${plan}. You should execute on the plan defined within it`,
|
||||||
synthetic: true,
|
synthetic: true,
|
||||||
})
|
})
|
||||||
userMessage.parts.push(part)
|
userMessage.parts.push(part)
|
||||||
}
|
}
|
||||||
|
return input.messages
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entering plan mode
|
// Entering plan mode
|
||||||
|
|||||||
@@ -2,6 +2,4 @@
|
|||||||
Your operational mode has changed from plan to build.
|
Your operational mode has changed from plan to build.
|
||||||
You are no longer in read-only mode.
|
You are no longer in read-only mode.
|
||||||
You are permitted to make file changes, run shell commands, and utilize your arsenal of tools as needed.
|
You are permitted to make file changes, run shell commands, and utilize your arsenal of tools as needed.
|
||||||
|
|
||||||
A plan file exists at {{plan}}. You should read this file and execute on the plan defined within it.
|
|
||||||
</system-reminder>
|
</system-reminder>
|
||||||
|
|||||||
Reference in New Issue
Block a user