| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #!/usr/bin/env node
- const {
- runtimeManifest,
- prepareOfficialCli,
- runOfficialCli,
- getOfficialCliStatus,
- getInitCommand,
- sanitizeCliText
- } = require('../mcp/src/core/wecom-cli-runtime');
- async function main() {
- const args = process.argv.slice(2);
- const command = args[0];
- if (command === 'install') {
- const installed = await prepareOfficialCli({ force: args.includes('--force') });
- console.log(
- JSON.stringify(
- {
- status: 'ok',
- package: runtimeManifest.package,
- version: runtimeManifest.version,
- cached: installed.cached
- },
- null,
- 2
- )
- );
- return;
- }
- if (command === 'status') {
- const status = await getOfficialCliStatus();
- console.log(JSON.stringify({ ...status, initCommand: status.ready ? undefined : getInitCommand() }, null, 2));
- return;
- }
- const result = await runOfficialCli(args, {
- inherited: true,
- timeoutMs: command === 'init' ? 10 * 60 * 1000 : 120000
- });
- if (result.exitCode !== 0) process.exit(result.exitCode);
- }
- main().catch(error => {
- console.error(`qiwei-official-cli failed: ${sanitizeCliText(error.message)}`);
- process.exit(1);
- });
|