WuYongJie 1b6425b552 feat(desktop): connect native Pi sessions with scoped rules and recovery
Track the fixed PhotoCraft source baseline with the existing native client integration. Use the actual Pi SDK for normal sends, durable session recovery, demand-loaded enterprise rules and checked undoable canvas tools. Retain request identities and never resend unknown inference. Include local packaging and real-call acceptance evidence.
2026-10-22 10:49:58 +08:00

22 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fs from 'node:fs/promises';
import path from 'node:path';
import { resolveRules } from '../src/rules.mjs';
import { atomic, digest } from '../src/store.mjs';
const configFile = process.argv[2];
const config = JSON.parse(await fs.readFile(configFile, 'utf8'));
const packPath = path.resolve('lib/detail-generator/knowledge/enterprise-20261013.json');
const bytes = await fs.readFile(packPath, 'utf8'), pack = JSON.parse(bytes);
const profile = pack.brands.find(b => b.name === '顾家');
if (!profile) throw Error('现有顾家导入快照不存在');
const catalog = {
brands: [{ id: 'local-import-gujia', name: '顾家', profile, revision: pack.version, source: 'repository-import:enterprise-20261013.json (draft)' }],
shops: [{ id: 'QA-A店', brandId: 'local-import-gujia', platform: 'local-qa', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['A店书桌规则口令:晨雾-2168'] }, { id: 'QA-B店', brandId: 'local-import-gujia', platform: 'local-qa', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['B店餐椅规则口令:海盐-7391'] }],
categories: [{ id: 'QA-书桌', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['没有承重或检测报告时不编造相应参数'] }, { id: 'QA-餐椅', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['不能把另一产品的尺寸与材质用于当前餐椅'] }],
bindings: [{ id: 'QA-A-desk', shopId: 'QA-A店', categoryId: 'QA-书桌', revision: 'qa-1', source: 'explicit-qa-fixture', state: 'ready', rules: [] }, { id: 'QA-B-chair', shopId: 'QA-B店', categoryId: 'QA-餐椅', revision: 'qa-1', source: 'explicit-qa-fixture', state: 'ready', rules: [] }],
};
config.canvasBinding = resolveRules({ brandId: 'local-import-gujia', shopId: 'QA-A店', categoryId: 'QA-书桌' }, catalog);
config.otherBinding = resolveRules({ brandId: 'local-import-gujia', shopId: 'QA-B店', categoryId: 'QA-餐椅' }, catalog);
await atomic(configFile, config);
await atomic(path.join(config.output, 'rule-source-manifest.json'), { brandSource: packPath, importedVersion: pack.version, hash: digest(bytes), status: profile.status, shopsAndCategories: 'explicit-local-qa-fixtures', productionCatalog: 'GET currently unavailable; no automatic fallback or deployment performed' });
console.log('Selected the existing local enterprise import explicitly; shop/category rules are labelled QA fixtures.');