@aipt/cli 0.1.33 → 0.1.35
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.
- package/README.md +1 -1
- package/dist/application-runner.js +211 -208
- package/dist/application.js +4 -3
- package/dist/chunk.js +3 -2
- package/dist/optional-runtime.js +7 -7
- package/dist/package-releases/aipt--cli/0.1.34/release.json +29 -0
- package/dist/package-releases/aipt--idp-setup/0.1.7/release.json +31 -0
- package/dist/package-releases/aipt--platform-kernel/0.1.9/release.json +33 -0
- package/docs/bootstrap.md +1 -1
- package/docs/vibe-coding-guide.md +1 -1
- package/documentation-manifest.json +1 -1
- package/package.json +1 -1
package/dist/application.js
CHANGED
|
@@ -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 Ja(`${o}.tmp`,o),await this.resymbolicate(t.releaseId),s}async resymbolicate(t){let r=await Zf(ve.join(this.releases(),t)).catch(()=>[]),n=[];for(let i of r)try{n.push(JSON.parse(await ni(ve.join(this.releases(),t,i),"utf8")))}catch{}for(let i of(await this.all()).filter(a=>a.releaseId===t&&a.state==="map-missing")){let a=!1,o=i.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=Xf(new Hf(p.map),{line:l.line,column:Math.max(0,l.column-1)});return m.source===null||m.line===null||m.column===null?l:(a=!0,{...l,source:m.source.replace(/^file:\/\//,""),sourceLine:m.line,sourceColumn:m.column+1})}catch{return l}});if(!a)continue;let s={...i,error:{...i.error,frames:o},state:"symbolicated"},c=ve.join(this.directory(),`${i.eventId}.json`),d=await Ba(`${c}.tmp`,"w",384);try{await d.writeFile(`${E(s)}
|
|
43
43
|
`),await d.sync()}finally{await d.close()}await Ja(`${c}.tmp`,c)}}};var Ue=(e,t,r,n,i)=>({code:e,severity:t,fact:r,message:n,...i===void 0?{}:{action:i}});async function ai(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 i=On(JSON.parse(await tm(Zc.join(e.projectRoot,".dyyto","evidence",`${n}.json`),"utf8")));if(i.evidenceId!==n||i.capabilityId!==r.capabilityId||i.capabilityVersion!==r.version||i.capabilityIntegrity!==r.integrity||i.projectStateDigest!==r.projectStateDigest||i.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 Qc(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 rm(e){try{let r=JSON.parse(await tm(Zc.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 wr(e.workspaceRoot).list({applicationId:e.applicationId});let t=(await kE(Zc.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 nm(e){let t=e.units.map(n=>{let i=n.findings.some(a=>a.severity==="critical")?"blocked":n.findings.some(a=>a.severity==="warning")?"attention":"healthy";return{...n,status:i}}),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 oi,realpath as im}from"node:fs/promises";import vr from"node:path";var ae=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function am(e){let t=await im(vr.resolve(e.projectRoot)),r=J(e.manifest),n=e.release.release,i=e.currentLock.capabilities.find(m=>m.capabilityId===n.capabilityId&&m.version===n.version);if(!i||i.packageAdoption!==void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Asset-only removal requires an adopted Capability without package ownership");let a=J({...r,capabilities:r.capabilities.filter(m=>m.capabilityId!==n.capabilityId)}),o=Buffer.from(`${JSON.stringify(a,null,2)}
|
|
44
44
|
`),s=await si(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)},...i.assets.map(m=>({path:m.path,kind:"remove",ownership:m.ownership??"owned-file",baseDigest:m.digest}))],d=await Promise.all(c.map(m=>si(t,m.path))),l={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:i.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:De({action:"remove",capability:l,changes:c,observedAssets:d,generatedAt:e.generatedAt,expiresAt:e.expiresAt}),manifest:a,desiredContents:new Map([["project-capabilities.json",o]]),transactionRoot:t,removedSources:[]}}async function si(e,t){try{let r=await oi(vr.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 el(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 im(vr.resolve(e.projectRoot)),r=J(e.manifest),n=e.release.release,i=e.packageSource?.topology,a=i?.transactionRoot??t,o=k=>i?.mode==="pnpm-shared-lockfile"?`${i.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=J({...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 si(a,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 oi(vr.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 oi(vr.join(t,"pnpm-lock.yaml")).catch(ne=>ne.code==="ENOENT"?void 0:Promise.reject(ne)),O=e.packageSource.topology??{schemaVersion:1,mode:"standalone",transactionRoot:t,unitRoot:t,unitRelativeRoot:".",unitImporterId:".",lockfilePath:"pnpm-lock.yaml"},se=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(se&&(!e.packageSource.resolutionEvidence||!e.packageSource.resolutionWorkerReleaseId))throw new H("PACKAGE_SOURCE_POLICY_VIOLATION");let Y=se?(e.packageChannel==="development"?ja:Sa)({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"?Da:Na)({release:n,...P,lockResolution:e.packageSource.lockResolution,consumerProfile:c,packageJson:k,...S===void 0?{}:{currentLockfile:S},generatedAt:e.generatedAt,expiresAt:e.expiresAt});_=Aa(Y),h.push({path:o("package.json"),kind:"replace",ownership:"owned-file",baseDigest:Y.packageJsonPreimageDigest,desiredDigest:Y.desiredPackageJsonDigest}),w.set(o("package.json"),Y.desiredPackageJson),h.push({path:O.lockfilePath,kind:S===void 0?"create":"replace",ownership:"owned-file",...S===void 0?{}:{baseDigest:v(S)},desiredDigest:Y.desiredLockfileDigest}),w.set(O.lockfilePath,Y.desiredLockfile)}catch(S){throw S instanceof H?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"?Oa(r):k.renderer==="application-config-binding-v1"?xa(r):S;if(k.ownership==="managed-region"){if(k.regionId===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Managed region identity is unavailable");let se;try{se=await oi(vr.join(t,...k.path.split("/")))}catch{throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The managed shared file is unavailable")}let $=Buffer.from(vu({source:se.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(se),desiredDigest:v($)}),w.set(o(k.path),$)}else{let se=await si(t,k.path);if(k.ownership==="seed-file"&&se.exists){let $=await oi(vr.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=>si(a,k.path))),A={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:h.filter(k=>k.path!==u&&k.path!==i?.lockfilePath).map(k=>({path:i?.mode==="pnpm-shared-lockfile"?k.path.slice(i.unitRelativeRoot.length+1):k.path,ownership:k.ownership,desiredDigest:k.desiredDigest})),verifiers:n.verifiers.map(k=>({id:k.id,kind:"file-digest"}))};return{plan:De({action:"adopt",capability:A,changes:h,observedAssets:b,generatedAt:e.generatedAt,expiresAt:e.expiresAt,..._===void 0?{}:{packageAdoption:_}}),manifest:m,desiredContents:w,transactionRoot:a,dependency:{profile:c,satisfied:!0}}}var om=br(nr(),1);var _E={$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:Z},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},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:Z},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}}}}},cD=new om.Ajv2020({allErrors:!0,strict:!0}).compile(_E);var pm=br(nr(),1);import{readFile as EE,realpath as AE}from"node:fs/promises";import sm from"node:path";var cm="^[a-z0-9]+(?:[.-][a-z0-9]+)*$",lm="^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)[^\\u0000]+$",RE={$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:cm},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},title:{type:"string",minLength:1,maxLength:80},locale:{const:"zh-CN"},rootProfile:{type:"object",additionalProperties:!1,required:["capabilityId","version"],properties:{capabilityId:{type:"string",pattern:Z},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:Z},version:{type:"string",minLength:1,maxLength:128},channel:{const:"development"}}}},expectedEntrypoint:{type:"string",pattern:lm,maxLength:240},verifiers:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",pattern:cm}},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:lm,maxLength:240}}}}}},dm=new pm.Ajv2020({allErrors:!0,strict:!0}).compile(RE),Ir=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function PE(e){return v(E(e))}function NE(e){if(!dm(e))throw new Ir("EXAMPLE_RECIPE_INVALID",dm.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 Ir("EXAMPLE_RECIPE_INVALID");return t}async function um(e){let t=await AE(sm.resolve(e)),r;try{r=NE(JSON.parse(await EE(sm.join(t,"recipe.json"),"utf8")))}catch(a){throw a instanceof Ir?a:new Ir("EXAMPLE_RECIPE_INVALID")}let{integrity:n,...i}=r;if(PE(i)!==n)throw new Ir("EXAMPLE_RECIPE_INTEGRITY_MISMATCH");return r}var gm=br(nr(),1);import{readFile as DE,realpath as SE}from"node:fs/promises";import fm from"node:path";var jE={$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:Z},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},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:Z},capability:{type:"string",pattern:`${Z.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:Z},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:Z},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"]}}}},mm=new gm.Ajv2020({allErrors:!0,strict:!0,formats:{date:/^\d{4}-\d{2}-\d{2}$/}}).compile(jE),Rt=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function $E(e){return v(E(e))}function OE(e){if(!mm(e))throw new Rt("TEMPLATE_INVALID",mm.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 Rt("TEMPLATE_INVALID");if(Date.parse(t.support.supportedUntil)<=Date.parse(t.support.supportedFrom))throw new Rt("TEMPLATE_INVALID");return t}async function ci(e,t=new Date){let r=await SE(fm.resolve(e)),n;try{n=OE(JSON.parse(await DE(fm.join(r,"template.json"),"utf8")))}catch(o){throw o instanceof Rt?o:new Rt("TEMPLATE_INVALID")}let{integrity:i,...a}=n;if($E(a)!==i)throw new Rt("TEMPLATE_INTEGRITY_MISMATCH");if(n.status==="recommended"&&Date.parse(n.support.supportedUntil)<t.getTime())throw new Rt("TEMPLATE_SUPPORT_EXPIRED");return n}import{readFile as hm}from"node:fs/promises";import ym from"node:path";var CE=/^[A-Z][A-Z0-9_]*$/u,TE=/(?:API_KEY|ACCESS_KEY|SECRET|TOKEN|PASSWORD|PRIVATE_KEY|DATABASE_URL|POSTGRES_URL)$/u;function xE(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||!CE.test(n[1]))continue;let i=n[1],a=n[2].trim();t.set(i,{name:i,requirement:a.length===0?"conditional":"optional",secret:TE.test(i),configured:!1,source:".env.example",configuredSource:null})}return[...t.values()]}async function wm(e){let t=await hm(ym.join(e.projectRoot,".env.example"),"utf8").then(()=>".env.example").catch(()=>null),r=t?await hm(ym.join(e.projectRoot,t),"utf8"):"",n=await Zn({projectRoot:e.projectRoot}).catch(()=>null);return{commands:["dev","build","test","package"].flatMap(a=>e.commands[a]?[{id:a,script:e.commands[a],mode:a==="dev"?"managed-process":"foreground-task"}]:[]),environment:n?n.entries.map(a=>({name:a.name,requirement:a.required?"conditional":"optional",secret:a.kind!=="value",configured:a.configured,source:"application-config-contract",configuredSource:"APP_CONFIG_DIR",display:a.display,...a.fingerprint?{fingerprint:a.fingerprint}:{}})):xE(r),environmentExample:t,productionValidation:{contract:!0,live:["provider-read","oss-write-read-delete"]}}}var vm={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"])},Im=new Set(["queued","running","succeeded","failed","outcome-unknown","cancelled"]);function bm(e,t){if(!vm[t.plane]||t.state&&!Im.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=vm[t.plane],n=t.from?Date.parse(t.from):null,i=t.to?Date.parse(t.to):null;if(n!==null&&Number.isNaN(n)||i!==null&&Number.isNaN(i)||n!==null&&i!==null&&n>i)throw new Error("OPERATION_FILTER_INVALID");let a=e.filter(d=>r.has(d.operation)),o=[...new Map(a.map(d=>[d.projectId,{id:d.projectId,name:d.projectName}])).values()].sort((d,l)=>d.name.localeCompare(l.name)),s=a.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)&&(i===null||Date.parse(d.createdAt)<=i)).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([...Im]),kinds:Object.freeze([...r])}),items:Object.freeze(s.slice(0,t.limit??50).map(Object.freeze)),hasMore:s.length>(t.limit??50)})}var li=class extends Error{code;constructor(t,r){super(r),this.code=t}},rl=/^sha256:[a-f0-9]{64}$/u,LE=/^sha512-[A-Za-z0-9+/]{86}==$/u,VE=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u,ME=/^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/u,qE=/[\u0000-\u001f\u007f]/u;function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Qr(e,t){let r=Object.keys(e).sort(),n=[...t].sort();return r.length===n.length&&r.every((i,a)=>i===n[a])}function Pt(e,t=500){return typeof e=="string"&&e.length>0&&e.length<=t&&!qE.test(e)}function tl(e){return Pt(e,500)&&!e.startsWith("/")&&!e.startsWith("../")&&!e.includes("/../")&&!e.includes("\\")}function km(e,t=128){return Array.isArray(e)&&e.length<=t&&e.every(r=>Pt(r,500))&&e.every((r,n)=>n===0||e[n-1]<r)}function UE(e){return e===null?!0:!Zr(e)||!Qr(e,["fileName","digest","integrity","fileCount","unpackedBytes"])?!1:tl(e.fileName)&&rl.test(String(e.digest))&&LE.test(String(e.integrity))&&Number.isSafeInteger(e.fileCount)&&Number(e.fileCount)>0&&Number.isSafeInteger(e.unpackedBytes)&&Number(e.unpackedBytes)>0}function FE(e){if(!Zr(e)||!Qr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence"])||e.schemaVersion!==1||e.kind!=="PackageRelease"||!VE.test(e.packageName)||!ME.test(e.version)||!Pt(e.title,120)||!Pt(e.summary,1e3)||!["candidate","stable","deprecated"].includes(e.maturity)||!Zr(e.source)||!Qr(e.source,["repository","path","revision","treeDigest"])||!Pt(e.source.repository)||!tl(e.source.path)||!Pt(e.source.revision,200)||!rl.test(String(e.source.treeDigest))||!UE(e.artifact)||!Zr(e.compatibility)||!Qr(e.compatibility,["node","packageManager"])||!Pt(e.compatibility.node,100)||!Pt(e.compatibility.packageManager,100)||!km(e.exports)||!km(e.consumerEvidence)||!Zr(e.documentation))return!1;let t=e.documentation.knowledgeRef===void 0?["readme"]:["readme","knowledgeRef"];return!Qr(e.documentation,t)||!tl(e.documentation.readme)||e.documentation.knowledgeRef!==void 0&&!Pt(e.documentation.knowledgeRef,500)?!1:e.artifact!==null||e.maturity!=="stable"}function zE(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(!FE(t))throw new li("PACKAGE_RELEASE_INVALID","PackageRelease \u5185\u5BB9\u65E0\u6548");return Object.freeze({...t,releaseDigest:v(E(t))})}function _m(e){if(!Zr(e)||!Qr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence","releaseDigest"])||!rl.test(String(e.releaseDigest)))throw new li("PACKAGE_RELEASE_INVALID","PackageRelease \u7ED3\u6784\u65E0\u6548");let{releaseDigest:t,schemaVersion:r,kind:n,...i}=e,a=zE(i);if(a.releaseDigest!==t)throw new li("PACKAGE_RELEASE_MODIFIED","PackageRelease \u5DF2\u88AB\u4FEE\u6539");return a}import{lstat as BE,readFile as JE,realpath as GE}from"node:fs/promises";import Em from"node:path";async function Am(e){let t=await GE(Em.resolve(e.projectRoot)),r=new Set(e.excludeCapabilityIds??[]),n=new Map,i=[...e.lock.capabilities].sort((o,s)=>o.committedAt.localeCompare(s.committedAt)||o.capabilityId.localeCompare(s.capabilityId));for(let o of i)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 a=[];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=Em.join(t,...o.path.split("/")),d=await BE(s).then(async l=>{if(!l.isFile()||l.isSymbolicLink())return;let p=await JE(s);if(o.ownership!=="managed-region")return v(p);if(o.regionId!==void 0)try{return v(Qi(p.toString("utf8"),o.regionId))}catch{return}}).catch(l=>l.code==="ENOENT"?void 0:Promise.reject(l))===o.digest;a.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 a}var nl="0.1.33",di={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},WE=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function Rm(e,t){return typeof e=="string"&&e.length>0&&e.length<=t&&!WE.test(e)}function KE(e){let t={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:di[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},r=YE(t);if(r===null)throw new TypeError("CLI domain error input is invalid");return r}function YE(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 i=s=>t[s]?.value,a=i("code");if(i("schemaVersion")!==1||i("kind")!=="dyyto-cli-domain-error"||typeof a!="string"||!(a in di)||i("exitCode")!==di[a]||!Rm(i("message"),500))return null;let o=i("nextStep");return o!==void 0&&!Rm(o,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:a,message:i("message"),exitCode:4,...o===void 0?{}:{nextStep:o}})}catch{return null}}var Te=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 di&&t.exitCode===di[t.code]?KE({code:t.code,message:t.message,...t.nextStep===void 0?{}:{nextStep:t.nextStep}}):void 0}};var Pm=`Dyyto Engineering Platform CLI
|
|
45
|
+
`),g=await si(a,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 oi(vr.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 oi(vr.join(t,"pnpm-lock.yaml")).catch(ne=>ne.code==="ENOENT"?void 0:Promise.reject(ne)),O=e.packageSource.topology??{schemaVersion:1,mode:"standalone",transactionRoot:t,unitRoot:t,unitRelativeRoot:".",unitImporterId:".",lockfilePath:"pnpm-lock.yaml"},se=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(se&&(!e.packageSource.resolutionEvidence||!e.packageSource.resolutionWorkerReleaseId))throw new H("PACKAGE_SOURCE_POLICY_VIOLATION");let Y=se?(e.packageChannel==="development"?ja:Sa)({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"?Da:Na)({release:n,...P,lockResolution:e.packageSource.lockResolution,consumerProfile:c,packageJson:k,...S===void 0?{}:{currentLockfile:S},generatedAt:e.generatedAt,expiresAt:e.expiresAt});_=Aa(Y),h.push({path:o("package.json"),kind:"replace",ownership:"owned-file",baseDigest:Y.packageJsonPreimageDigest,desiredDigest:Y.desiredPackageJsonDigest}),w.set(o("package.json"),Y.desiredPackageJson),h.push({path:O.lockfilePath,kind:S===void 0?"create":"replace",ownership:"owned-file",...S===void 0?{}:{baseDigest:v(S)},desiredDigest:Y.desiredLockfileDigest}),w.set(O.lockfilePath,Y.desiredLockfile)}catch(S){throw S instanceof H?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"?Oa(r):k.renderer==="application-config-binding-v1"?xa(r):S;if(k.ownership==="managed-region"){if(k.regionId===void 0)throw new ae("CAPABILITY_KIND_UNSUPPORTED","Managed region identity is unavailable");let se;try{se=await oi(vr.join(t,...k.path.split("/")))}catch{throw new ae("CAPABILITY_DEPENDENCY_UNSATISFIED","The managed shared file is unavailable")}let $=Buffer.from(vu({source:se.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(se),desiredDigest:v($)}),w.set(o(k.path),$)}else{let se=await si(t,k.path);if(k.ownership==="seed-file"&&se.exists){let $=await oi(vr.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=>si(a,k.path))),A={schemaVersion:1,capabilityId:n.capabilityId,version:n.version,integrity:n.integrity,assets:h.filter(k=>k.path!==u&&k.path!==i?.lockfilePath).map(k=>({path:i?.mode==="pnpm-shared-lockfile"?k.path.slice(i.unitRelativeRoot.length+1):k.path,ownership:k.ownership,desiredDigest:k.desiredDigest})),verifiers:n.verifiers.map(k=>({id:k.id,kind:"file-digest"}))};return{plan:De({action:"adopt",capability:A,changes:h,observedAssets:b,generatedAt:e.generatedAt,expiresAt:e.expiresAt,..._===void 0?{}:{packageAdoption:_}}),manifest:m,desiredContents:w,transactionRoot:a,dependency:{profile:c,satisfied:!0}}}var om=br(nr(),1);var _E={$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:Z},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},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:Z},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}}}}},cD=new om.Ajv2020({allErrors:!0,strict:!0}).compile(_E);var pm=br(nr(),1);import{readFile as EE,realpath as AE}from"node:fs/promises";import sm from"node:path";var cm="^[a-z0-9]+(?:[.-][a-z0-9]+)*$",lm="^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\)[^\\u0000]+$",RE={$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:cm},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},title:{type:"string",minLength:1,maxLength:80},locale:{const:"zh-CN"},rootProfile:{type:"object",additionalProperties:!1,required:["capabilityId","version"],properties:{capabilityId:{type:"string",pattern:Z},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:Z},version:{type:"string",minLength:1,maxLength:128},channel:{const:"development"}}}},expectedEntrypoint:{type:"string",pattern:lm,maxLength:240},verifiers:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",pattern:cm}},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:lm,maxLength:240}}}}}},dm=new pm.Ajv2020({allErrors:!0,strict:!0}).compile(RE),Ir=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function PE(e){return v(E(e))}function NE(e){if(!dm(e))throw new Ir("EXAMPLE_RECIPE_INVALID",dm.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 Ir("EXAMPLE_RECIPE_INVALID");return t}async function um(e){let t=await AE(sm.resolve(e)),r;try{r=NE(JSON.parse(await EE(sm.join(t,"recipe.json"),"utf8")))}catch(a){throw a instanceof Ir?a:new Ir("EXAMPLE_RECIPE_INVALID")}let{integrity:n,...i}=r;if(PE(i)!==n)throw new Ir("EXAMPLE_RECIPE_INTEGRITY_MISMATCH");return r}var gm=br(nr(),1);import{readFile as DE,realpath as SE}from"node:fs/promises";import fm from"node:path";var jE={$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:Z},version:{type:"string",minLength:1,maxLength:128},integrity:{type:"string",pattern:ut},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:Z},capability:{type:"string",pattern:`${Z.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:Z},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:Z},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"]}}}},mm=new gm.Ajv2020({allErrors:!0,strict:!0,formats:{date:/^\d{4}-\d{2}-\d{2}$/}}).compile(jE),Rt=class extends Error{code;issues;constructor(t,r=[]){super(t),this.code=t,this.issues=r}};function $E(e){return v(E(e))}function OE(e){if(!mm(e))throw new Rt("TEMPLATE_INVALID",mm.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 Rt("TEMPLATE_INVALID");if(Date.parse(t.support.supportedUntil)<=Date.parse(t.support.supportedFrom))throw new Rt("TEMPLATE_INVALID");return t}async function ci(e,t=new Date){let r=await SE(fm.resolve(e)),n;try{n=OE(JSON.parse(await DE(fm.join(r,"template.json"),"utf8")))}catch(o){throw o instanceof Rt?o:new Rt("TEMPLATE_INVALID")}let{integrity:i,...a}=n;if($E(a)!==i)throw new Rt("TEMPLATE_INTEGRITY_MISMATCH");if(n.status==="recommended"&&Date.parse(n.support.supportedUntil)<t.getTime())throw new Rt("TEMPLATE_SUPPORT_EXPIRED");return n}import{readFile as hm}from"node:fs/promises";import ym from"node:path";var CE=/^[A-Z][A-Z0-9_]*$/u,TE=/(?:API_KEY|ACCESS_KEY|SECRET|TOKEN|PASSWORD|PRIVATE_KEY|DATABASE_URL|POSTGRES_URL)$/u;function xE(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||!CE.test(n[1]))continue;let i=n[1],a=n[2].trim();t.set(i,{name:i,requirement:a.length===0?"conditional":"optional",secret:TE.test(i),configured:!1,source:".env.example",configuredSource:null})}return[...t.values()]}async function wm(e){let t=await hm(ym.join(e.projectRoot,".env.example"),"utf8").then(()=>".env.example").catch(()=>null),r=t?await hm(ym.join(e.projectRoot,t),"utf8"):"",n=await Zn({projectRoot:e.projectRoot}).catch(()=>null);return{commands:["dev","build","test","package"].flatMap(a=>e.commands[a]?[{id:a,script:e.commands[a],mode:a==="dev"?"managed-process":"foreground-task"}]:[]),environment:n?n.entries.map(a=>({name:a.name,requirement:a.required?"conditional":"optional",secret:a.kind!=="value",configured:a.configured,source:"application-config-contract",configuredSource:"APP_CONFIG_DIR",display:a.display,...a.fingerprint?{fingerprint:a.fingerprint}:{}})):xE(r),environmentExample:t,productionValidation:{contract:!0,live:["provider-read","oss-write-read-delete"]}}}var vm={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"])},Im=new Set(["queued","running","succeeded","failed","outcome-unknown","cancelled"]);function bm(e,t){if(!vm[t.plane]||t.state&&!Im.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=vm[t.plane],n=t.from?Date.parse(t.from):null,i=t.to?Date.parse(t.to):null;if(n!==null&&Number.isNaN(n)||i!==null&&Number.isNaN(i)||n!==null&&i!==null&&n>i)throw new Error("OPERATION_FILTER_INVALID");let a=e.filter(d=>r.has(d.operation)),o=[...new Map(a.map(d=>[d.projectId,{id:d.projectId,name:d.projectName}])).values()].sort((d,l)=>d.name.localeCompare(l.name)),s=a.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)&&(i===null||Date.parse(d.createdAt)<=i)).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([...Im]),kinds:Object.freeze([...r])}),items:Object.freeze(s.slice(0,t.limit??50).map(Object.freeze)),hasMore:s.length>(t.limit??50)})}var li=class extends Error{code;constructor(t,r){super(r),this.code=t}},rl=/^sha256:[a-f0-9]{64}$/u,LE=/^sha512-[A-Za-z0-9+/]{86}==$/u,VE=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u,ME=/^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$/u,qE=/[\u0000-\u001f\u007f]/u;function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Qr(e,t){let r=Object.keys(e).sort(),n=[...t].sort();return r.length===n.length&&r.every((i,a)=>i===n[a])}function Pt(e,t=500){return typeof e=="string"&&e.length>0&&e.length<=t&&!qE.test(e)}function tl(e){return Pt(e,500)&&!e.startsWith("/")&&!e.startsWith("../")&&!e.includes("/../")&&!e.includes("\\")}function km(e,t=128){return Array.isArray(e)&&e.length<=t&&e.every(r=>Pt(r,500))&&e.every((r,n)=>n===0||e[n-1]<r)}function UE(e){return e===null?!0:!Zr(e)||!Qr(e,["fileName","digest","integrity","fileCount","unpackedBytes"])?!1:tl(e.fileName)&&rl.test(String(e.digest))&&LE.test(String(e.integrity))&&Number.isSafeInteger(e.fileCount)&&Number(e.fileCount)>0&&Number.isSafeInteger(e.unpackedBytes)&&Number(e.unpackedBytes)>0}function FE(e){if(!Zr(e)||!Qr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence"])||e.schemaVersion!==1||e.kind!=="PackageRelease"||!VE.test(e.packageName)||!ME.test(e.version)||!Pt(e.title,120)||!Pt(e.summary,1e3)||!["candidate","stable","deprecated"].includes(e.maturity)||!Zr(e.source)||!Qr(e.source,["repository","path","revision","treeDigest"])||!Pt(e.source.repository)||!tl(e.source.path)||!Pt(e.source.revision,200)||!rl.test(String(e.source.treeDigest))||!UE(e.artifact)||!Zr(e.compatibility)||!Qr(e.compatibility,["node","packageManager"])||!Pt(e.compatibility.node,100)||!Pt(e.compatibility.packageManager,100)||!km(e.exports)||!km(e.consumerEvidence)||!Zr(e.documentation))return!1;let t=e.documentation.knowledgeRef===void 0?["readme"]:["readme","knowledgeRef"];return!Qr(e.documentation,t)||!tl(e.documentation.readme)||e.documentation.knowledgeRef!==void 0&&!Pt(e.documentation.knowledgeRef,500)?!1:e.artifact!==null||e.maturity!=="stable"}function zE(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(!FE(t))throw new li("PACKAGE_RELEASE_INVALID","PackageRelease \u5185\u5BB9\u65E0\u6548");return Object.freeze({...t,releaseDigest:v(E(t))})}function _m(e){if(!Zr(e)||!Qr(e,["schemaVersion","kind","packageName","version","title","summary","maturity","source","artifact","compatibility","exports","documentation","consumerEvidence","releaseDigest"])||!rl.test(String(e.releaseDigest)))throw new li("PACKAGE_RELEASE_INVALID","PackageRelease \u7ED3\u6784\u65E0\u6548");let{releaseDigest:t,schemaVersion:r,kind:n,...i}=e,a=zE(i);if(a.releaseDigest!==t)throw new li("PACKAGE_RELEASE_MODIFIED","PackageRelease \u5DF2\u88AB\u4FEE\u6539");return a}import{lstat as BE,readFile as JE,realpath as GE}from"node:fs/promises";import Em from"node:path";async function Am(e){let t=await GE(Em.resolve(e.projectRoot)),r=new Set(e.excludeCapabilityIds??[]),n=new Map,i=[...e.lock.capabilities].sort((o,s)=>o.committedAt.localeCompare(s.committedAt)||o.capabilityId.localeCompare(s.capabilityId));for(let o of i)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 a=[];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=Em.join(t,...o.path.split("/")),d=await BE(s).then(async l=>{if(!l.isFile()||l.isSymbolicLink())return;let p=await JE(s);if(o.ownership!=="managed-region")return v(p);if(o.regionId!==void 0)try{return v(Qi(p.toString("utf8"),o.regionId))}catch{return}}).catch(l=>l.code==="ENOENT"?void 0:Promise.reject(l))===o.digest;a.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 a}var nl="0.1.34",di={DEPENDENCIES_NOT_INSTALLED:4,VERIFIER_RUNTIME_INVALID:4},WE=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/u;function Rm(e,t){return typeof e=="string"&&e.length>0&&e.length<=t&&!WE.test(e)}function KE(e){let t={schemaVersion:1,kind:"dyyto-cli-domain-error",code:e.code,message:e.message,exitCode:di[e.code],...e.nextStep===void 0?{}:{nextStep:e.nextStep}},r=YE(t);if(r===null)throw new TypeError("CLI domain error input is invalid");return r}function YE(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 i=s=>t[s]?.value,a=i("code");if(i("schemaVersion")!==1||i("kind")!=="dyyto-cli-domain-error"||typeof a!="string"||!(a in di)||i("exitCode")!==di[a]||!Rm(i("message"),500))return null;let o=i("nextStep");return o!==void 0&&!Rm(o,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:a,message:i("message"),exitCode:4,...o===void 0?{}:{nextStep:o}})}catch{return null}}var Te=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 di&&t.exitCode===di[t.code]?KE({code:t.code,message:t.message,...t.nextStep===void 0?{}:{nextStep:t.nextStep}}):void 0}};var Pm=`Dyyto Engineering Platform CLI
|
|
46
46
|
|
|
47
47
|
Usage:
|
|
48
48
|
dyyto <command> [options]
|
|
@@ -51,6 +51,7 @@ Commands:
|
|
|
51
51
|
dyyto bootstrap --project DIR [--apply] \u521D\u59CB\u5316\u5E76\u9501\u5B9AVibe Coding\u5DE5\u7A0B\u4E0A\u4E0B\u6587
|
|
52
52
|
dyyto context resolve --project DIR \u89E3\u6790\u5F53\u524D\u5206\u652F\u7684\u5185\u5BB9\u5BFB\u5740\u5DE5\u7A0B\u4E0A\u4E0B\u6587
|
|
53
53
|
dyyto ready --project DIR \u68C0\u67E5\u4E0A\u4E0B\u6587\u3001\u914D\u7F6E\u4E0E\u5DE5\u7A0B\u5F00\u53D1\u5C31\u7EEA\u72B6\u6001
|
|
54
|
+
dyyto dev session start|show|finish \u7BA1\u7406\u76F4\u63A5\u5F00\u53D1\u4E0E\u9700\u6C42\u4EFB\u52A1\u5171\u7528\u7684\u5F00\u53D1 Session
|
|
54
55
|
dyyto agents sync --project DIR [--apply] \u540C\u6B65\u591A\u7F16\u7801Agent\u9002\u914D\u5668
|
|
55
56
|
dyyto agents remove --project DIR [--apply] \u5B89\u5168\u79FB\u9664\u53D7\u7BA1Agent\u9002\u914D\u5668
|
|
56
57
|
dyyto docs show --id ID \u8BFB\u53D6npm\u5305\u5185\u7A33\u5B9A\u6587\u6863
|
|
@@ -101,7 +102,7 @@ Options:
|
|
|
101
102
|
--json Emit one machine-readable JSON object
|
|
102
103
|
--help Show help
|
|
103
104
|
--version Show version
|
|
104
|
-
`;import{lstat as
|
|
105
|
+
`;import{lstat as US,readFile as HE,readdir as XE}from"node:fs/promises";import Dm from"node:path";var Nm={"workspace-node-application":"foundation.workspace-node-application@1.1.0","workspace-web-application":"foundation.workspace-web-application@1.1.0","workspace-expo-application":"foundation.workspace-expo-application@1.0.0","nextjs-full-stack-application":"foundation.nextjs-full-stack-application@1.0.0"};function Sm(e,t="package"){let r=t==="fixture"?"fixtures":"packages";return new RegExp(`^${r}/[a-z0-9][a-z0-9._-]*$`).test(e)?void 0:`Package path must be exactly ${r}/<lowercase-slug>.`}function jm(e,t,r){if(!(t in Nm))return"Add application requires a supported --profile.";let n=Nm[t];if(r!==n)return`Add application with profile ${t} requires --capability ${n}.`;if(!/^apps\/[a-z0-9][a-z0-9._-]*$/.test(e))return/^services\/[a-z0-9][a-z0-9._-]*$/.test(e)?t==="workspace-node-application"?void 0:"Service applications require profile workspace-node-application.":"Application path must be exactly apps/<lowercase-slug> or services/<lowercase-slug>."}async function Wa(e,t,r){for(let n of await XE(Dm.join(e,t),{withFileTypes:!0}).catch(()=>[]))if(!(!n.isDirectory()||n.isSymbolicLink()))try{if(JSON.parse(await HE(Dm.join(e,t,n.name,"project-capabilities.json"),"utf8")).profile?.parameters?.name===r)return!0}catch(i){if(i.code!=="ENOENT")throw i}return!1}async function $m(e,t){return await Wa(e,"apps",t)||await Wa(e,"services",t)}import{lstat as Om,mkdir as al,readFile as Cm,realpath as il,rm as ZE,writeFile as Tm}from"node:fs/promises";import Fe from"node:path";var ze=class extends Error{constructor(r,n){super(r,n===void 0?void 0:{cause:n});this.code=r}code},QE=e=>E(e),xm=e=>v(QE(e));async function Lm(e,t){let r=await il(Fe.resolve(e)),n=Fe.join(r,".examples");await al(n,{recursive:!0});let i=await il(n),a=Fe.resolve(r,t);if(Fe.dirname(a)!==i||Fe.basename(a).startsWith(".")||Fe.basename(a).length<1)throw new ze("SCAFFOLD_ARGUMENT_INVALID");if(await Om(a).then(()=>!0).catch(o=>o.code==="ENOENT"?!1:Promise.reject(o)))throw new ze("SCAFFOLD_TARGET_CONFLICT");return{workspaceRoot:r,output:a,outputRelativePath:Fe.relative(r,a)}}async function Vm(e){let t=e.artifactFallbackBundles??[];if(!/^sha256:[a-f0-9]{64}$/u.test(e.artifactBundle)||t.some(c=>!/^sha256:[a-f0-9]{64}$/u.test(c))||new Set([e.artifactBundle,...t]).size!==1+t.length||!Number.isSafeInteger(e.artifactPort)||e.artifactPort<1||e.artifactPort>65535)throw new ze("SCAFFOLD_ARGUMENT_INVALID");let r=await Lm(e.workspaceRoot,e.output),n=e.now??new Date().toISOString(),i={schemaVersion:1,state:"reviewable",recipeId:e.recipe.recipeId,recipeVersion:e.recipe.version,recipeIntegrity:e.recipe.integrity,workspaceRoot:r.workspaceRoot,outputRelativePath:r.outputRelativePath,locale:e.recipe.locale,channel:"development",artifactBundle:e.artifactBundle,artifactFallbackBundles:t,artifactPort:e.artifactPort,generatedAt:n,expiresAt:new Date(Date.parse(n)+30*6e4).toISOString()},a={...i,planId:xm(i)},o=Fe.join(r.workspaceRoot,".dyyto","scaffold-plans");await al(o,{recursive:!0});let s=Fe.join(o,`${a.planId}.json`);return await Tm(s,`${E(a)}
|
|
105
106
|
`,{flag:"wx",mode:384}).catch(async c=>{if(c.code!=="EEXIST"||await Cm(s,"utf8")!==`${E(a)}
|
|
106
107
|
`)throw new ze("SCAFFOLD_PLAN_INVALID")}),a}async function eA(e,t){if(!/^sha256:[a-f0-9]{64}$/u.test(t))throw new ze("SCAFFOLD_PLAN_INVALID");let r=await il(Fe.resolve(e)),n;try{n=JSON.parse(await Cm(Fe.join(r,".dyyto","scaffold-plans",`${t}.json`),"utf8"))}catch{throw new ze("SCAFFOLD_PLAN_NOT_FOUND")}let{planId:i,...a}=n;if(i!==t||xm(a)!==t||n.workspaceRoot!==r||Date.parse(n.expiresAt)<=Date.now())throw new ze("SCAFFOLD_PLAN_INVALID");return n}async function Mm(e){let t=await eA(e.workspaceRoot,e.approvedPlanId);if(t.recipeId!==e.recipe.recipeId||t.recipeVersion!==e.recipe.version||t.recipeIntegrity!==e.recipe.integrity)throw new ze("SCAFFOLD_PLAN_INVALID");let r=await Lm(t.workspaceRoot,t.outputRelativePath),n;try{n=await e.execute(r.output,t)}catch(s){throw await Om(r.output).then(()=>!0).catch(()=>!1)&&await ZE(r.output,{recursive:!0,force:!0}),new ze("SCAFFOLD_APPLY_FAILED",s)}let i={schemaVersion:1,scaffoldPlanId:t.planId,recipeIntegrity:t.recipeIntegrity,outputRelativePath:t.outputRelativePath,state:"adopted",receipts:n},a=v(E(i)),o=Fe.join(t.workspaceRoot,".dyyto","scaffold-evidence");return await al(o,{recursive:!0}),await Tm(Fe.join(o,`${a}.json`),`${E({...i,evidenceId:a})}
|
|
107
108
|
`,{flag:"wx",mode:384}),{evidenceId:a,output:r.output,receipts:n}}import{lstat as pi,readFile as ol,readdir as tA,realpath as sl}from"node:fs/promises";import pe from"node:path";var qm={capabilities:pe.resolve(import.meta.dirname,"catalog"),packages:pe.resolve(import.meta.dirname,"package-releases")};function rA(e){let t=new Map;for(let[r,n]of e.split(/\r?\n/u).entries()){let i=n.trim();if(i===""||i.startsWith("#"))continue;if(i.startsWith("export "))throw new Error(`Dyyto \u7EC4\u4EF6 .env:${r+1} \u4E0D\u5141\u8BB8\u4F7F\u7528 export`);let a=/^([A-Z][A-Z0-9_]*)=(.*)$/u.exec(i);if(!a)throw new Error(`Dyyto \u7EC4\u4EF6 .env:${r+1} \u4E0D\u662F\u4E25\u683C KEY=VALUE \u683C\u5F0F`);if(t.has(a[1]))throw new Error(`Dyyto \u7EC4\u4EF6 .env:${r+1} \u5305\u542B\u91CD\u590D\u53D8\u91CF ${a[1]}`);let o=a[2].trim();if((o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),/[`$][({]?/u.test(o))throw new Error(`Dyyto \u7EC4\u4EF6 .env:${r+1} \u4E0D\u5141\u8BB8\u547D\u4EE4\u6216\u53D8\u91CF\u5C55\u5F00`);t.set(a[1],o)}return t}async function Um(e,t){let r=await pi(e);if(!r.isFile()||r.isSymbolicLink()||r.nlink!==1)throw new Error(`${t}\u5FC5\u987B\u662F\u666E\u901A\u975E\u94FE\u63A5\u6587\u4EF6`);if(typeof process.getuid=="function"&&r.uid!==process.getuid())throw new Error(`${t}\u5FC5\u987B\u7531\u5F53\u524D\u7528\u6237\u62E5\u6709`);if((r.mode&511&-385)!==0)throw new Error(`${t}\u6743\u9650\u8FC7\u5BBD\uFF0C\u6700\u5927\u5141\u8BB80600`)}async function Ka(e,t){let r=await pi(e);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t}\u5FC5\u987B\u662F\u666E\u901A\u76EE\u5F55\u4E14\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5`);if(typeof process.getuid=="function"&&r.uid!==process.getuid())throw new Error(`${t}\u5FC5\u987B\u7531\u5F53\u524D\u7528\u6237\u62E5\u6709`);if((r.mode&511&-449)!==0)throw new Error(`${t}\u6743\u9650\u8FC7\u5BBD\uFF0C\u6700\u5927\u5141\u8BB80700`);return sl(e)}async function nA(e){let t=e;for(;;){if(await pi(pe.join(t,".git")).then(()=>!0).catch(n=>n.code==="ENOENT"?!1:Promise.reject(n)))throw new Error(`IDP_CONFIG_DIR \u5FC5\u987B\u4F4D\u4E8E Git \u4ED3\u5E93\u5916\uFF1A${t}`);let r=pe.dirname(t);if(r===t)return;t=r}}async function iA(e){if(!pe.isAbsolute(e))throw new Error("IDP_CONFIG_DIR \u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");let t=await Ka(e,"IDP_CONFIG_DIR");await nA(t);let r=await Ka(pe.join(t,"components"),"components"),n=await Ka(pe.join(r,"dyyto"),"Dyyto \u914D\u7F6E\u76EE\u5F55"),i=pe.relative(t,n);if(i.startsWith("..")||pe.isAbsolute(i))throw new Error("Dyyto \u914D\u7F6E\u76EE\u5F55\u8D8A\u8FC7 IDP_CONFIG_DIR");let a=pe.join(n,".env");await Um(a,"Dyyto \u7EC4\u4EF6 .env");let o=rA(await ol(a,"utf8")).get("DYYTO_PACKAGE_CATALOG_DIRS_FILE");if(o===void 0||o==="")return[];if(pe.isAbsolute(o)||o.includes("\0")||/[*?{}[\]]/u.test(o))throw new Error("DYYTO_PACKAGE_CATALOG_DIRS_FILE \u5FC5\u987B\u662F\u7EC4\u4EF6\u76EE\u5F55\u5185\u7684\u666E\u901A\u76F8\u5BF9\u6587\u4EF6\u8DEF\u5F84");let s=pe.resolve(n,o),c=pe.relative(n,s);if(c===""||c.startsWith("..")||pe.isAbsolute(c))throw new Error("DYYTO_PACKAGE_CATALOG_DIRS_FILE \u5FC5\u987B\u4F4D\u4E8E\u7EC4\u4EF6\u914D\u7F6E\u76EE\u5F55\u5185");let d=n;for(let u of c.split(pe.sep).slice(0,-1))d=await Ka(pe.join(d,u),"Package Catalog Binding \u7236\u76EE\u5F55");let l=await sl(pe.dirname(s)),p=pe.relative(n,l);if(p.startsWith("..")||pe.isAbsolute(p))throw new Error("Package Catalog Binding \u89E3\u6790\u540E\u8D8A\u8FC7\u7EC4\u4EF6\u914D\u7F6E\u76EE\u5F55");await Um(s,"Package Catalog Binding");let m=[];for(let u of(await ol(s,"utf8")).split(/\r?\n/u)){let f=u.trim();if(f===""||f.startsWith("#"))continue;if(!pe.isAbsolute(f))throw new Error("Package Catalog Binding \u4E2D\u7684\u8DEF\u5F84\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");let g=await pi(f);if(!g.isDirectory()||g.isSymbolicLink())throw new Error("Package Catalog Binding \u5FC5\u987B\u6307\u5411\u666E\u901A\u76EE\u5F55");let h=await sl(f),w=await pi(h);if(!w.isDirectory()||w.isSymbolicLink())throw new Error("Package Catalog Binding \u5FC5\u987B\u6307\u5411\u666E\u901A\u76EE\u5F55");m.includes(h)||m.push(h)}return m.sort()}async function aA(){let e=process.env.IDP_CONFIG_DIR,t=e===void 0?[]:await iA(e);return{capabilities:qm.capabilities,packages:[qm.packages,...t]}}async function Ya(e){return(await tA(e,{withFileTypes:!0})).filter(t=>t.isDirectory()&&!t.isSymbolicLink()).map(t=>t.name).sort()}function oA(e,t){let r=a=>a.split("-",1)[0].split(".").map(Number),n=r(e),i=r(t);for(let a=0;a<3;a+=1){let o=(n[a]??0)-(i[a]??0);if(o!==0)return o}return e.localeCompare(t)}function sA(e){let t=e.schemaVersion===2?e.availability.maturity:"legacy-unverified",r="consumerProfile"in e?e.consumerProfile:"\u591A\u79CD\u5DE5\u7A0B Profile";return{kind:"capability",ref:`capability:${e.capabilityId}@${e.version}`,id:e.capabilityId,version:e.version,title:e.capabilityId,summary:`\u9002\u7528\u4E8E ${r} \u7684\u5DE5\u7A0B\u80FD\u529B\u53D1\u884C\u3002`,maturity:t,integrity:e.integrity}}function cA(e){return{kind:"package",ref:`package:${e.packageName}@${e.version}`,id:e.packageName,version:e.version,title:e.title,summary:e.summary,maturity:e.maturity,integrity:e.releaseDigest}}async function lA(e){let t=[];for(let r of await Ya(e))for(let n of await Ya(pe.join(e,r))){let i=`capability:${r}@${n}`;t.push(ge(pe.join(e,r,n)).then(a=>({entry:{item:sA(a.release),release:a.release}})).catch(()=>({diagnostic:{ref:i,code:"CATALOG_RELEASE_INVALID",message:"Capability \u53D1\u884C\u672A\u901A\u8FC7\u5B8C\u6574\u6027\u6821\u9A8C"}})))}return(await Promise.all(t)).reduce((r,n)=>(n.entry!==void 0&&r.entries.push(n.entry),n.diagnostic!==void 0&&r.diagnostics.push(n.diagnostic),r),{entries:[],diagnostics:[]})}async function dA(e){let t=[];for(let r of await Ya(e))for(let n of await Ya(pe.join(e,r))){let i=pe.join(e,r,n,"release.json"),a=`package:${r}@${n}`;t.push(ol(i,"utf8").then(o=>{let s=_m(JSON.parse(o));return{entry:{item:cA(s),release:s}}}).catch(()=>({diagnostic:{ref:a,code:"CATALOG_RELEASE_INVALID",message:"PackageRelease \u672A\u901A\u8FC7\u5B8C\u6574\u6027\u6821\u9A8C"}})))}return(await Promise.all(t)).reduce((r,n)=>(n.entry!==void 0&&r.entries.push(n.entry),n.diagnostic!==void 0&&r.diagnostics.push(n.diagnostic),r),{entries:[],diagnostics:[]})}async function Fm(e){let t=e??await aA(),r=typeof t.packages=="string"?[t.packages]:[...t.packages],[n,...i]=await Promise.all([lA(t.capabilities),...r.map(dA)]),a=[...n.entries,...i.flatMap(d=>d.entries)].sort((d,l)=>d.item.ref.localeCompare(l.item.ref)),o=[],s=new Set,c=[];for(let d of a)s.has(d.item.ref)?c.push({ref:d.item.ref,code:"CATALOG_RELEASE_DUPLICATE",message:"\u591A\u4E2A Catalog Source \u58F0\u660E\u4E86\u540C\u4E00\u4E0D\u53EF\u53D8\u53D1\u884C ref"}):(s.add(d.item.ref),o.push(d));return{entries:o,diagnostics:[...n.diagnostics,...i.flatMap(d=>d.diagnostics),...c].sort((d,l)=>d.ref.localeCompare(l.ref))}}async function zm(e){let t=(e.query??"").trim().toLocaleLowerCase("zh-CN"),r=await Fm(e.roots),n=new Map;for(let{item:o}of r.entries){if(e.kind!==void 0&&o.kind!==e.kind)continue;let s=[o.id,o.version,o.title,o.summary,o.maturity].join(" ").toLocaleLowerCase("zh-CN");if(t!==""&&!s.includes(t))continue;let c=`${o.kind}:${o.id}`,d=n.get(c);(d===void 0||oA(d.version,o.version)<0)&&n.set(c,o)}let i=[...n.values()].sort((o,s)=>o.ref.localeCompare(s.ref)),a=e.limit??50;return{query:t,total:i.length,items:i.slice(0,a),diagnostics:r.diagnostics}}async function Bm(e){let t=e.ref.startsWith("package:")||e.ref.startsWith("capability:")?e.ref:`${e.ref.startsWith("@")?"package":"capability"}:${e.ref}`,r=await Fm(e.roots),n=r.entries.find(({item:a})=>a.ref===t),i=r.diagnostics.find(a=>a.ref===t);if(i?.code==="CATALOG_RELEASE_DUPLICATE")throw new Error(`\u53D1\u884C ref \u5728\u591A\u4E2A Catalog Source \u4E2D\u91CD\u590D\uFF1A${e.ref}`);if(n===void 0&&i!==void 0)throw new Error(`\u53D1\u884C\u672A\u901A\u8FC7\u5B8C\u6574\u6027\u6821\u9A8C\uFF1A${e.ref}`);if(n===void 0)throw new Error(`\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728\u53D1\u884C\uFF1A${e.ref}`);return n}var ui={"typescript-library":"foundation.typescript-quality@1.0.0","standalone-npm-package":"foundation.standalone-npm-package@1.2.0","workspace-root":"foundation.workspace-root@1.1.0","workspace-npm-package":"foundation.workspace-npm-package@1.2.0","workspace-node-application":"foundation.workspace-node-application@1.1.0","workspace-web-application":"foundation.workspace-web-application@1.1.0","workspace-expo-application":"foundation.workspace-expo-application@1.0.0","react-component-library":"foundation.react-component-library@1.1.0","workspace-react-component-library":"foundation.workspace-react-component-library@1.2.0","nextjs-full-stack-application":"foundation.nextjs-full-stack-application@1.0.0"},Km=fA(pA),mA=new Set(["template.typescript-library@1.0.0","template.typescript-library@1.1.0","template.react-component-library@1.0.0","template.react-component-library@1.1.0","template.nextjs-full-stack-application@1.0.0","template.expo-react-native-application@1.0.0","template.node-api-application@1.0.0","template.workspace-root@1.0.0","template.workspace-root@1.1.0","template.workspace-root@1.2.0","template.workspace-npm-package@1.0.0","template.workspace-react-component-library@1.0.0","template.workspace-react-component-library@1.1.0","template.workspace-react-component-library@1.2.0","template.web-frontend-application@1.0.0"]),Ym=(e,t)=>e==="foundation.workspace-root"&&t==="1.4.0"?{id:"template.workspace-root",version:"1.1.0"}:e==="foundation.workspace-root"&&t==="1.5.0"?{id:"template.workspace-root",version:"1.2.0"}:void 0,Ha={"workspace-npm-package":{id:"template.workspace-npm-package",version:"1.0.0"},"react-component-library":{id:"template.workspace-react-component-library",version:"1.2.0"},"workspace-web-application":{id:"template.web-frontend-application",version:"1.0.0"},"workspace-node-application":{id:"template.node-api-application",version:"1.0.0"},"workspace-expo-application":{id:"template.expo-react-native-application",version:"1.0.0"},"nextjs-full-stack-application":{id:"template.nextjs-full-stack-application",version:"1.0.0"}};function Hm(e){return e.capabilities.flatMap(t=>t.assets).filter(t=>t.ownership!=="seed-file")}async function Xa(e,t,r,n){if(t.release.schemaVersion!==2||t.release.packageSources.length===0)return;if(r.packageSourceProvider===void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Capability Release v2 requires a trusted Package Source Provider");let i=await te(N.join(e,"package.json")),a=await r.packageSourceProvider.inspect({projectRoot:e,release:t.release}),{resolvePnpmLock:o}=await import("./optional-runtime.js"),s=await Kr(e),c=await te(N.join(s.transactionRoot,s.lockfilePath)).catch(p=>p.code==="ENOENT"?void 0:Promise.reject(p));if(s.mode==="pnpm-shared-lockfile"){if(!c)throw new ae("CAPABILITY_PACKAGE_SOURCE_INVALID","Workspace shared lockfile is unavailable");if(!r.resolutionWorkerProvider)throw new ae("CAPABILITY_PACKAGE_SOURCE_INVALID","Shared workspace package adoption requires verified Resolution Worker Evidence");let p=Hn({release:t.release,packageJson:n??i}),m=new Date,u=new Date(m.getTime()+1800*1e3).toISOString(),f=await r.resolutionWorkerProvider.resolveWorkspace({topology:s,desiredPackageJson:p,currentLockfile:c,sources:t.release.packageSources,registryConfigs:a.registryConfigs,endpointBindings:a.endpointBindings,generatedAt:m.toISOString(),expiresAt:u});return{...a,lockResolution:{lockfile:f.evidence.desiredLockfile,packages:f.evidence.packageFacts.filter(g=>g.managed).map(({registryId:g,packageName:h,version:w,integrity:_})=>({registryId:g,packageName:h,version:w,integrity:_}))},resolutionEvidence:f.evidence,resolutionWorkerReleaseId:f.workerReleaseId,topology:s,currentLockfile:c,preservedImporterDigests:f.preservedImporterDigests}}let d=Vc({release:t.release,packageJson:n??i}),l=await o({desiredPackageJson:d,...c===void 0?{}:{currentLockfile:c},sources:t.release.packageSources,registries:a.registryConfigs,endpointBindings:a.endpointBindings});return{...a,lockResolution:l,topology:s,...c===void 0?{}:{currentLockfile:c},preservedImporterDigests:[]}}async function Xm(e,t,r,n){let i=r.capabilities.find(b=>b.capabilityId===t.release.capabilityId&&b.version===t.release.version);if(i&&!i.packageAdoption){let b=JSON.parse(await te(N.join(e,"project-capabilities.json"),"utf8")),A=new Date;return am({projectRoot:e,manifest:b,release:t,currentLock:r,generatedAt:A.toISOString(),expiresAt:new Date(A.getTime()+30*6e4).toISOString()})}if(t.release.schemaVersion!==2||n.packageSourceProvider===void 0)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Package removal requires a trusted Package Source Provider");if(!i?.packageAdoption)throw new ae("CAPABILITY_RELEASE_VERSION_UNSUPPORTED","Package removal requires Lock v2 ownership facts");let a=await n.packageSourceProvider.inspect({projectRoot:e,release:t.release}),o=await te(N.join(e,"package.json")),s=await te(N.join(e,"project-capabilities.json")),c=await Kr(e),d=await te(N.join(c.transactionRoot,c.lockfilePath)),l=new Set(r.capabilities.filter(b=>b!==i).flatMap(b=>b.packageAdoption?.sources.map(A=>A.packageName)??[])),p=i.packageAdoption.sources.filter(b=>!l.has(b.packageName)),m=c.mode==="pnpm-shared-lockfile"?qc({packageJson:o,remove:p}):Mc({packageJson:o,remove:p}),u=r.capabilities.filter(b=>b!==i).flatMap(b=>b.packageAdoption?.sources??[]),f=new Date,g=new Date(f.getTime()+1800*1e3).toISOString();if(c.mode==="pnpm-shared-lockfile"){if(!n.resolutionWorkerProvider)throw new ae("CAPABILITY_PACKAGE_SOURCE_INVALID","Shared workspace package removal requires verified Resolution Worker Evidence");let b=await n.resolutionWorkerProvider.resolveWorkspace({topology:c,desiredPackageJson:m,currentLockfile:d,sources:u,registryConfigs:a.registryConfigs,endpointBindings:a.endpointBindings,generatedAt:f.toISOString(),expiresAt:g}),A=[`${c.unitRelativeRoot}/project-capabilities.json`,`${c.unitRelativeRoot}/package.json`,c.lockfilePath,...i.assets.map(k=>`${c.unitRelativeRoot}/${k.path}`)],y=await Promise.all(A.map(async k=>te(N.join(c.transactionRoot,...k.split("/"))).then(S=>({path:k,exists:!0,digest:v(S)})).catch(S=>S.code==="ENOENT"?{path:k,exists:!1}:Promise.reject(S))));return{...pf({release:t.release,currentLock:r,projectManifest:s,packageJson:o,currentLockfile:d,endpointBindings:a.endpointBindings,observedAssets:y,topology:c,transactionRoot:c.transactionRoot,preservedImporterDigests:b.preservedImporterDigests,resolutionEvidence:b.evidence,resolutionWorkerReleaseId:b.workerReleaseId,remainingSources:u,generatedAt:f.toISOString(),expiresAt:g}),registryConfigs:a.registryConfigs,endpointBindings:a.endpointBindings}}let{resolvePnpmLock:h}=await import("./optional-runtime.js"),w=await h({desiredPackageJson:m,currentLockfile:d,sources:u,registrySources:[...u,...i.packageAdoption.sources],registries:a.registryConfigs,endpointBindings:a.endpointBindings}),_=await Promise.all(["project-capabilities.json","package.json","pnpm-lock.yaml",...i.assets.map(b=>b.path)].map(async b=>te(N.join(e,...b.split("/"))).then(A=>({path:b,exists:!0,digest:v(A)})).catch(A=>A.code==="ENOENT"?{path:b,exists:!1}:Promise.reject(A))));return{...df({release:t.release,currentLock:r,projectManifest:s,packageJson:o,currentLockfile:d,desiredLockfile:w.lockfile,endpointBindings:a.endpointBindings,observedAssets:_,generatedAt:f.toISOString(),expiresAt:g}),registryConfigs:a.registryConfigs,endpointBindings:a.endpointBindings}}function F(e){return e.includes("--json")?"json":"human"}function I(e){throw new Te({code:"CLI_ARGUMENT_INVALID",message:e,exitCode:2,nextStep:"Run dyyto --help."})}function Ae(e,t){return!/^[a-z0-9][a-z0-9.-]*$/u.test(e)||!/^\d+\.\d+\.\d+$/u.test(t)?I("The selected capability release identifier is invalid."):N.resolve(import.meta.dirname,"catalog",e,t)}function Za(e,t){return mA.has(`${e}@${t}`)?N.resolve(import.meta.dirname,"templates",e,t):I("The selected template release is not bundled with this CLI.")}function gA(e,t){return!/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(e)||!/^\d+\.\d+\.\d+$/.test(t)?I("The selected example recipe identity or version is invalid."):N.resolve(import.meta.dirname,"recipes",e,t)}function X(e){let t=N.relative(process.cwd(),e);return t.length>0&&t!==".."&&!t.startsWith(`..${N.sep}`)?t:N.basename(e)}async function Qa(e){let t=JSON.parse(await te(N.join(e,"project-capabilities.json"),"utf8")),r=t.capabilities?.[0];if(r===void 0)return I("Project manifest must select one capability.");let n=await ge(Ae(r.capabilityId,r.version)),i=await Se(e).catch(()=>null),a=new Date,s=await(t.profile?.id==="standalone-npm-package"?Bn:t.profile?.id==="react-component-library"?Jn:t.profile?.id==="nextjs-full-stack-application"?Yr:t.profile?.id==="workspace-npm-package"?Gn:t.profile?.id==="workspace-node-application"?Wn:t.profile?.id==="workspace-web-application"?Kn:t.profile?.id==="workspace-expo-application"?Yn:na)({projectRoot:e,manifest:t,release:n,...i===null?{}:{currentLock:i},generatedAt:a.toISOString(),expiresAt:new Date(a.getTime()+1800*1e3).toISOString()});return pr({projectRoot:e,plan:s.plan,now:a.toISOString()})}async function Zm(e){let t;try{t=oe({args:[...e],allowPositionals:!0,strict:!0,options:{json:{type:"boolean"},profile:{type:"string"},template:{type:"string"},capability:{type:"string"},name:{type:"string"},version:{type:"string"},license:{type:"string"},"publish-access":{type:"string"},repository:{type:"string"}}})}catch{return I("Create arguments are invalid.")}if(t.positionals.length!==1)return I("Create requires exactly one directory.");let r=t.values.template,n;if(typeof r=="string"){let[g,h]=r.split("@");n=await ci(Za(g,h))}let i=n?.profile.id??t.values.profile;if(i!=="typescript-library"&&i!=="standalone-npm-package"&&i!=="react-component-library"&&i!=="nextjs-full-stack-application"&&i!=="workspace-root")return I("Create requires a supported --profile.");let a=t.values.capability,o=i==="workspace-root"&&a==="foundation.workspace-root@1.0.0"||i==="standalone-npm-package"&&a==="foundation.standalone-npm-package@1.0.0",s=n?.profile.capability??(o?a:ui[i]);if(n!==void 0&&s.split("@")[0]!==ui[i].split("@")[0])return I(`Template ${n.templateId} is adopted with dyyto add, not dyyto create.`);if(n===void 0&&a!==s)return I(`Create requires --capability ${s}.`);if(n!==void 0&&a!==void 0)return I("Create with --template does not accept --capability.");let[c,d]=s.split("@"),l={};if(i==="standalone-npm-package"||i==="react-component-library"){let g=t.values.name,h=t.values.version,w=t.values.license,_=t.values["publish-access"],b=t.values.repository;if([g,h,w,_].some(A=>typeof A!="string")||d==="1.1.0"&&typeof b!="string")return I(`Standalone npm package requires --name, --version, --license, --publish-access${d==="1.1.0"?", and --repository":""}.`);l={name:String(g),version:String(h),license:String(w),publishAccess:String(_),...typeof b=="string"?{repository:b}:{}}}else if(i==="nextjs-full-stack-application"){if(typeof t.values.name!="string")return I("Next.js application requires --name.");l={name:t.values.name}}let p={schemaVersion:1,...n===void 0?{}:{template:{id:n.templateId,version:n.version}},profile:{id:i,parameters:l},capabilities:[{capabilityId:c,version:d}]};(i==="standalone-npm-package"||i==="react-component-library")&&Ft(J(p),i),i==="nextjs-full-stack-application"&&fr(J(p));let m=await wa({projectRoot:t.positionals[0],manifest:p}),u=await Qa(m.projectRoot),f=X(m.projectRoot);return{outputMode:F(e),human:`Project '${f}' initialized.
|
|
@@ -275,4 +276,4 @@ Source Maps: ${a.registrations.length}
|
|
|
275
276
|
`);return{outputMode:F(e),human:a,value:{schemaVersion:1,ok:!0,command:"catalog-search",result:i}}}async function UA(e){let t;try{t=oe({args:[...e],allowPositionals:!1,strict:!0,options:{json:{type:"boolean"},ref:{type:"string"}}})}catch{return I("Catalog show \u53C2\u6570\u65E0\u6548\u3002")}if(typeof t.values.ref!="string"||t.values.ref.trim()==="")return I("Catalog show \u9700\u8981 --ref\u3002");let r=await Bm({ref:t.values.ref});return{outputMode:F(e),human:`${r.item.ref}
|
|
276
277
|
${r.item.summary}
|
|
277
278
|
\u6210\u719F\u5EA6\uFF1A${r.item.maturity}
|
|
278
|
-
\u5B8C\u6574\u6027\uFF1A${r.item.integrity}`,value:{schemaVersion:1,ok:!0,command:"catalog-show",result:r}}}async function
|
|
279
|
+
\u5B8C\u6574\u6027\uFF1A${r.item.integrity}`,value:{schemaVersion:1,ok:!0,command:"catalog-show",result:r}}}async function lj(e,t={}){let r=e[0]==="--"?e.slice(1):e,n=F(r);if(r[0]==="--version"&&r.every(o=>o==="--version"||o==="--json"))return{outputMode:n,human:nl,value:{schemaVersion:1,ok:!0,command:"version",result:{version:nl}}};if(r.length===0||r[0]==="--help"||r[0]==="-h")return{outputMode:n,human:Pm,value:{schemaVersion:1,ok:!0,command:"help",result:{usage:"dyyto <command> [options]"}}};let[i,...a]=r;return i==="catalog"&&a[0]==="search"?qA(a.slice(1)):i==="catalog"&&a[0]==="show"?UA(a.slice(1)):i==="create"?Zm(a):i==="scaffold"&&a[0]==="example"?EA(a.slice(1),t):i==="retrofit"?hA(a):i==="dev"||i==="build"||i==="test"||i==="package"?yA(i,a):i==="add"&&a[0]==="package"?wA(a.slice(1)):i==="add"&&a[0]==="application"?vA(a.slice(1)):i==="add"&&a[0]==="feature"?Qm(a.slice(1),t):i==="remove"&&a[0]==="feature"?IA(a.slice(1),t):i==="plan"?bA(a):i==="upgrade"?_A(a,t):i==="apply"?cl(a,t):i==="verify"?ll(a):i==="inspect"?dl(a):i==="doctor"?OA(a):i==="recover"?AA(a):i==="lifecycle"&&typeof a[0]=="string"?RA(a[0],a.slice(1)):i==="packages"&&a[0]==="switch"?NA(a.slice(1)):i==="integrations"?PA(a):i==="maintenance"?DA(a):i==="config"&&a[0]==="inspect"?SA(a.slice(1)):i==="config"&&a[0]==="readiness"?jA(a.slice(1)):i==="operations"?$A(a):i==="baseline"?kA(a):i==="delivery"&&a[0]==="plan"?CA(a.slice(1)):i==="delivery"&&a[0]==="apply"?TA(a.slice(1)):i==="delivery"&&a[0]==="inspect"?xA(a.slice(1)):i==="observe"&&a[0]==="errors"?LA(a.slice(1)):i==="observe"&&a[0]==="error"?VA(a.slice(1)):i==="observe"&&a[0]==="release"&&a[1]==="register"?MA(a.slice(2)):I(`Unknown command '${i}'.`)}export{lj as runApplication};
|
package/dist/chunk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var h=Object.create;var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=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 C(n))!b.call(e,o)&&o!==t&&u(e,o,{get:()=>n[o],enumerable:!(r=w(n,o))||r.enumerable});return e};var N=(e,n,t)=>(t=e!=null?h(E(e)):{},v(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e));var F="0.1.
|
|
1
|
+
var h=Object.create;var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=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 C(n))!b.call(e,o)&&o!==t&&u(e,o,{get:()=>n[o],enumerable:!(r=w(n,o))||r.enumerable});return e};var N=(e,n,t)=>(t=e!=null?h(E(e)):{},v(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e));var F="0.1.34",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 j(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 s=o("nextStep");return s!==void 0&&!f(s,500)?null:Object.freeze({schemaVersion:1,kind:"dyyto-cli-domain-error",code:a,message:o("message"),exitCode:4,...s===void 0?{}:{nextStep:s}})}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]?j({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]
|
|
@@ -7,6 +7,7 @@ Commands:
|
|
|
7
7
|
dyyto bootstrap --project DIR [--apply] \u521D\u59CB\u5316\u5E76\u9501\u5B9AVibe Coding\u5DE5\u7A0B\u4E0A\u4E0B\u6587
|
|
8
8
|
dyyto context resolve --project DIR \u89E3\u6790\u5F53\u524D\u5206\u652F\u7684\u5185\u5BB9\u5BFB\u5740\u5DE5\u7A0B\u4E0A\u4E0B\u6587
|
|
9
9
|
dyyto ready --project DIR \u68C0\u67E5\u4E0A\u4E0B\u6587\u3001\u914D\u7F6E\u4E0E\u5DE5\u7A0B\u5F00\u53D1\u5C31\u7EEA\u72B6\u6001
|
|
10
|
+
dyyto dev session start|show|finish \u7BA1\u7406\u76F4\u63A5\u5F00\u53D1\u4E0E\u9700\u6C42\u4EFB\u52A1\u5171\u7528\u7684\u5F00\u53D1 Session
|
|
10
11
|
dyyto agents sync --project DIR [--apply] \u540C\u6B65\u591A\u7F16\u7801Agent\u9002\u914D\u5668
|
|
11
12
|
dyyto agents remove --project DIR [--apply] \u5B89\u5168\u79FB\u9664\u53D7\u7BA1Agent\u9002\u914D\u5668
|
|
12
13
|
dyyto docs show --id ID \u8BFB\u53D6npm\u5305\u5185\u7A33\u5B9A\u6587\u6863
|
|
@@ -57,4 +58,4 @@ Options:
|
|
|
57
58
|
--json Emit one machine-readable JSON object
|
|
58
59
|
--help Show help
|
|
59
60
|
--version Show version
|
|
60
|
-
`;import{lstat as x,readFile as R,readdir as A}from"node:fs/promises";import p from"node:path";var g={"workspace-node-application":"foundation.workspace-node-application@1.1.0","workspace-web-application":"foundation.workspace-web-application@1.1.0","workspace-expo-application":"foundation.workspace-expo-application@1.0.0","nextjs-full-stack-application":"foundation.nextjs-full-stack-application@1.0.0"};function S(e,n="package"){let t=n==="fixture"?"fixtures":"packages";return new RegExp(`^${t}/[a-z0-9][a-z0-9._-]*$`).test(e)?void 0:`Package path must be exactly ${t}/<lowercase-slug>.`}function P(e,n,t){if(!(n in g))return"Add application requires a supported --profile.";let r=g[n];if(t!==r)return`Add application with profile ${n} requires --capability ${r}.`;if(!/^apps\/[a-z0-9][a-z0-9._-]*$/.test(e))return/^services\/[a-z0-9][a-z0-9._-]*$/.test(e)?n==="workspace-node-application"?void 0:"Service applications require profile workspace-node-application.":"Application path must be exactly apps/<lowercase-slug> or services/<lowercase-slug>."}function
|
|
61
|
+
`;import{lstat as x,readFile as R,readdir as A}from"node:fs/promises";import p from"node:path";var g={"workspace-node-application":"foundation.workspace-node-application@1.1.0","workspace-web-application":"foundation.workspace-web-application@1.1.0","workspace-expo-application":"foundation.workspace-expo-application@1.0.0","nextjs-full-stack-application":"foundation.nextjs-full-stack-application@1.0.0"};function S(e,n="package"){let t=n==="fixture"?"fixtures":"packages";return new RegExp(`^${t}/[a-z0-9][a-z0-9._-]*$`).test(e)?void 0:`Package path must be exactly ${t}/<lowercase-slug>.`}function P(e,n,t){if(!(n in g))return"Add application requires a supported --profile.";let r=g[n];if(t!==r)return`Add application with profile ${n} requires --capability ${r}.`;if(!/^apps\/[a-z0-9][a-z0-9._-]*$/.test(e))return/^services\/[a-z0-9][a-z0-9._-]*$/.test(e)?n==="workspace-node-application"?void 0:"Service applications require profile workspace-node-application.":"Application path must be exactly apps/<lowercase-slug> or services/<lowercase-slug>."}function d(e,n){let t=e.indexOf(n);return t<0?void 0:e[t+1]}async function y(e,n,t){for(let r of await A(p.join(e,n),{withFileTypes:!0}).catch(()=>[]))if(!(!r.isDirectory()||r.isSymbolicLink()))try{if(JSON.parse(await R(p.join(e,n,r.name,"project-capabilities.json"),"utf8")).profile?.parameters?.name===t)return!0}catch(o){if(o.code!=="ENOENT")throw o}return!1}async function I(e,n){return await y(e,"apps",n)||await y(e,"services",n)}async function B(e){if(e[0]!=="add")return;let n=d(e,"--path");if(n===void 0)return;let t=d(e,"--workspace"),r=d(e,"--name");if(e[1]==="package"){let a=d(e,"--kind")==="fixture"?"fixture":"package",s=S(n,a);return s!==void 0||t===void 0||r===void 0?s:await x(p.join(t,"package.json")).then(i=>i.isFile()).catch(()=>!1)?await y(t,a==="fixture"?"fixtures":"packages",r)?"A workspace package already uses this npm name.":void 0:"Workspace root must be applied and free of drift before adding a package."}if(e[1]!=="application")return;let o=P(n,d(e,"--profile")??"workspace-node-application",d(e,"--capability"));return o!==void 0||t===void 0||r===void 0?o:await x(p.join(t,"package.json")).then(a=>a.isFile()).catch(()=>!1)?await I(t,r)?"A workspace application already uses this name.":void 0:"Workspace root must be applied and free of drift before adding an application."}export{O as a,N as b,F as c,T as d,l as e,z as f,S as g,P as h,y as i,I as j,B as k};
|