This commit captures uncommitted modifications that accumulated in the working tree across multiple in-progress workstreams. It is a snapshot to clear the deck before sf v3 work begins; individual workstreams should land separately on top of this. Notable additions: - trace-collector.ts, traces.ts, src/tests/trace-export.test.ts — trace export plumbing - biome.json — Biome linter configuration - .gitignore — exclude native/npm/**/*.node compiled binaries The bulk of the diff is across src/resources/extensions/sf/ (301 files) and src/resources/extensions/sf/tests/ (277 files), reflecting the ongoing sf extension work. Specific feature commits should follow this snapshot rather than being archaeology'd out of it. The 76MB native/npm/linux-x64-gnu/forge_engine.node compiled binary was left out of the commit — it's now gitignored and built locally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
/**
|
|
* Models.json resolution with fallback to ~/.pi/agent/models.json
|
|
*
|
|
* SF uses ~/.sf/agent/models.json, but for a smooth migration/development
|
|
* experience, this module provides resolution logic that:
|
|
*
|
|
* 1. Reads ~/.sf/agent/models.json if it exists
|
|
* 2. Falls back to ~/.pi/agent/models.json if SF file doesn't exist
|
|
* 3. Merges both files if both exist (SF takes precedence)
|
|
*/
|
|
|
|
import { existsSync } from "node:fs";
|
|
import { homedir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { agentDir } from "./app-paths.js";
|
|
|
|
const SF_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. ~/.sf/agent/models.json (exists) → return this path
|
|
* 2. ~/.pi/agent/models.json (exists) → return this path (fallback)
|
|
* 3. Neither exists → return SF path (will be created)
|
|
*
|
|
* @returns The path to use for models.json
|
|
*/
|
|
export function resolveModelsJsonPath(): string {
|
|
if (existsSync(SF_MODELS_PATH)) {
|
|
return SF_MODELS_PATH;
|
|
}
|
|
if (existsSync(PI_MODELS_PATH)) {
|
|
return PI_MODELS_PATH;
|
|
}
|
|
return SF_MODELS_PATH;
|
|
}
|