This repository has been archived on 2026-09-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BPOS-MVP/activities/quote-sourcing/src/manifest.ts
T
ChaiHaoandClaude Opus 5 374206b408 六个活动的汇报界面与技能补齐;skill-engine 接上装配面
汇报界面(AM 07):
  · 视图外壳与卡片件提到 `@sdk`(viewShell / kvCard / tableCard / stagesCard / noteCard)——
    六个活动共用一套面貌,不各自发明;样式内联自带(沙箱页面不继承工作台 CSS)。
  · flow 四活动按**步序位置**挂模版:
    A1 事态全景 / 打标判据 / 成果预览;A4 取价基准 / 定价与门禁 / 草案待放行;
    A6 正式报价单 / 放行即发出;A7 结果登记 / 闭环待放行。
  · loop 两活动按**阶段与里程碑**组织:案例全景一屏,画阶段生命周期态、当下可为、目标缺口 ——
    素材全部来自语义引擎,零 LLM 即可成屏;模型只决定下一步做什么,不负责画面。
    为此给 loop-engine 补了视图端口,与 flow 共用同一个网关。
  · 每张模版都把「这一屏在说什么 / 放行意味着什么」写在数据旁边 ——
    人要在数据上作判断,判据就得摆在手边。

技能(AM 08):
  · 六个活动各写了 1–2 条真技能:适用描述 + 方法正文 + 结晶片段脚本。
    正文写的是**方法经验**而非流程复述(如「原文没写的不要补」「该等还是该问」
    「无基准不是异常,是一种基准」)。
  · 资源声明放**技能 ID**(权力面),资产放**定义本体**(方法面),两处分清。
  · **skill-engine 从来没有被构造过** —— 模块实现完整却无人调用,这是它一直没被用上的原因。
    容器里补上:目录与白名单都取自活动清单,装配前查扩权。
  · loop 的叙事面接入**技能目录**(渐进披露:常驻上下文只给「有哪些方法、何时适用」,
    正文等 AI 说要才加载),装配随即**盖戳入任务记忆** —— 回放与归因依赖之。

gates: tsc / eslint / depcruise(334 模块)/ 423 测试 全绿

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
2026-07-27 10:59:13 +08:00

188 lines
7.2 KiB
TypeScript

