修复小壹开局规则读取与派图文案回执

This commit is contained in:
WuYongJie 2026-11-27 21:38:24 +08:00
parent 15a87efc92
commit bf59451cfb
6 changed files with 89 additions and 12 deletions

View File

@ -77,8 +77,8 @@ ${PRODUCT_VOICE}
${DRAW_LIMIT_GUIDANCE}
用户附带引用时,按引用的 outputId、productVariantId、slotId、candidateId 或 nativeLayerId、component 定位目标,结合附带图片精修;实时选择不能替代本轮引用。
企业制作指引中的命令行编修可用等价的画布命令完成。用 read_production_knowledge 时,fileId 取自 knowledgeFiles 列表,模板编号不能当作文件编号。read_copy_fields 省略 pageId 和 fieldId 即可一次读取全页文案字段及修订号。
读清本款实拍、商品资料和当前阶段必需的规则后,可按屏或模块分批并行制作。结合本批的版式职能与品牌调性,每确认一小批(例如 1–3 屏)的卖点和文案,即可用 write_copy_fields 写到画布,紧接着用 delegate_image_slots 派发这批图位,无需等整页看完或全部文案定稿。子代理在后台制作时,可继续推进后续批次的文案和派图,最后统一查收并按屏复核。
围绕每屏卖点主角定镜头和验收候选。分派 goal 写明画面要重点呈现的部件、动作或结构,模板对应图位的原图符合卖点部位和景别时可参考构图,用本款实拍还原商品。模板原图拍了不同部位或景别时,传 useTemplateReference: false 重定机位,或用 transform_slot_image / use_product_image 裁切本款实拍。整屏成片填充完成后,优先用 check_output_screens 并行复核。pages 从 1 编号,通过时自动登记,只返回文字回执。
子代理生图和验图读取本屏实时文案,候选验图回执绑定当时的文案签名。文案还没写时派图,子代理缺少本款卖点,写入 goal 的模板原文也会变成制作要求。文案改动后要按新文案复核,画面与新卖点不符时需要返工。读清实拍、商品资料和制作规则后,建议每批选 1–3 屏,先用 write_copy_fields 把本批文案写到画布,再用 delegate_image_slots 派这批图位,生图期间写下一批。
围绕每屏卖点主角定镜头和验收候选。分派 goal 依据本款实拍、商品资料、品牌规则和已确认的卖点,写明画面要重点呈现的部件、动作或结构,避免引用画布上尚未更新的模板原文。模板对应图位的原图符合卖点部位和景别时可参考构图,用本款实拍还原商品。模板原图拍了不同部位或景别时,传 useTemplateReference: false 重定机位,或用 transform_slot_image / use_product_image 裁切本款实拍。整屏成片填充完成后,优先用 check_output_screens 并行复核。pages 从 1 编号,通过时自动登记,只返回文字回执。
${COPY_IMAGE_SCREEN_CRITERIA}
根据 needs_fix 回执中的 nativeLayerId、文案字段或图位定位修正。需要看实际像素时用 read_output_screen(其 page 从 0 编号)。可用 native_catalog 查命令并用 native_call 改冲突文字层、结构线、引线和尺寸标注。已映射文字也可用 write_copy_fields。图文不一致时,按商品资料选择修正文案、裁切或调整构图、围绕卖点重做图片。修正后仅将受影响的屏重新交给 check_output_screens。
需要独立观察结果的工具(如 open_production_output、read_output_screen、await_image_slots、finish_production)单独调用。多项连续查目录、批量采纳、批量回填文案及图层隐藏、选择、变换、样式修正等确定性操作,优先合并在一次 codemode 脚本中依次 await,使用各步实际回执衔接后续操作。

View File

