mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
d2974a9ff6
* refactor(adapters): convert adapter layer from TypeScript to JavaScript Core framework stays TypeScript; adapter layer moves to JS-first. Adapters are essentially "executable config + browser scripts" that barely use TS features — this simplifies the build/distribution pipeline by removing the dist/clis/ intermediate compilation step. Changes: - Convert all 753 adapter files in clis/ from .ts to .js - Update tsconfig to exclude clis/ from compilation - Simplify build-manifest to scan clis/*.js directly (no dist/clis/) - Update discovery, main, fetch-adapters to load JS adapters from clis/ - Update generate-verified to output .js artifacts - Update package.json files field: dist/clis/ → clis/ - Fix all test files for the .ts → .js transition * fix(main): use findPackageRoot for BUILTIN_CLIS path The previous relative path (../../clis from __dirname) only worked for dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname is <repo>/src — resolving to /clis instead of <repo>/clis. Use findPackageRoot() which works for both dev and prod paths.
45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
export const modelCommand = cli({
|
|
site: 'antigravity',
|
|
name: 'model',
|
|
description: 'Switch the active LLM model in Antigravity',
|
|
domain: 'localhost',
|
|
strategy: Strategy.UI,
|
|
browser: true,
|
|
args: [
|
|
{ name: 'name', help: 'Target model name (e.g. claude, gemini, o1)', required: true, positional: true }
|
|
],
|
|
columns: ['Status'],
|
|
func: async (page, kwargs) => {
|
|
const targetName = kwargs.name.toLowerCase();
|
|
await page.evaluate(`
|
|
async () => {
|
|
const targetModelName = ${JSON.stringify(targetName)};
|
|
|
|
// 1. Locate the model selector dropdown trigger
|
|
const trigger = document.querySelector('div[aria-haspopup="dialog"] > div[tabindex="0"]');
|
|
if (!trigger) throw new Error('Could not find the model selector trigger in the UI');
|
|
trigger.click();
|
|
|
|
// 2. Wait a brief moment for React to mount the Portal/Dialog
|
|
await new Promise(r => setTimeout(r, 200));
|
|
|
|
// 3. Find the option spanning target text
|
|
const spans = Array.from(document.querySelectorAll('[role="dialog"] span'));
|
|
const target = spans.find(s => s.innerText.toLowerCase().includes(targetModelName));
|
|
if (!target) {
|
|
// If not found, click the trigger again to close it safely
|
|
trigger.click();
|
|
throw new Error('Model matching "' + targetModelName + '" was not found in the dropdown list.');
|
|
}
|
|
|
|
// 4. Click the closest parent that handles the row action
|
|
const optionNode = target.closest('.cursor-pointer') || target;
|
|
optionNode.click();
|
|
}
|
|
`);
|
|
await page.wait(0.5);
|
|
return [{ Status: `Model switched to: ${kwargs.name}` }];
|
|
},
|
|
});
|