gongxiangp2/apps/detail-agent-pi/scripts/import-enterprise-rules.mjs
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

12 lines
929 B
JavaScript

import fs from 'node:fs/promises';
import path from 'node:path';
import { atomic } from '../src/store.mjs';
import { importEnterpriseRules } from '../src/enterprise-rules.mjs';
const [platformFile, knowledgeRoot, output] = process.argv.slice(2);
if (!platformFile || !knowledgeRoot || !output) throw Error('用法:<素材库目录快照> <知识库详情页技能目录> <本地规则包路径>');
const platform = JSON.parse(await fs.readFile(platformFile, 'utf8'));
const catalog = await importEnterpriseRules(platform, knowledgeRoot);
await atomic(path.resolve(output), catalog);
console.log(JSON.stringify({ revision: catalog.revision, brands: catalog.brands.map(b => b.name), ready: catalog.bindings.map(b => ({ template: b.id, shop: catalog.shops.find(s => s.id === b.shopId).name, category: catalog.categories.find(c => c.id === b.categoryId).name })), sourceFiles: catalog.sourceFiles.length, productionWrites: 0 }));