@ -96,8 +96,10 @@ export async function callProductionTool(host, name, args, signal) {
if (name==='plan_production') {
const {id,name,version,productionRoute}=goal.template??{};
const {product,dimensions,note}=host.productEvidence??{};
const knowledge=productionKnowledge(host.productionSkills?.knowledge??host.knowledgeContext);
return {requestedOutputs:goal.requestedOutputs,pendingOutputs:goal.pendingOutputs,
workingOutput:null,template:{id,name,version,productionRoute},product:{...product,dimensions,note}};
workingOutput:null,template:{id,name,version,productionRoute},product:{...product,dimensions,note},
knowledgeFiles:knowledge.files};
}
if (name==='read_production_knowledge') {
const knowledge=productionKnowledge(host.productionSkills?.knowledge??host.knowledgeContext);

View File

@ -78,7 +78,7 @@ const dispatchArgs={requestId:text,expectedRevision:optional(rev),expectedHash:o
export const productionOperationTools = [
['open_production_output','打开本轮指定输出和花色。切换前保存原工程,返回保存结果、新画布绑定及待交付项。用 plan_production 获取输出和花色。收到绑定回执后再操作画布。',obj({outputId:text,variantId:text})],
['plan_production','读取当前商品规格与备注、模板、图位和本轮其它待处理输出。按 slotIds 读取指定图位的规则和要求。模板规则从项目 Skill 及其引用读取。调用图位工具时优先使用 pictures 中的 fieldId。',obj({slotIds:optional(ids)})],
['plan_production','读取当前商品规格与备注、模板、图位和本轮其它待处理输出。按 slotIds 读取指定图位的规则和要求。模板规则从项目 Skill 及其引用读取。pictures 中的 copyReady 表示关联字段没有待写文案。调用图位工具时优先使用 pictures 中的 fieldId。',obj({slotIds:optional(ids)})],
['read_production_knowledge','读取当前阶段固定版本的制作规则,按回执的 nextOffset 翻页。'+knowledgeFileIdInstruction,obj({fileId:text,offset:optional(page)})],
['read_copy_fields','省略 pageId 和 fieldId 可一次读取全页文案字段、当前文字及修订号。需要模板样稿与发布要求时,指定 pageId 或 fieldId 读取对应范围。',obj({
pageId:optional(Type.String()),fieldId:optional(Type.String()),
@ -93,7 +93,7 @@ export const productionOperationTools = [
['transform_slot_image','在本机裁切、镜像、旋转、缩放或位移同图位或跨图位候选及本款实拍,返回新候选和像素清晰度指标。',obj({slotId:slotRef,...transformImageArgs})],
['prepare_image_request','保存完整生图请求,返回正式文本、参考顺序、模型参数与请求编号。'+imagePromptGuidance,obj({slotId:slotRef,...preparationArgs})],
['dispatch_image_request','审阅准备回执后填写 requestId 确认派发。宿主从该编号绑定的请求读取版本和哈希。使用 await_image_slots 或 review_image_slots 查看实际结果。'+DRAW_LIMIT_GUIDANCE,obj(dispatchArgs)],
['delegate_image_slots','异步分派一批图位,空闲的制作助手立即开始,其余图位顺序排队。每确认一小批卖点与文案即可分派对应图位,后台制作期间可继续写下一批。每个 goal 写明对应屏的核心卖点与画面要证明的细节。每个图位单独返回已接收或无法定位的结果。',obj({
['delegate_image_slots','异步分派一批图位,空闲的制作助手立即开始,其余图位顺序排队。每个 goal 写明对应屏的核心卖点与画面要证明的细节。逐图位返回接收情况及关联的待写文案字段。',obj({
jobs:Type.Array(obj({slotId:slotRef,goal:text,reworkCandidateId:optional(Type.String({description:'返工时,指定之前被退回的候选号。'}))})),
})],
['await_image_slots','等待正在运行的制作或验图返回,并读取已有回执。省略 slotIds 时同时等待按屏复核,结论见 screenChecks。已经返回结果未知的原请求用 reconcile_image_slots 核查。',obj({slotIds:optional(ids)})],
@ -489,6 +489,13 @@ export async function openProductionOperations(host,{maxActiveDelegates=6,maxGen
const snapshot=await canvas.detailCopyFields?.({includeFilled:true});
return Array.isArray(snapshot)?{fields:snapshot}:snapshot??{};
};
const pendingCopyBySlot=async selected=>{
const linked=selected.filter(slot=>slot.relatedFields?.length);
if(!linked.length)return new Map();
const pending=await canvas.detailCopyFields({includeFilled:false});
return new Map(linked.map(slot=>[slot.id,pending.filter(row=>slot.relatedFields.includes(row.field))
.map(({field,label,currentText})=>({fieldId:field,label,currentText}))]));
};
const liveSlotCopy=async slot=>{
const {fields:copyFields,pages}=await copySnapshot();
const journalCopy=Object.values(evidenceMatches(plan)?journal.copyEvidence??{}:{});
@ -950,9 +957,10 @@ export async function openProductionOperations(host,{maxActiveDelegates=6,maxGen
const variant=variants?.find(row=>row.id===variantId);
const selected=(await liveSlots()).filter(slot=>!requested.size||matched.has(slot.id));
const statuses=drawStatuses(selected);
const pendingCopy=await pendingCopyBySlot(selected);
const pictures=selected.map(slot=>{
const {id,fieldId,label,productionRule,requirements,sourcePolicy}=slot;
return {id,fieldId,label,...statuses.get(id),
return {id,fieldId,label,...statuses.get(id),copyReady:!pendingCopy.get(id)?.length,
...(requested.size?{productionRule,requirements,sourcePolicy}:null)};
});
const {production,...template}=plan.template;
@ -1089,11 +1097,13 @@ export async function openProductionOperations(host,{maxActiveDelegates=6,maxGen
async delegate_image_slots({jobs:requested},signal){
const assigned=[],unmatched=[];
const statuses=drawStatuses(await liveSlots());
for(const {slotId,goal,reworkCandidateId} of requested){
const slot=findSlot(slotId);
const resolved=requested.map(job=>({...job,slot:findSlot(job.slotId)}));
const pendingCopy=await pendingCopyBySlot(resolved.map(job=>job.slot).filter(Boolean));
for(const {slotId,goal,reworkCandidateId,slot} of resolved){
if(!slot){unmatched.push({slotId,reason:slotNotFound});continue;}
const workerId='delegate:'+slot.id;
const status=statuses.get(slot.id);
const pendingCopyFields=pendingCopy.get(slot.id);
const status={...statuses.get(slot.id),...(pendingCopyFields?.length?{pendingCopyFields}:null)};
if(slotWorking(slot.id)){assigned.push({id:slot.id,state:'already_running',...status});continue;}
const row={number:nextWorkerNumber(),slotId:slot.id,label:slot.label,step:'排队中',active:true};
let rework, produced=false;
@ -1201,7 +1211,8 @@ export async function openProductionOperations(host,{maxActiveDelegates=6,maxGen
assigned.push({id:slot.id,state:'assigned',...status});
}
if(delegateQueue.length)notice('图位已排队');
return {assigned,...(unmatched.length?{unmatched}:{})};
return {assigned,...(unmatched.length?{unmatched}:null),
...(assigned.some(row=>row.pendingCopyFields)?{copyContext:'子代理按本屏实时已写文案理解卖点和验图。待写字段仍为模板原文或空白,写进 goal 的模板原文会作为制作要求传给子代理。'}:null)};
},
async await_image_slots({slotIds}){
const wanted=new Set(selections(slotIds).map(slot=>slot.id));

View File

@ -580,6 +580,24 @@ test('an unbound production turn checks project originals without opening any wo
assert.equal(goal.outputId,undefined);
});
test('the unbound production plan lists the same readable knowledge files as the bound plan',async t=>{
const {host}=await tailFixture(t,['hero']);
const boundGoal=host.productionGoal;
host.productionGoal={requestedOutputs:[boundGoal],pendingOutputs:[boundGoal]};
host.productionSkills={knowledge:{skills:[{
fileId:'released-file',revision:'r3',path:'production/SKILL.md',kind:'skill',loadText:async()=>'以本款事实为依据',
}]}};
const plan=await callProductionTool(host,'plan_production',{});
assert.equal(plan.workingOutput,null);
assert.deepEqual(plan.knowledgeFiles,[{fileId:'released-file',revision:'r3',path:'production/SKILL.md',kind:'skill'}]);
const {text}=await callProductionTool(host,'read_production_knowledge',{fileId:plan.knowledgeFiles[0].fileId});
assert.equal(text,'以本款事实为依据');
host.productionGoal=boundGoal;
const actions=await openProductionOperations(host);
t.after(()=>actions.close());
assert.deepEqual((await actions.plan_production()).knowledgeFiles,plan.knowledgeFiles);
});
test('P07 waits for both candidate reviews and persists the automatic adoption decision',async t=>{
for(const scenario of [
{verdicts:['pass','revise'],winner:0,reason:'only_pass',recoverA:true},
@ -607,7 +625,7 @@ test('P07 waits for both candidate reviews and persists the automatic adoption d
workflowRead:async()=>({available:true,canvasFirst:true,outputId:'detail',productVariantId:'oak',
template:{contentHash:'studio',production:{autoAdoptionPolicy:policy}},totalSlots:1,
slots:[{id:slotId,fieldId:'cover',documentId:'P07',relatedFields:['title']}]}),
detailCopyFields:async()=>({fields:[{page:'P07',field:'title',currentText}]}),
detailCopyFields:async({includeFilled})=>includeFilled?{fields:[{page:'P07',field:'title',currentText}]}:[],
async delta(_text,_thinking,{heading}){if(heading==='画布回填回执')placed.resolve();},
async detailRecover(recoveredSlot,{candidateId}){
assert.equal(recoveredSlot,slotId);
@ -778,6 +796,48 @@ test('a malformed slot reference does not strand the other explicitly delegated
assert.deepEqual(await actions.delegate_image_slots({jobs:[]}),{assigned:[]});
});
test('plans and delegate receipts report only linked pending copy and enqueue every requested slot',async t=>{
const {host}=await tailFixture(t,[]);
const slots=[
{id:'front',fieldId:'front-image',documentId:'front',relatedFields:['title','tagline','detail-image']},
{id:'detail',fieldId:'detail-image',documentId:'detail',relatedFields:['caption']},
{id:'photo',fieldId:'photo-image',documentId:'front',relatedFields:[]},
];
const title={field:'title',label:'标题',page:'front',currentText:'模板原文',templateSample:true};
const tagline={field:'tagline',label:'副标题',page:'front',currentText:''};
const unrelated={field:'note',label:'说明',page:'front',relatedFields:['front-image'],currentText:''};
const caption={field:'caption',label:'细节说明',page:'detail',currentText:'榫接结构'};
const pending=[title,tagline,unrelated];
const fields=[...pending,caption];
const started=[];
const workflowRead=host.canvas.workflowRead;
host.canvas.workflowRead=async()=>({...await workflowRead(),totalSlots:slots.length,slots});
host.canvas.detailCopyFields=async({includeFilled})=>includeFilled
?{fields,pages:['front','detail']}:pending;
host.runDetailAgent=async (id,_instructions,input)=>started.push([id,JSON.parse(input).screenCopy.map(row=>row.text)]);
const actions=await openProductionOperations(host);
t.after(()=>actions.close());
const readiness=async()=>Object.fromEntries((await actions.plan_production()).pictures.map(row=>[row.id,row.copyReady]));
assert.deepEqual(await readiness(),{front:false,detail:true,photo:true});
const receipt=await actions.delegate_image_slots({jobs:slots.map(({fieldId})=>({slotId:fieldId,goal:'展示本款实拍细节'}))});
assert.deepEqual(receipt.assigned.map(({id,state,pendingCopyFields})=>({id,state,pendingCopyFields})),[
{id:'front',state:'assigned',pendingCopyFields:[
{fieldId:'title',label:'标题',currentText:'模板原文'},
{fieldId:'tagline',label:'副标题',currentText:''},
]},
{id:'detail',state:'assigned',pendingCopyFields:undefined},
{id:'photo',state:'assigned',pendingCopyFields:undefined},
]);
assert.match(receipt.copyContext,/实时已写文案.*goal 的模板原文/);
await Promise.all(slots.map(({id})=>actions.await_image_slots({slotIds:[id]})));
assert.deepEqual(started.sort(([a],[b])=>a.localeCompare(b)),[['detail',['榫接结构']],['front',[]],['photo',[]]]);
Object.assign(title,{currentText:'实木餐椅',templateSample:false});
tagline.currentText='弧形靠背';
pending.splice(0,2);
assert.deepEqual(await readiness(),{front:true,detail:true,photo:true});
});
test('a rework delegate sees the rejected image, exact previous prompt and review before sending a changed request',async t=>{
const dir=await fs.mkdtemp(path.join(os.tmpdir(),'jiansun-pi-'));
t.after(()=>cleanup(dir));

View File

@ -74,7 +74,9 @@ test('production review guidance covers copy, images and overlays followed by vi
assert.doesNotMatch(copy, technicalBrand, name);
}
assert.match(prompt, /read_copy_fields 省略 pageId 和 fieldId 即可一次读取全页文案字段/);
assert.match(prompt, /每确认一小批[^。]*write_copy_fields[^。]*delegate_image_slots[^。]*。子代理在后台制作时[^。]*后续批次[^。]*按屏复核/);
assert.match(prompt, /子代理生图和验图读取本屏实时文案[^。]*回执绑定当时的文案签名/);
assert.match(prompt, /建议每批选 1–3 屏[^。]*write_copy_fields[^。]*delegate_image_slots[^。]*生图期间写下一批/);
assert.match(prompt, /分派 goal[^。]*避免引用画布上尚未更新的模板原文/);
const knowledge = productionTools.find(([name]) => name === 'read_production_knowledge')?.[1];
assert.match(knowledge, /fileId 必须取自 knowledgeFiles[^。]*不能传模板编号/);
for (const guidance of ['IMAGE_COPY_CRITERIA', 'COPY_IMAGE_REVIEW_GUIDANCE']) {

View File

@ -244,3 +244,5 @@ R12 续跑首条推理准备 7.674 秒,首次采用 15 分 22 秒。117 笔模
| 模板缺少发布许可 | 旧架构 A03 写着无许可即拦。按后来产品要求,未发布许可时原生命令默认允许并记录。发布了具体范围时按模板声明执行 |
| 商品标注的 Skill 规则 | 现有家具 Skill 将指示线配套的文字、尺寸和材质列为人工后期。R6 的 Pi 自行隐藏两组旧标注,副本上仍有独立的旧材质与质保说明。可在正式企业资源明确无人值守对旧字样的更新、留空或隐藏规则,现有发布资源继续使用原版本 |
| 电脑桌本款尺寸 | R20 按 SZ012616 查正式知识库未找到对应文件。当前字段范围和已发布的退役记录均未覆盖草稿里仍显示的三处固定旧规格。补本款正式规格表,或在模板发布物明确这些旧数字与标线在缺值时允许隐藏,再续做详情并验收三类输出。见 `batch-09/desk-linked-skill-r20/desk-spec-and-fixed-layers.json` |
- R4 · 开画布前的制作计划列出可读的固定版本规则文件。画布计划返回图位关联文案就绪状态,派发回执列出宿主标记待写的关联文字并按请求排队。小壹根据实时文案和验图依据自主安排制作批次。