From 4c8ed7fe7e57167e2f15da6bedbec84fd26805cd Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Fri, 27 Nov 2026 22:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=94=E7=A6=BB=E5=B0=8F=E5=A3=B9=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E4=BB=A3=E7=90=86=E7=9A=84=E6=8A=80=E8=83=BD=E6=9D=A5?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/photocraft-extension.mjs | 3 ++- .../detail-agent-pi/test/native-wire.test.mjs | 4 +-- apps/detail-agent-pi/test/pi.test.mjs | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/detail-agent-pi/src/photocraft-extension.mjs b/apps/detail-agent-pi/src/photocraft-extension.mjs index 8eafaae7..249b3cd6 100644 --- a/apps/detail-agent-pi/src/photocraft-extension.mjs +++ b/apps/detail-agent-pi/src/photocraft-extension.mjs @@ -44,7 +44,8 @@ export async function createPhotoCraftExtensions(host, existing = [], { noExtensions: true, noThemes: true, noContextFiles: true, additionalExtensionPaths: includeGoal ? [path.join(goalPackage, '.pi', 'extensions', 'pi-goal', 'index.ts')] : [], additionalSkillPaths: includeGoal ? [path.join(goalPackage, 'skills'), productionSkills] : [], - noSkills: !includeProjectResources, noPromptTemplates: !includeProjectResources, + noSkills: includeGoal || !includeProjectResources, + noPromptTemplates: !includeProjectResources, systemPromptOverride: () => systemPrompt, appendSystemPrompt: [], extensionsOverride: result => ({...result, extensions:[...existing, ...result.extensions]}), diff --git a/apps/detail-agent-pi/test/native-wire.test.mjs b/apps/detail-agent-pi/test/native-wire.test.mjs index 19441a5f..af367d7a 100644 --- a/apps/detail-agent-pi/test/native-wire.test.mjs +++ b/apps/detail-agent-pi/test/native-wire.test.mjs @@ -1227,7 +1227,7 @@ test('reading a fresh production goal never starts the strategy, image workers, assert.equal((await host.productionOperations).active,0); }); -test('production loads the project’s native skill and prompt template', async t => { +test('production loads project prompt templates without discovering project skills', async t => { const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'pi-recovery-project-resources-')); t.after(() => cleanup(dir)); const cwd = path.join(dir, 'workspace'); @@ -1240,7 +1240,7 @@ test('production loads the project’s native skill and prompt template', async await fs.writeFile(path.join(promptDir, 'fixture-copy.md'), '---\ndescription: Write a fixture headline.\n---\nDescribe the work surface.'); const {resourceLoader} = await createPhotoCraftExtensions({workingDirectory: cwd, store: {dir}}, [], {includeGoal: true}); - assert.ok(resourceLoader.getSkills().skills.some(skill => skill.name === 'desk-copy')); + assert.ok(!resourceLoader.getSkills().skills.some(skill => skill.name === 'desk-copy')); assert.equal(resourceLoader.getPrompts().prompts.find(prompt => prompt.name === 'fixture-copy')?.content, 'Describe the work surface.'); }); diff --git a/apps/detail-agent-pi/test/pi.test.mjs b/apps/detail-agent-pi/test/pi.test.mjs index 27ca5598..2546b5de 100644 --- a/apps/detail-agent-pi/test/pi.test.mjs +++ b/apps/detail-agent-pi/test/pi.test.mjs @@ -96,12 +96,15 @@ test('Pi production and its worker read the same locked Skill and its relative r productEvidence:{accountScope:id.scope,project:id.project,documentId,brief:{brandName:'试验品牌',categoryName:'灯具'}}})}; let main=0,worker=0,serial=0; const reads=new Map(); + const skillLists=new Map(); const transport={info:info(id.scope),stream(_model,context){ const system=getCurrentSystemPrompt(context.messages); assert.match(system,/lighting<\/name>/); assert.doesNotMatch(system,/PINNED_FINISH|Use the \[fixture notes\]/); const location=system.match(/lighting<\/name>[\s\S]*?([^<]*SKILL\.md)<\/location>/u)[1]; const child=system.includes('完成主代理委托的图位'); + const skillList=system.match(/[\s\S]*?<\/available_skills>/u)[0]; + skillLists.set(child?'worker':'main',[...skillList.matchAll(/([^<]+)<\/name>/gu)].map(match=>match[1]).sort()); const steps=child?[ ['read',{path:location}], ['read',{path:path.join(path.dirname(location),'references','finish.md')}], @@ -120,6 +123,24 @@ test('Pi production and its worker read the same locked Skill and its relative r return step?stream([{type:'toolCall',name:step[0],id:'skill-'+(++serial),arguments:step[1]}]): stream([{type:'text',text:'本轮结束。'}]); }}; + const home=path.join(dir,'home'); + for(const [base,name] of [ + [path.join(home,'.agents','skills'),'personal-skill'], + [path.join(store.dir,'skills'),'global-skill'], + [path.join(store.dir,'workspace','.pi','skills'),'workspace-skill'], + ]){ + const skillDir=path.join(base,name); + await fs.mkdir(skillDir,{recursive:true}); + await fs.writeFile(path.join(skillDir,'SKILL.md'),`---\nname: ${name}\ndescription: An unbound test skill.\n---\nFixture only.`); + } + for(const key of ['HOME','USERPROFILE']){ + const previous=process.env[key]; + process.env[key]=home; + t.after(()=>{ + if(previous===undefined) delete process.env[key]; + else process.env[key]=previous; + }); + } const host=await DetailPiAgent.open({store,canvas,transport,documentId,productionGoal:{outputId:'detail',variantId,workspaceId:randomUUID(),requestedOutputs:[{outputId:'detail',variantId}],skillRunDeadline:runDeadline}}); let loads=0; const documents=[]; @@ -133,6 +154,10 @@ test('Pi production and its worker read the same locked Skill and its relative r host.enterpriseContext.load=async()=>{loads++;return knowledge;}; try { assert.equal((await host.prompt('制作详情页')).production.complete,true); + await t.test('production prompts only list bound and bundled skills',()=>{ + const expected=['lighting','pi-goal-writer','product-image-sources']; + assert.deepEqual(Object.fromEntries(skillLists),{main:expected,worker:expected}); + }); const context=await host.modelContext({}, {loadKnowledge:true}); assert.deepEqual(context.enterpriseKnowledge.sources.map(row=>row.revision),['r4','r7']); assert.equal(loads,1,'read-only context uses the original locked selection');