mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-03 07:33:45 +00:00
Refactor application path handling and data storage architecture
Replace simple directory-based path system with git-aware data management that uses global data directories and proper workspace detection. 🤖 Generated with opencode Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
18
packages/opencode/src/util/filesystem.ts
Normal file
18
packages/opencode/src/util/filesystem.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { exists } from "fs/promises"
|
||||
import { dirname, join } from "path"
|
||||
|
||||
export namespace Filesystem {
|
||||
export async function findUp(target: string, start: string) {
|
||||
let currentDir = start
|
||||
while (true) {
|
||||
const targetPath = join(currentDir, target)
|
||||
if (await exists(targetPath)) return targetPath
|
||||
const parentDir = dirname(currentDir)
|
||||
if (parentDir === currentDir) {
|
||||
return
|
||||
}
|
||||
currentDir = parentDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import path from "path"
|
||||
import { AppPath } from "../app/path"
|
||||
import fs from "fs/promises"
|
||||
export namespace Log {
|
||||
const write = {
|
||||
@@ -12,8 +11,9 @@ export namespace Log {
|
||||
}
|
||||
|
||||
export async function file(directory: string) {
|
||||
const outPath = path.join(AppPath.data(directory), "opencode.out.log")
|
||||
const errPath = path.join(AppPath.data(directory), "opencode.err.log")
|
||||
await fs.mkdir(directory, { recursive: true })
|
||||
const outPath = path.join(directory, "opencode.out.log")
|
||||
const errPath = path.join(directory, "opencode.err.log")
|
||||
await fs.truncate(outPath).catch(() => {})
|
||||
await fs.truncate(errPath).catch(() => {})
|
||||
const out = Bun.file(outPath)
|
||||
|
||||
Reference in New Issue
Block a user