Skip to content

Commit 008f1dd

Browse files
committed
Add agent homepage URLs, installation error translations, and a not-installed check that prompts users to install missing CLI agents
- when agent is not installed on the computer, show appropriate notification - place homepage_url in `apps/editor/src/constants/agents.ts` and show button "Instructions" on [Fragment] - translate [Fragment] └── apps └── editor └── src ├── constants │ └── agents.ts ├── i18n │ └── translations │ └── utils │ └── agentic-cli-invocation.ts └── utils └── agentic-cli-invocation ├── agents │ ├── antigravity.ts │ ├── claude.ts │ ├── codex.ts │ ├── cursor.ts │ ├── grok.ts │ ├── index.ts │ ├── muse.ts │ └── opencode.ts ├── invoke-agentic-cli.ts └── utils └── check-command-exists.ts
1 parent 550905e commit 008f1dd

3 files changed

Lines changed: 99 additions & 18 deletions

File tree

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
type Agents = {
22
[name: string]: {
33
docs_url?: string
4+
homepage_url?: string
45
}
56
}
67

78
export const AGENTS = {
89
Antigravity: {
9-
docs_url: 'https://antigravity.google/docs/cli/headless/'
10+
docs_url: 'https://antigravity.google/docs/cli/headless/',
11+
homepage_url: 'https://antigravity.google/'
12+
},
13+
'Claude Code': {
14+
docs_url: 'https://code.claude.com/docs/en/headless',
15+
homepage_url: 'https://code.claude.com'
1016
},
11-
'Claude Code': { docs_url: 'https://code.claude.com/docs/en/headless' },
1217
Codex: {
13-
docs_url: 'https://learn.chatgpt.com/docs/non-interactive-mode'
18+
docs_url: 'https://learn.chatgpt.com/docs/non-interactive-mode',
19+
homepage_url: 'https://learn.chatgpt.com'
20+
},
21+
Cursor: {
22+
docs_url: 'https://cursor.com/docs/cli/headless',
23+
homepage_url: 'https://cursor.com'
24+
},
25+
'Grok Build': {
26+
docs_url: 'https://docs.x.ai/build/cli/headless-scripting',
27+
homepage_url: 'https://x.ai/grok'
1428
},
15-
Cursor: { docs_url: 'https://cursor.com/docs/cli/headless' },
16-
'Grok Build': { docs_url: 'https://docs.x.ai/build/cli/headless-scripting' },
17-
'Muse Code': { docs_url: 'https://dev.meta.ai/docs/muse-code/extending#headless' },
18-
OpenCode: { docs_url: 'https://opencode.ai/docs/cli/' }
29+
'Muse Code': {
30+
docs_url: 'https://dev.meta.ai/docs/muse-code/extending#headless',
31+
homepage_url: 'https://dev.meta.ai'
32+
},
33+
OpenCode: {
34+
docs_url: 'https://opencode.ai/docs/cli/',
35+
homepage_url: 'https://opencode.ai'
36+
}
1937
} satisfies Agents

