sync
This commit is contained in:
@@ -161,10 +161,9 @@ export namespace Session {
|
||||
)
|
||||
|
||||
export async function create(parentID?: string) {
|
||||
const app = App.info()
|
||||
return createNext({
|
||||
parentID,
|
||||
directory: app.path.cwd,
|
||||
directory: Paths.directory,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -443,7 +442,6 @@ export namespace Session {
|
||||
},
|
||||
}
|
||||
|
||||
const app = App.info()
|
||||
const userParts = await Promise.all(
|
||||
input.parts.map(async (part): Promise<MessageV2.Part[]> => {
|
||||
if (part.type === "file") {
|
||||
@@ -714,8 +712,8 @@ export namespace Session {
|
||||
system,
|
||||
mode: inputMode,
|
||||
path: {
|
||||
cwd: app.path.cwd,
|
||||
root: app.path.root,
|
||||
cwd: Paths.directory,
|
||||
root: Paths.worktree,
|
||||
},
|
||||
cost: 0,
|
||||
tokens: {
|
||||
@@ -869,8 +867,8 @@ export namespace Session {
|
||||
role: "assistant",
|
||||
system,
|
||||
path: {
|
||||
cwd: app.path.cwd,
|
||||
root: app.path.root,
|
||||
cwd: Paths.directory,
|
||||
root: Paths.worktree,
|
||||
},
|
||||
cost: 0,
|
||||
tokens: {
|
||||
@@ -1266,7 +1264,6 @@ export namespace Session {
|
||||
const lastSummary = msgs.findLast((msg) => msg.info.role === "assistant" && msg.info.summary === true)
|
||||
const filtered = msgs.filter((msg) => !lastSummary || msg.info.id >= lastSummary.info.id)
|
||||
const model = await Provider.getModel(input.providerID, input.modelID)
|
||||
const app = App.info()
|
||||
const system = [
|
||||
...SystemPrompt.summarize(input.providerID),
|
||||
...(await SystemPrompt.environment()),
|
||||
@@ -1280,8 +1277,8 @@ export namespace Session {
|
||||
system,
|
||||
mode: "build",
|
||||
path: {
|
||||
cwd: app.path.cwd,
|
||||
root: app.path.root,
|
||||
cwd: Paths.directory,
|
||||
root: Paths.worktree,
|
||||
},
|
||||
summary: true,
|
||||
cost: 0,
|
||||
@@ -1395,7 +1392,6 @@ export namespace Session {
|
||||
providerID: string
|
||||
messageID: string
|
||||
}) {
|
||||
const app = App.info()
|
||||
await Session.chat({
|
||||
sessionID: input.sessionID,
|
||||
messageID: input.messageID,
|
||||
@@ -1405,10 +1401,10 @@ export namespace Session {
|
||||
{
|
||||
id: Identifier.ascending("part"),
|
||||
type: "text",
|
||||
text: PROMPT_INITIALIZE.replace("${path}", app.path.root),
|
||||
text: PROMPT_INITIALIZE.replace("${path}", Paths.worktree),
|
||||
},
|
||||
],
|
||||
})
|
||||
await App.initialize()
|
||||
await Project.setInitialized()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { App } from "../app/app"
|
||||
import { Ripgrep } from "../file/ripgrep"
|
||||
import { Global } from "../global"
|
||||
import { Filesystem } from "../util/filesystem"
|
||||
@@ -13,6 +12,8 @@ import PROMPT_GEMINI from "./prompt/gemini.txt"
|
||||
import PROMPT_ANTHROPIC_SPOOF from "./prompt/anthropic_spoof.txt"
|
||||
import PROMPT_SUMMARIZE from "./prompt/summarize.txt"
|
||||
import PROMPT_TITLE from "./prompt/title.txt"
|
||||
import { Project } from "../project/project"
|
||||
import { Paths } from "../project/path"
|
||||
|
||||
export namespace SystemPrompt {
|
||||
export function header(providerID: string) {
|
||||
@@ -27,21 +28,21 @@ export namespace SystemPrompt {
|
||||
}
|
||||
|
||||
export async function environment() {
|
||||
const app = App.info()
|
||||
const project = Project.use()
|
||||
return [
|
||||
[
|
||||
`Here is some useful information about the environment you are running in:`,
|
||||
`<env>`,
|
||||
` Working directory: ${app.path.cwd}`,
|
||||
` Is directory a git repo: ${app.git ? "yes" : "no"}`,
|
||||
` Working directory: ${Paths.directory}`,
|
||||
` Is directory a git repo: ${project.vcs === "git" ? "yes" : "no"}`,
|
||||
` Platform: ${process.platform}`,
|
||||
` Today's date: ${new Date().toDateString()}`,
|
||||
`</env>`,
|
||||
`<project>`,
|
||||
` ${
|
||||
app.git
|
||||
project.vcs === "git"
|
||||
? await Ripgrep.tree({
|
||||
cwd: app.path.cwd,
|
||||
cwd: Paths.directory,
|
||||
limit: 200,
|
||||
})
|
||||
: ""
|
||||
@@ -58,12 +59,11 @@ export namespace SystemPrompt {
|
||||
]
|
||||
|
||||
export async function custom() {
|
||||
const { cwd, root } = App.info().path
|
||||
const config = await Config.get()
|
||||
const paths = new Set<string>()
|
||||
|
||||
for (const item of CUSTOM_FILES) {
|
||||
const matches = await Filesystem.findUp(item, cwd, root)
|
||||
const matches = await Filesystem.findUp(item, Paths.directory, Paths.worktree)
|
||||
matches.forEach((path) => paths.add(path))
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export namespace SystemPrompt {
|
||||
|
||||
if (config.instructions) {
|
||||
for (const instruction of config.instructions) {
|
||||
const matches = await Filesystem.globUp(instruction, cwd, root).catch(() => [])
|
||||
const matches = await Filesystem.globUp(instruction, Paths.directory, Paths.worktree).catch(() => [])
|
||||
matches.forEach((path) => paths.add(path))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user