Dax Raad 8 місяців тому
батько
коміт
60faa26a15

+ 5 - 0
packages/opencode/src/app/app.ts

@@ -33,9 +33,14 @@ export namespace App {
   const APP_JSON = "app.json"
   const APP_JSON = "app.json"
 
 
   async function create(input: { cwd: string; version: string }) {
   async function create(input: { cwd: string; version: string }) {
+    log.info("creating", {
+      cwd: input.cwd,
+      version: input.version,
+    })
     const git = await Filesystem.findUp(".git", input.cwd).then((x) =>
     const git = await Filesystem.findUp(".git", input.cwd).then((x) =>
       x ? path.dirname(x) : undefined,
       x ? path.dirname(x) : undefined,
     )
     )
+    log.info("git", { git })
 
 
     const data = path.join(
     const data = path.join(
       Global.Path.data,
       Global.Path.data,

+ 1 - 1
packages/opencode/src/index.ts

@@ -17,7 +17,7 @@ import { VERSION } from "./cli/version"
 import { ScrapCommand } from "./cli/cmd/scrap"
 import { ScrapCommand } from "./cli/cmd/scrap"
 import { Log } from "./util/log"
 import { Log } from "./util/log"
 
 
-await Log.init({ print: false })
+await Log.init({ print: process.argv.includes("--print-logs") })
 
 
 yargs(hideBin(process.argv))
 yargs(hideBin(process.argv))
   .scriptName("opencode")
   .scriptName("opencode")

+ 10 - 1
packages/opencode/src/util/log.ts

@@ -2,16 +2,24 @@ import path from "path"
 import fs from "fs/promises"
 import fs from "fs/promises"
 import { Global } from "../global"
 import { Global } from "../global"
 export namespace Log {
 export namespace Log {
+  const Default = create()
+
   export interface Options {
   export interface Options {
     print: boolean
     print: boolean
   }
   }
 
 
+  let logpath = ""
+
+  export function file() {
+    return logpath
+  }
+
   export async function init(options: Options) {
   export async function init(options: Options) {
     const dir = path.join(Global.Path.data, "log")
     const dir = path.join(Global.Path.data, "log")
     await fs.mkdir(dir, { recursive: true })
     await fs.mkdir(dir, { recursive: true })
     cleanup(dir)
     cleanup(dir)
     if (options.print) return
     if (options.print) return
-    const logpath = path.join(dir, new Date().toISOString() + ".log")
+    logpath = path.join(dir, new Date().toISOString().split(".")[0] + ".log")
     const logfile = Bun.file(logpath)
     const logfile = Bun.file(logpath)
     await fs.truncate(logpath).catch(() => {})
     await fs.truncate(logpath).catch(() => {})
     const writer = logfile.writer()
     const writer = logfile.writer()
@@ -20,6 +28,7 @@ export namespace Log {
       writer.flush()
       writer.flush()
       return true
       return true
     }
     }
+    Default.info("initialized", { file: logpath })
   }
   }
 
 
   async function cleanup(dir: string) {
   async function cleanup(dir: string) {