@aipt/cli 0.1.23 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -237,7 +237,7 @@ ${c.map(l=>` ${l}`).join(`
237
237
  `)}async function ey(e){let t=await Xh(Ve.resolve(e.projectRoot)),r=await Zh(t),n=Ve.relative(r,t).split(Ve.sep).join("/");if(!n||n.startsWith("../"))throw new ut("WORKSPACE_TOPOLOGY_OWNER_MISSING");let o=await zo(Ve.join(t,"pnpm-lock.yaml")),i=await zo(Ve.join(t,"pnpm-workspace.yaml"));if(!o&&!i)throw new ut("WORKSPACE_TOPOLOGY_MIGRATION_REQUIRED");let a=await Jo(Ve.join(r,"pnpm-lock.yaml")),s=await Jo(Ve.join(r,"pnpm-workspace.yaml"));if(!M0(a.toString("utf8"),n))throw new ut("WORKSPACE_TOPOLOGY_IMPORTER_MISSING");if(i&&!/^packages:\s*\[\]/mu.test(i.toString("utf8")))throw new ut("WORKSPACE_TOPOLOGY_PREIMAGE_CONFLICT");let c=i?Qh(s,i):s,l=[...y(c)!==y(s)?[{path:"pnpm-workspace.yaml",kind:"replace",ownership:"owned-file",baseDigest:y(s),desiredDigest:y(c)}]:[],...o?[{path:`${n}/pnpm-lock.yaml`,kind:"remove",ownership:"owned-file",baseDigest:y(o)}]:[],...i?[{path:`${n}/pnpm-workspace.yaml`,kind:"remove",ownership:"owned-file",baseDigest:y(i)}]:[]],d=e.generatedAt??new Date().toISOString(),p=e.expiresAt??new Date(Date.parse(d)+30*6e4).toISOString(),f=ke({action:"upgrade",capability:{schemaVersion:1,capabilityId:"foundation.workspace-topology-migration",version:"1.0.0",integrity:y("foundation.workspace-topology-migration@1.0.0"),assets:[],verifiers:[]},changes:l,observedAssets:l.map(m=>({path:m.path,exists:!0,digest:m.baseDigest})),generatedAt:d,expiresAt:p});return{plan:await Mt({projectRoot:t,transactionRoot:r,plan:f,now:d}),transactionRoot:r}}async function ty(e){let t=await Xh(Ve.resolve(e.projectRoot)),r=await Zh(t),n=await jr({projectRoot:t,planId:e.approvedPlanId});if(n.capability.capabilityId!=="foundation.workspace-topology-migration"||n.state!=="reviewable")throw new ut("WORKSPACE_TOPOLOGY_PREIMAGE_CONFLICT");let o=new Map,i=n.operations.find(c=>c.path==="pnpm-workspace.yaml"&&c.kind==="replace");if(i){let c=await Jo(Ve.join(t,"pnpm-workspace.yaml")),l=await Jo(Ve.join(r,"pnpm-workspace.yaml")),d=Qh(l,c);if(y(d)!==i.desiredDigest)throw new ut("WORKSPACE_TOPOLOGY_PREIMAGE_CONFLICT");o.set("pnpm-workspace.yaml",d)}let a=await ir({projectRoot:r,plan:n,approvedPlanId:e.approvedPlanId,desiredContents:o,now:e.now??new Date().toISOString()}),s=await ar(a);return{planId:n.planId,transactionRoot:r,transaction:s}}import{createInterface as U0}from"node:readline";import Ba from"node:process";var F0=[{name:"dyyto_catalog_search",title:"\u641C\u7D22 Dyyto \u5DE5\u7A0B\u80FD\u529B\u76EE\u5F55",description:"\u641C\u7D22\u7ECF\u8FC7\u5B8C\u6574\u6027\u6821\u9A8C\u7684\u6700\u65B0 Capability \u4E0E PackageRelease\uFF1B\u4E0D\u4F1A\u4FEE\u6539\u9879\u76EE\u3002",inputSchema:{type:"object",properties:{query:{type:"string",description:"\u540D\u79F0\u3001\u8BF4\u660E\u6216\u6210\u719F\u5EA6\u5173\u952E\u8BCD\uFF1B\u7559\u7A7A\u65F6\u5217\u51FA\u5168\u90E8\u3002"},kind:{type:"string",enum:["package","capability"],description:"\u53EF\u9009\u7684\u8D44\u4EA7\u7C7B\u578B\u3002"},limit:{type:"integer",minimum:1,maximum:200,default:50}},additionalProperties:!1}},{name:"dyyto_catalog_show",title:"\u8BFB\u53D6 Dyyto \u53D1\u884C\u4E8B\u5B9E",description:"\u6309\u4E0D\u53EF\u53D8 ref \u8BFB\u53D6\u5B8C\u6574 Capability \u6216 PackageRelease\u3002",inputSchema:{type:"object",properties:{ref:{type:"string",description:"\u4F8B\u5982 package:@aipt/platform-kernel@0.1.0\u3002"}},required:["ref"],additionalProperties:!1}}];function Rd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function za(e,t){return{jsonrpc:"2.0",id:e,result:t}}function Go(e,t,r){return{jsonrpc:"2.0",id:e,error:{code:t,message:r}}}async function q0(e,t){let r=e.id??null;if(e.method==="notifications/initialized")return null;if(e.method==="initialize")return za(r,{protocolVersion:"2025-06-18",capabilities:{tools:{listChanged:!1}},serverInfo:{name:"dyyto-catalog",version:On},instructions:"\u8FD9\u662F\u53EA\u8BFB\u5DE5\u7A0B\u80FD\u529B\u76EE\u5F55\u3002\u5148\u641C\u7D22\uFF0C\u518D\u7528\u4E0D\u53EF\u53D8 ref \u8BFB\u53D6\u53D1\u884C\u4E8B\u5B9E\u3002"});if(e.method==="tools/list")return za(r,{tools:F0});if(e.method!=="tools/call")return Go(r,-32601,`\u4E0D\u652F\u6301\u7684\u65B9\u6CD5\uFF1A${e.method}`);if(!Rd(e.params)||typeof e.params.name!="string"||e.params.arguments!==void 0&&!Rd(e.params.arguments))return Go(r,-32602,"tools/call \u53C2\u6570\u65E0\u6548");let n=e.params.arguments??{};try{let o;if(e.params.name==="dyyto_catalog_search"){if(n.query!==void 0&&typeof n.query!="string")throw new Error("query \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");if(n.kind!==void 0&&n.kind!=="package"&&n.kind!=="capability")throw new Error("kind \u53EA\u63A5\u53D7 package \u6216 capability");if(n.limit!==void 0&&(!Number.isSafeInteger(n.limit)||Number(n.limit)<1||Number(n.limit)>200))throw new Error("limit \u5FC5\u987B\u662F 1 \u5230 200 \u7684\u6574\u6570");o=await Da({...typeof n.query=="string"?{query:n.query}:{},...n.kind==="package"||n.kind==="capability"?{kind:n.kind}:{},...typeof n.limit=="number"?{limit:n.limit}:{},...t===void 0?{}:{roots:t}})}else if(e.params.name==="dyyto_catalog_show"){if(typeof n.ref!="string"||n.ref.trim()==="")throw new Error("ref \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");o=await ja({ref:n.ref,...t===void 0?{}:{roots:t}})}else return Go(r,-32602,`\u672A\u77E5\u5DE5\u5177\uFF1A${e.params.name}`);return za(r,{content:[{type:"text",text:JSON.stringify(o)}],structuredContent:o})}catch(o){let i=o instanceof Error?o.message:"Catalog \u5DE5\u5177\u6267\u884C\u5931\u8D25";return za(r,{isError:!0,content:[{type:"text",text:i}]})}}async function ry(){let e=U0({input:Ba.stdin,crlfDelay:1/0,terminal:!1});for await(let t of e){if(t.trim()==="")continue;let r;try{let o=JSON.parse(t);if(!Rd(o)||o.jsonrpc!=="2.0"||typeof o.method!="string"){Ba.stdout.write(`${JSON.stringify(Go(null,-32600,"JSON-RPC \u8BF7\u6C42\u65E0\u6548"))}
238
238
  `);continue}r=o}catch{Ba.stdout.write(`${JSON.stringify(Go(null,-32700,"JSON \u89E3\u6790\u5931\u8D25"))}
239
239
  `);continue}let n=await q0(r);n!==null&&Ba.stdout.write(`${JSON.stringify(n)}
240
- `)}}import{createHash as B0}from"node:crypto";import{chmod as z0,lstat as J0,mkdir as G0,readFile as Ga,realpath as ny,rename as W0,unlink as K0,writeFile as Y0}from"node:fs/promises";import Be from"node:path";var _d="1.0.0",Gt=Object.freeze({"@aipt/cli":"0.1.23","@aipt/idp-cli":"0.1.2","@aipt/idp-deploy":"0.1.5"}),oy=Object.entries(Gt).map(([e,t])=>`${e}@${t}`),Ed="<!-- dyyto:agent-policy:start -->",Wo="<!-- dyyto:agent-policy:end -->",He=class extends Error{constructor(r,n){super(n);this.code=r}code},Ye=e=>`sha256:${B0("sha256").update(e).digest("hex")}`,Nn=e=>Array.isArray(e)?`[${e.map(Nn).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>`${JSON.stringify(t)}:${Nn(r)}`).join(",")}}`:JSON.stringify(e),Ja=`${Ed}
240
+ `)}}import{createHash as B0}from"node:crypto";import{chmod as z0,lstat as J0,mkdir as G0,readFile as Ga,realpath as ny,rename as W0,unlink as K0,writeFile as Y0}from"node:fs/promises";import Be from"node:path";var _d="1.0.0",Gt=Object.freeze({"@aipt/cli":"0.1.24","@aipt/idp-cli":"0.1.3","@aipt/idp-deploy":"0.1.6"}),oy=Object.entries(Gt).map(([e,t])=>`${e}@${t}`),Ed="<!-- dyyto:agent-policy:start -->",Wo="<!-- dyyto:agent-policy:end -->",He=class extends Error{constructor(r,n){super(n);this.code=r}code},Ye=e=>`sha256:${B0("sha256").update(e).digest("hex")}`,Nn=e=>Array.isArray(e)?`[${e.map(Nn).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>`${JSON.stringify(t)}:${Nn(r)}`).join(",")}}`:JSON.stringify(e),Ja=`${Ed}
241
241
  ## Dyyto \u5DE5\u7A0B\u80FD\u529B\u5E73\u53F0
242
242
 
243
243
  \u672C\u9879\u76EE\u7531 Dyyto \u7EB3\u7BA1\u3002\u5F00\u59CB\u7F16\u7801\u524D\u6267\u884C \`dyyto context --project .\` \u4E0E \`dyyto doctor --project .\`\u3002
@@ -264,7 +264,7 @@ description: \u5728Dyyto\u7EB3\u7BA1\u9879\u76EE\u4E2D\u5F00\u53D1\u3001\u6539\u
264
264
  ---`],[".claude/skills/dyyto-engineering/SKILL.md",`---
265
265
  name: dyyto-engineering
266
266
  description: \u5728Dyyto\u7EB3\u7BA1\u9879\u76EE\u4E2D\u5F00\u53D1\u3001\u6539\u9020\u3001\u9A8C\u8BC1\u6216\u90E8\u7F72\u65F6\u4F7F\u7528\u3002
267
- ---`]];async function Pd(e){if(!Be.isAbsolute(e))throw new He("BOOTSTRAP_PROJECT_NOT_ABSOLUTE","--project\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\u3002");let t=await ny(e),r=await J0(t);if(!r.isDirectory()||r.isSymbolicLink())throw new He("BOOTSTRAP_PROJECT_INVALID","\u9879\u76EE\u5FC5\u987B\u662F\u666E\u901A\u76EE\u5F55\u3002");return t}async function Wr(e){return Ga(e,"utf8").catch(t=>t.code==="ENOENT"?"":Promise.reject(t))}async function Wa(e,t){await G0(Be.dirname(e),{recursive:!0,mode:448});let r=`${e}.candidate-${process.pid}`;await Y0(r,t,{mode:384,flag:"wx"}),await W0(r,e),await z0(e,e.endsWith(".json")?384:420)}function Z0(){return[{id:"engineering-workflow",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/engineering-workflow.md",contentDigest:"sha256:a998adc964edea5ab17eadfeeb14f8503fe4a3636e4e6bae7c19aa56ee1baa21"},{id:"vibe-coding-guide",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/vibe-coding-guide.md",contentDigest:"sha256:e630a00032f05a639f2f09b484026c93a356fcefddd56aaf95d3b0bf4e224902"},{id:"toolchain-troubleshooting",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/troubleshooting.md",contentDigest:"sha256:8d46b5486e532a4a5739d4bfd2675abf9de487681d91155e889fbf4cb8186208"},{id:"idp-integration",package:"@aipt/idp-cli",version:Gt["@aipt/idp-cli"],path:"docs/integration.md",contentDigest:"sha256:ad16f812d516763140c14efe8a0afb275b420987d23e0d6071fbbb7312b7324c"},{id:"local-deployment",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/local-deployment.md",contentDigest:"sha256:4d86d7e7ed8619fa750430989afefe71e033673adedb924bb60b4272d7d2e3f6"},{id:"application-config-workspace",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/application-config-workspace.md",contentDigest:"sha256:d5ae60d7ef71422721b9fe34aaf11ad118d7e4a9ffacd9832aa69c259ef927f8"},{id:"idpctl-troubleshooting",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/troubleshooting.md",contentDigest:"sha256:db2f18eb19fb98e81edf6ea2789fcd72c5158d733a7e93b9fe9f1c34c4632d10"}].map(e=>({...e,referenceDigest:Ye(Nn(e))}))}async function iy(e){let t=await Pd(e),r=[];for(let[p,f]of Ad){let u=await Wr(Be.join(t,p)),m=H0(u,f);r.push({path:p,preimageDigest:Ye(u),desired:m,desiredDigest:Ye(m)})}let n=`${JSON.stringify({schemaVersion:1,kind:"DyytoToolchainLock",packageManager:"pnpm",tools:Gt},null,2)}
267
+ ---`]];async function Pd(e){if(!Be.isAbsolute(e))throw new He("BOOTSTRAP_PROJECT_NOT_ABSOLUTE","--project\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\u3002");let t=await ny(e),r=await J0(t);if(!r.isDirectory()||r.isSymbolicLink())throw new He("BOOTSTRAP_PROJECT_INVALID","\u9879\u76EE\u5FC5\u987B\u662F\u666E\u901A\u76EE\u5F55\u3002");return t}async function Wr(e){return Ga(e,"utf8").catch(t=>t.code==="ENOENT"?"":Promise.reject(t))}async function Wa(e,t){await G0(Be.dirname(e),{recursive:!0,mode:448});let r=`${e}.candidate-${process.pid}`;await Y0(r,t,{mode:384,flag:"wx"}),await W0(r,e),await z0(e,e.endsWith(".json")?384:420)}function Z0(){return[{id:"engineering-workflow",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/engineering-workflow.md",contentDigest:"sha256:a998adc964edea5ab17eadfeeb14f8503fe4a3636e4e6bae7c19aa56ee1baa21"},{id:"vibe-coding-guide",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/vibe-coding-guide.md",contentDigest:"sha256:e630a00032f05a639f2f09b484026c93a356fcefddd56aaf95d3b0bf4e224902"},{id:"toolchain-troubleshooting",package:"@aipt/cli",version:Gt["@aipt/cli"],path:"docs/troubleshooting.md",contentDigest:"sha256:8d46b5486e532a4a5739d4bfd2675abf9de487681d91155e889fbf4cb8186208"},{id:"idp-integration",package:"@aipt/idp-cli",version:Gt["@aipt/idp-cli"],path:"docs/integration.md",contentDigest:"sha256:69c08c13cc326a9779799320edb1399226fb0f186e6897477665c1c46da2220c"},{id:"local-deployment",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/local-deployment.md",contentDigest:"sha256:ec78ed0fa4bfc0973c8cc93263a3f48a4a5aaf148d677cced2b45f636d8e1c77"},{id:"application-config-workspace",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/application-config-workspace.md",contentDigest:"sha256:9217b59ab06cc2039c5b0a95ef4628b89116df94cce7627c9892feb7d70cc798"},{id:"idpctl-troubleshooting",package:"@aipt/idp-deploy",version:Gt["@aipt/idp-deploy"],path:"docs/troubleshooting.md",contentDigest:"sha256:db2f18eb19fb98e81edf6ea2789fcd72c5158d733a7e93b9fe9f1c34c4632d10"}].map(e=>({...e,referenceDigest:Ye(Nn(e))}))}async function iy(e){let t=await Pd(e),r=[];for(let[p,f]of Ad){let u=await Wr(Be.join(t,p)),m=H0(u,f);r.push({path:p,preimageDigest:Ye(u),desired:m,desiredDigest:Ye(m)})}let n=`${JSON.stringify({schemaVersion:1,kind:"DyytoToolchainLock",packageManager:"pnpm",tools:Gt},null,2)}
268
268
  `,o=`${JSON.stringify({schemaVersion:1,kind:"AgentPolicyLock",policy:{id:"dyyto.engineering",version:_d,digest:Ye(Ja)},adapters:Ad.map(([p])=>p)},null,2)}
269
269
  `,i=`${JSON.stringify({schemaVersion:1,kind:"DocumentationLock",documents:Z0()},null,2)}
270
270
  `;for(let[p,f]of[[".dyyto/toolchain.lock.json",n],[".dyyto/agent-policy.lock.json",o],[".dyyto/documentation.lock.json",i]]){let u=await Wr(Be.join(t,p));r.push({path:p,preimageDigest:Ye(u),desired:f,desiredDigest:Ye(f)})}let a={schemaVersion:1,kind:"DyytoBootstrapPlan",projectRoot:t,policyVersion:_d,files:r,createdAt:new Date().toISOString()},s={...a,planId:Ye(Nn(a))},c=Be.join(t,".dyyto/plans/bootstrap",`${s.planId.slice(7)}.json`),l=await Wr(c),d=`${JSON.stringify(s,null,2)}
@@ -42,7 +42,7 @@ ${r}`;if(n===0){let l=e.source.replace(/\n*$/g,"");return`${l}${l.length===0?"":
42
42
  `),await c.sync()}finally{await c.close()}return await Ui(`${o}.tmp`,o),await this.resymbolicate(t.releaseId),s}async resymbolicate(t){let r=await Jf(ve.join(this.releases(),t)).catch(()=>[]),n=[];for(let a of r)try{n.push(JSON.parse(await ta(ve.join(this.releases(),t,a),"utf8")))}catch{}for(let a of(await this.all()).filter(i=>i.releaseId===t&&i.state==="map-missing")){let i=!1,o=a.error.frames.map(l=>{let p=n.find(m=>new URL(l.file,"http://local").pathname.endsWith(`/${m.registration.asset}`));if(!p||l.line===void 0||l.column===void 0)return l;try{let m=Bf(new zf(p.map),{line:l.line,column:Math.max(0,l.column-1)});return m.source===null||m.line===null||m.column===null?l:(i=!0,{...l,source:m.source.replace(/^file:\/\//,""),sourceLine:m.line,sourceColumn:m.column+1})}catch{return l}});if(!i)continue;let s={...a,error:{...a.error,frames:o},state:"symbolicated"},c=ve.join(this.directory(),`${a.eventId}.json`),d=await qi(`${c}.tmp`,"w",384);try{await d.writeFile(`${E(s)}
43
43
  `),await d.sync()}finally{await d.close()}await Ui(`${c}.tmp`,c)}}};var Ue=(e,t,r,n,a)=>({code:e,severity:t,fact:r,message:n,...a===void 0?{}:{action:a}});async function na(e){if(e.lock.capabilities.length===0||e.lock.capabilities.some(r=>r.evidenceIds.length===0))return[Ue("EVIDENCE_INVALID","critical","evidence","\u5DF2\u9A8C\u8BC1\u9501\u7F3A\u5C11\u5B8C\u6574\u8BC1\u636E\u5F15\u7528\u3002","\u91CD\u65B0\u8FD0\u884C\u9A8C\u8BC1\uFF1B\u82E5\u4E8B\u52A1\u672A\u5B8C\u6210\uFF0C\u5148\u6267\u884C\u5B89\u5168\u6062\u590D\u3002")];for(let r of e.lock.capabilities)for(let n of r.evidenceIds)try{let a=$n(JSON.parse(await Kf(Yc.join(e.projectRoot,".dyyto","evidence",`${n}.json`),"utf8")));if(a.evidenceId!==n||a.capabilityId!==r.capabilityId||a.capabilityVersion!==r.version||a.capabilityIntegrity!==r.integrity||a.projectStateDigest!==r.projectStateDigest||a.result!=="passed")return[Ue("EVIDENCE_INVALID","critical","evidence","\u91C7\u7528\u8BC1\u636E\u4E0E\u5DF2\u9A8C\u8BC1\u9501\u7684\u8EAB\u4EFD\u6216\u5DE5\u7A0B\u72B6\u6001\u4E0D\u4E00\u81F4\u3002","\u91CD\u65B0\u8FD0\u884C\u9A8C\u8BC1\uFF1B\u82E5\u73B0\u573A\u5DF2\u53D8\u5316\uFF0C\u5148\u68C0\u67E5\u5E76\u91CD\u65B0\u89C4\u5212\u3002")]}catch{return[Ue("EVIDENCE_INVALID","critical","evidence","\u91C7\u7528\u8BC1\u636E\u7F3A\u5931\u3001\u635F\u574F\u6216\u4E0D\u7B26\u5408\u5951\u7EA6\u3002","\u91CD\u65B0\u8FD0\u884C\u9A8C\u8BC1\uFF1B\u82E5\u4E8B\u52A1\u672A\u5B8C\u6210\uFF0C\u5148\u6267\u884C\u5B89\u5168\u6062\u590D\u3002")]}let t=e.lock.capabilities.reduce((r,n)=>r+n.evidenceIds.length,0);return[Ue("EVIDENCE_VALID","info","evidence",`\u5DF2\u6838\u9A8C ${e.lock.capabilities.length} \u9879\u80FD\u529B\u7684 ${t} \u6761\u91C7\u7528\u8BC1\u636E\u3002`)]}function Hc(e){return e==="adopted"?[]:e==="planned"?[Ue("ADOPTION_PLANNED","warning","lock","\u80FD\u529B\u91C7\u7528\u4ECD\u5904\u4E8E\u8BA1\u5212\u9636\u6BB5\u3002","\u5BA1\u9605\u5E76\u6279\u51C6\u7CBE\u786E Plan\u3002")]:e==="applied-unverified"?[Ue("VERIFICATION_REQUIRED","warning","evidence","\u53D8\u66F4\u5DF2\u5E94\u7528\u4F46\u5C1A\u672A\u5F62\u6210\u9A8C\u8BC1\u8BC1\u636E\u3002","\u8FD0\u884C\u9A8C\u8BC1\u5E76\u63D0\u4EA4\u91C7\u7528\u9501\u3002")]:e==="drifted"?[Ue("REPOSITORY_DRIFT","warning","repository","\u5DE5\u7A0B\u73B0\u573A\u4E0E\u5DF2\u9501\u5B9A\u4E8B\u5B9E\u4E0D\u4E00\u81F4\u3002","\u68C0\u67E5\u5DEE\u5F02\u5E76\u91CD\u65B0\u89C4\u5212\uFF0C\u5E73\u53F0\u4E0D\u4F1A\u8986\u76D6\u7528\u6237\u4FEE\u6539\u3002")]:e==="recovery-required"?[Ue("RECOVERY_REQUIRED","critical","recovery","\u68C0\u6D4B\u5230\u672A\u5B8C\u6210\u7684\u6301\u4E45\u5316\u4E8B\u52A1\u3002","\u5148\u6267\u884C\u5B89\u5168\u6062\u590D\uFF0C\u518D\u7EE7\u7EED\u5176\u4ED6\u64CD\u4F5C\u3002")]:[Ue("FACT_INVALID","critical","manifest","\u5DE5\u7A0B\u5355\u5143\u4E8B\u5B9E\u65E0\u6CD5\u5B89\u5168\u8BFB\u53D6\u3002","\u4FEE\u590D\u8BE5\u5355\u5143\u7684 Manifest \u6216\u5143\u6570\u636E\u540E\u91CD\u65B0\u8BCA\u65AD\u3002")]}async function Yf(e){try{let r=JSON.parse(await Kf(Yc.join(e.workspaceRoot,".dyyto","observability","config.json"),"utf8"));if(!Array.isArray(r.applications)||!r.applications.includes(e.applicationId))return[Ue("OBSERVABILITY_NOT_CONFIGURED","warning","repository","\u5F53\u524D Web \u5E94\u7528\u5C1A\u672A\u914D\u7F6E\u8FD0\u884C\u65F6\u9519\u8BEF\u91C7\u96C6\u3002","\u767B\u8BB0\u5E94\u7528 Origin\uFF0C\u5E76\u542F\u52A8\u672C\u5730\u91C7\u96C6\u7AEF\u3002")]}catch{return[Ue("OBSERVABILITY_NOT_CONFIGURED","warning","repository","\u5F53\u524D Web \u5E94\u7528\u5C1A\u672A\u914D\u7F6E\u8FD0\u884C\u65F6\u9519\u8BEF\u91C7\u96C6\u3002","\u767B\u8BB0\u5E94\u7528 Origin\uFF0C\u5E76\u542F\u52A8\u672C\u5730\u91C7\u96C6\u7AEF\u3002")]}await new yr(e.workspaceRoot).list({applicationId:e.applicationId});let t=(await gE(Yc.join(e.workspaceRoot,".dyyto","observability","quarantine")).catch(()=>[])).length;return t>0?[Ue("OBSERVABILITY_STORE_DAMAGED","critical","repository",`\u8FD0\u884C\u65F6\u9519\u8BEF\u672C\u5730\u5B58\u50A8\u5DF2\u9694\u79BB ${t} \u6761\u635F\u574F\u8BB0\u5F55\uFF0C\u5065\u5EB7\u4E8B\u4EF6\u4ECD\u53EF\u67E5\u8BE2\u3002`,"\u68C0\u67E5\u672C\u673A\u78C1\u76D8\u72B6\u6001\uFF0C\u5E76\u663E\u5F0F\u5904\u7406\u9694\u79BB\u8BB0\u5F55\u3002")]:[Ue("OBSERVABILITY_CONFIGURED","info","repository","\u8FD0\u884C\u65F6\u9519\u8BEF\u91C7\u96C6\u914D\u7F6E\u4E0E\u672C\u5730\u5B58\u50A8\u53EF\u8BFB\u53D6\u3002")]}function Hf(e){let t=e.units.map(n=>{let a=n.findings.some(i=>i.severity==="critical")?"blocked":n.findings.some(i=>i.severity==="warning")?"attention":"healthy";return{...n,status:a}}),r={total:t.length,healthy:t.filter(n=>n.status==="healthy").length,attention:t.filter(n=>n.status==="attention").length,blocked:t.filter(n=>n.status==="blocked").length};return{schemaVersion:1,workspace:e.workspace,generatedAt:e.generatedAt,status:r.blocked>0?"blocked":r.attention>0?"attention":"healthy",summary:r,units:t}}import{readFile as aa,realpath as Xf}from"node:fs/promises";import wr from"node:path";var ae=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Zf(e){let t=await Xf(wr.resolve(e.projectRoot)),r=W(e.manifest),n=e.release.release,a=e.currentLock.capabilities.find(m=>m.capabilityId===n.capabilityId&&m.version===n.version);if(!a||a.packageAdoption!==void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Asset-only removal requires an adopted Capability without package ownership");let i=W({...r,capabilities:r.capabilities.filter(m=>m.capabilityId!==n.capabilityId)}),o=Buffer.from(`${JSON.stringify(i,null,2)}
44
44
  `),s=await ia(t,"project-capabilities.json");if(!s.exists||s.digest===void 0)throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","Project manifest is unavailable");let c=[{path:"project-capabilities.json",kind:"replace",ownership:"owned-file",baseDigest:s.digest,desiredDigest:v(o)},...a.assets.map(m=>({path:m.path,kind:"remove",ownership:m.ownership??"owned-file",baseDigest:m.digest}))],d=await Promise.all(c.map(m=>ia(t,m.path))),l={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:a.assets.map(m=>({path:m.path,ownership:m.ownership??"owned-file",desiredDigest:m.digest})),verifiers:n.verifiers.map(m=>({id:m.id,kind:"file-digest"}))};return{plan:Ne({action:"remove",capability:l,changes:c,observedAssets:d,generatedAt:e.generatedAt,expiresAt:e.expiresAt}),manifest:i,desiredContents:new Map([["project-capabilities.json",o]]),transactionRoot:t,removedSources:[]}}async function ia(e,t){try{let r=await aa(wr.join(e,...t.split("/")));return{path:t,exists:!0,digest:v(r)}}catch(r){if(r.code==="ENOENT")return{path:t,exists:!1};throw r}}async function Xc(e){if(e.release.release.schemaVersion===2&&e.release.release.packageSources.length>0&&e.packageSource===void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Capability Release v2 requires verified package source facts");let t=await Xf(wr.resolve(e.projectRoot)),r=W(e.manifest),n=e.release.release,a=e.packageSource?.topology,i=a?.transactionRoot??t,o=k=>a?.mode==="pnpm-shared-lockfile"?`${a.unitRelativeRoot}/${k}`:k;if(n.kind!=="engineering-feature"||n.consumerProfile!=="any-project")throw new ae("CAPABILITY_KIND_UNSUPPORTED","Only an addable engineering feature can use this lifecycle");if(r.capabilities.some(k=>k.capabilityId===n.capabilityId))throw new ae("CAPABILITY_ALREADY_SELECTED","The capability is already selected by this project");let s=r.profile?.id,c=s==="typescript-library"?"blank-typescript-library":s,d=n.dependencies?.profiles??[],l=e.currentLock.capabilities.find(k=>k.consumerProfile===c);if(c===void 0||!d.includes(c)||l===void 0)throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The project profile does not satisfy this capability dependency");if((n.dependencies?.capabilities??[]).some(k=>!r.capabilities.some(S=>S.capabilityId===k)||!e.currentLock.capabilities.some(S=>S.capabilityId===k)))throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","A required project capability is not adopted and verified");let m=W({...r,capabilities:[...r.capabilities,{capabilityId:n.capabilityId,version:n.version}]}),u=o("project-capabilities.json"),f=Buffer.from(`${JSON.stringify(m,null,2)}
45
- `),g=await ia(i,u);if(!g.exists||g.digest===void 0)throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The project manifest is unavailable");let h=[{path:u,kind:"replace",ownership:"owned-file",baseDigest:g.digest,desiredDigest:v(f)}],w=new Map([[u,f]]),_;if(n.schemaVersion===2&&n.packageSources.length>0){if(e.packageSource===void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Capability Release v2 requires verified package source facts");let k;try{k=await aa(wr.join(t,"package.json"))}catch{throw new ae("CAPABILITY_PACKAGE_SOURCE_INVALID","\u9879\u76EE package.json \u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u5305\u91C7\u7528\u8BA1\u5212")}try{let S=e.packageSource.currentLockfile??await aa(wr.join(t,"pnpm-lock.yaml")).catch(re=>re.code==="ENOENT"?void 0:Promise.reject(re)),O=e.packageSource.topology??{schemaVersion:1,mode:"standalone",transactionRoot:t,unitRoot:t,unitRelativeRoot:".",unitImporterId:".",lockfilePath:"pnpm-lock.yaml"},ie=O.mode==="pnpm-shared-lockfile",$={mode:O.mode,unitRelativeRoot:O.unitRelativeRoot,unitImporterId:O.unitImporterId,lockfilePath:O.lockfilePath,...O.workspaceManifestPath?{workspaceManifestPath:O.workspaceManifestPath,workspaceManifestDigest:O.workspaceManifestDigest}:{}},P={registryConfigs:e.packageSource.registryConfigs,endpointBindings:e.packageSource.endpointBindings,receipts:e.packageSource.receipts,inspections:e.packageSource.inspections};if(ie&&(!e.packageSource.resolutionEvidence||!e.packageSource.resolutionWorkerReleaseId))throw new Y("PACKAGE_SOURCE_POLICY_VIOLATION");let K=ie?(e.packageChannel==="development"?Di:Ni)({release:n,...P,consumerProfile:c,packageJson:k,currentLockfile:S,generatedAt:e.generatedAt,expiresAt:e.expiresAt,topology:$,preservedImporterDigests:e.packageSource.preservedImporterDigests??[],resolutionEvidence:e.packageSource.resolutionEvidence,resolutionWorkerReleaseId:e.packageSource.resolutionWorkerReleaseId}):(e.packageChannel==="development"?Pi:Ri)({release:n,...P,lockResolution:e.packageSource.lockResolution,consumerProfile:c,packageJson:k,...S===void 0?{}:{currentLockfile:S},generatedAt:e.generatedAt,expiresAt:e.expiresAt});_=_i(K),h.push({path:o("package.json"),kind:"replace",ownership:"owned-file",baseDigest:K.packageJsonPreimageDigest,desiredDigest:K.desiredPackageJsonDigest}),w.set(o("package.json"),K.desiredPackageJson),h.push({path:O.lockfilePath,kind:S===void 0?"create":"replace",ownership:"owned-file",...S===void 0?{}:{baseDigest:v(S)},desiredDigest:K.desiredLockfileDigest}),w.set(O.lockfilePath,K.desiredLockfile)}catch(S){throw S instanceof Y?new ae("CAPABILITY_PACKAGE_SOURCE_INVALID",S.code):S}}for(let k of n.assets){let S=e.release.contents.get(k.path);if(S===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Capability asset content is unavailable");let O=k.renderer==="application-config-contract-v1"?Si(r):k.renderer==="application-config-binding-v1"?ji(r):S;if(k.ownership==="managed-region"){if(k.regionId===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Managed region identity is unavailable");let ie;try{ie=await aa(wr.join(t,...k.path.split("/")))}catch{throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The managed shared file is unavailable")}let $=Buffer.from(hu({source:ie.toString("utf8"),regionId:k.regionId,content:Buffer.from(O).toString("utf8")}));h.push({path:o(k.path),kind:"merge",ownership:"managed-region",regionId:k.regionId,baseDigest:v(ie),desiredDigest:v($)}),w.set(o(k.path),$)}else{let ie=await ia(t,k.path);if(k.ownership==="seed-file"&&ie.exists){let $=await aa(wr.join(t,...k.path.split("/")));h.push({path:o(k.path),kind:"create",ownership:"seed-file",desiredDigest:v($)}),w.set(o(k.path),$)}else h.push({path:o(k.path),kind:"create",ownership:k.ownership,desiredDigest:v(O)}),w.set(o(k.path),O)}}let b=await Promise.all(h.map(k=>ia(i,k.path))),A={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:h.filter(k=>k.path!==u&&k.path!==a?.lockfilePath).map(k=>({path:a?.mode==="pnpm-shared-lockfile"?k.path.slice(a.unitRelativeRoot.length+1):k.path,ownership:k.ownership,desiredDigest:k.desiredDigest})),verifiers:n.verifiers.map(k=>({id:k.id,kind:"file-digest"}))};return{plan:Ne({action:"adopt",capability:A,changes:h,observedAssets:b,generatedAt:e.generatedAt,expiresAt:e.expiresAt,..._===void 0?{}:{packageAdoption:_}}),manifest:m,desiredContents:w,transactionRoot:i,dependency:{profile:c,satisfied:!0}}}var Qf=Ir(rr(),1);var hE={$id:"https://schemas.dyyto.dev/platform/solution-catalog-entry-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","solutionId","version","integrity","title","summary","maturity","members","integration","exit"],properties:{schemaVersion:{const:1},solutionId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},summary:{type:"string",minLength:1,maxLength:240},maturity:{enum:["guided","automated"]},members:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["capabilityId","version","role","required"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},role:{type:"string",minLength:1,maxLength:80},required:{type:"boolean"}}}},integration:{type:"object",additionalProperties:!1,required:["prerequisites","steps","verification","result"],properties:{prerequisites:{type:"array",minItems:1,maxItems:16,items:{type:"string",minLength:1,maxLength:200}},steps:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["label","command"],properties:{label:{type:"string",minLength:1,maxLength:80},command:{type:"string",minLength:1,maxLength:2e3}}}},verification:{type:"array",minItems:1,maxItems:32,items:{type:"string",minLength:1,maxLength:1e3}},result:{type:"string",minLength:1,maxLength:400}}},exit:{type:"object",additionalProperties:!1,required:["summary"],properties:{summary:{type:"string",minLength:1,maxLength:400}}}}},eD=new Qf.Ajv2020({allErrors:!0,strict:!0}).compile(hE);var am=Ir(rr(),1);import{readFile as yE,realpath as wE}from"node:fs/promises";import em from"node:path";var tm="^[a-z0-9]+(?:[.-][a-z0-9]+)*$",rm="^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)[^\\u0000]+$",vE={$id:"https://schemas.dyyto.dev/platform/example-recipe-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","recipeId","version","integrity","title","locale","rootProfile","capabilities","expectedEntrypoint","verifiers","manualAcceptance","cleanup"],properties:{schemaVersion:{const:1},recipeId:{type:"string",pattern:tm},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},locale:{const:"zh-CN"},rootProfile:{type:"object",additionalProperties:!1,required:["capabilityId","version"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128}}},capabilities:{type:"array",minItems:1,maxItems:16,items:{type:"object",additionalProperties:!1,required:["capabilityId","version","channel"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},channel:{const:"development"}}}},expectedEntrypoint:{type:"string",pattern:rm,maxLength:240},verifiers:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",pattern:tm}},manualAcceptance:{type:"array",minItems:1,maxItems:32,items:{type:"string",minLength:1,maxLength:240}},cleanup:{type:"object",additionalProperties:!1,required:["ownedStateDirectories"],properties:{ownedStateDirectories:{type:"array",maxItems:8,uniqueItems:!0,items:{type:"string",pattern:rm,maxLength:240}}}}}},nm=new am.Ajv2020({allErrors:!0,strict:!0}).compile(vE),vr=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function IE(e){return v(E(e))}function bE(e){if(!nm(e))throw new vr("EXAMPLE_RECIPE_INVALID",nm.errors??[]);let t=e,r=[t.rootProfile.capabilityId,...t.capabilities.map(n=>n.capabilityId)];if(new Set(r).size!==r.length||t.capabilities.some(n=>n.version.includes("workspace:")||n.capabilityId.includes("ai-education-poc")))throw new vr("EXAMPLE_RECIPE_INVALID");return t}async function im(e){let t=await wE(em.resolve(e)),r;try{r=bE(JSON.parse(await yE(em.join(t,"recipe.json"),"utf8")))}catch(i){throw i instanceof vr?i:new vr("EXAMPLE_RECIPE_INVALID")}let{integrity:n,...a}=r;if(IE(a)!==n)throw new vr("EXAMPLE_RECIPE_INTEGRITY_MISMATCH");return r}var cm=Ir(rr(),1);import{readFile as kE,realpath as _E}from"node:fs/promises";import om from"node:path";var EE={$id:"https://schemas.dyyto.dev/platform/engineering-template-release-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","templateId","version","integrity","title","summary","status","profile","parameters","commands","technology","support","integration","metrics"],properties:{schemaVersion:{const:1},templateId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},summary:{type:"string",minLength:1,maxLength:240},status:{enum:["candidate","recommended","deprecated"]},profile:{type:"object",additionalProperties:!1,required:["id","capability"],properties:{id:{type:"string",pattern:H},capability:{type:"string",pattern:`${H.slice(1,-1)}@[0-9]+\\.[0-9]+\\.[0-9]+$`}}},parameters:{type:"array",minItems:0,maxItems:32,items:{type:"object",additionalProperties:!1,required:["id","required","description"],properties:{id:{type:"string",pattern:"^[a-z][A-Za-z0-9]*$"},required:{type:"boolean"},description:{type:"string",minLength:1,maxLength:160}}}},commands:{type:"object",minProperties:1,additionalProperties:!1,properties:{dev:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},build:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},test:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},package:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"}}},technology:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["id","version","policy","verifiedAt","rationale","alternative","exit"],properties:{id:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:64},policy:{enum:["recommended","allowed"]},verifiedAt:{type:"string",format:"date"},rationale:{type:"string",minLength:1,maxLength:240},alternative:{type:"string",minLength:1,maxLength:160},exit:{type:"string",minLength:1,maxLength:240}}}},support:{type:"object",additionalProperties:!1,required:["owner","tier","supportedFrom","supportedUntil","upgradeCadence","eolNoticeDays"],properties:{owner:{type:"string",pattern:H},tier:{const:"production"},supportedFrom:{type:"string",format:"date"},supportedUntil:{type:"string",format:"date"},upgradeCadence:{type:"string",minLength:1,maxLength:80},eolNoticeDays:{type:"integer",minimum:30,maximum:730}}},integration:{type:"object",additionalProperties:!1,required:["prerequisites","createCommand","result"],properties:{prerequisites:{type:"array",minItems:1,maxItems:16,items:{type:"string",minLength:1,maxLength:200}},createCommand:{type:"string",minLength:1,maxLength:2e3},result:{type:"string",minLength:1,maxLength:400}}},metrics:{type:"array",minItems:1,uniqueItems:!0,items:{enum:["time-to-green-build","time-to-first-business-commit","manual-engineering-edits","upgrade-conflicts"]}}}},sm=new cm.Ajv2020({allErrors:!0,strict:!0,formats:{date:/^\d{4}-\d{2}-\d{2}$/}}).compile(EE),At=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function AE(e){return v(E(e))}function RE(e){if(!sm(e))throw new At("TEMPLATE_INVALID",sm.errors??[]);let t=e;if(new Set(t.parameters.map(r=>r.id)).size!==t.parameters.length||new Set(t.technology.map(r=>r.id)).size!==t.technology.length)throw new At("TEMPLATE_INVALID");if(Date.parse(t.support.supportedUntil)<=Date.parse(t.support.supportedFrom))throw new At("TEMPLATE_INVALID");return t}async function oa(e,t=new Date){let r=await _E(om.resolve(e)),n;try{n=RE(JSON.parse(await kE(om.join(r,"template.json"),"utf8")))}catch(o){throw o instanceof At?o:new At("TEMPLATE_INVALID")}let{integrity:a,...i}=n;if(AE(i)!==a)throw new At("TEMPLATE_INTEGRITY_MISMATCH");if(n.status==="recommended"&&Date.parse(n.support.supportedUntil)<t.getTime())throw new At("TEMPLATE_SUPPORT_EXPIRED");return n}import{readFile as lm}from"node:fs/promises";import dm from"node:path";var PE=/^[A-Z][A-Z0-9_]*$/u,NE=/(?:API_KEY|ACCESS_KEY|SECRET|TOKEN|PASSWORD|PRIVATE_KEY|DATABASE_URL|POSTGRES_URL)$/u;function DE(e){let t=new Map;for(let r of e.split(/\r?\n/u)){let n=/^([A-Z][A-Z0-9_]*)=(.*)$/u.exec(r.trim());if(!n||!PE.test(n[1]))continue;let a=n[1],i=n[2].trim();t.set(a,{name:a,requirement:i.length===0?"conditional":"optional",secret:NE.test(a),configured:!1,source:".env.example",configuredSource:null})}return[...t.values()]}async function pm(e){let t=await lm(dm.join(e.projectRoot,".env.example"),"utf8").then(()=>".env.example").catch(()=>null),r=t?await lm(dm.join(e.projectRoot,t),"utf8"):"",n=await $i({projectRoot:e.projectRoot}).catch(()=>null);return{commands:["dev","build","test","package"].flatMap(i=>e.commands[i]?[{id:i,script:e.commands[i],mode:i==="dev"?"managed-process":"foreground-task"}]:[]),environment:n?n.entries.map(i=>({name:i.name,requirement:i.required?"conditional":"optional",secret:i.kind!=="value",configured:i.configured,source:"application-config-contract",configuredSource:"APP_CONFIG_DIR",display:i.display,...i.fingerprint?{fingerprint:i.fingerprint}:{}})):DE(r),environmentExample:t,productionValidation:{contract:!0,live:["provider-read","oss-write-read-delete"]}}}var um={change:new Set(["plan","apply","upgrade","recover","baseline-next","add-package","add-application","add-feature"]),quality:new Set(["inspect","verify","doctor","maintenance","test","build"]),delivery:new Set(["package","delivery-plan","delivery-apply","delivery-inspect"])},fm=new Set(["queued","running","succeeded","failed","outcome-unknown","cancelled"]);function mm(e,t){if(!um[t.plane]||t.state&&!fm.has(t.state)||t.limit!==void 0&&(!Number.isSafeInteger(t.limit)||t.limit<1||t.limit>200))throw new Error("OPERATION_FILTER_INVALID");let r=um[t.plane],n=t.from?Date.parse(t.from):null,a=t.to?Date.parse(t.to):null;if(n!==null&&Number.isNaN(n)||a!==null&&Number.isNaN(a)||n!==null&&a!==null&&n>a)throw new Error("OPERATION_FILTER_INVALID");let i=e.filter(d=>r.has(d.operation)),o=[...new Map(i.map(d=>[d.projectId,{id:d.projectId,name:d.projectName}])).values()].sort((d,l)=>d.name.localeCompare(l.name)),s=i.filter(d=>(!t.projectId||d.projectId===t.projectId)&&(!t.state||d.state===t.state)&&(!t.kind||d.operation===t.kind)&&(n===null||Date.parse(d.createdAt)>=n)&&(a===null||Date.parse(d.createdAt)<=a)).sort((d,l)=>l.updatedAt.localeCompare(d.updatedAt)),c={total:s.length,running:s.filter(d=>d.state==="running"||d.state==="queued").length,succeeded:s.filter(d=>d.state==="succeeded").length,attention:s.filter(d=>d.state==="failed"||d.state==="outcome-unknown").length};return Object.freeze({schemaVersion:1,plane:t.plane,summary:Object.freeze(c),facets:Object.freeze({projects:Object.freeze(o),states:Object.freeze([...fm]),kinds:Object.freeze([...r])}),items:Object.freeze(s.slice(0,t.limit??50).map(Object.freeze)),hasMore:s.length>(t.limit??50)})}var sa=class extends Error{code;constructor(t,r){super(r),this.code=t}},Qc=/^sha256:[a-f0-9]{64}$/u,SE=/^sha512-[A-Za-z0-9+/]{86}==$/u,jE=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u,$E=/^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/u,OE=/[\u0000-\u001f\u007f]/u;function Xr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Zr(e,t){let r=Object.keys(e).sort(),n=[...t].sort();return r.length===n.length&&r.every((a,i)=>a===n[i])}function Rt(e,t=500){return typeof e=="string"&&e.length>0&&e.length<=t&&!OE.test(e)}function Zc(e){return Rt(e,500)&&!e.startsWith("/")&&!e.startsWith("../")&&!e.includes("/../")&&!e.includes("\\")}function gm(e,t=128){return Array.isArray(e)&&e.length<=t&&e.every(r=>Rt(r,500))&&e.every((r,n)=>n===0||e[n-1]<r)}function CE(e){return e===null?!0:!Xr(e)||!Zr(e,["fileName","digest","integrity","fileCount","unpackedBytes"])?!1:Zc(e.fileName)&&Qc.test(String(e.digest))&&SE.test(String(e.integrity))&&Number.isSafeInteger(e.fileCount)&&Number(e.fileCount)>0&&Number.isSafeInteger(e.unpackedBytes)&&Number(e.unpackedBytes)>0}function TE(e){if(!Xr(e)||!Zr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence"])||e.schemaVersion!==1||e.kind!=="PackageRelease"||!jE.test(e.packageName)||!$E.test(e.version)||!Rt(e.title,120)||!Rt(e.summary,1e3)||!["candidate","stable","deprecated"].includes(e.maturity)||!Xr(e.source)||!Zr(e.source,["repository","path","revision","treeDigest"])||!Rt(e.source.repository)||!Zc(e.source.path)||!Rt(e.source.revision,200)||!Qc.test(String(e.source.treeDigest))||!CE(e.artifact)||!Xr(e.compatibility)||!Zr(e.compatibility,["node","packageManager"])||!Rt(e.compatibility.node,100)||!Rt(e.compatibility.packageManager,100)||!gm(e.exports)||!gm(e.consumerEvidence)||!Xr(e.documentation))return!1;let t=e.documentation.knowledgeRef===void 0?["readme"]:["readme","knowledgeRef"];return!Zr(e.documentation,t)||!Zc(e.documentation.readme)||e.documentation.knowledgeRef!==void 0&&!Rt(e.documentation.knowledgeRef,500)?!1:e.artifact!==null||e.maturity!=="stable"}function xE(e){let t={schemaVersion:1,kind:"PackageRelease",...e,source:Object.freeze({...e.source}),artifact:e.artifact===null?null:Object.freeze({...e.artifact}),compatibility:Object.freeze({...e.compatibility}),exports:Object.freeze([...e.exports]),documentation:Object.freeze({...e.documentation}),consumerEvidence:Object.freeze([...e.consumerEvidence])};if(!TE(t))throw new sa("PACKAGE_RELEASE_INVALID","PackageRelease \u5185\u5BB9\u65E0\u6548");return Object.freeze({...t,releaseDigest:v(E(t))})}function hm(e){if(!Xr(e)||!Zr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence","releaseDigest"])||!Qc.test(String(e.releaseDigest)))throw new sa("PACKAGE_RELEASE_INVALID","PackageRelease \u7ED3\u6784\u65E0\u6548");let{releaseDigest:t,schemaVersion:r,kind:n,...a}=e,i=xE(a);if(i.releaseDigest!==t)throw new sa("PACKAGE_RELEASE_MODIFIED","PackageRelease \u5DF2\u88AB\u4FEE\u6539");return i}import{lstat as LE,readFile as VE,realpath as ME}from"node:fs/promises";import ym from"node:path";async function wm(e){let t=await ME(ym.resolve(e.projectRoot)),r=new Set(e.excludeCapabilityIds??[]),n=new Map,a=[...e.lock.capabilities].sort((o,s)=>o.committedAt.localeCompare(s.committedAt)||o.capabilityId.localeCompare(s.capabilityId));for(let o of a)if(!r.has(o.capabilityId))for(let s of o.assets){let c=s.ownership??"owned-file",d=`${s.path}\0`;if(c==="managed-region")n.delete(d);else for(let p of n.keys())p.startsWith(d)&&n.delete(p);let l=c==="managed-region"?`${d}${s.regionId??""}`:d;n.set(l,{capabilityId:o.capabilityId,path:s.path,digest:s.digest,ownership:c,...s.regionId===void 0?{}:{regionId:s.regionId}})}let i=[];for(let o of[...n.values()].sort((s,c)=>s.path.localeCompare(c.path)||(s.regionId??"").localeCompare(c.regionId??"")||s.capabilityId.localeCompare(c.capabilityId))){let s=ym.join(t,...o.path.split("/")),d=await LE(s).then(async l=>{if(!l.isFile()||l.isSymbolicLink())return;let p=await VE(s);if(o.ownership!=="managed-region")return v(p);if(o.regionId!==void 0)try{return v(Xa(p.toString("utf8"),o.regionId))}catch{return}}).catch(l=>l.code==="ENOENT"?void 0:Promise.reject(l))===o.digest;i.push({capabilityId:o.capabilityId,path:o.path,kind:"create",ownership:o.ownership,...o.regionId===void 0?{}:{regionId:o.regionId},desiredDigest:o.digest,disposition:d?"noop":"conflict",...d?{}:{conflictCode:"BASE_DIGEST_MISMATCH"}})}return i}var el="0.1.23",ca={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},qE=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function vm(e,t){return typeof e=="string"&&e.length>0&&e.length<=t&&!qE.test(e)}function UE(e){let t={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:ca[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},r=FE(t);if(r===null)throw new TypeError("CLI domain error input is invalid");return r}function FE(e){try{if(typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype)return null;let t=Object.getOwnPropertyDescriptors(e);if(Reflect.ownKeys(t).some(s=>typeof s=="symbol"))return null;let r=Object.keys(t).sort(),n="nextStep"in t?["code","exitCode","kind","message","nextStep","schemaVersion"]:["code","exitCode","kind","message","schemaVersion"];if(r.length!==n.length||r.some((s,c)=>s!==n[c])||Object.values(t).some(s=>!("value"in s)))return null;let a=s=>t[s]?.value,i=a("code");if(a("schemaVersion")!==1||a("kind")!=="dyyto-cli-domain-error"||typeof i!="string"||!(i in ca)||a("exitCode")!==ca[i]||!vm(a("message"),500))return null;let o=a("nextStep");return o!==void 0&&!vm(o,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:i,message:a("message"),exitCode:4,...o===void 0?{}:{nextStep:o}})}catch{return null}}var Ce=class extends Error{code;exitCode;nextStep;domainError;constructor(t){super(t.message),this.name="CliError",this.code=t.code,this.exitCode=t.exitCode,this.nextStep=t.nextStep,this.domainError=t.code in ca&&t.exitCode===ca[t.code]?UE({code:t.code,message:t.message,...t.nextStep===void 0?{}:{nextStep:t.nextStep}}):void 0}};var Im=`Dyyto Engineering Platform CLI
45
+ `),g=await ia(i,u);if(!g.exists||g.digest===void 0)throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The project manifest is unavailable");let h=[{path:u,kind:"replace",ownership:"owned-file",baseDigest:g.digest,desiredDigest:v(f)}],w=new Map([[u,f]]),_;if(n.schemaVersion===2&&n.packageSources.length>0){if(e.packageSource===void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Capability Release v2 requires verified package source facts");let k;try{k=await aa(wr.join(t,"package.json"))}catch{throw new ae("CAPABILITY_PACKAGE_SOURCE_INVALID","\u9879\u76EE package.json \u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u5305\u91C7\u7528\u8BA1\u5212")}try{let S=e.packageSource.currentLockfile??await aa(wr.join(t,"pnpm-lock.yaml")).catch(re=>re.code==="ENOENT"?void 0:Promise.reject(re)),O=e.packageSource.topology??{schemaVersion:1,mode:"standalone",transactionRoot:t,unitRoot:t,unitRelativeRoot:".",unitImporterId:".",lockfilePath:"pnpm-lock.yaml"},ie=O.mode==="pnpm-shared-lockfile",$={mode:O.mode,unitRelativeRoot:O.unitRelativeRoot,unitImporterId:O.unitImporterId,lockfilePath:O.lockfilePath,...O.workspaceManifestPath?{workspaceManifestPath:O.workspaceManifestPath,workspaceManifestDigest:O.workspaceManifestDigest}:{}},P={registryConfigs:e.packageSource.registryConfigs,endpointBindings:e.packageSource.endpointBindings,receipts:e.packageSource.receipts,inspections:e.packageSource.inspections};if(ie&&(!e.packageSource.resolutionEvidence||!e.packageSource.resolutionWorkerReleaseId))throw new Y("PACKAGE_SOURCE_POLICY_VIOLATION");let K=ie?(e.packageChannel==="development"?Di:Ni)({release:n,...P,consumerProfile:c,packageJson:k,currentLockfile:S,generatedAt:e.generatedAt,expiresAt:e.expiresAt,topology:$,preservedImporterDigests:e.packageSource.preservedImporterDigests??[],resolutionEvidence:e.packageSource.resolutionEvidence,resolutionWorkerReleaseId:e.packageSource.resolutionWorkerReleaseId}):(e.packageChannel==="development"?Pi:Ri)({release:n,...P,lockResolution:e.packageSource.lockResolution,consumerProfile:c,packageJson:k,...S===void 0?{}:{currentLockfile:S},generatedAt:e.generatedAt,expiresAt:e.expiresAt});_=_i(K),h.push({path:o("package.json"),kind:"replace",ownership:"owned-file",baseDigest:K.packageJsonPreimageDigest,desiredDigest:K.desiredPackageJsonDigest}),w.set(o("package.json"),K.desiredPackageJson),h.push({path:O.lockfilePath,kind:S===void 0?"create":"replace",ownership:"owned-file",...S===void 0?{}:{baseDigest:v(S)},desiredDigest:K.desiredLockfileDigest}),w.set(O.lockfilePath,K.desiredLockfile)}catch(S){throw S instanceof Y?new ae("CAPABILITY_PACKAGE_SOURCE_INVALID",S.code):S}}for(let k of n.assets){let S=e.release.contents.get(k.path);if(S===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Capability asset content is unavailable");let O=k.renderer==="application-config-contract-v1"?Si(r):k.renderer==="application-config-binding-v1"?ji(r):S;if(k.ownership==="managed-region"){if(k.regionId===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Managed region identity is unavailable");let ie;try{ie=await aa(wr.join(t,...k.path.split("/")))}catch{throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The managed shared file is unavailable")}let $=Buffer.from(hu({source:ie.toString("utf8"),regionId:k.regionId,content:Buffer.from(O).toString("utf8")}));h.push({path:o(k.path),kind:"merge",ownership:"managed-region",regionId:k.regionId,baseDigest:v(ie),desiredDigest:v($)}),w.set(o(k.path),$)}else{let ie=await ia(t,k.path);if(k.ownership==="seed-file"&&ie.exists){let $=await aa(wr.join(t,...k.path.split("/")));h.push({path:o(k.path),kind:"create",ownership:"seed-file",desiredDigest:v($)}),w.set(o(k.path),$)}else h.push({path:o(k.path),kind:"create",ownership:k.ownership,desiredDigest:v(O)}),w.set(o(k.path),O)}}let b=await Promise.all(h.map(k=>ia(i,k.path))),A={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:h.filter(k=>k.path!==u&&k.path!==a?.lockfilePath).map(k=>({path:a?.mode==="pnpm-shared-lockfile"?k.path.slice(a.unitRelativeRoot.length+1):k.path,ownership:k.ownership,desiredDigest:k.desiredDigest})),verifiers:n.verifiers.map(k=>({id:k.id,kind:"file-digest"}))};return{plan:Ne({action:"adopt",capability:A,changes:h,observedAssets:b,generatedAt:e.generatedAt,expiresAt:e.expiresAt,..._===void 0?{}:{packageAdoption:_}}),manifest:m,desiredContents:w,transactionRoot:i,dependency:{profile:c,satisfied:!0}}}var Qf=Ir(rr(),1);var hE={$id:"https://schemas.dyyto.dev/platform/solution-catalog-entry-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","solutionId","version","integrity","title","summary","maturity","members","integration","exit"],properties:{schemaVersion:{const:1},solutionId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},summary:{type:"string",minLength:1,maxLength:240},maturity:{enum:["guided","automated"]},members:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["capabilityId","version","role","required"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},role:{type:"string",minLength:1,maxLength:80},required:{type:"boolean"}}}},integration:{type:"object",additionalProperties:!1,required:["prerequisites","steps","verification","result"],properties:{prerequisites:{type:"array",minItems:1,maxItems:16,items:{type:"string",minLength:1,maxLength:200}},steps:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["label","command"],properties:{label:{type:"string",minLength:1,maxLength:80},command:{type:"string",minLength:1,maxLength:2e3}}}},verification:{type:"array",minItems:1,maxItems:32,items:{type:"string",minLength:1,maxLength:1e3}},result:{type:"string",minLength:1,maxLength:400}}},exit:{type:"object",additionalProperties:!1,required:["summary"],properties:{summary:{type:"string",minLength:1,maxLength:400}}}}},eD=new Qf.Ajv2020({allErrors:!0,strict:!0}).compile(hE);var am=Ir(rr(),1);import{readFile as yE,realpath as wE}from"node:fs/promises";import em from"node:path";var tm="^[a-z0-9]+(?:[.-][a-z0-9]+)*$",rm="^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)[^\\u0000]+$",vE={$id:"https://schemas.dyyto.dev/platform/example-recipe-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","recipeId","version","integrity","title","locale","rootProfile","capabilities","expectedEntrypoint","verifiers","manualAcceptance","cleanup"],properties:{schemaVersion:{const:1},recipeId:{type:"string",pattern:tm},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},locale:{const:"zh-CN"},rootProfile:{type:"object",additionalProperties:!1,required:["capabilityId","version"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128}}},capabilities:{type:"array",minItems:1,maxItems:16,items:{type:"object",additionalProperties:!1,required:["capabilityId","version","channel"],properties:{capabilityId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},channel:{const:"development"}}}},expectedEntrypoint:{type:"string",pattern:rm,maxLength:240},verifiers:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",pattern:tm}},manualAcceptance:{type:"array",minItems:1,maxItems:32,items:{type:"string",minLength:1,maxLength:240}},cleanup:{type:"object",additionalProperties:!1,required:["ownedStateDirectories"],properties:{ownedStateDirectories:{type:"array",maxItems:8,uniqueItems:!0,items:{type:"string",pattern:rm,maxLength:240}}}}}},nm=new am.Ajv2020({allErrors:!0,strict:!0}).compile(vE),vr=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function IE(e){return v(E(e))}function bE(e){if(!nm(e))throw new vr("EXAMPLE_RECIPE_INVALID",nm.errors??[]);let t=e,r=[t.rootProfile.capabilityId,...t.capabilities.map(n=>n.capabilityId)];if(new Set(r).size!==r.length||t.capabilities.some(n=>n.version.includes("workspace:")||n.capabilityId.includes("ai-education-poc")))throw new vr("EXAMPLE_RECIPE_INVALID");return t}async function im(e){let t=await wE(em.resolve(e)),r;try{r=bE(JSON.parse(await yE(em.join(t,"recipe.json"),"utf8")))}catch(i){throw i instanceof vr?i:new vr("EXAMPLE_RECIPE_INVALID")}let{integrity:n,...a}=r;if(IE(a)!==n)throw new vr("EXAMPLE_RECIPE_INTEGRITY_MISMATCH");return r}var cm=Ir(rr(),1);import{readFile as kE,realpath as _E}from"node:fs/promises";import om from"node:path";var EE={$id:"https://schemas.dyyto.dev/platform/engineering-template-release-v1.json",type:"object",additionalProperties:!1,required:["schemaVersion","templateId","version","integrity","title","summary","status","profile","parameters","commands","technology","support","integration","metrics"],properties:{schemaVersion:{const:1},templateId:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:dt},title:{type:"string",minLength:1,maxLength:80},summary:{type:"string",minLength:1,maxLength:240},status:{enum:["candidate","recommended","deprecated"]},profile:{type:"object",additionalProperties:!1,required:["id","capability"],properties:{id:{type:"string",pattern:H},capability:{type:"string",pattern:`${H.slice(1,-1)}@[0-9]+\\.[0-9]+\\.[0-9]+$`}}},parameters:{type:"array",minItems:0,maxItems:32,items:{type:"object",additionalProperties:!1,required:["id","required","description"],properties:{id:{type:"string",pattern:"^[a-z][A-Za-z0-9]*$"},required:{type:"boolean"},description:{type:"string",minLength:1,maxLength:160}}}},commands:{type:"object",minProperties:1,additionalProperties:!1,properties:{dev:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},build:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},test:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"},package:{type:"string",pattern:"^[a-z][a-z0-9.:-]*$"}}},technology:{type:"array",minItems:1,maxItems:32,items:{type:"object",additionalProperties:!1,required:["id","version","policy","verifiedAt","rationale","alternative","exit"],properties:{id:{type:"string",pattern:H},version:{type:"string",minLength:1,maxLength:64},policy:{enum:["recommended","allowed"]},verifiedAt:{type:"string",format:"date"},rationale:{type:"string",minLength:1,maxLength:240},alternative:{type:"string",minLength:1,maxLength:160},exit:{type:"string",minLength:1,maxLength:240}}}},support:{type:"object",additionalProperties:!1,required:["owner","tier","supportedFrom","supportedUntil","upgradeCadence","eolNoticeDays"],properties:{owner:{type:"string",pattern:H},tier:{const:"production"},supportedFrom:{type:"string",format:"date"},supportedUntil:{type:"string",format:"date"},upgradeCadence:{type:"string",minLength:1,maxLength:80},eolNoticeDays:{type:"integer",minimum:30,maximum:730}}},integration:{type:"object",additionalProperties:!1,required:["prerequisites","createCommand","result"],properties:{prerequisites:{type:"array",minItems:1,maxItems:16,items:{type:"string",minLength:1,maxLength:200}},createCommand:{type:"string",minLength:1,maxLength:2e3},result:{type:"string",minLength:1,maxLength:400}}},metrics:{type:"array",minItems:1,uniqueItems:!0,items:{enum:["time-to-green-build","time-to-first-business-commit","manual-engineering-edits","upgrade-conflicts"]}}}},sm=new cm.Ajv2020({allErrors:!0,strict:!0,formats:{date:/^\d{4}-\d{2}-\d{2}$/}}).compile(EE),At=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function AE(e){return v(E(e))}function RE(e){if(!sm(e))throw new At("TEMPLATE_INVALID",sm.errors??[]);let t=e;if(new Set(t.parameters.map(r=>r.id)).size!==t.parameters.length||new Set(t.technology.map(r=>r.id)).size!==t.technology.length)throw new At("TEMPLATE_INVALID");if(Date.parse(t.support.supportedUntil)<=Date.parse(t.support.supportedFrom))throw new At("TEMPLATE_INVALID");return t}async function oa(e,t=new Date){let r=await _E(om.resolve(e)),n;try{n=RE(JSON.parse(await kE(om.join(r,"template.json"),"utf8")))}catch(o){throw o instanceof At?o:new At("TEMPLATE_INVALID")}let{integrity:a,...i}=n;if(AE(i)!==a)throw new At("TEMPLATE_INTEGRITY_MISMATCH");if(n.status==="recommended"&&Date.parse(n.support.supportedUntil)<t.getTime())throw new At("TEMPLATE_SUPPORT_EXPIRED");return n}import{readFile as lm}from"node:fs/promises";import dm from"node:path";var PE=/^[A-Z][A-Z0-9_]*$/u,NE=/(?:API_KEY|ACCESS_KEY|SECRET|TOKEN|PASSWORD|PRIVATE_KEY|DATABASE_URL|POSTGRES_URL)$/u;function DE(e){let t=new Map;for(let r of e.split(/\r?\n/u)){let n=/^([A-Z][A-Z0-9_]*)=(.*)$/u.exec(r.trim());if(!n||!PE.test(n[1]))continue;let a=n[1],i=n[2].trim();t.set(a,{name:a,requirement:i.length===0?"conditional":"optional",secret:NE.test(a),configured:!1,source:".env.example",configuredSource:null})}return[...t.values()]}async function pm(e){let t=await lm(dm.join(e.projectRoot,".env.example"),"utf8").then(()=>".env.example").catch(()=>null),r=t?await lm(dm.join(e.projectRoot,t),"utf8"):"",n=await $i({projectRoot:e.projectRoot}).catch(()=>null);return{commands:["dev","build","test","package"].flatMap(i=>e.commands[i]?[{id:i,script:e.commands[i],mode:i==="dev"?"managed-process":"foreground-task"}]:[]),environment:n?n.entries.map(i=>({name:i.name,requirement:i.required?"conditional":"optional",secret:i.kind!=="value",configured:i.configured,source:"application-config-contract",configuredSource:"APP_CONFIG_DIR",display:i.display,...i.fingerprint?{fingerprint:i.fingerprint}:{}})):DE(r),environmentExample:t,productionValidation:{contract:!0,live:["provider-read","oss-write-read-delete"]}}}var um={change:new Set(["plan","apply","upgrade","recover","baseline-next","add-package","add-application","add-feature"]),quality:new Set(["inspect","verify","doctor","maintenance","test","build"]),delivery:new Set(["package","delivery-plan","delivery-apply","delivery-inspect"])},fm=new Set(["queued","running","succeeded","failed","outcome-unknown","cancelled"]);function mm(e,t){if(!um[t.plane]||t.state&&!fm.has(t.state)||t.limit!==void 0&&(!Number.isSafeInteger(t.limit)||t.limit<1||t.limit>200))throw new Error("OPERATION_FILTER_INVALID");let r=um[t.plane],n=t.from?Date.parse(t.from):null,a=t.to?Date.parse(t.to):null;if(n!==null&&Number.isNaN(n)||a!==null&&Number.isNaN(a)||n!==null&&a!==null&&n>a)throw new Error("OPERATION_FILTER_INVALID");let i=e.filter(d=>r.has(d.operation)),o=[...new Map(i.map(d=>[d.projectId,{id:d.projectId,name:d.projectName}])).values()].sort((d,l)=>d.name.localeCompare(l.name)),s=i.filter(d=>(!t.projectId||d.projectId===t.projectId)&&(!t.state||d.state===t.state)&&(!t.kind||d.operation===t.kind)&&(n===null||Date.parse(d.createdAt)>=n)&&(a===null||Date.parse(d.createdAt)<=a)).sort((d,l)=>l.updatedAt.localeCompare(d.updatedAt)),c={total:s.length,running:s.filter(d=>d.state==="running"||d.state==="queued").length,succeeded:s.filter(d=>d.state==="succeeded").length,attention:s.filter(d=>d.state==="failed"||d.state==="outcome-unknown").length};return Object.freeze({schemaVersion:1,plane:t.plane,summary:Object.freeze(c),facets:Object.freeze({projects:Object.freeze(o),states:Object.freeze([...fm]),kinds:Object.freeze([...r])}),items:Object.freeze(s.slice(0,t.limit??50).map(Object.freeze)),hasMore:s.length>(t.limit??50)})}var sa=class extends Error{code;constructor(t,r){super(r),this.code=t}},Qc=/^sha256:[a-f0-9]{64}$/u,SE=/^sha512-[A-Za-z0-9+/]{86}==$/u,jE=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u,$E=/^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/u,OE=/[\u0000-\u001f\u007f]/u;function Xr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Zr(e,t){let r=Object.keys(e).sort(),n=[...t].sort();return r.length===n.length&&r.every((a,i)=>a===n[i])}function Rt(e,t=500){return typeof e=="string"&&e.length>0&&e.length<=t&&!OE.test(e)}function Zc(e){return Rt(e,500)&&!e.startsWith("/")&&!e.startsWith("../")&&!e.includes("/../")&&!e.includes("\\")}function gm(e,t=128){return Array.isArray(e)&&e.length<=t&&e.every(r=>Rt(r,500))&&e.every((r,n)=>n===0||e[n-1]<r)}function CE(e){return e===null?!0:!Xr(e)||!Zr(e,["fileName","digest","integrity","fileCount","unpackedBytes"])?!1:Zc(e.fileName)&&Qc.test(String(e.digest))&&SE.test(String(e.integrity))&&Number.isSafeInteger(e.fileCount)&&Number(e.fileCount)>0&&Number.isSafeInteger(e.unpackedBytes)&&Number(e.unpackedBytes)>0}function TE(e){if(!Xr(e)||!Zr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence"])||e.schemaVersion!==1||e.kind!=="PackageRelease"||!jE.test(e.packageName)||!$E.test(e.version)||!Rt(e.title,120)||!Rt(e.summary,1e3)||!["candidate","stable","deprecated"].includes(e.maturity)||!Xr(e.source)||!Zr(e.source,["repository","path","revision","treeDigest"])||!Rt(e.source.repository)||!Zc(e.source.path)||!Rt(e.source.revision,200)||!Qc.test(String(e.source.treeDigest))||!CE(e.artifact)||!Xr(e.compatibility)||!Zr(e.compatibility,["node","packageManager"])||!Rt(e.compatibility.node,100)||!Rt(e.compatibility.packageManager,100)||!gm(e.exports)||!gm(e.consumerEvidence)||!Xr(e.documentation))return!1;let t=e.documentation.knowledgeRef===void 0?["readme"]:["readme","knowledgeRef"];return!Zr(e.documentation,t)||!Zc(e.documentation.readme)||e.documentation.knowledgeRef!==void 0&&!Rt(e.documentation.knowledgeRef,500)?!1:e.artifact!==null||e.maturity!=="stable"}function xE(e){let t={schemaVersion:1,kind:"PackageRelease",...e,source:Object.freeze({...e.source}),artifact:e.artifact===null?null:Object.freeze({...e.artifact}),compatibility:Object.freeze({...e.compatibility}),exports:Object.freeze([...e.exports]),documentation:Object.freeze({...e.documentation}),consumerEvidence:Object.freeze([...e.consumerEvidence])};if(!TE(t))throw new sa("PACKAGE_RELEASE_INVALID","PackageRelease \u5185\u5BB9\u65E0\u6548");return Object.freeze({...t,releaseDigest:v(E(t))})}function hm(e){if(!Xr(e)||!Zr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence","releaseDigest"])||!Qc.test(String(e.releaseDigest)))throw new sa("PACKAGE_RELEASE_INVALID","PackageRelease \u7ED3\u6784\u65E0\u6548");let{releaseDigest:t,schemaVersion:r,kind:n,...a}=e,i=xE(a);if(i.releaseDigest!==t)throw new sa("PACKAGE_RELEASE_MODIFIED","PackageRelease \u5DF2\u88AB\u4FEE\u6539");return i}import{lstat as LE,readFile as VE,realpath as ME}from"node:fs/promises";import ym from"node:path";async function wm(e){let t=await ME(ym.resolve(e.projectRoot)),r=new Set(e.excludeCapabilityIds??[]),n=new Map,a=[...e.lock.capabilities].sort((o,s)=>o.committedAt.localeCompare(s.committedAt)||o.capabilityId.localeCompare(s.capabilityId));for(let o of a)if(!r.has(o.capabilityId))for(let s of o.assets){let c=s.ownership??"owned-file",d=`${s.path}\0`;if(c==="managed-region")n.delete(d);else for(let p of n.keys())p.startsWith(d)&&n.delete(p);let l=c==="managed-region"?`${d}${s.regionId??""}`:d;n.set(l,{capabilityId:o.capabilityId,path:s.path,digest:s.digest,ownership:c,...s.regionId===void 0?{}:{regionId:s.regionId}})}let i=[];for(let o of[...n.values()].sort((s,c)=>s.path.localeCompare(c.path)||(s.regionId??"").localeCompare(c.regionId??"")||s.capabilityId.localeCompare(c.capabilityId))){let s=ym.join(t,...o.path.split("/")),d=await LE(s).then(async l=>{if(!l.isFile()||l.isSymbolicLink())return;let p=await VE(s);if(o.ownership!=="managed-region")return v(p);if(o.regionId!==void 0)try{return v(Xa(p.toString("utf8"),o.regionId))}catch{return}}).catch(l=>l.code==="ENOENT"?void 0:Promise.reject(l))===o.digest;i.push({capabilityId:o.capabilityId,path:o.path,kind:"create",ownership:o.ownership,...o.regionId===void 0?{}:{regionId:o.regionId},desiredDigest:o.digest,disposition:d?"noop":"conflict",...d?{}:{conflictCode:"BASE_DIGEST_MISMATCH"}})}return i}var el="0.1.24",ca={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},qE=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function vm(e,t){return typeof e=="string"&&e.length>0&&e.length<=t&&!qE.test(e)}function UE(e){let t={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:ca[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},r=FE(t);if(r===null)throw new TypeError("CLI domain error input is invalid");return r}function FE(e){try{if(typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype)return null;let t=Object.getOwnPropertyDescriptors(e);if(Reflect.ownKeys(t).some(s=>typeof s=="symbol"))return null;let r=Object.keys(t).sort(),n="nextStep"in t?["code","exitCode","kind","message","nextStep","schemaVersion"]:["code","exitCode","kind","message","schemaVersion"];if(r.length!==n.length||r.some((s,c)=>s!==n[c])||Object.values(t).some(s=>!("value"in s)))return null;let a=s=>t[s]?.value,i=a("code");if(a("schemaVersion")!==1||a("kind")!=="dyyto-cli-domain-error"||typeof i!="string"||!(i in ca)||a("exitCode")!==ca[i]||!vm(a("message"),500))return null;let o=a("nextStep");return o!==void 0&&!vm(o,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:i,message:a("message"),exitCode:4,...o===void 0?{}:{nextStep:o}})}catch{return null}}var Ce=class extends Error{code;exitCode;nextStep;domainError;constructor(t){super(t.message),this.name="CliError",this.code=t.code,this.exitCode=t.exitCode,this.nextStep=t.nextStep,this.domainError=t.code in ca&&t.exitCode===ca[t.code]?UE({code:t.code,message:t.message,...t.nextStep===void 0?{}:{nextStep:t.nextStep}}):void 0}};var Im=`Dyyto Engineering Platform CLI
46
46
 
47
47
  Usage:
48
48
  dyyto <command> [options]
package/dist/chunk.js CHANGED
@@ -1,4 +1,4 @@
1
- var h=Object.create;var y=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var O=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}};var v=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!b.call(e,o)&&o!==t&&y(e,o,{get:()=>n[o],enumerable:!(r=C(n,o))||r.enumerable});return e};var N=(e,n,t)=>(t=e!=null?h(E(e)):{},v(n||!e||!e.__esModule?y(t,"default",{value:e,enumerable:!0}):t,e));var F="0.1.23",c={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},D=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function f(e,n){return typeof e=="string"&&e.length>0&&e.length<=n&&!D.test(e)}function S(e){let n={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:c[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},t=m(n);if(t===null)throw new TypeError("CLI domain error input is invalid");return t}function m(e){try{if(typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype)return null;let n=Object.getOwnPropertyDescriptors(e);if(Reflect.ownKeys(n).some(i=>typeof i=="symbol"))return null;let t=Object.keys(n).sort(),r="nextStep"in n?["code","exitCode","kind","message","nextStep","schemaVersion"]:["code","exitCode","kind","message","schemaVersion"];if(t.length!==r.length||t.some((i,k)=>i!==r[k])||Object.values(n).some(i=>!("value"in i)))return null;let o=i=>n[i]?.value,a=o("code");if(o("schemaVersion")!==1||o("kind")!=="dyyto-cli-domain-error"||typeof a!="string"||!(a in c)||o("exitCode")!==c[a]||!f(o("message"),500))return null;let d=o("nextStep");return d!==void 0&&!f(d,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:a,message:o("message"),exitCode:4,...d===void 0?{}:{nextStep:d}})}catch{return null}}function T(e){if(e instanceof l&&e.domainError!==void 0)return e.domainError;try{if(typeof e!="object"||e===null)return null;let n=Object.getOwnPropertyDescriptor(e,"domainError");return n!==void 0&&"value"in n?m(n.value):null}catch{return null}}var l=class extends Error{code;exitCode;nextStep;domainError;constructor(n){super(n.message),this.name="CliError",this.code=n.code,this.exitCode=n.exitCode,this.nextStep=n.nextStep,this.domainError=n.code in c&&n.exitCode===c[n.code]?S({code:n.code,message:n.message,...n.nextStep===void 0?{}:{nextStep:n.nextStep}}):void 0}};var z=`Dyyto Engineering Platform CLI
1
+ var h=Object.create;var y=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var O=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}};var v=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of w(n))!b.call(e,o)&&o!==t&&y(e,o,{get:()=>n[o],enumerable:!(r=C(n,o))||r.enumerable});return e};var N=(e,n,t)=>(t=e!=null?h(E(e)):{},v(n||!e||!e.__esModule?y(t,"default",{value:e,enumerable:!0}):t,e));var F="0.1.24",c={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},D=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function f(e,n){return typeof e=="string"&&e.length>0&&e.length<=n&&!D.test(e)}function S(e){let n={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:c[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},t=m(n);if(t===null)throw new TypeError("CLI domain error input is invalid");return t}function m(e){try{if(typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype)return null;let n=Object.getOwnPropertyDescriptors(e);if(Reflect.ownKeys(n).some(i=>typeof i=="symbol"))return null;let t=Object.keys(n).sort(),r="nextStep"in n?["code","exitCode","kind","message","nextStep","schemaVersion"]:["code","exitCode","kind","message","schemaVersion"];if(t.length!==r.length||t.some((i,k)=>i!==r[k])||Object.values(n).some(i=>!("value"in i)))return null;let o=i=>n[i]?.value,a=o("code");if(o("schemaVersion")!==1||o("kind")!=="dyyto-cli-domain-error"||typeof a!="string"||!(a in c)||o("exitCode")!==c[a]||!f(o("message"),500))return null;let d=o("nextStep");return d!==void 0&&!f(d,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:a,message:o("message"),exitCode:4,...d===void 0?{}:{nextStep:d}})}catch{return null}}function T(e){if(e instanceof l&&e.domainError!==void 0)return e.domainError;try{if(typeof e!="object"||e===null)return null;let n=Object.getOwnPropertyDescriptor(e,"domainError");return n!==void 0&&"value"in n?m(n.value):null}catch{return null}}var l=class extends Error{code;exitCode;nextStep;domainError;constructor(n){super(n.message),this.name="CliError",this.code=n.code,this.exitCode=n.exitCode,this.nextStep=n.nextStep,this.domainError=n.code in c&&n.exitCode===c[n.code]?S({code:n.code,message:n.message,...n.nextStep===void 0?{}:{nextStep:n.nextStep}}):void 0}};var z=`Dyyto Engineering Platform CLI
2
2
 
3
3
  Usage:
4
4
  dyyto <command> [options]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "package": "@aipt/cli",
4
- "version": "0.1.23",
4
+ "version": "0.1.24",
5
5
  "documents": [
6
6
  { "id": "bootstrap", "path": "docs/bootstrap.md", "digest": "sha256:05a41f0d6c57fb04c936e9ddb516c888bea18ea8a248aeb63261c0bf5eedf35d" },
7
7
  { "id": "agent-integration", "path": "docs/agent-integration.md", "digest": "sha256:6b3e9425bd5caf233971bc27dc2ef765bd1e9b92a049d3a394e075ed80c0863f" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipt/cli",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Dyyto 无服务工程能力目录、规划、应用与验证 CLI。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,9 +29,9 @@
29
29
  "devDependencies": {
30
30
  "esbuild": "0.28.2",
31
31
  "@aipt/page-definition": "0.1.0",
32
- "@aipt/object-store": "0.1.0",
33
32
  "@aipt/page-host-gateway": "0.1.0",
34
- "@aipt/platform-kernel": "0.1.7"
33
+ "@aipt/platform-kernel": "0.1.7",
34
+ "@aipt/object-store": "0.1.0"
35
35
  },
36
36
  "idpPackageRelease": {
37
37
  "title": "Dyyto CLI",