GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tweak: add model flag support for agent create command · bpd1069/opencode@ca599ab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/src
    • agent
      • agent.ts
    • cli/cmd
      • agent.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/agent/agent.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/agent/agent.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ export namespace Agent {
256256
return state().then((x) => Object.values(x))
257257
}
258258

259-
export async function generate(input: { description: string }) {
259+
export async function generate(input: { description: string; model?: { providerID: string; modelID: string } }) {
260260
const cfg = await Config.get()
261-
const defaultModel = await Provider.defaultModel()
261+
const defaultModel = input.model ?? (await Provider.defaultModel())
262262
const model = await Provider.getModel(defaultModel.providerID, defaultModel.modelID)
263263
const language = await Provider.getLanguage(model)
264264
const system = SystemPrompt.header(defaultModel.providerID)
Collapse file

‎packages/opencode/src/cli/cmd/agent.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/agent.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as prompts from "@clack/prompts"
33
import { UI } from "../ui"
44
import { Global } from "../../global"
55
import { Agent } from "../../agent/agent"
6+
import { Provider } from "../../provider/provider"
67
import path from "path"
78
import fs from "fs/promises"
89
import matter from "gray-matter"
@@ -47,6 +48,11 @@ const AgentCreateCommand = cmd({
4748
.option("tools", {
4849
type: "string",
4950
describe: `comma-separated list of tools to enable (default: all). Available: "${AVAILABLE_TOOLS.join(", ")}"`,
51+
})
52+
.option("model", {
53+
type: "string",
54+
alias: ["m"],
55+
describe: "model to use in the format of provider/model",
5056
}),
5157
async handler(args) {
5258
await Instance.provide({
@@ -114,7 +120,8 @@ const AgentCreateCommand = cmd({
114120
// Generate agent
115121
const spinner = prompts.spinner()
116122
spinner.start("Generating agent configuration...")
117-
const generated = await Agent.generate({ description }).catch((error) => {
123+
const model = args.model ? Provider.parseModel(args.model) : undefined
124+
const generated = await Agent.generate({ description, model }).catch((error) => {
118125
spinner.stop(`LLM failed to generate agent: ${error.message}`, 1)
119126
if (isFullyNonInteractive) process.exit(1)
120127
throw new UI.CancelledError()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.