Browse Source

feat: mode flag in cli run command

adamdottv 7 months ago
parent
commit
5dc1920a4c
2 changed files with 10 additions and 1 deletions
  1. 9 0
      packages/opencode/src/cli/cmd/run.ts
  2. 1 1
      packages/opencode/src/session/index.ts

+ 9 - 0
packages/opencode/src/cli/cmd/run.ts

@@ -8,6 +8,7 @@ import { Flag } from "../../flag/flag"
 import { Config } from "../../config/config"
 import { bootstrap } from "../bootstrap"
 import { MessageV2 } from "../../session/message-v2"
+import { Mode } from "../../session/mode"
 
 const TOOL: Record<string, [string, string]> = {
   todowrite: ["Todo", UI.Style.TEXT_WARNING_BOLD],
@@ -52,6 +53,10 @@ export const RunCommand = cmd({
         alias: ["m"],
         describe: "model to use in the format of provider/model",
       })
+      .option("mode", {
+        type: "string",
+        describe: "mode to use",
+      })
   },
   handler: async (args) => {
     let message = args.message.join(" ")
@@ -139,10 +144,14 @@ export const RunCommand = cmd({
         UI.error(err)
       })
 
+      // TODO: dax, should this impact model selection as well?
+      const mode = args.mode ? await Mode.get(args.mode) : await Mode.list().then((x) => x[0])
+
       const result = await Session.chat({
         sessionID: session.id,
         providerID,
         modelID,
+        mode: mode.name,
         parts: [
           {
             type: "text",

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

@@ -284,7 +284,7 @@ export namespace Session {
     sessionID: string
     providerID: string
     modelID: string
-    mode: string
+    mode?: string
     parts: MessageV2.UserPart[]
   }) {
     const l = log.clone().tag("session", input.sessionID)