‎apps/editor/src/i18n/translations/utils/agentic-cli-invocation.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,24 @@ export const translations = {
197197
hu: 'várakozás az ügynökre...',
198198
bg: 'изчакване на агент...'
199199
},
200+
'utils.agentic-cli-invocation.error.not-installed': {
201+
en: 'The {agent} CLI is not installed on this computer.',
202+
pl: 'CLI {agent} nie jest zainstalowane na tym komputerze.',
203+
'zh-cn': '{agent} CLI 未安装在此计算机上。',
204+
ja: '{agent} CLI はこのコンピューターにインストールされていません。',
205+
'zh-tw': '{agent} CLI 未安裝在此電腦上。',
206+
de: 'Die {agent} CLI ist auf diesem Computer nicht installiert.',
207+
es: 'La CLI de {agent} no está instalada en esta computadora.',
208+
fr: "L'interface CLI {agent} n'est pas installée sur cet ordinateur.",
209+
'pt-br': 'O CLI {agent} não está instalado neste computador.',
210+
ru: 'CLI {agent} не установлен на этом компьютере.',
211+
ko: '{agent} CLI가 이 컴퓨터에 설치되어 있지 않습니다.',
212+
it: 'La CLI di {agent} non è installata su questo computer.',
213+
tr: '{agent} CLI bu bilgisayarda yüklü değil.',
214+
cs: 'CLI {agent} není na tomto počítači nainstalováno.',
215+
hu: 'A {agent} CLI nincs telepítve ezen a számítógépen.',
216+
bg: 'CLI {agent} не е инсталиран на този компютър.'
217+
},
200218
'utils.agentic-cli-invocation.error.failed': {
201219
en: 'Agent execution failed: {error}',
202220
pl: 'Wykonywanie agenta nie powiodło się: {error}',
@@ -215,6 +233,24 @@ export const translations = {
215233
hu: 'Az ügynök futtatása sikertelen: {error}',
216234
bg: 'Изпълнението на агента се провали: {error}'
217235
},
236+
'utils.agentic-cli-invocation.error.installation-instructions': {
237+
en: 'Installation instructions',
238+
pl: 'Instrukcje instalacji',
239+
'zh-cn': '安装说明',
240+
ja: 'インストール手順',
241+
'zh-tw': '安裝說明',
242+
de: 'Installationsanweisungen',
243+
es: 'Instrucciones de instalación',
244+
fr: "Instructions d'installation",
245+
'pt-br': 'Instruções de instalação',
246+
ru: 'Инструкции по установке',
247+
ko: '설치 지침',
248+
it: "Istruzioni per l'installazione",
249+
tr: 'Kurulum talimatları',
250+
cs: 'Pokyny k instalaci',
251+
hu: 'Telepítési útmutató',
252+
bg: 'Инструкции за инсталиране'
253+
},
218254
'utils.agentic-cli-invocation.agent.finished': {
219255
en: 'Agent finished in {duration}.',
220256
pl: 'Agent zakończył działanie w {duration}.',

‎apps/editor/src/utils/agentic-cli-invocation/invoke-agentic-cli.ts‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { spawn } from 'child_process'
66
import { CLI_AGENTS } from './agents'
77
import { Logger } from '@shared/utils/logger'
88
import { ConfigAgentConfigurationFormat } from '@/utils/agent-configuration-format-converters'
9+
import { AGENTS } from '@/constants/agents'
910

1011
let _output_channel: vscode.OutputChannel | undefined
1112

@@ -45,9 +46,11 @@ export const invoke_agentic_cli = async (params: {
4546
let show_quick_pick = params.use_quick_pick
4647

4748
while (true) {
48-
const available_agents = CLI_AGENTS.filter((a) => a.is_installed())
49+
const config = vscode.workspace.getConfiguration('codeWebChat')
50+
const agents_config =
51+
config.get<ConfigAgentConfigurationFormat[]>('agents', []) || []
4952

50-
if (available_agents.length == 0) {
53+
if (agents_config.length === 0) {
5154
vscode.window.showInformationMessage(
5255
t('utils.agentic-cli-invocation.info.no-agents')
5356
)
@@ -59,10 +62,6 @@ export const invoke_agentic_cli = async (params: {
5962
tooltip: t('common.close')
6063
}
6164

62-
const config = vscode.workspace.getConfiguration('codeWebChat')
63-
const agents_config =
64-
config.get<ConfigAgentConfigurationFormat[]>('agents', []) || []
65-
6665
let selected_agent_cmd: string | undefined
6766
let flags_string: string | undefined
6867
let selected_config_name: string | undefined
@@ -72,7 +71,7 @@ export const invoke_agentic_cli = async (params: {
7271
(c) => c.name === current_agent_config_name
7372
)
7473
if (config_item) {
75-
const agent_info = available_agents.find(
74+
const agent_info = CLI_AGENTS.find(
7675
(a) => a.label === config_item.agent
7776
)
7877
if (agent_info) {
@@ -86,7 +85,7 @@ export const invoke_agentic_cli = async (params: {
8685
if (last_used) {
8786
const config_item = agents_config.find((c) => c.name === last_used)
8887
if (config_item) {
89-
const agent_info = available_agents.find(
88+
const agent_info = CLI_AGENTS.find(
9089
(a) => a.label === config_item.agent
9190
)
9291
if (agent_info) {
@@ -99,7 +98,7 @@ export const invoke_agentic_cli = async (params: {
9998

10099
if (!selected_agent_cmd && agents_config.length === 1) {
101100
const config_item = agents_config[0]
102-
const agent_info = available_agents.find(
101+
const agent_info = CLI_AGENTS.find(
103102
(a) => a.label === config_item.agent
104103
)
105104
if (agent_info) {
@@ -126,7 +125,7 @@ export const invoke_agentic_cli = async (params: {
126125
.get<ConfigAgentConfigurationFormat[]>('agents', []) || []
127126

128127
for (const agent_config of current_agents_config) {
129-
const agent_info = available_agents.find(
128+
const agent_info = CLI_AGENTS.find(
130129
(a) => a.label == agent_config.agent
131130
)
132131
if (!agent_info) continue
@@ -263,6 +262,34 @@ export const invoke_agentic_cli = async (params: {
263262
selected_config_name = agent_selection_result.config_name
264263
}
265264

265+
const selected_agent_info = CLI_AGENTS.find(
266+
(a) => a.cmd === selected_agent_cmd
267+
)
268+
269+
if (selected_agent_info && !selected_agent_info.is_installed()) {
270+
const response = await vscode.window.showWarningMessage(
271+
t('utils.agentic-cli-invocation.error.not-installed', {
272+
agent: selected_agent_info.label
273+
}),
274+
t('utils.agentic-cli-invocation.error.installation-instructions')
275+
)
276+
277+
if (
278+
response ==
279+
t('utils.agentic-cli-invocation.error.installation-instructions')
280+
) {
281+
const agent_label = selected_agent_info.label as keyof typeof AGENTS
282+
const url = AGENTS[agent_label]?.homepage_url
283+
if (url) {
284+
vscode.env.openExternal(vscode.Uri.parse(url))
285+
}
286+
}
287+
288+
show_quick_pick = true
289+
current_agent_config_name = undefined
290+
continue
291+
}
292+
266293
if (selected_config_name && params.on_agent_selected) {
267294
params.on_agent_selected(selected_config_name)
268295
}
@@ -358,7 +385,7 @@ export const invoke_agentic_cli = async (params: {
358385
)
359386
}
360387

361-
const agent_info = available_agents.find(
388+
const agent_info = CLI_AGENTS.find(
362389
(a) => a.cmd == selected_agent_cmd
363390
)
364391
if (!agent_info) break

0 commit comments

Comments
 (0)