MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / installFromPanel

Function installFromPanel

apps/kimi-code/src/tui/commands/plugins.ts:296–334  ·  view source on GitHub ↗
(
  host: SlashCommandHost,
  panel: PluginsPanelComponent,
  source: string,
  label: string,
  official: boolean,
)

Source from the content-addressed store, hash-verified

294}
295
296async function installFromPanel(
297 host: SlashCommandHost,
298 panel: PluginsPanelComponent,
299 source: string,
300 label: string,
301 official: boolean,
302): Promise<void> {
303 if (!(await confirmInstallTrust(host, label, official))) {
304 host.showStatus(`Install cancelled: ${label}.`);
305 host.restoreEditor();
306 return;
307 }
308 // Official installs keep the panel mounted and show the inline installing
309 // state; third-party installs pass through a trust prompt that replaces the
310 // panel, so fall back to a transcript status for those.
311 if (official) {
312 panel.setInstalling(truncateForStatus(label));
313 } else {
314 host.showStatus(`Installing or updating ${label} from marketplace...`);
315 }
316 host.state.ui.requestRender();
317 try {
318 await installPluginFromSource(host, source);
319 } catch (error) {
320 if (official) {
321 panel.clearInstalling();
322 host.state.ui.requestRender();
323 } else {
324 // The trust prompt replaced the panel; re-mount it so the user can retry
325 // instead of being dropped back at the editor.
326 host.mountEditorReplacement(panel);
327 }
328 host.showError(`Failed to install ${label}: ${formatErrorMessage(error)}`);
329 return;
330 }
331 // Close the panel after installing so the result status and the
332 // "/reload or /new" tip are visible in the transcript.
333 host.restoreEditor();
334}
335
336async function applyPluginEnabled(
337 host: SlashCommandHost,

Callers 1

Calls 11

formatErrorMessageFunction · 0.90
confirmInstallTrustFunction · 0.85
truncateForStatusFunction · 0.85
installPluginFromSourceFunction · 0.85
setInstallingMethod · 0.80
clearInstallingMethod · 0.80
showStatusMethod · 0.65
restoreEditorMethod · 0.65
requestRenderMethod · 0.65
showErrorMethod · 0.65

Tested by

no test coverage detected