Issues addressed: 1. guided-flow.ts: Remove 12 unnecessary 'ctx as any' casts - ctx is already ExtensionCommandContext, matching showNextAction/showConfirm signatures - The casts masked type-checking with no benefit 2. triage-ui.ts: Remove 1 unnecessary 'ctx as any' cast (same issue as #1) 3. migrate/command.ts: Remove 2 unnecessary 'ctx as any' casts (same issue as #1) 4. models-resolver.ts: Remove dead exports hasBothModelsFiles() and getModelsPaths() - Never imported outside the module or in any test file - resolveModelsJsonPath() (the only consumer) remains 5. resource-loader.ts: Remove dead export readManagedResourceSyncedAt() - Exported but never imported anywhere in the entire codebase 6. bg-shell/overlay.ts: Extract processStatusHeader() helper - DRYs the duplicated status icon + name + uptime + tab indicator construction shared between renderOutput() and renderEvents() 7. get-secrets-from-user.ts: Merge duplicate vercel/convex deployment blocks - Both had identical exec → check result code → push applied/errors pattern - Merged into single conditional with destination-specific command string Documented but not changed (boundary constraints): - src/mcp-server.ts ↔ src/resources/extensions/gsd/mcp-server.ts (compiled/jiti boundary prevents sharing) - src/remote-questions-config.ts ↔ remote-questions/remote-command.ts (same compiled/jiti boundary per #592) - cli.ts internal duplication of session setup (structural, different resource loader configs)
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
/**
|
|
* Models.json resolution with fallback to ~/.pi/agent/models.json
|
|
*
|
|
* GSD uses ~/.gsd/agent/models.json, but for a smooth migration/development
|
|
* experience, this module provides resolution logic that:
|
|
*
|
|
* 1. Reads ~/.gsd/agent/models.json if it exists
|
|
* 2. Falls back to ~/.pi/agent/models.json if GSD file doesn't exist
|
|
* 3. Merges both files if both exist (GSD takes precedence)
|
|
*/
|
|
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
import { homedir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { agentDir } from './app-paths.js'
|
|
|
|
const GSD_MODELS_PATH = join(agentDir, 'models.json')
|
|
const PI_MODELS_PATH = join(homedir(), '.pi', 'agent', 'models.json')
|
|
|
|
/**
|
|
* Resolve the path to models.json with fallback logic.
|
|
*
|
|
* Priority:
|
|
* 1. ~/.gsd/agent/models.json (exists) → return this path
|
|
* 2. ~/.pi/agent/models.json (exists) → return this path (fallback)
|
|
* 3. Neither exists → return GSD path (will be created)
|
|
*
|
|
* @returns The path to use for models.json
|
|
*/
|
|
export function resolveModelsJsonPath(): string {
|
|
if (existsSync(GSD_MODELS_PATH)) {
|
|
return GSD_MODELS_PATH
|
|
}
|
|
if (existsSync(PI_MODELS_PATH)) {
|
|
return PI_MODELS_PATH
|
|
}
|
|
return GSD_MODELS_PATH
|
|
}
|
|
|
|
|