/**
* 活动包清单 —— 统一报价 A3 · 渠道寻源(**案例活动 · loop**)。
*
* 业务素材:docs/MVP示例工作流.html §1.5。按 README《归一化对照表》映射:
* 案例图 → CMMN XML;案例说明书 → 同版本叙事面;
* `!必做` → entryCriterion 常项;`看情况` → discretionary(planningTable);
* `#可反复` → repetitionRule;`▶需拍板` → manualActivation + 放行;
* `⏱时限/回价到期` → 时间监听(**时限必配**)。
*/
import type { ActivityManifest, DmnModel } from '@contracts';
import { SOURCING_SKILLS } from './skills.ts';
import { SOURCING_CASE } from './views/report.ts';
import { activityIdSchema } from '@contracts';
import { CMMN_XML, NARRATIVE } from './case-model.ts';
const DOMAIN = 'quote_sourcing';
const ACTIVITY_ID = activityIdSchema.parse('quote-sourcing');
/** 采用策略 —— 「能算的不问 LLM」:场景 × 历史情形 → 直采 / 重询 */
export const STRATEGY_DMN: DmnModel = {
drd: [{ decision: 'sourcing-strategy', requires: [], inputs: ['scenario', 'priceDrift', 'quoteCount'] }],
tables: [
{
id: 'sourcing-strategy',
label: '采用策略判定',
hitPolicy: 'FIRST',
inputs: [
{ name: 'scenario', expression: 'scenario' },
{ name: 'priceDrift', expression: 'priceDrift' },
{ name: 'quoteCount', expression: 'quoteCount' },
],
outputs: [{ name: 'strategy' }, { name: 'needNewQuote' }],
rules: [
{ id: 'st-spot', when: ['"现货","样品"', '-', '-'], then: ['一律重询', true] },
{ id: 'st-early-direct', when: ['"BOM早期"', '<= 0.10', '-'], then: ['直采', false] },
{ id: 'st-early-avg', when: ['"BOM早期"', '[0.10..0.20]', '-'], then: ['取均价', false] },
{ id: 'st-late-direct', when: ['"BOM后期"', '-', '>= 3'], then: ['历史最低直采', false] },
{ id: 'st-default', when: ['-', '-', '-'], then: ['重询', true] },
],
},
],
};
export const manifest: ActivityManifest = {
identity: {
activityId: ACTIVITY_ID,
name: 'A3 · 渠道寻源',
packageVersion: '0.1.2',
category: '统一报价',
paradigm: 'loop',
sdkVersion: '0.1.0-m5',
checksum: 'dev-checksum-quote-sourcing',
},
contract: {
activityId: ACTIVITY_ID,
version: '0.1.0',
input: {
data: {
type: 'object',
required: ['pn', 'scenario'],
properties: {
pn: { type: 'string' },
scenario: { type: 'string' },
quantity: { type: 'integer' },
targetPrice: { type: 'number' },
},
},
messageAllowed: true,
messageHint: '急料、客户特殊要求写这里',
},
output: {
mandatory: [
{
name: 'compare',
payload: { type: 'object', required: ['rows'], properties: { rows: { type: 'array' } } },
description: '寻源比价表(多渠道横比定底)',
},
],
selective: [],
},
requiredDeliverables: [{ key: 'compare-table', label: '寻源比价表' }],
acceptanceCriteria: [
{ key: 'each-has-quote', label: '每料有有效报价或明确无货', level: 'L2', predicate: 'unquoted = 0' },
{ key: 'channels-enough', label: 'BOM后期每料 2~3 家渠道', level: 'L2', predicate: 'channelsPicked >= 2' },
{ key: 'cross-check', label: '价格验证按场景规则做过', level: 'L3' },
{ key: 'prm-release', label: '采购放行', level: 'L5' },
],
prohibitions: [
{ key: 'no-stockless-trader', statement: '现货场景不得选无库存转单商' },
{ key: 'no-unverified', statement: '不实回价或远低行情的,必须换渠道补询,不得直接采用' },
],
authorization: {
discretion: [{ key: 'channel-band', statement: '按场景放宽或收紧渠道尺度;贸易商尽量不用' }],
preauthorizedActions: [{ tool: 'mail.send', operation: 'inquiry', limit: '询价模板' }],
humanCallBudget: 8,
},
resources: {
tools: [{ name: 'mail.send' }, { name: 'crm.history-price-read' }],
skills: SOURCING_SKILLS.map((s) => s.id),
models: ['quote-extractor'],
roles: ['PRM'],
budget: { steps: 120, tokens: 300_000, activeMinutes: 480, humanCalls: 8 },
},
},
declarations: {
models: ['quote-extractor'],
tools: [{ name: 'mail.send' }, { name: 'crm.history-price-read' }],
ledger: [
{
domain: DOMAIN,
object: 'supplier_quote',
label: '供应商回价单',
fields: [
{ name: 'pn', type: 'text', primaryKey: true, masked: false },
{ name: 'supplier', type: 'text', primaryKey: true, masked: false, label: '供应商' },
{ name: 'price', type: 'number', primaryKey: false, masked: false, label: '回价' },
{ name: 'moq', type: 'integer', primaryKey: false, masked: false, label: 'MOQ' },
{ name: 'lead_time', type: 'text', primaryKey: false, masked: false, label: '交期' },
{ name: 'valid_until', type: 'date', primaryKey: false, masked: false, label: '有效期' },
{ name: 'grade', type: 'text', primaryKey: false, masked: false, label: '渠道等级' },
],
},
{
domain: DOMAIN,
object: 'compare_table',
label: '寻源比价表',
fields: [
{ name: 'pn', type: 'text', primaryKey: true, masked: false },
{ name: 'supplier', type: 'text', primaryKey: false, masked: false },
{ name: 'price', type: 'number', primaryKey: false, masked: false },
{ name: 'conclusion', type: 'text', primaryKey: false, masked: false, label: '结论' },
],
},
],
listeners: [
{
// 回价到期:临过期提醒复核确认,过期触发重询 —— 时限必配
origin: 'static',
eventType: 'data',
keyFilter: { kind: 'supplier-quote' },
semantic: 'observe',
deadline: 'P4D',
escalation: ['nudge', 'escalate'],
},
{
origin: 'static',
eventType: 'time',
keyFilter: { kind: 'quote-expiry' },
semantic: 'observe',
deadline: 'P7D',
escalation: ['nudge', 'reroute'],
},
],
// 按场景时限:BOM早期/现货 1~4 日、样品 1~3 日、BOM后期 3~9 日 —— 取最宽做停滞阈值
harness: {
memoryWindow: 30,
stallAfter: 'P2D',
nudge: [{ after: 'P1D', action: 'nudge' }],
retry: { times: 2, backoff: 'PT5M' },
},
},
assets: {
businessModel: {
paradigm: 'loop',
cmmnXml: CMMN_XML,
// 双表示同版本:XML 是机器面,说明书是叙事面 —— 不允许分叉
narrative: NARRATIVE,
dmn: STRATEGY_DMN,
},
skills: SOURCING_SKILLS,
viewTemplates: [{ name: 'case-overview', html: SOURCING_CASE }],
cardSchemas: {},
distillHooks: [
{ on: 'milestone', milestone: 'M_quotes', prompt: '归纳各渠道的回价节奏与配合度。' },
{ on: 'terminal', prompt: '归纳本单寻源:哪些渠道靠谱、哪些场景的价格验证规则该收紧。' },
],
},
samples: [
{ name: 'BOM后期询价', input: { pn: 'LM358DR', scenario: 'BOM后期', quantity: 5000 }, expect: { ports: ['compare'] } },
],
entry: { file: 'index.js', checksum: 'dev-entry-quote-sourcing' },
};