Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bin/sync-models.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ const DRY_RUN = process.argv.includes('--dry-run');
const VERBOSE = process.argv.includes('--verbose') || process.argv.includes('-v');

const ROOT_DIR = path.resolve(import.meta.dirname, '..');
const OPENCODE_CONFIG_PATH = path.join(ROOT_DIR, '.opencode/opencode.jsonc');
const POLICY_PATH = path.join(import.meta.dirname, 'sync-models.policy.json');
const HOME_DIR = process.env.HOME || '/home/user';
// Config resolution (#591): in a repo checkout, sync the repo's own
// .opencode/opencode.jsonc. When home-manager installs this script it lands
// alone in the Nix store, so ROOT_DIR resolves to /nix and the repo-relative
// path never exists — fall back to the deployed user config, which is the
// file the sync-models service actually maintains. $OPENCODE_CONFIG_PATH
// overrides both.
const REPO_CONFIG_PATH = path.join(ROOT_DIR, '.opencode/opencode.jsonc');
const USER_CONFIG_PATH = path.join(HOME_DIR, '.config/opencode/opencode.jsonc');
const OPENCODE_CONFIG_PATH =
process.env.OPENCODE_CONFIG_PATH ||
(fs.existsSync(REPO_CONFIG_PATH) ? REPO_CONFIG_PATH : USER_CONFIG_PATH);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Package the policy with the deployed script

When this fallback is taken by the Home Manager service or installed CLI, ${../../bin/sync-models.mjs} is copied into the Nix store as a lone file, so the adjacent sync-models.policy.json still cannot be found. loadPolicy() therefore returns an empty policy, causing both Antigravity providers to retain stale entries and add every discovered model rather than only the newest models in the configured families. The deployed path should also resolve or package the policy before allowing the service to update the user config.

Useful? React with 👍 / 👎.

const POLICY_PATH = path.join(import.meta.dirname, 'sync-models.policy.json');
const CODEX_CACHE_PATH = path.join(HOME_DIR, '.codex/models_cache.json');
const GEMINI_CACHE_PATH = path.join(HOME_DIR, '.gemini/antigravity_models_cache.json');
const LS_LOG_PATH = path.join(HOME_DIR, '.config/Antigravity/logs/language_server.log');
Expand Down
Loading