smoke-package.mjs 1.3 KB

123456789101112131415161718192021
  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. import { checkPackage } from '../install.js';
  4. import { resultEnvelope } from '../mcp/src/core/result-envelope.mjs';
  5. import { buildImageSetPlan, verifyPlan } from '../mcp/src/features/planning/planner.mjs';
  6. const root = path.resolve(import.meta.dirname, '..');
  7. const checked = checkPackage(root);
  8. if (!checked.ok) throw new Error(`Package check failed: ${checked.errors.join(', ')}`);
  9. const envelope = resultEnvelope({ status: 'ok', assistantMessage: 'smoke' });
  10. for (const key of ['status','assistantMessage','summary','data','files','nextActions','warnings','errors']) {
  11. if (!(key in envelope)) throw new Error(`Missing envelope field: ${key}`);
  12. }
  13. const plan = buildImageSetPlan({ request: '规划七张商品套图', productDescription: '测试商品' });
  14. verifyPlan(plan);
  15. if (plan.items.length !== 7 || plan.requiresConfirmation !== true) throw new Error('Planning smoke failed.');
  16. for (const locale of ['zh', 'en']) {
  17. const directory = path.join(root, 'mcp', 'catalog', 'templates', locale);
  18. if (fs.readdirSync(directory).filter(name => name.endsWith('.json')).length !== 25) throw new Error(`${locale} template count mismatch`);
  19. }
  20. console.log(JSON.stringify({ status: 'ok', check: checked, planId: plan.planId, templates: 50 }, null, 2));