refactor: migrate src/session/instruction.ts from Bun.file() to Filesystem module (#14130)
This commit is contained in:
@@ -85,7 +85,7 @@ export namespace InstructionPrompt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const file of globalFiles()) {
|
for (const file of globalFiles()) {
|
||||||
if (await Bun.file(file).exists()) {
|
if (await Filesystem.exists(file)) {
|
||||||
paths.add(path.resolve(file))
|
paths.add(path.resolve(file))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -120,9 +120,7 @@ export namespace InstructionPrompt {
|
|||||||
const paths = await systemPaths()
|
const paths = await systemPaths()
|
||||||
|
|
||||||
const files = Array.from(paths).map(async (p) => {
|
const files = Array.from(paths).map(async (p) => {
|
||||||
const content = await Bun.file(p)
|
const content = await Filesystem.readText(p).catch(() => "")
|
||||||
.text()
|
|
||||||
.catch(() => "")
|
|
||||||
return content ? "Instructions from: " + p + "\n" + content : ""
|
return content ? "Instructions from: " + p + "\n" + content : ""
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -164,7 +162,7 @@ export namespace InstructionPrompt {
|
|||||||
export async function find(dir: string) {
|
export async function find(dir: string) {
|
||||||
for (const file of FILES) {
|
for (const file of FILES) {
|
||||||
const filepath = path.resolve(path.join(dir, file))
|
const filepath = path.resolve(path.join(dir, file))
|
||||||
if (await Bun.file(filepath).exists()) return filepath
|
if (await Filesystem.exists(filepath)) return filepath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +180,7 @@ export namespace InstructionPrompt {
|
|||||||
|
|
||||||
if (found && found !== target && !system.has(found) && !already.has(found) && !isClaimed(messageID, found)) {
|
if (found && found !== target && !system.has(found) && !already.has(found) && !isClaimed(messageID, found)) {
|
||||||
claim(messageID, found)
|
claim(messageID, found)
|
||||||
const content = await Bun.file(found)
|
const content = await Filesystem.readText(found).catch(() => undefined)
|
||||||
.text()
|
|
||||||
.catch(() => undefined)
|
|
||||||
if (content) {
|
if (content) {
|
||||||
results.push({ filepath: found, content: "Instructions from: " + found + "\n" + content })
|
results.push({ filepath: found, content: "Instructions from: " + found + "\n" + content })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user