Dax Raad 8 месяцев назад
Родитель
Сommit
a5a39dada7
2 измененных файлов с 18 добавлено и 0 удалено
  1. 2 0
      packages/opencode/src/app/app.ts
  2. 16 0
      packages/opencode/src/session/session.ts

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

@@ -13,6 +13,7 @@ export namespace App {
       time: z.object({
       time: z.object({
         initialized: z.number().optional(),
         initialized: z.number().optional(),
       }),
       }),
+      git: z.boolean(),
       path: z.object({
       path: z.object({
         data: z.string(),
         data: z.string(),
         root: z.string(),
         root: z.string(),
@@ -58,6 +59,7 @@ export namespace App {
       time: {
       time: {
         initialized: state.initialized,
         initialized: state.initialized,
       },
       },
+      git: git !== undefined,
       path: {
       path: {
         data,
         data,
         root: git ?? input.cwd,
         root: git ?? input.cwd,

+ 16 - 0
packages/opencode/src/session/session.ts

@@ -25,6 +25,7 @@ import { Message } from "./message"
 import { Bus } from "../bus"
 import { Bus } from "../bus"
 import { Provider } from "../provider/provider"
 import { Provider } from "../provider/provider"
 import { SessionContext } from "./context"
 import { SessionContext } from "./context"
+import { ListTool } from "../tool/ls"
 
 
 export namespace Session {
 export namespace Session {
   const log = Log.create({ service: "session" })
   const log = Log.create({ service: "session" })
@@ -204,6 +205,7 @@ export namespace Session {
       )
       )
 
 
     if (msgs.length === 0) {
     if (msgs.length === 0) {
+      const app = App.info()
       const system: Message.Info = {
       const system: Message.Info = {
         id: Identifier.ascending("message"),
         id: Identifier.ascending("message"),
         role: "system",
         role: "system",
@@ -212,6 +214,20 @@ export namespace Session {
             type: "text",
             type: "text",
             text: PROMPT_ANTHROPIC,
             text: PROMPT_ANTHROPIC,
           },
           },
+          {
+            type: "text",
+            text: `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"}
+Platform: ${process.platform}
+Today's date: ${new Date().toISOString()}
+</env>
+<project>
+${await ListTool.execute({ path: app.path.cwd }, { sessionID: input.sessionID }).then((x) => x.output)}
+</project>
+            `,
+          },
         ],
         ],
         metadata: {
         metadata: {
           sessionID: input.sessionID,
           sessionID: input.sessionID,