fmode-image.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env node
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { spawnSync } = require('child_process');
  6. const SKILL_NAME = 'fmode-image';
  7. const SOURCE_ROOT = path.resolve(__dirname, '..');
  8. const SKILL_SOURCE = path.join(SOURCE_ROOT, 'skills', SKILL_NAME);
  9. const GEN_SCRIPT = path.join(SKILL_SOURCE, 'scripts', 'gen.py');
  10. const WORKSPACE_ROOT = process.cwd();
  11. function runGen(passthrough) {
  12. const python = process.platform === 'win32' ? 'python' : 'python3';
  13. const result = spawnSync(python, [GEN_SCRIPT, ...passthrough], { stdio: 'inherit', shell: false });
  14. if (result.error) {
  15. console.error(`fmode-image: failed to launch generator: ${result.error.message}`);
  16. process.exit(1);
  17. }
  18. process.exit(result.status ?? 0);
  19. }
  20. const args = process.argv.slice(2);
  21. if (args.length === 0) {
  22. console.log(`fmode-image — Fmode Image Generator
  23. 用法:
  24. npx fmode-image --arch "prompt" [name] 生成架构图 (1792x1024, ¥0.5)
  25. npx fmode-image --scene "prompt" [name] 生成场景图 (1024x1024, ¥0.3)
  26. 示例:
  27. npx fmode-image --arch "内容营销预审Agent Harness架构,五层..." case01
  28. npx fmode-image --scene "法务团队被稿件淹没的办公场景" legal-scene
  29. 自动读取 FMODE_API_KEY (env/.fmode/config.json/.env)
  30. `);
  31. process.exit(0);
  32. }
  33. runGen(args);