Skip to content

Commit 3d0c64d

Browse files
author
shihzu
committed
fix(auth): display schema and provider metadata in auth list (anomalyco#4533)
- Added reading of raw auth.json data to access metadata fields - Created new 'Configuration' section to display $schema and provider fields - Improved display formatting for object and string values - Fixed issue where metadata fields showed as 'undefined' Fixes anomalyco#4533
1 parent 48412f7 commit 3d0c64d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Instance } from "../../project/instance"
1313
import type { Hooks } from "@opencode-ai/plugin"
1414
import { Process } from "../../util/process"
1515
import { text } from "node:stream/consumers"
16+
import { Filesystem } from "../../util/filesystem"
1617

1718
type PluginAuth = NonNullable<Hooks["auth"]>
1819

@@ -211,6 +212,7 @@ export const AuthListCommand = cmd({
211212
const homedir = os.homedir()
212213
const displayPath = authPath.startsWith(homedir) ? authPath.replace(homedir, "~") : authPath
213214
prompts.intro(`Credentials ${UI.Style.TEXT_DIM}${displayPath}`)
215+
const rawAuthData = await Filesystem.readJson<Record<string, any>>(authPath).catch(() => ({}))
214216
const results = Object.entries(await Auth.all())
215217
const database = await ModelsDev.get()
216218

@@ -221,6 +223,25 @@ export const AuthListCommand = cmd({
221223

222224
prompts.outro(`${results.length} credentials`)
223225

226+
const metadataFields = ['$schema', 'provider']
227+
const hasMetadata = metadataFields.some(key => rawAuthData[key] !== undefined)
228+
229+
if (hasMetadata) {
230+
UI.empty()
231+
prompts.intro("Configuration")
232+
233+
for (const key of metadataFields) {
234+
if (rawAuthData[key] !== undefined) {
235+
const value = typeof rawAuthData[key] === 'object'
236+
? JSON.stringify(rawAuthData[key], null, 2)
237+
: String(rawAuthData[key])
238+
prompts.log.info(`${key} ${UI.Style.TEXT_DIM}${value}`)
239+
}
240+
}
241+
242+
prompts.outro("metadata fields")
243+
}
244+
224245
// Environment variables section
225246
const activeEnvVars: Array<{ provider: string; envVar: string }> = []
226247

0 commit comments

Comments
 (0)