()
| 344 | } |
| 345 | |
| 346 | export function generateCompletionCache(): void { |
| 347 | if (!app.isPackaged) return; |
| 348 | |
| 349 | const entryPath = getOpenClawEntryPath(); |
| 350 | if (!existsSync(entryPath)) return; |
| 351 | |
| 352 | const execPath = getNodeExecForCli(); |
| 353 | |
| 354 | const child = spawn(execPath, [entryPath, 'completion', '--write-state'], { |
| 355 | env: { |
| 356 | ...process.env, |
| 357 | ELECTRON_RUN_AS_NODE: '1', |
| 358 | OPENCLAW_NO_RESPAWN: '1', |
| 359 | OPENCLAW_EMBEDDED_IN: 'ClawX', |
| 360 | }, |
| 361 | stdio: 'ignore', |
| 362 | detached: false, |
| 363 | windowsHide: true, |
| 364 | }); |
| 365 | |
| 366 | child.on('close', (code) => { |
| 367 | if (code === 0) { |
| 368 | logger.info('OpenClaw completion cache generated'); |
| 369 | } else { |
| 370 | logger.warn(`OpenClaw completion cache generation exited with code ${code}`); |
| 371 | } |
| 372 | }); |
| 373 | |
| 374 | child.on('error', (err) => { |
| 375 | logger.warn('Failed to generate completion cache:', err); |
| 376 | }); |
| 377 | } |
| 378 | |
| 379 | export function installCompletionToProfile(): void { |
| 380 | if (!app.isPackaged) return; |
no test coverage detected