@fugood/bricks-cli 2.25.0-beta.63 → 2.25.0-beta.64

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.
Files changed (82) hide show
  1. package/lib/1010.js +1 -0
  2. package/lib/1178.js +1 -0
  3. package/lib/1215.js +1 -0
  4. package/lib/{708.js → 1708.js} +2 -2
  5. package/lib/1759.js +1 -0
  6. package/lib/1936.js +1 -0
  7. package/lib/2151.js +1 -0
  8. package/lib/{209.js → 2209.js} +3 -3
  9. package/lib/2247.js +1 -0
  10. package/lib/2486.js +1 -0
  11. package/lib/2557.js +1 -0
  12. package/lib/{223.js → 3223.js} +1 -1
  13. package/lib/3332.js +13 -0
  14. package/lib/3690.js +1 -0
  15. package/lib/3774.js +44 -0
  16. package/lib/3976.js +14 -0
  17. package/lib/4305.js +1 -0
  18. package/lib/4456.js +3 -0
  19. package/lib/{192.js → 4479.js} +4 -4
  20. package/lib/4530.js +22 -0
  21. package/lib/4642.js +9 -0
  22. package/lib/4685.js +1202 -0
  23. package/lib/5212.js +1 -0
  24. package/lib/{658.js → 5658.js} +1 -1
  25. package/lib/5785.js +1 -0
  26. package/lib/6194.js +3 -0
  27. package/lib/6370.js +1 -0
  28. package/lib/6645.js +1 -0
  29. package/lib/6818.js +1 -0
  30. package/lib/7111.js +2 -0
  31. package/lib/7456.js +1 -0
  32. package/lib/7511.js +1 -0
  33. package/lib/7574.js +1 -0
  34. package/lib/7648.js +1 -0
  35. package/lib/8026.js +1 -0
  36. package/lib/{117.js → 8117.js} +2 -2
  37. package/lib/8166.js +1 -0
  38. package/lib/853.js +1 -0
  39. package/lib/915.js +3 -3
  40. package/lib/9320.js +3 -0
  41. package/lib/{387.js → 9387.js} +1 -1
  42. package/lib/9405.js +1 -0
  43. package/lib/9430.js +1 -0
  44. package/lib/{583.js → 9583.js} +1 -1
  45. package/lib/9663.js +1 -0
  46. package/lib/{866.js → 9866.js} +1 -1
  47. package/lib/9940.js +19 -0
  48. package/lib/index.js +17 -17
  49. package/package.json +5 -5
  50. package/lib/10.js +0 -1
  51. package/lib/111.js +0 -2
  52. package/lib/166.js +0 -1
  53. package/lib/178.js +0 -1
  54. package/lib/212.js +0 -1
  55. package/lib/215.js +0 -1
  56. package/lib/247.js +0 -1
  57. package/lib/274.js +0 -55
  58. package/lib/305.js +0 -1
  59. package/lib/306.js +0 -1
  60. package/lib/320.js +0 -3
  61. package/lib/332.js +0 -13
  62. package/lib/358.js +0 -1
  63. package/lib/370.js +0 -1
  64. package/lib/405.js +0 -1
  65. package/lib/430.js +0 -1
  66. package/lib/456.js +0 -3
  67. package/lib/479.js +0 -1231
  68. package/lib/486.js +0 -1
  69. package/lib/511.js +0 -1
  70. package/lib/557.js +0 -1
  71. package/lib/574.js +0 -1
  72. package/lib/645.js +0 -1
  73. package/lib/648.js +0 -1
  74. package/lib/663.js +0 -1
  75. package/lib/690.js +0 -1
  76. package/lib/75.js +0 -1
  77. package/lib/759.js +0 -1
  78. package/lib/785.js +0 -1
  79. package/lib/818.js +0 -1
  80. package/lib/917.js +0 -1
  81. package/lib/936.js +0 -1
  82. package/lib/940.js +0 -19
package/lib/3774.js ADDED
@@ -0,0 +1,44 @@
1
+ export const __rspack_esm_id=3774;export const __rspack_esm_ids=[3774];export const __webpack_modules__={79491(e){e.exports=import("oxfmt").then(function(e){return e})},48875(e,t){let r=["title","update_timestamp"],i=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),n=e=>void 0===e||"function"==typeof e||"symbol"==typeof e,a=e=>"number"!=typeof e||Number.isFinite(e)?e:null,s=e=>{if(!n(e))return Array.isArray(e)?e.map(e=>n(e)?null:s(e)):i(e)?Object.entries(e).reduce((e,[t,r])=>(n(r)||(e[t]=s(r)),e),{}):a(e)},o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)&&!n(e[t]),l=(e,t)=>{let r=e[t];return n(r)?null:r},d=(e,t)=>{if((e=a(e))===(t=a(t)))return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!d(l(e,r),l(t,r)))return!1;return!0}if(i(e)&&i(t)){let r=0;for(let i of Object.keys(e))if(!n(e[i])&&(r+=1,!o(t,i)||!d(e[i],t[i])))return!1;let i=0;for(let e of Object.keys(t))n(t[e])||(i+=1);return r===i}return!1},c=e=>{if(!i(e))return e;let t={...e};for(let e of r)delete t[e];return t},p=(e,t,r,n)=>{if(!d(e,t)){if(i(e)&&i(t)){for(let i of new Set([...Object.keys(e),...Object.keys(t)])){let a=o(e,i),l=o(t,i);if(!a&&!l)continue;let d=[...r,i];l?a?p(e[i],t[i],d,n):n.push({op:"set",path:d,value:s(t[i])}):n.push({op:"unset",path:d})}return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let i=0;i<t.length;i+=1)p(l(e,i),l(t,i),[...r,i],n);return}n.push({op:"set",path:r,value:s(t)})}};t.O2=(e,t)=>{let r=[];return p(c(e),c(t),[],r),r}},2985(e,t,r){r.d(t,{Re:()=>d,m4:()=>l});var i,n=r(99436),a=r(51455),s=r(76760),o=r(48875),l=(e,t)=>{if(null==e)return{status:"no_baseline"};if(null==t)return{status:"unavailable"};var r=(0,o.O2)(e,t);return{status:"ok",ops:r,opCount:r.length}},d=(i=n(function*(e){try{return JSON.parse((yield(0,a.readFile)(s.join(e,".bricks/build/application-config.json"),"utf8")))}catch{return null}}),function(e){return i.apply(this,arguments)})},3540(e,t,r){r.d(t,{S:()=>p,a:()=>c});var i,n,a=r(99436),s=r(51455),o=r(76760),l=".bricks/edits.jsonl",d=(i=a(function*(e){var t=o.join(e,".gitignore"),r=yield(0,s.readFile)(t,"utf8").catch(e=>{if(e?.code==="ENOENT")return"";throw e});if(!r.split(/\r?\n/).map(e=>e.trim()).some(e=>e===l||".bricks/"===e||".bricks"===e)){var i=r&&!r.endsWith("\n")?"\n":"";yield(0,s.writeFile)(t,`${r}${i}
2
+ # MCP entry-editing audit log
3
+ ${l}
4
+ `)}}),function(e){return i.apply(this,arguments)}),c=(n=a(function*(e,t){var r=o.join(e,".bricks");yield(0,s.mkdir)(r,{recursive:!0}),yield d(e),yield(0,s.appendFile)(o.join(r,"edits.jsonl"),`${JSON.stringify(t)}
5
+ `)}),function(e,t){return n.apply(this,arguments)}),p=()=>({session:process.env.BRICKS_CTOR_SESSION_ID||process.env.CODEX_SESSION_ID,agent:process.env.BRICKS_CTOR_AGENT_ID||process.env.USER})},98009(e,t,r){r.d(t,{Gp:()=>l,HJ:()=>u,Hn:()=>a,JJ:()=>p,Kx:()=>y,Pb:()=>m,RI:()=>o,bf:()=>c,jc:()=>f,u4:()=>s,zu:()=>d});var i=r(58135),n=r(76760),a={trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100},s=e=>!!e&&"object"==typeof e&&!Array.isArray(e),o=(e,t)=>n.relative(e,t).replace(/\\/g,"/").replace(/^\.\/+/,""),l=e=>i.isIdentifier(e)?e.name:i.isStringLiteral(e)||i.isNumericLiteral(e)?String(e.value):null,d=e=>/^[$A-Z_a-z][$\w]*$/.test(e)?i.identifier(e):i.stringLiteral(e),c=(e,t)=>e.properties.find(e=>!!i.isObjectProperty(e)&&l(e.key)===t),p=(e,t)=>{var r=c(e,t);if(r&&i.isStringLiteral(r.value))return r.value.value},u=(e,t,r)=>{var n=c(e,t);if(n){n.value=r;return}e.properties.push(i.objectProperty(d(t),r))},f=(e,t)=>{var r=e.properties.findIndex(e=>!!i.isObjectProperty(e)&&l(e.key)===t);r>=0&&e.properties.splice(r,1)},m=(e,t)=>{var r=e.program.body,n=r.findLastIndex(e=>i.isImportDeclaration(e));r.splice(n+1,0,t)},y=(e,t,r)=>{var n=new Set(Array.from(r).filter(Boolean));if(0!==n.size){var a,s=function(e){return i.isImportDeclaration(e)&&"bricks-ctor"===e.source.value&&"type"===t==("type"===e.importKind)?(e.specifiers.forEach(e=>{if(i.isImportSpecifier(e)){var t=e.imported;i.isIdentifier(t)&&n.delete(t.name),i.isStringLiteral(t)&&n.delete(t.value)}}),n.forEach(t=>{e.specifiers.push(i.importSpecifier(i.identifier(t),i.identifier(t)))}),{v:void 0}):0};for(var o of e.program.body)if(0!==(a=s(o))&&a)return a.v;var l=i.importDeclaration(Array.from(n).map(e=>i.importSpecifier(i.identifier(e),i.identifier(e))),i.stringLiteral("bricks-ctor"));"type"===t&&(l.importKind="type"),m(e,l)}}},54452(e,t,r){r.d(t,{H:()=>c});var i,n,a=r(99436),s=r(75720),o=r(2985),l={FORCE_COLOR:"0",NO_COLOR:"1"},d=(i=a(function*(e){var t=yield(0,o.Re)(e);try{yield(0,s.sh)`bun compile`.cwd(e).env({...l,BRICKS_CTOR_ENABLE_EDITING_TOOLS:"0"}).text()}catch(e){var r=[e.stdout?.toString()??"",e.stderr?.toString()??"",e.message].filter(Boolean).join("\n").trim();return{status:"compile:failed",errors:r?[r]:["bun compile failed"]}}var i=yield(0,o.Re)(e);return{status:"compile:ok",errors:[],configChange:(0,o.m4)(t,i)}}),function(e){return i.apply(this,arguments)}),c=(n=a(function*(e,t){return(void 0!==t?t:!["0","false","no","off"].includes((process.env.BRICKS_CTOR_MCP_EDIT_VERIFY??"true").toLowerCase()))?d(e):{status:"skipped",errors:[]}}),function(e,t){return n.apply(this,arguments)})},85949(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>tm,register:()=>tf});var n,a,s,o,l,d,c,p,u,f,m,y,v,h,b,w,x,g,_,j,P,k,E,S,$,A,I,O,C,N,T=r(68832),R=r(99436),D=r(44668),F=r(5018),L=r(63315),B=r(30409),K=r(40906),U=r(59410),z=r(2235),q=r(46773),M=r(80004),Y=r(58135),J=r(11978),H=r(79491),V=r(51455),G=r(77598),W=r(76760),X=r(84867),Z=r(54452),Q=r(98009),ee=r(3540),et=e([H]);function er(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(er=function(){return!!e})()}H=(et.then?(await et)():et)[0];var ei=z.default||z,en=M.default||M,ea={"bricks.ts":{kind:"brick",namespace:"bricks",varPrefix:"b",idType:"brick",idPrefix:"BRICK_",typename:"Brick"},"generators.ts":{kind:"generator",namespace:"generators",varPrefix:"g",idType:"generator",idPrefix:"GENERATOR_",typename:"Generator"},"canvases.ts":{kind:"canvas",namespace:"canvases",varPrefix:"c",idType:"canvas",idPrefix:"CANVAS_",typename:"Canvas"},"data.ts":{kind:"data",namespace:"data",varPrefix:"d",idType:"data",idPrefix:"PROPERTY_BANK_DATA_NODE_",typename:"Data"},"animations.ts":{kind:"animation",namespace:"animations",varPrefix:"a",idType:"animation",idPrefix:"ANIMATION_",typename:"Animation"}},es=function(e){function t(e,r,i,n=!1){var a,s,o;return F(this,t),s=t,o=[r],s=B(s),(a=L(this,er()?Reflect.construct(s,o||[],B(this).constructor):s.apply(this,o))).name="EntryEditingError",a.code=e,a.details=i,a.isMcpError=n,a}return K(t,e),D(t)}(U(Error)),eo=(e,t)=>{if(W.isAbsolute(t))throw new es("invalid_file","File must be project-relative",{file:t});var r=W.resolve(e,t),i=W.relative(e,r);if(i.startsWith("..")||W.isAbsolute(i))throw new es("invalid_file","File must stay inside the project directory",{file:t});return r},el=(e,t)=>{try{return(0,q.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new es("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},ed=(n=R(function*(e,t){var r=yield(0,V.readFile)(t,"utf8"),i=(0,Q.RI)(e,t);return{source:r,ast:el(r,i),absPath:t,relPath:i,kind:(e=>{var t=W.basename(e),r=ea[t];if(!r)throw new es("unsupported_file",`Unsupported entry file: ${t}`,{file:e,expected:Object.keys(ea)});return r})(t)}}),function(e,t){return n.apply(this,arguments)}),ec=e=>e.program.body.flatMap(e=>{if(!Y.isExportNamedDeclaration(e)||!Y.isVariableDeclaration(e.declaration))return[];var t=e.declaration;return t.declarations.flatMap(r=>{if(!Y.isIdentifier(r.id))return[];var i,n=r.id.typeAnnotation;Y.isTSTypeAnnotation(n)&&Y.isTSTypeReference(n.typeAnnotation)&&Y.isIdentifier(n.typeAnnotation.typeName)&&(i=n.typeAnnotation.typeName.name);var a=Y.isObjectExpression(r.init)?r.init:void 0;return[{name:r.id.name,node:e,declaration:t,declarator:r,object:a,id:a?(0,Q.JJ)(a,"id"):void 0,alias:a?(0,Q.JJ)(a,"alias"):void 0,typeName:i}]})}),ep=(e,t)=>{var r=ec(e.ast);if(t.entry){var i=r.find(e=>e.name===t.entry);if(i)return i;var n=r.filter(e=>e.alias===t.entry);if(1===n.length)return n[0];if(n.length>1)throw new es("ambiguous_reference",`Alias is ambiguous: ${t.entry}`,{file:e.relPath,entry:t.entry,matches:n.map(e=>e.name)});throw new es("entry_not_found",`Entry not found (by name or alias): ${t.entry}`,{file:e.relPath,entry:t.entry})}if(t.id){var a=r.find(e=>e.id===t.id);if(!a)throw new es("entry_not_found",`Entry id not found: ${t.id}`,{file:e.relPath,id:t.id});return a}throw new es("missing_target","Provide entry or id")},eu=e=>e.split(W.sep).find(e=>/^subspace-\d+$/.test(e))||"unknown-subspace",ef=e=>{var t=e.split(W.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new es("invalid_file","Entry file must be inside subspaces/subspace-N",{file:e});return t.slice(0,r+1).join(W.sep)},em=(a=R(function*(e){var t=W.join(e,"subspaces");return(yield(0,V.readdir)(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&/^subspace-\d+$/.test(e.name)).map(e=>W.join(t,e.name)).sort()}),function(e){return a.apply(this,arguments)}),ey=(s=R(function*(e){var t=Object.keys(ea),r=yield(0,V.readdir)(e,{withFileTypes:!0}).catch(()=>[]),i=new Set(r.filter(e=>e.isFile()).map(e=>e.name));return t.filter(e=>i.has(e)).map(t=>W.join(e,t))}),function(e){return s.apply(this,arguments)}),ev=(o=R(function*(e){var t=yield em(e);return(yield Promise.all(t.map(ey))).flat()}),function(e){return o.apply(this,arguments)}),eh=(l=R(function*(e,t){if(t.file)return eo(e,t.file);if(!t.id)throw new es("missing_file","Provide file, or provide id for global lookup");for(var r of yield ev(e)){var i=yield ed(e,r);if(ec(i.ast).find(e=>e.id===t.id))return r}throw new es("entry_not_found",`Entry id not found: ${t.id}`,{id:t.id})}),function(e,t){return l.apply(this,arguments)}),eb=(d=R(function*(e,t){var r=yield eh(e,t),i=yield ed(e,r),n=ep(i,t),a=((e,t)=>{if(!e.object)throw new es("fallback_recommended",`Entry ${e.name} in ${t} is not a top-level exported object literal. Edit this file directly for this one.`,{file:t,entry:e.name,check:"top-level export const object literal"});return e.object})(n,i.relPath);return{parsed:i,entry:n,object:a}}),function(e,t){return d.apply(this,arguments)}),ew=(e,t)=>Y.callExpression(Y.identifier("makeId"),t?[Y.stringLiteral(e),Y.stringLiteral(t)]:[Y.stringLiteral(e)]),ex=e=>{var t=[];for(var r of e.split(".").filter(Boolean))for(var i=/([^\[\]]+)|\[(\d+)\]/g,n=void 0;n=i.exec(r);)n[1]&&t.push({key:n[1]}),n[2]&&t.push({index:Number(n[2])});if(0===t.length)throw new es("invalid_path",`Invalid path: ${e}`,{path:e});return t},eg=e=>Y.isTSAsExpression(e)||Y.isTSSatisfiesExpression(e)||Y.isTSNonNullExpression(e)||Y.isParenthesizedExpression(e)?eg(e.expression):e,e_=(e,t)=>{var r=eg(e);if(!Y.isObjectExpression(r))throw new es("fallback_recommended",`Target path ${t} is not an object literal. Edit this file directly for this one.`,{path:t,expected:"object literal",actual:r.type});return r},ej=(e,t)=>{var r=eg(e);if(!Y.isArrayExpression(r))throw new es("fallback_recommended",`Target path ${t} is not an array literal. Edit this file directly for this one.`,{path:t,expected:"array literal",actual:r.type});return r},eP=e=>"array"==("index"in e?"array":"object")?Y.arrayExpression([]):Y.objectExpression([]),ek=(c=R(function*(e,t,r,i){for(var n=ex(t),a=e,s=0;s<n.length;s+=1){var o=n[s],l=s===n.length-1;if("key"in o){var d=e_(a,t);if(l)return void(0,Q.HJ)(d,o.key,(yield eF(r,i)));var c=n[s+1],p=(0,Q.bf)(d,o.key);p||(p=Y.objectProperty((0,Q.zu)(o.key),eP(c)),d.properties.push(p)),a=p.value;continue}var u=ej(a,t);if(o.index<0||o.index>u.elements.length)throw new es("invalid_path",`Array index out of range for ${t}`,{path:t,index:o.index});if(l){u.elements[o.index]=yield eF(r,i);return}u.elements[o.index]||(u.elements[o.index]=eP(n[s+1])),a=u.elements[o.index]}}),function(e,t,r,i){return c.apply(this,arguments)}),eE=(e,t)=>{for(var r=ex(t),i=e,n=0;n<r.length;n+=1){var a=r[n],s=n===r.length-1;if("key"in a){var o=e_(i,t);if(s)return void(0,Q.jc)(o,a.key);var l=(0,Q.bf)(o,a.key);if(!l)return;i=l.value;continue}var d=ej(i,t);if(a.index<0||a.index>=d.elements.length)return;if(s)return void d.elements.splice(a.index,1);var c=d.elements[a.index];if(!c)return;i=c}},eS=(e,t)=>{var r=(0,Q.bf)(e,"switches");if(!r)throw new es("fallback_recommended","Entry has no switches array",{path:"switches"});var i=ej(r.value,"switches"),n="number"==typeof t?t:i.elements.findIndex(e=>Y.isObjectExpression(e)&&(0,Q.JJ)(e,"id")===t);if(n<0||n>=i.elements.length)throw new es("entry_not_found",`Switch not found: ${t}`,{switch:t});var a=i.elements[n];if(!Y.isObjectExpression(a))throw new es("fallback_recommended",`Switch ${String(t)} is not an object literal. Edit this file directly for this one.`,{switch:t});return a},e$=(e,t)=>{var r=t.replace(/\.[tj]sx?$/,""),i=W.relative(W.dirname(e),r).replace(/\\/g,"/");return i.startsWith(".")||(i=`./${i}`),i},eA=e=>{var t=new Set;return e.program.body.forEach(e=>{Y.isImportDeclaration(e)?e.specifiers.forEach(e=>t.add(e.local.name)):Y.isExportNamedDeclaration(e)&&Y.isVariableDeclaration(e.declaration)&&e.declaration.declarations.forEach(e=>{Y.isIdentifier(e.id)&&t.add(e.id.name)})}),t},eI=(e,t,r)=>{for(var i of e.ast.program.body)if(Y.isImportDeclaration(i)&&i.source.value===t){var n=i.specifiers.find(e=>Y.isImportDefaultSpecifier(e));if(n)return n.local.name}var a=eA(e.ast),s=r;if(a.has(s)){for(var o=1;a.has(`${s}${o}`);)o+=1;s=`${s}${o}`}var l=Y.importDeclaration([Y.importDefaultSpecifier(Y.identifier(s))],Y.stringLiteral(t));return(0,Q.Pb)(e.ast,l),s},eO=e=>{(0,Q.Kx)(e.parsed.ast,"type",e.typeImports),(0,Q.Kx)(e.parsed.ast,"value",e.valueImports)},eC=(p=R(function*(e,t,r){if(null==r||""===r)return t;if("number"==typeof r)return W.join(e,"subspaces",`subspace-${r}`);var i=String(r);if(/^\d+$/.test(i))return W.join(e,"subspaces",`subspace-${i}`);if(/^subspace-\d+$/.test(i))return W.join(e,"subspaces",i);if(i.includes("/"))return eo(e,i);var n,a=yield em(e),s=function*(){var t=W.join(o,"index.ts"),r=yield(0,V.readFile)(t,"utf8").catch(()=>"");if(!r)return 0;var n=el(r,(0,Q.RI)(e,t)),a=!1;if(en(n,{ObjectProperty(e){"id"===(0,Q.Gp)(e.node.key)&&Y.isStringLiteral(e.node.value)&&e.node.value.value===i&&(a=!0,e.stop())}}),a)return{v:o}};for(var o of a)if(n=yield*s(),0!==n&&n)return n.v;throw new es("reference_not_found",`Subspace not found: ${i}`,{subspace:i})}),function(e,t,r){return p.apply(this,arguments)}),eN=(u=R(function*(e,t){var r,i,n=ef(e.parsed.absPath),a=yield eC(e.projectDir,n,t),s=W.basename(a),o=/^subspace-(\d+)$/.exec(s);if(!o)throw new es("invalid_subspace",`Not a subspace directory: ${s}`,{subspace:t});var l=W.join(a,"index.ts"),d=yield(0,V.readFile)(l,"utf8").catch(()=>null);if(null==d)throw new es("reference_not_found",`Subspace not found: ${t}`,{subspace:t});var c=(r=el(d,(0,Q.RI)(e.projectDir,l)),en(r,{ObjectProperty(e){if("id"===(0,Q.Gp)(e.node.key)){var t=e.node.value;Y.isStringLiteral(t)&&t.value.startsWith("SUBSPACE_")&&(i=t.value,e.stop())}}}),i);if(!c)throw new es("invalid_subspace",`Subspace index has no SUBSPACE_ id: ${s}/index.ts`,{subspace:t});return{id:c,index:Number(o[1]),label:s,indexPath:l,isCurrent:W.resolve(a)===W.resolve(n)}}),function(e,t){return u.apply(this,arguments)}),eT=(f=R(function*(e,t){var r=yield eN(e,t);if(r.isCurrent)return e.references.push({input:t,id:r.id,sameFile:!1,display:`'${r.id}'`,targetAbsPath:r.indexPath}),{resolved:r,expression:Y.stringLiteral(r.id)};var i=eI(e.parsed,`../${r.label}`,`subspace${r.index}`);return e.references.push({input:t,id:r.id,sameFile:!1,display:`() => ${i}`,targetAbsPath:r.indexPath}),{resolved:r,expression:Y.arrowFunctionExpression([],Y.identifier(i))}}),function(e,t){return f.apply(this,arguments)}),eR=(m=R(function*(e,t,r,i){var n=ef(t),a=yield eC(e,n,i),s=yield ey(a),o=[];for(var l of s){var d=yield ed(e,l),c=d.kind;for(var p of ec(d.ast))if(p.name===r||p.id===r||p.alias===r){var u=W.resolve(l)===W.resolve(t),f=W.basename(a);o.push({input:r,id:p.id,alias:p.alias,varName:p.name,namespace:c.namespace,display:`${c.namespace}.${p.name}`,targetAbsPath:l,sameFile:u,subspaceLabel:f,importSource:u?void 0:e$(t,l)})}}if(0===o.length)throw new es("reference_not_found",`Reference not found: ${r}`,{ref:r,subspace:i??W.basename(n)});if(o.length>1)throw new es("ambiguous_reference",`Reference is ambiguous: ${r}`,{ref:r,matches:o.map(t=>({file:(0,Q.RI)(e,t.targetAbsPath),entry:t.varName,id:t.id,alias:t.alias}))});return o[0]}),function(e,t,r,i){return m.apply(this,arguments)}),eD=(y=R(function*(e,t,r){var i=yield eR(t.projectDir,t.parsed.absPath,e,r);if(i.sameFile)return t.references.push(i),Y.identifier(i.varName);var n=ef(t.parsed.absPath),a=ef(i.targetAbsPath),s=i.subspaceLabel.replace(/[^a-zA-Z0-9_$]/g,""),o=n===a?i.namespace:`${s}${i.namespace[0].toUpperCase()}${i.namespace.slice(1)}`,l=((e,t,r,i)=>{for(var n of e.ast.program.body)if(Y.isImportDeclaration(n)&&n.source.value===r){var a=n.specifiers.find(Y.isImportNamespaceSpecifier);if(a)return a.local.name}var s=eA(e.ast),o=i;if(s.has(o)){for(var l=1;s.has(`${o}${l}`);)l+=1;o=`${o}${l}`}var d=Y.importDeclaration([Y.importNamespaceSpecifier(Y.identifier(o))],Y.stringLiteral(r));return(0,Q.Pb)(e.ast,d),o})(t.parsed,i.namespace,i.importSource,o);return i.importLocal=l,t.references.push({...i,display:`${l}.${i.varName}`,importLocal:l}),Y.memberExpression(Y.identifier(l),Y.identifier(i.varName))}),function(e,t,r){return y.apply(this,arguments)}),eF=(v=R(function*(e,t){if((0,Q.u4)(e)&&"string"==typeof e.expr&&1===Object.keys(e).length){var r=e.expr;try{return(0,q.parseExpression)(r,{plugins:["typescript"]})}catch(e){throw new es("invalid_expr",`Invalid TypeScript expression: ${e.message}`,{expr:r})}}if((0,Q.u4)(e)&&"string"==typeof e.link){t.valueImports.add("linkData");var i=yield eD(e.link,t,e.subspace);return Y.callExpression(Y.identifier("linkData"),[Y.arrowFunctionExpression([],i)])}if((0,Q.u4)(e)&&"string"==typeof e.ref){var n=yield eD(e.ref,t,e.subspace);return Y.arrowFunctionExpression([],n)}if(Array.isArray(e))return Y.arrayExpression((yield Promise.all(e.map(e=>eF(e,t)))));if((0,Q.u4)(e)){var a,s=yield Promise.all(Object.entries(e).map((a=R(function*([e,r]){return Y.objectProperty((0,Q.zu)(e),(yield eF(r,t)))}),function(e){return a.apply(this,arguments)})));return Y.objectExpression(s)}return void 0===e?Y.identifier("undefined"):Y.valueToNode(e)}),function(e,t){return v.apply(this,arguments)}),eL=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,resolved:e.importLocal?`${e.importLocal}.${e.varName}`:e.sameFile?e.varName:e.display,file:e.targetAbsPath})),eB=(h=R(function*(e){var t=ei(e.ast,{comments:!0},e.source).code,r=yield(0,H.format)(e.absPath,t,Q.Hn);if(r.errors.length>0)throw new es("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return h.apply(this,arguments)}),eK=(b=R(function*(e){var t=yield eB(e);return el(t,e.relPath),yield(0,V.writeFile)(e.absPath,t),t}),function(e){return b.apply(this,arguments)}),eU=(e,t)=>{if(e){var r=eu(e.absPath);return`${t?.name||"entry"} (${e.kind.kind}, ${r})`}},ez=(w=R(function*(e,t,r,i){var n={ts:new Date().toISOString(),tool:t,op:r?.op||(r?.set?"set":r?.unset?"unset":t),target:{file:r?.file,entry:r?.entry,id:r?.id},provenance:(0,ee.S)()};try{var a=yield i(),s={...n,...a};return yield(0,ee.a)(e,s).catch(e=>{s.auditError=e.message}),s}catch(i){var o=i instanceof es?i:new es("error",i.message||String(i),void 0,!0),l="fallback_recommended"===o.code?"fallback_recommended":"error",d={...n,outcome:l,input:r,error:{code:o.code,message:o.message,details:o.details},summary:"fallback_recommended"===l?`${t} could not safely edit this standard path; edit the file directly`:`${t} failed: ${o.message}`,isError:o.isMcpError||"error"===l};return yield(0,ee.a)(e,d).catch(e=>{d.auditError=e.message}),d}}),function(e,t,r,i){return w.apply(this,arguments)}),eq=(x=R(function*(e,t){return ez(e,"edit_entry",t,R(function*(){var r=yield eb(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eS(a,t.switch);for(var l of Object.entries(t.set||{})){var d=T(l,2),c=d[0],p=d[1];yield ek(o,c,p,s)}for(var u of[...t.unset||[]].sort((e,t)=>{for(var r=ex(e).map(e=>"index"in e?e.index:-1),i=ex(t).map(e=>"index"in e?e.index:-1),n=0;n<Math.min(r.length,i.length);n+=1)if(r[n]!==i[n])return i[n]-r[n];return i.length-r.length}))eE(o,u);eO(s),yield eK(i);var f=yield(0,Z.H)(e,t.verify),m=eU(i,n);return{file:i.relPath,entry:n.name,id:n.id,change:{set:t.set||{},unset:t.unset||[],references:eL(s.references)},outcome:"compile:failed"===f.status?"verify_failed":"ok",verify:f,summary:`edited ${m} -> ${f.status}`}}))}),function(e,t){return x.apply(this,arguments)}),eM=e=>{switch(e){case"IfStatement":return"an if statement";case"ForStatement":case"ForOfStatement":case"ForInStatement":return"a for loop";case"WhileStatement":case"DoWhileStatement":return"a while loop";case"SwitchStatement":return"a switch statement";case"TryStatement":return"a try/catch block";case"FunctionDeclaration":return"a function declaration";case"ReturnStatement":return"a return before the final statement";default:return`a ${e}`}},eY=(e,t)=>{for(var r=0;r<e.length;r+=1){var i=e[r],n=r===e.length-1;if("ExpressionStatement"===i.type){var a=eJ(i.expression);if(a)return a;continue}if("VariableDeclaration"===i.type){for(var s of i.declarations)if("Identifier"!==s.id.type||!s.init)return"a destructuring or uninitialized declaration";continue}if(t&&n&&"ReturnStatement"===i.type){var o=i.argument?eJ(i.argument):null;if(o)return o;continue}return eM(i.type)}return null},eJ=e=>{if(e?.type!=="CallExpression"||e.arguments?.length||e.callee?.type!=="ArrowFunctionExpression"&&e.callee?.type!=="FunctionExpression")return null;var t=e.callee.body;return t?.type==="BlockStatement"?eY(t.body,!0):eJ(t)},eH=(g=R(function*(e,t){if(e?.expr)return eF(e,t);var r,i=(e=>{if(!(0,Q.u4)(e)||!(0,Q.u4)(e.action))return e;var t=e.action,r={handler:e.handler,name:t.name??t.__actionName,waitAsync:e.waitAsync};if(t.cast&&(r.cast=t.cast),Array.isArray(t.params))for(var i of(r.params={},t.params)){if(!(0,Q.u4)(i)||"string"!=typeof i.input)throw new es("invalid_action",'Compiled action params entries require { input: "name", value }',{param:i});r.params[i.input]=i.value}if(Array.isArray(t.dataParams))for(var n of(r.dataParams={},t.dataParams)){var a=(0,Q.u4)(n?.input)?n.input.ref:n?.input;if("string"!=typeof a||!a)throw new es("invalid_action","Compiled action dataParams entries require { input: dataRef, value }",{param:n});r.dataParams[a]=n.value}return r})(e),n=i?.name;if(!n)throw new es("invalid_action","Action requires name");if("PROPERTY_BANK_EXPRESSION"===n&&(0,Q.u4)(i.params)){var a=i.params.expression;"string"==typeof a&&(e=>{try{t=(0,J.qg)(e,{ecmaVersion:2020})}catch(t){throw new es("invalid_action",`PROPERTY_BANK_EXPRESSION does not parse: ${t.message}`,{expression:e})}var t,r=eY(t.body,!1);if(r)throw new es("invalid_action",`PROPERTY_BANK_EXPRESSION cannot evaluate ${r}: the runtime folds the expression into a single expression (expression statements, simple const/let declarations, and a final return inside an IIFE only). Use ternaries instead of statements, or move branching logic to a DataCalculationScript.`,{expression:e})})(a)}var s="System",o=i.cast;if("system"===i.handler||null==i.handler)r=Y.stringLiteral("system"),o||=`SystemAction${n.toLowerCase().split("_").filter(Boolean).map(e=>`${e[0].toUpperCase()}${e.slice(1)}`).join("")}`;else if((0,Q.u4)(i.handler)&&"string"==typeof i.handler.ref){var l=yield eR(t.projectDir,t.parsed.absPath,i.handler.ref,i.handler.subspace);if("bricks"!==l.namespace&&"generators"!==l.namespace)throw new es("invalid_action",`Action handler must be a brick or generator, got ${l.namespace}: ${i.handler.ref}`,{handler:i.handler});s="bricks"===l.namespace?"Brick":"Generator";var d=yield eD(i.handler.ref,t,i.handler.subspace);r=Y.arrowFunctionExpression([],d)}else if((0,Q.u4)(i.handler)&&null!=i.handler.subspace)r=(yield eT(t,i.handler.subspace)).expression,s="Subspace";else throw new es("invalid_action","Unsupported action handler",{handler:i.handler});var c=[Y.objectProperty(Y.identifier("__actionName"),Y.stringLiteral(n)),Y.objectProperty(Y.identifier("parent"),Y.stringLiteral(s)),Y.objectProperty(Y.identifier("name"),Y.stringLiteral(n))];if(i.params){var p,u=yield Promise.all(Object.entries(i.params).map((p=R(function*([e,r]){return Y.objectExpression([Y.objectProperty(Y.identifier("input"),Y.stringLiteral(e)),Y.objectProperty(Y.identifier("value"),(yield eF(r,t)))])}),function(e){return p.apply(this,arguments)})));c.push(Y.objectProperty(Y.identifier("params"),Y.arrayExpression(u)))}if(i.dataParams){var f,m=yield Promise.all(Object.entries(i.dataParams).map((f=R(function*([e,r]){var i=yield eD(e,t);return Y.objectExpression([Y.objectProperty(Y.identifier("input"),Y.arrowFunctionExpression([],i)),Y.objectProperty(Y.identifier("value"),(yield eF(r,t)))])}),function(e){return f.apply(this,arguments)})));c.push(Y.objectProperty(Y.identifier("dataParams"),Y.arrayExpression(m)))}var y=Y.objectExpression(c);return o&&(t.typeImports.add(o),y=Y.tsAsExpression(y,Y.tsTypeReference(Y.identifier(o)))),Y.objectExpression([Y.objectProperty(Y.identifier("handler"),r),Y.objectProperty(Y.identifier("action"),y),Y.objectProperty(Y.identifier("waitAsync"),Y.booleanLiteral(!!i.waitAsync))])}),function(e,t){return g.apply(this,arguments)}),eV=(e,t,r)=>{var i=(0,Q.bf)(e,t);return i||(i=Y.objectProperty((0,Q.zu)(t),Y.objectExpression([])),e.properties.push(i)),e_(i.value,r)},eG=(e,t,r)=>{var i=(0,Q.bf)(e,t);return i||(i=Y.objectProperty((0,Q.zu)(t),Y.arrayExpression([])),e.properties.push(i)),ej(i.value,r)},eW=(_=R(function*(e,t){return ez(e,"edit_events",t,R(function*(){var r=yield eb(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=null==t.switch?a:eS(a,t.switch),l=t.op;if("clear"===l||"remove"===l||"move"===l){var d=(0,Q.bf)(o,"events"),c=d?e_(d.value,"events"):null,p=c?(0,Q.bf)(c,t.event):null,u=p?ej(p.value,`events.${t.event}`):null;if("clear"===l)c&&(0,Q.jc)(c,t.event);else if("move"===l){if(null==t.index)throw new es("invalid_index","move requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new es("invalid_index","move index out of range",{index:t.index});var f=Number(t.to);if(!Number.isFinite(f)||f<0||f>=u.elements.length)throw new es("invalid_index","move requires valid to index",{to:t.to});var m=u.elements.splice(t.index,1),y=T(m,1)[0];u.elements.splice(f,0,y)}else{if(null==t.index)throw new es("invalid_index","remove requires index");if(!u||t.index<0||t.index>=u.elements.length)throw new es("invalid_index","remove index out of range",{index:t.index});u.elements.splice(t.index,1),0===u.elements.length&&c&&(0,Q.jc)(c,t.event)}}else if("add"===l||"replace"===l){var v=yield eH(t.action,s),h=eV(o,"events","events"),b=eG(h,t.event,`events.${t.event}`),w=t.index??b.elements.length;if("replace"===l){if(w<0||w>=b.elements.length)throw new es("invalid_index","replace index out of range",{index:w});b.elements[w]=v}else{if(w<0||w>b.elements.length)throw new es("invalid_index","add index out of range",{index:w});b.elements.splice(w,0,v)}}else throw new es("invalid_op",`Unsupported edit_events op: ${l}`);eO(s),yield eK(i);var x=yield(0,Z.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{event:t.event,op:l,index:t.index,references:eL(s.references)},outcome:"compile:failed"===x.status?"verify_failed":"ok",verify:x,summary:`${l} event ${t.event} on ${eU(i,n)} -> ${x.status}`}}))}),function(e,t){return _.apply(this,arguments)}),eX=e=>{if((0,Q.u4)(e)&&"string"==typeof e.expr)return e;if(!(0,Q.u4)(e))throw new es("invalid_item","Canvas item requires frame { x, y, width, height }");for(var t of["x","y","width","height"])if("number"!=typeof e[t])throw new es("invalid_item",`Canvas item frame requires numeric ${t}`,{frame:e});return e},eZ=(j=R(function*(e,t,r){if(!e?.ref&&e?.subspace==null)throw new es("invalid_item","Canvas item requires ref (brick) or subspace (embed)");var i,n=eX(e.frame??r);if(e.ref){var a=yield eD(e.ref,t,e.subspace);i=Y.arrowFunctionExpression([],a)}else{var s=yield eT(t,e.subspace),o=s.resolved,l=s.expression;if(o.isCurrent)throw new es("invalid_item","A subspace cannot embed itself",{subspace:e.subspace});i=l}return Y.objectExpression([Y.objectProperty(Y.identifier("item"),i),Y.objectProperty(Y.identifier("frame"),(yield eF(n,t))),...null==e.hidden?[]:[Y.objectProperty(Y.identifier("hidden"),Y.booleanLiteral(!!e.hidden))]])}),function(e,t,r){return j.apply(this,arguments)}),eQ=(P=R(function*(e,t){return ez(e,"edit_canvas_items",t,R(function*(){var r=yield eb(e,t),i=r.parsed,n=r.entry,a=r.object;if("canvas"!==i.kind.kind)throw new es("invalid_file","edit_canvas_items only edits canvases.ts entries",{file:i.relPath});var s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eG(a,"items","items"),l=t.op;if("add"===l||"replace"===l){var d=yield eZ(t.item,s,t.frame),c=t.index??o.elements.length;if("replace"===l){if(c<0||c>=o.elements.length)throw new es("invalid_index","replace index out of range",{index:c});o.elements[c]=d}else{if(c<0||c>o.elements.length)throw new es("invalid_index","add index out of range",{index:c});o.elements.splice(c,0,d)}}else if("remove"===l){if(null==t.index)throw new es("invalid_index","remove requires index");if(t.index<0||t.index>=o.elements.length)throw new es("invalid_index","remove index out of range",{index:t.index});o.elements.splice(t.index,1)}else if("move"===l){if(null==t.index)throw new es("invalid_index","move requires index");if(!t.frame)throw new es("invalid_item","move requires frame");if(t.index<0||t.index>=o.elements.length)throw new es("invalid_index","move index out of range",{index:t.index});var p=o.elements[t.index];if(!Y.isObjectExpression(p))throw new es("fallback_recommended","Canvas item is not an object literal",{index:t.index});(0,Q.HJ)(p,"frame",(yield eF(eX(t.frame),s)))}else throw new es("invalid_op",`Unsupported edit_canvas_items op: ${l}`);eO(s),yield eK(i);var u=yield(0,Z.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:eL(s.references)},outcome:"compile:failed"===u.status?"verify_failed":"ok",verify:u,summary:`${l} canvas item on ${eU(i,n)} -> ${u.status}`}}))}),function(e,t){return P.apply(this,arguments)}),e0=(k=R(function*(e,t){var r=(e=>{switch(e?.__typename){case"SwitchCondInnerStateCurrentCanvas":return{type:"inner_state",key:"current_canvas",value:e.value,subspace:e.subspace};case"SwitchCondInnerStateOutlet":return{type:"inner_state",outlet:e.outlet,value:e.value};case"SwitchCondData":return{type:"property_bank",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondPropertyBankByItemKey":return{type:"property_bank_by_item_key",ref:e.data??e.ref,value:e.value,subspace:e.subspace};default:return e}})(e);if(r?.expr)return eF(r,t);if(r?.type==="inner_state"&&"current_canvas"===r.key){var i=yield eD(r.value,t,r.subspace);return Y.objectExpression([Y.objectProperty(Y.identifier("__typename"),Y.stringLiteral("SwitchCondInnerStateCurrentCanvas")),Y.objectProperty(Y.identifier("value"),Y.arrowFunctionExpression([],i))])}if(r?.type==="inner_state"){var n=r.outlet||r.key;if(!n)throw new es("invalid_switch","Switch inner-state outlet condition requires outlet or key");return Y.objectExpression([Y.objectProperty(Y.identifier("__typename"),Y.stringLiteral("SwitchCondInnerStateOutlet")),Y.objectProperty(Y.identifier("outlet"),Y.stringLiteral(n)),Y.objectProperty(Y.identifier("value"),(yield eF(r.value,t)))])}var a=r?.ref||r?.data||r?.key;if(!a)throw new es("invalid_switch","Switch condition requires data ref");var s=yield eD(a,t,r.subspace);return Y.objectExpression([Y.objectProperty(Y.identifier("__typename"),Y.stringLiteral(r?.type==="property_bank_by_item_key"?"SwitchCondPropertyBankByItemKey":"SwitchCondData")),Y.objectProperty(Y.identifier("data"),Y.arrowFunctionExpression([],s)),Y.objectProperty(Y.identifier("value"),(yield eF(r.value,t)))])}),function(e,t){return k.apply(this,arguments)}),e1=new Set(["id","title","description","conds","override","property","outlets","animation","events","disabled","break"]),e4=(E=R(function*(e,t){for(var r of Object.keys(e))if(!e1.has(r))throw new es("invalid_switch",`Unknown switch field: ${r}`,{field:r,supported:Array.from(e1)});if(void 0!==e.events)throw new es("invalid_switch","Set switch events with edit_events using its switch parameter");if(e.id&&!/^BRICK_STATE_GROUP_[0-9a-fA-F-]{36}$/.test(e.id))throw new es("invalid_switch","Switch id must match BRICK_STATE_GROUP_<uuid>; omit id to generate one",{id:e.id});var i,n=e.id?Y.stringLiteral(e.id):ew("switch");e.id||t.valueImports.add("makeId");var a=[Y.objectProperty(Y.identifier("id"),n)];for(var s of(null!=e.title&&a.push(Y.objectProperty(Y.identifier("title"),Y.stringLiteral(e.title))),null!=e.description&&a.push(Y.objectProperty(Y.identifier("description"),Y.stringLiteral(e.description))),e.conds&&a.push(Y.objectProperty(Y.identifier("conds"),Y.arrayExpression((yield Promise.all(e.conds.map((i=R(function*(e){return Y.objectExpression([Y.objectProperty(Y.identifier("method"),Y.stringLiteral(e.method||"==")),Y.objectProperty(Y.identifier("cond"),(yield e0(e.cond||e,t)))])}),function(e){return i.apply(this,arguments)}))))))),e.override&&a.push(Y.objectProperty(Y.identifier("override"),(yield eF(e.override,t)))),["property","outlets","animation"]))null!=e[s]&&a.push(Y.objectProperty(Y.identifier(s),(yield eF(e[s],t))));return null!=e.disabled&&a.push(Y.objectProperty(Y.identifier("disabled"),Y.booleanLiteral(!!e.disabled))),null!=e.break&&a.push(Y.objectProperty(Y.identifier("break"),Y.booleanLiteral(!!e.break))),Y.objectExpression(a)}),function(e,t){return E.apply(this,arguments)}),e5=(S=R(function*(e,t){return ez(e,"edit_switches",t,R(function*(){var r=yield eb(e,t),i=r.parsed,n=r.entry,a=r.object,s={projectDir:e,parsed:i,references:[],typeImports:new Set,valueImports:new Set},o=eG(a,"switches","switches"),l=t.op,d=e=>"number"==typeof e?e:e?o.elements.findIndex(t=>Y.isObjectExpression(t)&&(0,Q.JJ)(t,"id")===e):-1;if("add"===l||"replace"===l){var c=yield e4(t.switch||{},s),p=null==t.index?o.elements.length:d(t.index);if("replace"===l){if(p<0||p>=o.elements.length)throw new es("invalid_index","replace index out of range",{index:p});o.elements[p]=c}else{if(p<0||p>o.elements.length)throw new es("invalid_index","add requires a valid switch id or index",{index:t.index});o.elements.splice(p,0,c)}}else if("remove"===l){var u=d(t.index);if(u<0||u>=o.elements.length)throw new es("invalid_index","remove requires a valid switch id or index",{index:t.index});o.elements.splice(u,1)}else if("move"===l){var f=d(t.index);if(f<0||f>=o.elements.length)throw new es("invalid_index","move requires a valid switch id or index",{index:t.index});var m=Number(t.to);if(!Number.isFinite(m)||m<0||m>=o.elements.length)throw new es("invalid_index","move requires valid to index",{to:t.to});var y=o.elements.splice(f,1),v=T(y,1)[0];o.elements.splice(m,0,v)}else throw new es("invalid_op",`Unsupported edit_switches op: ${l}`);eO(s),yield eK(i);var h=yield(0,Z.H)(e,t.verify);return{file:i.relPath,entry:n.name,id:n.id,change:{op:l,index:t.index,references:eL(s.references)},outcome:"compile:failed"===h.status?"verify_failed":"ok",verify:h,summary:`${l} switch on ${eU(i,n)} -> ${h.status}`}}))}),function(e,t){return S.apply(this,arguments)}),e9=($=R(function*(e,t,r,i){var n=[Y.objectProperty(Y.identifier("__typename"),Y.stringLiteral(e.typename)),Y.objectProperty(Y.identifier("id"),r)];return t.alias&&n.push(Y.objectProperty(Y.identifier("alias"),Y.stringLiteral(t.alias))),null!=t.title&&n.push(Y.objectProperty(Y.identifier("title"),Y.stringLiteral(t.title))),null!=t.description&&n.push(Y.objectProperty(Y.identifier("description"),Y.stringLiteral(t.description))),"brick"===e.kind||"generator"===e.kind?(n.push(Y.objectProperty(Y.identifier("templateKey"),Y.stringLiteral(t.templateKey||""))),n.push(Y.objectProperty(Y.identifier("property"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("events"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("outlets"),Y.objectExpression([]))),"brick"===e.kind&&n.push(Y.objectProperty(Y.identifier("animation"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("switches"),Y.arrayExpression([])))):"canvas"===e.kind?(n.push(Y.objectProperty(Y.identifier("property"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("events"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("switches"),Y.arrayExpression([]))),n.push(Y.objectProperty(Y.identifier("items"),Y.arrayExpression([])))):"data"===e.kind?(n.push(Y.objectProperty(Y.identifier("type"),Y.stringLiteral(t.dataType||"any"))),n.push(Y.objectProperty(Y.identifier("schema"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("events"),Y.objectExpression([]))),n.push(Y.objectProperty(Y.identifier("value"),Y.identifier("undefined")))):"animation"===e.kind&&(n.push(Y.objectProperty(Y.identifier("runType"),Y.stringLiteral("once"))),n.push(Y.objectProperty(Y.identifier("property"),Y.stringLiteral("opacity"))),n.push(Y.objectProperty(Y.identifier("config"),(yield eF({__type:"AnimationTimingConfig",toValue:1,duration:300,easing:"",delay:0,isInteraction:!0},i))))),Y.objectExpression(n)}),function(e,t,r,i){return $.apply(this,arguments)}),e8=(A=R(function*(e,t,r){var i=W.basename(t);for(var n of(yield ev(e)).filter(e=>W.basename(e)===i)){var a=yield ed(e,n);if(ec(a.ast).some(e=>e.alias===r))return!0}return!1}),function(e,t,r){return A.apply(this,arguments)}),e7=(I=R(function*(e,t){return ez(e,"new_entry",t,R(function*(){if(!t.file)throw new es("missing_file","new_entry requires file");if(!t.type)throw new es("missing_type","new_entry requires TypeScript type");var r=eo(e,t.file),i=yield ed(e,r),n=new Set(ec(i.ast).map(e=>e.name)),a="string"==typeof t.id?t.id:void 0,s=a||"string"!=typeof t.alias||!t.alias||(yield e8(e,r,t.alias))?void 0:t.alias,o=a?Y.stringLiteral(a):ew(i.kind.idType,s),l=t.entry||((e,t,r,i)=>{var n,a=(e=>{if(!e)return null;var t=e.replace(/[^a-zA-Z0-9_$]/g,"");return t?(/^[0-9]/.test(t)&&(t=`_${t}`),t):null})(i)||(r?`${t.varPrefix}${n=r.replace(/^[A-Z_]+/g,""),`${n.substr(15,3)}${n.substr(20,1)}`}`:`${t.varPrefix}Entry`);if(!e.has(a))return a;for(var s=1;e.has(`${a}${s}`);)s+=1;return`${a}${s}`})(n,i.kind,a,t.alias||t.title),d={projectDir:e,parsed:i,references:[],typeImports:new Set([t.type]),valueImports:new Set};a||d.valueImports.add("makeId");var c=yield e9(i.kind,t,o,d),p=Y.variableDeclarator(Y.identifier(l),c);for(var u of(p.id.typeAnnotation=Y.tsTypeAnnotation(Y.tsTypeReference(Y.identifier(t.type))),i.ast.program.body.push(Y.exportNamedDeclaration(Y.variableDeclaration("const",[p]))),Object.entries(t.set||{}))){var f=T(u,2),m=f[0],y=f[1];yield ek(c,m,y,d)}for(var v of t.events||[]){if(!(0,Q.u4)(v)||"string"!=typeof v.event||!v.event||!v.action)throw new es("invalid_action","events entries require { event, action }",{event:v});var h=eV(c,"events","events");eG(h,v.event,`events.${v.event}`).elements.push((yield eH(v.action,d)))}eO(d),yield eK(i);var b=yield(0,Z.H)(e,t.verify);return{file:i.relPath,entry:l,id:a,idExpression:a??(s?`makeId('${i.kind.idType}', '${s}')`:`makeId('${i.kind.idType}')`),change:{set:t.set||{},events:t.events||[],references:eL(d.references)},outcome:"compile:failed"===b.status?"verify_failed":"ok",verify:b,summary:`created ${l} (${i.kind.kind}, ${eu(i.absPath)}) -> ${b.status}`}}))}),function(e,t){return I.apply(this,arguments)}),e6=(e,t)=>{var r;return Y.isArrowFunctionExpression(e)&&0===e.params.length&&(r=e.body,!!r&&(Y.isIdentifier(r)?r.name===t.varName:!!Y.isMemberExpression(r)&&!!Y.isIdentifier(r.object)&&!!Y.isIdentifier(r.property)&&r.object.name===t.namespace&&r.property.name===t.varName))},e2=(e,t)=>Y.isCallExpression(e)&&Y.isIdentifier(e.callee,{name:"linkData"})&&e6(e.arguments[0],t),e3=(e,t)=>{if(!e)return!1;if(e6(e,t)||e2(e,t))return!0;var r=!1;return en(Y.file(Y.program([Y.expressionStatement(Y.cloneNode(e,!0))])),{ArrowFunctionExpression(e){e6(e.node,t)&&(r=!0,e.stop())},CallExpression(e){e2(e.node,t)&&(r=!0,e.stop())}}),r},te=(e,t,r,i=[],n={})=>{if(Y.isProgram(e))return void e.body.forEach((e,a)=>te(e,t,r,[...i,String(a)],n));if(Y.isExportNamedDeclaration(e)&&e.declaration)return void te(e.declaration,t,r,i,n);if(Y.isVariableDeclaration(e))return void e.declarations.forEach((e,a)=>te(e,t,r,[...i,String(a)],n));if(Y.isVariableDeclarator(e)&&e.init)return void te(e.init,t,r,i,n);if(Y.isObjectExpression(e)){for(var a=e.properties.length-1;a>=0;a-=1){var s=e.properties[a];if(Y.isObjectProperty(s)){var o=(0,Q.Gp)(s.key)||`property-${a}`,l=[...i,o];if(e6(s.value,t)||e2(s.value,t)){i.includes("outlets")?(e.properties.splice(a,1),r.push({action:"drop_outlet",path:l.join(".")})):n.dataCalc&&("output"===o||"error"===o)?(s.value=Y.nullLiteral(),r.push({action:"null_output",path:l.join(".")})):(s.value=Y.identifier("undefined"),r.push({action:"null_link",path:l.join(".")}));continue}te(s.value,t,r,l,n)}}return}if(Y.isArrayExpression(e))for(var d=i[i.length-1],c=i.includes("events")&&"events"!==d,p=n.dataCalc?["items","params","dataParams","conds","switches","inputs","outputs"]:["items","params","dataParams","conds","switches"],u=e.elements.length-1;u>=0;u-=1){var f=e.elements[u];if(f){var m=[...i,String(u)];if(e3(f,t)&&(p.includes(d)||c||e6(f,t))){e.elements.splice(u,1),r.push({action:c?"delete_event_handler":n.dataCalc&&("inputs"===d||"outputs"===d)?"remove_io_item":"remove_reference_item",path:m.join(".")});continue}te(f,t,r,m,n)}}},tt=(e,t)=>{var r=e.ast.program.body.indexOf(t.node);r>=0&&e.ast.program.body.splice(r,1)},tr=(O=R(function*(e,t,r){if("project"===r)return ev(e);var i=ef(t),n=yield ey(i),a=W.join(i,"data-calc"),s=yield(0,V.readdir)(a,{withFileTypes:!0}).catch(()=>[]);return[...n,...s.filter(e=>e.isFile()&&e.name.endsWith(".ts")).map(e=>W.join(a,e.name))]}),function(e,t,r){return O.apply(this,arguments)}),ti=(C=R(function*(e,t){return ez(e,"remove_entry",t,R(function*(){var r,i=yield eb(e,t),n=i.parsed,a=i.entry,s={varName:a.name,namespace:n.kind.namespace,id:a.id},o=yield tr(e,n.absPath,t.scope),l=[],d=yield Promise.all(o.map((r=R(function*(t){var r=yield(0,V.readFile)(t,"utf8");return{absPath:t,relPath:(0,Q.RI)(e,t),source:r,ast:el(r,(0,Q.RI)(e,t)),kind:ea[W.basename(t)]||n.kind}}),function(e){return r.apply(this,arguments)}))),c=function*(e){var t,r,i,o,d;(o=(e.absPath===n.absPath?(t=a.name,r=Y.cloneNode(e.ast,!0),i={...e,ast:r},tt(i,ep(i,{entry:t})),i):e).ast,d=[],en(o,{ArrowFunctionExpression(e){e6(e.node,s)&&d.push({type:"ref",loc:e.node.loc?.start})},CallExpression(e){e2(e.node,s)&&d.push({type:"link",loc:e.node.loc?.start})}}),d).forEach(t=>l.push({file:e.relPath,...t}))};for(var p of d)yield*c(p);if(t.strict&&l.length>0)return{file:n.relPath,entry:a.name,id:a.id,outcome:"refused",touchedSites:l,verify:{status:"skipped",errors:[]},summary:`refused to remove ${eU(n,a)}; ${l.length} reference(s) found`};var u=function*(e){var t=[],r={dataCalc:e.absPath.split(W.sep).includes("data-calc")};if(e.absPath===n.absPath&&(tt(e,ep(e,{entry:a.name})),t.push({action:"remove_entry",path:a.name})),te(e.ast.program,s,t,[],r),0===t.length)return 1;var i=yield eB(e);el(i,e.relPath),yield(0,V.writeFile)(e.absPath,i),t.forEach(t=>l.push({file:e.relPath,...t}))};for(var f of d)if(yield*u(f))continue;var m=yield(0,Z.H)(e,t.verify);return{file:n.relPath,entry:a.name,id:a.id,outcome:"compile:failed"===m.status?"verify_failed":"ok",touchedSites:l,verify:m,summary:`removed ${eU(n,a)} with ${l.length} touched site(s) -> ${m.status}`}}))}),function(e,t){return C.apply(this,arguments)}),tn=(N=R(function*(e,t){return ez(e,"new_subspace",t,R(function*(){var r=W.join(e,"root.ts"),i=(0,Q.RI)(e,r),n=yield(0,V.readFile)(r,"utf8").catch(()=>null);if(null==n)throw new es("invalid_file","Project has no root.ts to wire the subspace into");var a={source:n,ast:el(n,i),absPath:r,relPath:i},s=a.ast.program.body.find(e=>Y.isExportDefaultDeclaration(e));if(!s||!Y.isArrayExpression(s.declaration))throw new es("fallback_recommended","root.ts default export is not a subspace array literal; wire the new subspace manually",{file:i});var o=(yield em(e)).reduce((e,t)=>{var r=/^subspace-(\d+)$/.exec(W.basename(t));return r?Math.max(e,Number(r[1])):e},-1)+1,l=`subspace-${o}`,d=W.join(e,"subspaces",l),c=`SUBSPACE_${(0,G.randomUUID)()}`,p=`CANVAS_${(0,G.randomUUID)()}`,u=(({subspaceId:e,canvasId:t,title:r,description:i,layout:n,portal:a})=>{var s=[`width: ${n.width}`,`height: ${n.height}`,...n.resizeMode?[`resizeMode: '${n.resizeMode}'`]:[]];return{"data.ts":"import type { Data } from 'bricks-ctor'\n","bricks.ts":"import type { Brick } from 'bricks-ctor'\n","generators.ts":"import type { Generator } from 'bricks-ctor'\n","animations.ts":"import type { Animation } from 'bricks-ctor'\n","canvases.ts":`import type { Canvas } from 'bricks-ctor'
6
+
7
+ export const cMain: Canvas = {
8
+ __typename: 'Canvas',
9
+ id: '${t}',
10
+ title: 'Canvas 1',
11
+ description: '',
12
+ property: {},
13
+ events: {},
14
+ switches: [],
15
+ items: [],
16
+ }
17
+ `,"data-calc/index.ts":"export const dataCalculation = []\n","index.ts":`import type { Subspace } from 'bricks-ctor'
18
+ import * as canvases from './canvases'
19
+ import * as data from './data'
20
+ import * as animations from './animations'
21
+ import * as generators from './generators'
22
+ import * as bricks from './bricks'
23
+ import { dataCalculation } from './data-calc'
24
+
25
+ export default {
26
+ __typename: 'Subspace',
27
+ id: '${e}',
28
+ title: ${JSON.stringify(r)},
29
+ description: ${JSON.stringify(i)},${a?`
30
+ portal: '${a}',`:""}
31
+ layout: { ${s.join(", ")} },
32
+ rootCanvas: canvases.cMain,
33
+ canvases: Object.values(canvases),
34
+ animations: Object.values(animations),
35
+ bricks: Object.values(bricks),
36
+ generators: Object.values(generators),
37
+ data: Object.values(data),
38
+ dataRouting: [],
39
+ dataCalculation,
40
+ events: {},
41
+ } as Subspace
42
+
43
+ export { bricks, generators, canvases, data }
44
+ `}})({subspaceId:c,canvasId:p,title:t.title,description:t.description??"",layout:{width:t.layout?.width??96,height:t.layout?.height??54,resizeMode:t.layout?.resizeMode},portal:t.portal});yield(0,V.mkdir)(W.join(d,"data-calc"),{recursive:!0});var f=[];for(var m of Object.entries(u)){var y=T(m,2),v=y[0],h=y[1],b=W.join(d,v),w=yield(0,H.format)(b,h,Q.Hn);yield(0,V.writeFile)(b,w.errors.length>0?h:w.code),f.push((0,Q.RI)(e,b))}var x=eI(a,`./subspaces/${l}`,`subspace${o}`);s.declaration.elements.push(Y.identifier(x)),yield eK(a);var g=yield(0,Z.H)(e,t.verify);return{subspace:l,id:c,index:o,files:f,change:{op:"new_subspace",rootImport:x},outcome:"compile:failed"===g.status?"verify_failed":"ok",verify:g,summary:`new_subspace ${l} (${t.title}) wired into root.ts -> ${g.status}`}}))}),function(e,t){return N.apply(this,arguments)}),ta=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}],isError:e.isError||void 0}),ts=X.bz().describe('Value grammar: JSON scalars/arrays/objects emit literals; { link: "dataIdOrAlias" } emits linkData(() => data.dX) for property/data-link values; { ref: "idOrAliasOrVar", subspace?: "subspace-1"|1|"SUBSPACE_id" } emits () => namespace.varName; { expr: "raw TypeScript expression" } is spliced verbatim.'),to=X.Yj().describe("Dotted entry path to edit, for example title, property.url, outlets.response, animation.show, value, type, switches[0].property.text, or items[0].frame."),tl=X.Yj().describe("Project-relative entry file path, for example subspaces/subspace-0/bricks.ts, generators.ts, canvases.ts, data.ts, or animations.ts."),td=X.Yj().describe("Exported const name or entity alias to edit, for example bWelcomeText, gApiClient, cMain, or an alias like welcomeText."),tc=X.Yj().describe("Entry id fallback. When file is omitted, scans project subspaces for this id."),tp=X.zM().describe("Override compile verification for this call. Defaults to BRICKS_CTOR_MCP_EDIT_VERIFY, otherwise true."),tu={file:tl.optional(),entry:td.optional(),id:tc.optional(),verify:tp.optional()};function tf(e,t){var r,i,n,a,s,o,l;e.tool("edit_entry","Edit map-shaped facets on an existing bricks-ctor entry by source AST. Use set/unset with dotted paths and the shared value grammar.",{...tu,set:X.g1(to,ts).describe("Map of dotted paths to values. Values use the shared grammar: JSON literals, { link }, { ref }, or { expr }.").optional(),unset:X.YO(to).describe("Dotted paths to remove.").optional(),switch:X.KC([X.Yj(),X.ai()]).describe("Optional switch id or zero-based switch index; edits that switch object instead of the entry root.").optional()},(r=R(function*(e){return ta((yield eq(t,e)))}),function(e){return r.apply(this,arguments)})),e.tool("edit_events","Edit an event action array on an entry or switch. Adds/removes/replaces/moves/clears EventAction objects.",{...tu,event:X.Yj().describe("Camel-case source event key such as onPress, showStart, update, enter, or firstEnter."),op:X.k5(["add","remove","replace","move","clear"]).describe("Array operation. add inserts at index or appends; replace/remove require index; move reorders index to `to`; clear removes the event key."),index:X.ai().describe("Zero-based event action index. For add this is the insertion position.").optional(),to:X.ai().describe("Destination zero-based index for move.").optional(),action:ts.describe('For add/replace, the flattened form: { handler: "system"|{ref}|{subspace: "subspace-1"|1|"SUBSPACE_id"}, name: "ACTION_NAME", params?: { inputName: value }, dataParams?: { dataRef: value }, cast?: "TypeName", waitAsync?: boolean }. Cross-subspace {subspace} handlers emit a () => subspaceN getter; the emitting subspace itself stays a literal id. The compiled source form { handler, action: { name, params: [...], dataParams: [...] }, waitAsync } and { expr: "raw EventAction" } are also accepted.').optional(),switch:X.KC([X.Yj(),X.ai()]).describe("Optional switch id or zero-based switch index; edits that switch events object.").optional()},(i=R(function*(e){return ta((yield eW(t,e)))}),function(e){return i.apply(this,arguments)})),e.tool("edit_canvas_items","Edit a Canvas entry items array. Use add/remove/replace to place bricks or move to update an item frame.",{...tu,op:X.k5(["add","remove","replace","move"]).describe("Canvas item operation. add inserts/appends, replace/remove use index, move updates frame at index."),index:X.ai().describe("Zero-based canvas item index.").optional(),item:ts.describe('For add/replace: { ref: "brickIdOrAliasOrVar", subspace?: ..., frame: { x, y, width, height, ... }, hidden?: boolean } places a brick; { subspace: "subspace-1"|1|"SUBSPACE_id", frame: ... } without ref embeds that subspace (emits a () => subspaceN getter). Frames require numeric x/y/width/height.').optional(),frame:ts.describe("Replacement frame such as { x, y, width, height }. Required for move; for add/replace it is used when item.frame is omitted.").optional()},(n=R(function*(e){return ta((yield eQ(t,e)))}),function(e){return n.apply(this,arguments)})),e.tool("edit_switches","Edit an entry switches array. Use edit_entry/edit_events with switch when changing switch facet bodies.",{...tu,op:X.k5(["add","remove","replace","move"]).describe("Switch array operation. add inserts/appends, replace/remove use index, move reorders to `to`."),index:X.KC([X.Yj(),X.ai()]).describe("Switch id or zero-based switch index. For add, this is optional insertion position.").optional(),to:X.ai().describe("Destination zero-based index for move.").optional(),switch:ts.describe('For add/replace: { id? (BRICK_STATE_GROUP_<uuid>; omit to auto-generate), title?, description?, conds?: [{ method: "=="|"!="|">"|"<"|">="|"<=", cond }], override?: { animation?, event?, property?, outlet? }, property?, outlets?, animation?, disabled?, break? }. Cond forms: { type: "inner_state", key: "current_canvas", value: canvasRef }, { type: "inner_state", outlet: "outletName", value }, { type: "property_bank", ref: dataRef, value }, { type: "property_bank_by_item_key", ref: dataRef, value }, a compiled { __typename: "SwitchCond..." } object, or { expr }. Set switch events with edit_events using its switch parameter.').optional()},(a=R(function*(e){return ta((yield e5(t,e)))}),function(e){return a.apply(this,arguments)})),e.tool("new_entry","Create a minimal standard-style exported entry skeleton in an entry file, then optionally apply set/events edits.",{file:tl,entry:td.describe("Optional exported const name. Defaults from alias/title/id.").optional(),templateKey:X.Yj().describe("Brick/generator templateKey such as BRICK_TEXT or GENERATOR_HTTP.").optional(),type:X.Yj().describe("TypeScript type imported from bricks-ctor, for example BrickText, GeneratorHTTP, Canvas, Data, or Animation."),alias:X.Yj().describe("Optional entry alias. Also influences default exported const name.").optional(),title:X.Yj().describe("Optional entry title.").optional(),description:X.Yj().describe("Optional entry description.").optional(),id:tc.describe("Optional explicit id. If omitted, the tool generates one with the file-kind prefix.").optional(),dataType:X.Yj().describe("For data.ts only: initial Data.type value. Defaults to any.").optional(),set:X.g1(to,ts).describe("Optional initial dotted-path values applied after creating the skeleton. Values use JSON literals, { link }, { ref }, or { expr }.").optional(),events:X.YO(ts).describe("Optional initial event actions as objects with { event, action }.").optional(),verify:tp.optional()},(s=R(function*(e){return ta((yield e7(t,e)))}),function(e){return s.apply(this,arguments)})),e.tool("remove_entry","Remove an entry. By default cascades same-subspace references in standard entry object/array shapes; strict mode refuses when references exist.",{...tu,strict:X.zM().describe("When true, do not edit files; refuse and return reference sites if the entry is referenced.").optional(),scope:X.k5(["subspace","project"]).describe("Reference scan scope. subspace is default; project scans all subspaces.").optional()},(o=R(function*(e){return ta((yield ti(t,e)))}),function(e){return o.apply(this,arguments)})),e.tool("new_subspace","Scaffold a new subspaces/subspace-N directory (standard entry files + root canvas, fixed SUBSPACE_ id) and wire it into root.ts. Embed it afterwards with edit_canvas_items { subspace } or target it with edit_events { handler: { subspace } }.",{title:X.Yj().describe("Subspace title shown in the editor."),description:X.Yj().describe("Optional subspace description.").optional(),layout:X.Ik({width:X.ai(),height:X.ai(),resizeMode:X.k5(["cover","stretch"]).optional()}).describe("Subspace grid the embed frame scales; defaults to { width: 96, height: 54 }. Use a smaller grid plus resizeMode: 'stretch' for panel modules.").optional(),portal:X.k5(["top","left","bottom","right"]).describe("Dock the subspace to a viewport edge as an always-on overlay instead of a canvas-embeddable module.").optional(),verify:tp.optional()},(l=R(function*(e){return ta((yield tn(t,e)))}),function(e){return l.apply(this,arguments)}))}var tm={editEntry:eq,editEvents:eW,editCanvasItems:eQ,editSwitches:e5,newEntry:e7,newSubspace:tn,removeEntry:ti,resolveReference:eR};i()}catch(e){i(e)}})}};
package/lib/3976.js ADDED
@@ -0,0 +1,14 @@
1
+ export const __rspack_esm_id=3976;export const __rspack_esm_ids=[3976];export const __webpack_modules__={79491(e){e.exports=import("oxfmt").then(function(e){return e})},48875(e,t){let r=["title","update_timestamp"],i=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),a=e=>void 0===e||"function"==typeof e||"symbol"==typeof e,n=e=>"number"!=typeof e||Number.isFinite(e)?e:null,o=e=>{if(!a(e))return Array.isArray(e)?e.map(e=>a(e)?null:o(e)):i(e)?Object.entries(e).reduce((e,[t,r])=>(a(r)||(e[t]=o(r)),e),{}):n(e)},s=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)&&!a(e[t]),l=(e,t)=>{let r=e[t];return a(r)?null:r},c=(e,t)=>{if((e=n(e))===(t=n(t)))return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!c(l(e,r),l(t,r)))return!1;return!0}if(i(e)&&i(t)){let r=0;for(let i of Object.keys(e))if(!a(e[i])&&(r+=1,!s(t,i)||!c(e[i],t[i])))return!1;let i=0;for(let e of Object.keys(t))a(t[e])||(i+=1);return r===i}return!1},u=e=>{if(!i(e))return e;let t={...e};for(let e of r)delete t[e];return t},d=(e,t,r,a)=>{if(!c(e,t)){if(i(e)&&i(t)){for(let i of new Set([...Object.keys(e),...Object.keys(t)])){let n=s(e,i),l=s(t,i);if(!n&&!l)continue;let c=[...r,i];l?n?d(e[i],t[i],c,a):a.push({op:"set",path:c,value:o(t[i])}):a.push({op:"unset",path:c})}return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let i=0;i<t.length;i+=1)d(l(e,i),l(t,i),[...r,i],a);return}a.push({op:"set",path:r,value:o(t)})}};t.O2=(e,t)=>{let r=[];return d(u(e),u(t),[],r),r}},2985(e,t,r){r.d(t,{Re:()=>c,m4:()=>l});var i,a=r(99436),n=r(51455),o=r(76760),s=r(48875),l=(e,t)=>{if(null==e)return{status:"no_baseline"};if(null==t)return{status:"unavailable"};var r=(0,s.O2)(e,t);return{status:"ok",ops:r,opCount:r.length}},c=(i=a(function*(e){try{return JSON.parse((yield(0,n.readFile)(o.join(e,".bricks/build/application-config.json"),"utf8")))}catch{return null}}),function(e){return i.apply(this,arguments)})},3540(e,t,r){r.d(t,{S:()=>d,a:()=>u});var i,a,n=r(99436),o=r(51455),s=r(76760),l=".bricks/edits.jsonl",c=(i=n(function*(e){var t=s.join(e,".gitignore"),r=yield(0,o.readFile)(t,"utf8").catch(e=>{if(e?.code==="ENOENT")return"";throw e});if(!r.split(/\r?\n/).map(e=>e.trim()).some(e=>e===l||".bricks/"===e||".bricks"===e)){var i=r&&!r.endsWith("\n")?"\n":"";yield(0,o.writeFile)(t,`${r}${i}
2
+ # MCP entry-editing audit log
3
+ ${l}
4
+ `)}}),function(e){return i.apply(this,arguments)}),u=(a=n(function*(e,t){var r=s.join(e,".bricks");yield(0,o.mkdir)(r,{recursive:!0}),yield c(e),yield(0,o.appendFile)(s.join(r,"edits.jsonl"),`${JSON.stringify(t)}
5
+ `)}),function(e,t){return a.apply(this,arguments)}),d=()=>({session:process.env.BRICKS_CTOR_SESSION_ID||process.env.CODEX_SESSION_ID,agent:process.env.BRICKS_CTOR_AGENT_ID||process.env.USER})},98009(e,t,r){r.d(t,{Gp:()=>l,HJ:()=>p,Hn:()=>n,JJ:()=>d,Kx:()=>m,Pb:()=>y,RI:()=>s,bf:()=>u,jc:()=>f,u4:()=>o,zu:()=>c});var i=r(58135),a=r(76760),n={trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100},o=e=>!!e&&"object"==typeof e&&!Array.isArray(e),s=(e,t)=>a.relative(e,t).replace(/\\/g,"/").replace(/^\.\/+/,""),l=e=>i.isIdentifier(e)?e.name:i.isStringLiteral(e)||i.isNumericLiteral(e)?String(e.value):null,c=e=>/^[$A-Z_a-z][$\w]*$/.test(e)?i.identifier(e):i.stringLiteral(e),u=(e,t)=>e.properties.find(e=>!!i.isObjectProperty(e)&&l(e.key)===t),d=(e,t)=>{var r=u(e,t);if(r&&i.isStringLiteral(r.value))return r.value.value},p=(e,t,r)=>{var a=u(e,t);if(a){a.value=r;return}e.properties.push(i.objectProperty(c(t),r))},f=(e,t)=>{var r=e.properties.findIndex(e=>!!i.isObjectProperty(e)&&l(e.key)===t);r>=0&&e.properties.splice(r,1)},y=(e,t)=>{var r=e.program.body,a=r.findLastIndex(e=>i.isImportDeclaration(e));r.splice(a+1,0,t)},m=(e,t,r)=>{var a=new Set(Array.from(r).filter(Boolean));if(0!==a.size){var n,o=function(e){return i.isImportDeclaration(e)&&"bricks-ctor"===e.source.value&&"type"===t==("type"===e.importKind)?(e.specifiers.forEach(e=>{if(i.isImportSpecifier(e)){var t=e.imported;i.isIdentifier(t)&&a.delete(t.name),i.isStringLiteral(t)&&a.delete(t.value)}}),a.forEach(t=>{e.specifiers.push(i.importSpecifier(i.identifier(t),i.identifier(t)))}),{v:void 0}):0};for(var s of e.program.body)if(0!==(n=o(s))&&n)return n.v;var l=i.importDeclaration(Array.from(a).map(e=>i.importSpecifier(i.identifier(e),i.identifier(e))),i.stringLiteral("bricks-ctor"));"type"===t&&(l.importKind="type"),y(e,l)}}},54452(e,t,r){r.d(t,{H:()=>u});var i,a,n=r(99436),o=r(75720),s=r(2985),l={FORCE_COLOR:"0",NO_COLOR:"1"},c=(i=n(function*(e){var t=yield(0,s.Re)(e);try{yield(0,o.sh)`bun compile`.cwd(e).env({...l,BRICKS_CTOR_ENABLE_EDITING_TOOLS:"0"}).text()}catch(e){var r=[e.stdout?.toString()??"",e.stderr?.toString()??"",e.message].filter(Boolean).join("\n").trim();return{status:"compile:failed",errors:r?[r]:["bun compile failed"]}}var i=yield(0,s.Re)(e);return{status:"compile:ok",errors:[],configChange:(0,s.m4)(t,i)}}),function(e){return i.apply(this,arguments)}),u=(a=n(function*(e,t){return(void 0!==t?t:!["0","false","no","off"].includes((process.env.BRICKS_CTOR_MCP_EDIT_VERIFY??"true").toLowerCase()))?c(e):{status:"skipped",errors:[]}}),function(e,t){return a.apply(this,arguments)})},69899(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>eJ,register:()=>eN});var a,n,o,s,l,c,u,d,p,f,y,m,b,v,h,g,x,_,w,j,k,I=r(68832),S=r(99436),$=r(44668),E=r(5018),O=r(63315),P=r(30409),C=r(40906),D=r(59410),A=r(2235),L=r(46773),R=r(58135),F=r(11978),T=r(79491),N=r(51455),J=r(76760),Y=r(84867),M=r(54452),z=r(98009),H=r(3540),q=e([T]);function K(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(K=function(){return!!e})()}T=(q.then?(await q)():q)[0];var B=A.default||A,W=function(e){function t(e,r,i,a=!1){var n,o,s;return E(this,t),o=t,s=[r],o=P(o),(n=O(this,K()?Reflect.construct(o,s||[],P(this).constructor):o.apply(this,s))).name="DataCalcEditingError",n.code=e,n.details=i,n.isMcpError=a,n}return C(t,e),$(t)}(D(Error)),U=(e,t)=>{if(J.isAbsolute(t))throw new W("invalid_file","File must be project-relative",{file:t});var r=J.resolve(e,t),i=J.relative(e,r);if(i.startsWith("..")||J.isAbsolute(i))throw new W("invalid_file","File must stay inside the project directory",{file:t});return r},V=(e,t)=>{try{return(0,L.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new W("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},G=(a=S(function*(e,t){var r=yield(0,N.readFile)(t,"utf8"),i=(0,z.RI)(e,t);return{source:r,ast:V(r,i),absPath:t,relPath:i}}),function(e,t){return a.apply(this,arguments)}),Z=e=>e.program.body.flatMap(e=>R.isExportNamedDeclaration(e)&&R.isVariableDeclaration(e.declaration)?e.declaration.declarations.flatMap(e=>{if(!R.isIdentifier(e.id))return[];var t,r=e.id.typeAnnotation;R.isTSTypeAnnotation(r)&&R.isTSTypeReference(r.typeAnnotation)&&R.isIdentifier(r.typeAnnotation.typeName)&&(t=r.typeAnnotation.typeName.name);var i=R.isObjectExpression(e.init)?e.init:void 0;return[{name:e.id.name,object:i,id:i?(0,z.JJ)(i,"id"):void 0,alias:i?(0,z.JJ)(i,"alias"):void 0,typeName:t}]}):[]),Q=(e,t)=>{if(null==t||""===t)return J.join(e,"subspaces/subspace-0");if("number"==typeof t)return J.join(e,"subspaces",`subspace-${t}`);var r=String(t);if(/^\d+$/.test(r))return J.join(e,"subspaces",`subspace-${r}`);if(/^subspace-\d+$/.test(r))return J.join(e,"subspaces",r);if(r.includes("/"))return U(e,r);throw new W("unsupported_subspace",`Unsupported subspace locator: ${r}`,{subspace:r})},X=e=>{var t=J.basename(e),r=/^data-calculation-(.+)\.ts$/.exec(t);if(!r)throw new W("invalid_file","Expected data-calculation-{slug}.ts file",{file:e});return r[1]},ee=(n=S(function*(e){return(yield(0,N.readdir)(e,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isFile()&&/^data-calculation-.+\.ts$/.test(e.name)&&!e.name.endsWith(".sandbox.ts")).map(t=>J.join(e,t.name)).sort()}),function(e){return n.apply(this,arguments)}),et=e=>{var t=(0,z.bf)(e,"code")?.value;return t&&R.isExpression(t)?t:null},er=e=>{var t=R.isAwaitExpression(e)?e.argument:e;if(!R.isCallExpression(t))return null;var r=t.arguments[0];if(!R.isNewExpression(r)||!R.isIdentifier(r.callee)||"URL"!==r.callee.name)return null;var i=r.arguments[0];return R.isStringLiteral(i)?i.value:null},ei=(o=S(function*(e,t){if(t.file)a=U(e,t.file);else{var r,i,a,n=Q(e,t.subspace),o=J.join(n,"data-calc"),s=yield ee(o),l=t.calc;if(!l)throw new W("missing_calc","Provide file or subspace+calc");for(var c of s){if(l===X(c)){a=c;break}try{var u=yield G(e,c),d=Z(u.ast).find(e=>"dataCalculation"===e.name);if(d&&(l===d.alias||l===d.id)){a=c;break}}catch{continue}}}if(!a)throw new W("calc_not_found",`Data calc not found: ${t.calc}`,{calc:t.calc,subspace:t.subspace??"subspace-0"});var p=yield G(e,a),f=(e=>{var t=Z(e.ast).find(e=>"dataCalculation"===e.name);if(!t||!t.object)throw new W("fallback_recommended",`Data calc ${e.relPath} is not a single exported object literal. Edit this file directly for this one.`,{file:e.relPath,check:"export const dataCalculation object literal"});var r=(0,z.JJ)(t.object,"__typename");if("DataCalculationScript"!==r)throw new W("fallback_recommended",`Data calc ${e.relPath} is ${r||"not DataCalculationScript"}. DataCalculationMap is out of scope; edit this file directly.`,{file:e.relPath,typename:r});return t.object})(p),y=X(a),m=(r=et(f),(i=er(r))&&/^(\.\/)?[^/\\]+\.sandbox\.js$/.test(i)?i.replace(/^\.\//,""):`data-calculation-${y}.sandbox.js`);return{parsed:p,object:f,slug:y,sandboxFile:m}}),function(e,t){return o.apply(this,arguments)}),ea=e=>{for(var t of e.program.body)if(R.isImportDeclaration(t)&&"node:fs/promises"===t.source.value){t.specifiers.some(e=>R.isImportSpecifier(e)&&R.isIdentifier(e.imported)&&"readFile"===e.imported.name)||t.specifiers.push(R.importSpecifier(R.identifier("readFile"),R.identifier("readFile")));return}(0,z.Pb)(e,R.importDeclaration([R.importSpecifier(R.identifier("readFile"),R.identifier("readFile"))],R.stringLiteral("node:fs/promises")))},en=e=>{(0,z.Kx)(e.parsed.ast,"type",e.typeImports),(0,z.Kx)(e.parsed.ast,"value",e.valueImports)},eo=(s=S(function*(e,t,r,i){var a,n=(e=>{var t=e.split(J.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new W("invalid_file","Data-calc file must be inside subspaces/subspace-N/data-calc",{file:e});return t.slice(0,r+1).join(J.sep)})(t),o=null==i?n:Q(e,i),s=J.join(o,"data.ts"),l=yield G(e,s),c=Z(l.ast).filter(e=>e.name===r||e.id===r||e.alias===r);if(0===c.length)throw new W("reference_not_found",`Data reference not found: ${r}`,{ref:r,subspace:J.basename(o)});if(c.length>1)throw new W("ambiguous_reference",`Data reference is ambiguous: ${r}`,{ref:r,matches:c.map(t=>({file:(0,z.RI)(e,s),entry:t.name,id:t.id,alias:t.alias}))});var u=J.resolve(s)===J.resolve(t);return{input:r,id:c[0].id,alias:c[0].alias,varName:c[0].name,sameFile:u,importSource:u?void 0:((a=J.relative(J.dirname(t),s).replace(/\\/g,"/")).startsWith(".")||(a=`./${a}`),a.replace(/\.(ts|tsx|js|jsx)$/,""))}}),function(e,t,r,i){return s.apply(this,arguments)}),es=(l=S(function*(e,t){if((0,z.u4)(e)&&"string"==typeof e.expr)return(0,L.parseExpression)(e.expr,{plugins:["typescript"]});var r="string"==typeof e?e:(0,z.u4)(e)?e.ref:void 0;if("string"!=typeof r||!r)throw new W("invalid_ref","Data getter requires a data ref string");var i=yield eo(t.projectDir,t.parsed.absPath,r,(0,z.u4)(e)?e.subspace:void 0),a=i.sameFile?"data":((e,t,r)=>{for(var i of e.ast.program.body)if(R.isImportDeclaration(i)&&i.source.value===t){var a=i.specifiers.find(e=>R.isImportNamespaceSpecifier(e));if(a)return a.local.name}var n=R.importDeclaration([R.importNamespaceSpecifier(R.identifier(r))],R.stringLiteral(t));return(0,z.Pb)(e.ast,n),r})(t.parsed,i.importSource||"../data","data");return t.references.push(i),R.arrowFunctionExpression([],R.memberExpression(R.identifier(a),R.identifier(i.varName)))}),function(e,t){return l.apply(this,arguments)}),el=(c=S(function*(e,t){return null==e?R.nullLiteral():es(e,t)}),function(e,t){return c.apply(this,arguments)}),ec=(u=S(function*(e,t){var r=J.join(e,"subspaces");for(var i of yield(0,N.readdir)(r,{withFileTypes:!0}).catch(()=>[]))if(i.isDirectory()&&/^subspace-\d+$/.test(i.name))for(var a of yield ee(J.join(r,i.name,"data-calc")))try{var n=yield G(e,a),o=Z(n.ast).find(e=>"dataCalculation"===e.name);if(o?.alias===t)return!0}catch{continue}return!1}),function(e,t){return u.apply(this,arguments)}),eu=new Set(["__typename","id","code","enableAsync","inputs","output","outputs","error"]),ed=e=>R.awaitExpression(R.callExpression(R.identifier("readFile"),[R.newExpression(R.identifier("URL"),[R.stringLiteral(`./${e}`),R.memberExpression(R.metaProperty(R.identifier("import"),R.identifier("meta")),R.identifier("url"))]),R.stringLiteral("utf8")])),ep=(d=S(function*(e,t){if((0,z.u4)(e)){if("string"==typeof e.expr)return(0,L.parseExpression)(e.expr,{plugins:["typescript"]});if("string"==typeof e.ref)return es(e,t)}if(null===e)return R.nullLiteral();if(void 0===e)return R.identifier("undefined");if("string"==typeof e)return R.stringLiteral(e);if("number"==typeof e)return R.numericLiteral(e);if("boolean"==typeof e)return R.booleanLiteral(e);if(Array.isArray(e))return R.arrayExpression((yield Promise.all(e.map(e=>ep(e,t)))));if((0,z.u4)(e)){var r,i=yield Promise.all(Object.entries(e).map((r=S(function*([e,r]){return R.objectProperty((0,z.zu)(e),(yield ep(r,t)))}),function(e){return r.apply(this,arguments)})));return R.objectExpression(i)}throw new W("invalid_value",`Unsupported value: ${String(e)}`)}),function(e,t){return d.apply(this,arguments)}),ef=(p=S(function*(e){var t=B(e.ast,{comments:!0},e.source).code,r=yield(0,T.format)(e.absPath,t,z.Hn);if(r.errors.length>0)throw new W("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return p.apply(this,arguments)}),ey=(f=S(function*(e){var t=yield ef(e);return V(t,e.relPath),yield(0,N.writeFile)(e.absPath,t),t}),function(e){return f.apply(this,arguments)}),em=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}],isError:e.isError||void 0}),eb=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,entry:e.varName})),ev=(y=S(function*(e,t,r,i){var a=new Date().toISOString(),n=(0,H.S)();try{var o=yield i();return yield(0,H.a)(e,{ts:a,tool:t,input:r,provenance:n,outcome:o.outcome,summary:o.summary,result:o}),o}catch(i){var s=i instanceof W,l=s&&"fallback_recommended"===i.code?"fallback_recommended":"error",c={outcome:l,isError:"error"===l,error:{code:s?i.code:"unexpected_error",message:i.message,details:s?i.details:void 0},summary:`${t} failed: ${i.message}`};return yield(0,H.a)(e,{ts:a,tool:t,input:r,provenance:n,outcome:c.outcome,summary:c.summary,error:c.error}).catch(()=>void 0),c}}),function(e,t,r,i){return y.apply(this,arguments)}),eh=(m=S(function*(e,t){var r=new Set((yield ee(e)).map(X));if(t){var i=t.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"calc";if(!r.has(i))return i;for(var a=1;r.has(`${i}-${a}`);)a+=1;return`${i}-${a}`}for(var n=0;r.has(String(n));)n+=1;return String(n)}),function(e,t){return m.apply(this,arguments)}),eg=e=>{try{return(0,F.qg)(e,{sourceType:"module",ecmaVersion:2020}),!0}catch{return!1}},ex=e=>{var t=e??"";if(/export\s+(async\s+)?function\s+main\s*\(/.test(t)){var r=t.endsWith("\n")?t:`${t}
6
+ `;if(!eg(r))throw new W("invalid_code","Sandbox code does not parse as a module (note: top-level await requires export async function main)");return r}var i=t.trim();if(!i)return"export function main() {\n}\n";for(var a of["","async "]){var n=`export ${a}function main() {
7
+ ${i}
8
+ }
9
+ `;if(eg(n))return n}throw new W("invalid_code","Sandbox code does not parse as a script body (statements with top-level return)")},e_=(b=S(function*(e,t){yield(0,N.mkdir)(t,{recursive:!0});var r=yield ee(t),i=r.map((e,t)=>{var r=X(e);return`import { dataCalculation as dataCalculation${t} } from './data-calculation-${r}'`}).join("\n"),a=r.map((e,t)=>`dataCalculation${t}`).join(",\n "),n=`${i}
10
+
11
+ export const dataCalculation = [
12
+ ${a}
13
+ ]
14
+ `,o=J.join(t,"index.ts"),s={absPath:o,relPath:(0,z.RI)(e,o),source:n,ast:V(n,(0,z.RI)(e,o))};return yield ey(s),(0,z.RI)(e,o)}),function(e,t){return b.apply(this,arguments)}),ew=(v=S(function*(e,t){var r=J.join(t,"index.ts"),i=(0,z.RI)(e,r),a=yield(0,N.readFile)(r,"utf8").catch(e=>{if(e?.code==="ENOENT")return null;throw e});if(null==a)return{warning:`${i} not found; wire the data-calc import manually`};var n=yield G(e,r),o=(e=>{for(var t of e.program.body)if(R.isExportDefaultDeclaration(t)){var r=t.declaration;if(R.isObjectExpression(r))return r;if(R.isTSAsExpression(r)&&R.isObjectExpression(r.expression))return r.expression}return null})(n.ast);if(!o)return{warning:`${i} has no default-export object; wire the data-calc import manually`};var s=(0,z.bf)(o,"dataCalculation");if(s&&R.isIdentifier(s.value))return null;if(s&&!(R.isArrayExpression(s.value)&&0===s.value.elements.length))return{warning:`${i} has a non-empty dataCalculation value; wire the data-calc import manually`};if(n.ast.program.body.some(e=>R.isImportDeclaration(e)&&("./data-calc"===e.source.value||"./data-calc/index"===e.source.value))||(0,z.Pb)(n.ast,R.importDeclaration([R.importSpecifier(R.identifier("dataCalculation"),R.identifier("dataCalculation"))],R.stringLiteral("./data-calc"))),s)s.value=R.identifier("dataCalculation"),R.isIdentifier(s.key)&&(s.shorthand=!0);else{var l=R.objectProperty(R.identifier("dataCalculation"),R.identifier("dataCalculation"));l.shorthand=!0,o.properties.push(l)}return yield ey(n),{touched:n.relPath}}),function(e,t){return v.apply(this,arguments)}),ej=(h=S(function*(e,t,r){if(!t.key)throw new W("missing_key",`${e} item requires key`);if(null==t.data)throw new W("missing_data",`${e} item requires data`);var i=[R.objectProperty(R.identifier("key"),R.stringLiteral(t.key)),R.objectProperty(R.identifier("data"),(yield es(t.data,r)))];return"inputs"===e&&i.push(R.objectProperty(R.identifier("trigger"),R.booleanLiteral(!1!==t.trigger))),R.objectExpression(i)}),function(e,t,r){return h.apply(this,arguments)}),ek=(g=S(function*(e,t,r){if("inputs"===e){var i=new Set;for(var a of t){if(i.has(a?.key))throw new W("duplicate_key",`Input key already exists: ${a.key}`,{key:a.key});i.add(a?.key)}}return R.arrayExpression((yield Promise.all(t.map(t=>ej(e,t,r)))))}),function(e,t,r){return g.apply(this,arguments)}),eI=(e,t)=>{if("number"==typeof t.index)return t.index;if(!t.key)return -1;var r=e.elements.map((e,t)=>({element:e,index:t})).filter(({element:e})=>R.isObjectExpression(e)&&(0,z.JJ)(e,"key")===t.key);if(r.length>1)throw new W("ambiguous_key",`IO key is ambiguous: ${t.key}`,{key:t.key,count:r.length});return r[0]?.index??-1},eS=(x=S(function*(e,t,r,i){let a;r.typeImports.add("DataCalculationScript"),r.valueImports.add("makeId"),ea(r.parsed.ast);var n=[R.objectProperty(R.identifier("__typename"),R.stringLiteral("DataCalculationScript")),R.objectProperty(R.identifier("id"),e.id?R.stringLiteral(e.id):(a="property_bank_calc",R.callExpression(R.identifier("makeId"),i?[R.stringLiteral(a),R.stringLiteral(i)]:[R.stringLiteral(a)])))];return e.alias&&n.push(R.objectProperty(R.identifier("alias"),R.stringLiteral(e.alias))),null!=e.title&&n.push(R.objectProperty(R.identifier("title"),R.stringLiteral(e.title))),null!=e.description&&n.push(R.objectProperty(R.identifier("description"),R.stringLiteral(e.description))),null!=e.note&&n.push(R.objectProperty(R.identifier("note"),R.stringLiteral(e.note))),n.push(R.objectProperty(R.identifier("code"),ed(t))),n.push(R.objectProperty(R.identifier("enableAsync"),R.booleanLiteral(!!e.enableAsync))),null!=e.triggerMode&&n.push(R.objectProperty(R.identifier("triggerMode"),R.stringLiteral(e.triggerMode))),n.push(R.objectProperty(R.identifier("inputs"),(yield ek("inputs",e.inputs||[],r)))),n.push(R.objectProperty(R.identifier("output"),(yield el(e.output,r)))),n.push(R.objectProperty(R.identifier("outputs"),(yield ek("outputs",e.outputs||[],r)))),n.push(R.objectProperty(R.identifier("error"),(yield el(e.error,r)))),R.objectExpression(n)}),function(e,t,r,i){return x.apply(this,arguments)}),e$=(_=S(function*(e,t){return ev(e,"new_data_calc",t,S(function*(){var r,i,a,n=Q(e,t.subspace),o=J.join(n,"data-calc");yield(0,N.mkdir)(o,{recursive:!0});var s=yield eh(o,t.alias),l=`data-calculation-${s}.sandbox.js`,c=J.join(o,`data-calculation-${s}.ts`),u=J.join(o,l),d=(r=(0,z.RI)(e,c),i="export const dataCalculation = {}\n",(a=V(i,r)).program.body=[],{ast:a,source:i,absPath:c,relPath:r}),p={projectDir:e,parsed:d,references:[],typeImports:new Set,valueImports:new Set},f=t.id||"string"!=typeof t.alias||!t.alias||(yield ec(e,t.alias))?void 0:t.alias,y=yield eS(t,l,p,f),m=R.variableDeclarator(R.identifier("dataCalculation"),y);m.id.typeAnnotation=R.tsTypeAnnotation(R.tsTypeReference(R.identifier("DataCalculationScript"))),d.ast.program.body.push(R.exportNamedDeclaration(R.variableDeclaration("const",[m]))),en(p),yield(0,N.writeFile)(u,ex(t.code)),yield ey(d);var b=[{file:(0,z.RI)(e,c),action:"create_calc"},{file:(0,z.RI)(e,u),action:"write_sandbox"}];b.push({file:yield e_(e,o),action:"regenerate_index"});var v=yield ew(e,n);v?.touched&&b.push({file:v.touched,action:"wire_subspace_index"});var h=yield(0,M.H)(e,t.verify);return{file:(0,z.RI)(e,c),subspace:J.basename(n),calc:s,idExpression:t.id??(f?`makeId('property_bank_calc', '${f}')`:"makeId('property_bank_calc')"),outcome:"compile:failed"===h.status?"verify_failed":"ok",touchedSites:b,...v?.warning?{warnings:[v.warning]}:{},verify:h,references:eb(p.references),summary:`created data calc ${s} in ${J.basename(n)} -> ${h.status}`}}))}),function(e,t){return _.apply(this,arguments)}),eE=(w=S(function*(e,t){return ev(e,"edit_data_calc",t,S(function*(){var r=yield ei(e,t),i={projectDir:e,parsed:r.parsed,references:[],typeImports:new Set,valueImports:new Set},a=[];for(var n of Object.entries(t.set||{})){var o=I(n,2),s=o[0],l=o[1];if("output"===s||"error"===s)(0,z.HJ)(r.object,s,(yield el(l,i)));else if("inputs"===s||"outputs"===s){if(!Array.isArray(l))throw new W("invalid_value",`${s} must be an array of IO items`);(0,z.HJ)(r.object,s,(yield ek(s,l,i)))}else if("code"===s)throw new W("invalid_field","Set code via the dedicated code parameter so it stays normalized to the sandbox file");else(0,z.HJ)(r.object,s,(yield ep(l,i)))}for(var c of t.unset||[]){if(eu.has(c))throw new W("invalid_field",`Cannot unset required field: ${c}`,{field:c});(0,z.jc)(r.object,c)}if(null!=t.code){var u=et(r.object);if(!(e=>{if(!e)return!1;if(R.isStringLiteral(e)||R.isTemplateLiteral(e))return!0;var t=er(e);return null!=t&&/^(\.\/)?[^/\\]+\.sandbox\.js$/.test(t)})(u))throw new W("fallback_recommended",`Data calc ${r.parsed.relPath} has an unsupported code expression. Edit this file directly for this one.`,{file:r.parsed.relPath,field:"code"});var d=r.sandboxFile,p=J.join(J.dirname(r.parsed.absPath),d);yield(0,N.writeFile)(p,ex(t.code)),ea(r.parsed.ast),(0,z.HJ)(r.object,"code",ed(d)),a.push({file:(0,z.RI)(e,p),action:"write_sandbox"})}en(i),yield ey(r.parsed),a.unshift({file:r.parsed.relPath,action:"edit_calc"});var f=yield(0,M.H)(e,t.verify);return{file:r.parsed.relPath,calc:r.slug,outcome:"compile:failed"===f.status?"verify_failed":"ok",touchedSites:a,verify:f,references:eb(i.references),summary:`edited data calc ${r.slug} -> ${f.status}`}}))}),function(e,t){return w.apply(this,arguments)}),eO=(j=S(function*(e,t){return ev(e,"edit_data_calc_io",t,S(function*(){var r=yield ei(e,t),i={projectDir:e,parsed:r.parsed,references:[],typeImports:new Set,valueImports:new Set},a=t.field,n=((e,t)=>{var r=(0,z.bf)(e,t);if(r){if(!R.isArrayExpression(r.value))throw new W("fallback_recommended",`${t} is not an array. Edit this file directly.`);return r.value}var i=R.arrayExpression([]);return e.properties.push(R.objectProperty(R.identifier(t),i)),i})(r.object,a),o=t.op;if("clear"===o)n.elements=[];else if("remove"===o){var s=eI(n,t);if(s<0||s>=n.elements.length)throw new W("invalid_index","remove requires a valid key or index");n.elements.splice(s,1)}else if("add"===o||"replace"===o){var l="replace"===o?eI(n,t):t.index;if("replace"===o&&(l<0||l>=n.elements.length))throw new W("invalid_index","replace requires a valid key or index");if("add"===o&&"number"==typeof l&&(l<0||l>n.elements.length))throw new W("invalid_index","add index out of range",{index:l});"inputs"===a&&((e,t,r)=>{if(e.elements.some((e,i)=>i!==r&&R.isObjectExpression(e)&&(0,z.JJ)(e,"key")===t))throw new W("duplicate_key",`Input key already exists: ${t}`,{key:t})})(n,t.key,"replace"===o?l:void 0);var c=yield ej(a,t,i);"replace"===o?n.elements[l]=c:n.elements.splice("number"==typeof l?l:n.elements.length,0,c)}else throw new W("invalid_op",`Unsupported edit_data_calc_io op: ${o}`);en(i),yield ey(r.parsed);var u=yield(0,M.H)(e,t.verify);return{file:r.parsed.relPath,calc:r.slug,outcome:"compile:failed"===u.status?"verify_failed":"ok",change:{field:a,op:o,key:t.key,index:t.index},verify:u,references:eb(i.references),summary:`${o} ${a} on data calc ${r.slug} -> ${u.status}`}}))}),function(e,t){return j.apply(this,arguments)}),eP=(k=S(function*(e,t){return ev(e,"remove_data_calc",t,S(function*(){var r=yield ei(e,t),i=J.dirname(r.parsed.absPath),a=J.join(i,r.sandboxFile);yield(0,N.rm)(r.parsed.absPath,{force:!0}),yield(0,N.rm)(a,{force:!0});var n=yield e_(e,i),o=yield(0,M.H)(e,t.verify);return{file:r.parsed.relPath,calc:r.slug,outcome:"compile:failed"===o.status?"verify_failed":"ok",touchedSites:[{file:r.parsed.relPath,action:"delete_calc"},{file:(0,z.RI)(e,a),action:"delete_sandbox"},{file:n,action:"regenerate_index"}],verify:o,summary:`removed data calc ${r.slug} -> ${o.status}`}}))}),function(e,t){return k.apply(this,arguments)}),eC=Y.bz().describe('Value grammar: JSON literals, bare data ref strings for output/error/IO data, { ref, subspace }, or { expr: "raw TypeScript expression" }.'),eD=Y.Yj().describe("Project-relative data-calc file path, for example subspaces/subspace-0/data-calc/data-calculation-total.ts."),eA=Y.KC([Y.Yj(),Y.ai()]).describe('Subspace locator. Defaults to subspace-0; accepts 0, "0", "subspace-0", or a project-relative subspace path.'),eL=Y.Yj().describe("Data calc locator inside the subspace: alias, explicit string id, or filename slug."),eR=Y.zM().describe("Override compile verification. Defaults to BRICKS_CTOR_MCP_EDIT_VERIFY, otherwise true."),eF={file:eD.optional(),subspace:eA.optional(),calc:eL.optional(),verify:eR.optional()},eT=Y.Ik({key:Y.Yj().describe('Sandbox input/output key, for example "price" or "total".'),data:eC.describe("Data ref as alias/id/varName, { ref, subspace }, or { expr }."),trigger:Y.zM().describe("Inputs only; defaults true.").optional()}).describe("DataCalculationScript IO item.");function eN(e,t){var r,i,a,n;e.tool("new_data_calc","Create a standard DataCalculationScript in data-calc/{calc}.ts plus its sandbox JS file, regenerate data-calc/index.ts, and wire minimal subspace indexes.",{subspace:eA.optional(),alias:Y.Yj().describe("Optional alias; also drives the filename slug.").optional(),title:Y.Yj().describe("Optional title.").optional(),description:Y.Yj().describe("Optional description.").optional(),note:Y.Yj().describe("Optional script note.").optional(),triggerMode:Y.k5(["auto","manual"]).describe("Optional trigger mode; omitted by default.").optional(),enableAsync:Y.zM().describe("Whether the sandbox main may be async. Defaults false.").optional(),code:Y.Yj().describe("Sandbox body. The tool wraps it as export function main() { ... } unless already wrapped.").optional(),inputs:Y.YO(eT).describe("Initial script inputs. Input keys must be unique.").optional(),outputs:Y.YO(eT).describe("Initial fan-out outputs. Output keys may repeat.").optional(),output:eC.describe("Single output data ref or null.").optional(),error:eC.describe("Error output data ref or null.").optional(),id:Y.Yj().describe("Optional explicit id. Defaults to source expression makeId('property_bank_calc').").optional(),verify:eR.optional()},(r=S(function*(e){return em((yield e$(t,e)))}),function(e){return r.apply(this,arguments)})),e.tool("edit_data_calc","Edit DataCalculationScript scalar fields, output/error refs, or sandbox code. Code edits normalize inline code to sandbox file-form.",{...eF,set:Y.g1(Y.Yj().describe("Top-level field path such as title, description, note, alias, triggerMode, enableAsync, output, or error."),eC).describe("Fields to set. output/error accept bare data ref strings, { ref, subspace }, { expr }, or null; inputs/outputs accept whole replacement arrays of { key, data, trigger? }. Use the code parameter for code.").optional(),unset:Y.YO(Y.Yj()).describe("Top-level fields to remove.").optional(),code:Y.Yj().describe("Replacement sandbox body. The tool wraps it as export function main() { ... } unless already wrapped.").optional()},(i=S(function*(e){return em((yield eE(t,e)))}),function(e){return i.apply(this,arguments)})),e.tool("edit_data_calc_io","Edit DataCalculationScript inputs or outputs arrays. Inputs require unique keys; outputs may repeat keys for fan-out.",{...eF,field:Y.k5(["inputs","outputs"]).describe("Which IO array to edit."),op:Y.k5(["add","remove","replace","clear"]).describe("Array operation."),key:Y.Yj().describe("IO key target. Ambiguous repeated output keys must use index.").optional(),index:Y.ai().describe("Zero-based IO index target or add insertion index.").optional(),data:eC.describe("For add/replace: data ref as string, { ref, subspace }, or { expr }.").optional(),trigger:Y.zM().describe("Inputs only; defaults true.").optional()},(a=S(function*(e){return em((yield eO(t,e)))}),function(e){return a.apply(this,arguments)})),e.tool("remove_data_calc","Remove a standard DataCalculationScript .ts file plus its sandbox file and regenerate data-calc/index.ts. No reverse cascade is needed.",eF,(n=S(function*(e){return em((yield eP(t,e)))}),function(e){return n.apply(this,arguments)}))}var eJ={newDataCalc:e$,editDataCalc:eE,editDataCalcIo:eO,removeDataCalc:eP,resolveCalcTarget:ei};i()}catch(e){i(e)}})}};
package/lib/4305.js ADDED
@@ -0,0 +1 @@
1
+ export const __rspack_esm_id=4305;export const __rspack_esm_ids=[4305];export const __webpack_modules__={7944(e,o,r){r.r(o),r.d(o,{DEVTOOLS_TOKEN_REFRESH_AHEAD_MS:()=>a,getOrIssueDevtoolsToken:()=>k,issueDevtoolsAccessTokenCore:()=>c});var s,t,n=r(99436),i=r(47988),a=6048e5,c=(s=n(function*({client:e,ttlSeconds:o}={}){if(!e?.issueDevtoolsAccessToken)throw Error("A BRICKS workspace client is required to issue a DevTools access token.");return e.issueDevtoolsAccessToken({ttlSeconds:o})}),function(){return s.apply(this,arguments)}),k=(t=n(function*({profile:e,client:o,workspaceId:r,ttlSeconds:s,force:t=!1,now:n=Date.now()}={}){var k=e||(0,i.getCurrentProfile)(),p=(0,i.getTokenInfo)(k),u=p?.workspaceId,l=r||u;if(!l)throw Error(`Profile ${k} is not logged in or has no workspace id.`);var f=i.default.get("devtoolsTokens")||{},_=f[k]||{},d=_[l];if(!t&&((e,o=Date.now())=>{if(!e?.token||!e?.expiresAt)return!1;var r=new Date(e.expiresAt).getTime();return Number.isFinite(r)&&r-o>a})(d,n))return d;if(String(l)!==String(u))throw Error(`Profile ${k} has no usable DevTools token for workspace ${l}.`);var v=yield c({client:o,ttlSeconds:s});if(!v?.token||!v?.expiresAt)throw Error("DevTools access token response was incomplete.");var w={token:v.token,expiresAt:v.expiresAt,jti:v.jti,workspaceId:v.workspaceId||l};return i.default.set("devtoolsTokens",{...f,[k]:{..._,[l]:w}}),w}),function(){return t.apply(this,arguments)})}};
package/lib/4456.js ADDED
@@ -0,0 +1,3 @@
1
+ export const __rspack_esm_id=4456;export const __rspack_esm_ids=[4456];export const __webpack_modules__={65650(e,t,r){e.exports=r(78942).Symbol},65111(e){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}},44187(e){e.exports=function(e,t,r,i){var n=-1,o=null==e?0:e.length;for(i&&o&&(r=e[++n]);++n<o;)r=t(r,e[n],n,e);return r}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},87379(e,t,r){var i=r(65650),n=r(8870),o=r(29005),u=i?i.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":u&&u in Object(e)?n(e):o(e)}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},52291(e,t,r){var i=r(65650),n=r(65111),o=r(53142),u=r(51187),a=1/0,l=i?i.prototype:void 0,c=l?l.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return n(t,e)+"";if(u(t))return c?c.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},93640(e,t,r){var i=r(44187),n=r(45881),o=r(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return i(o(n(t).replace(u,"")),e,"")}}},69968(e,t,r){e.exports=r(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},74967(e){e.exports="object"==typeof global&&global&&global.Object===Object&&global},8870(e,t,r){var i=r(65650),n=Object.prototype,o=n.hasOwnProperty,u=n.toString,a=i?i.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),r=e[a];try{e[a]=void 0;var i=!0}catch(e){}var n=u.call(e);return i&&(t?e[a]=r:delete e[a]),n}},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},29005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},78942(e,t,r){var i=r(74967),n="object"==typeof self&&self&&self.Object===Object&&self;e.exports=i||n||Function("return this")()},10482(e){var t="\\ud800-\\udfff",r="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",n="A-Z\\xc0-\\xd6\\xd8-\\xde",o="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+o+"]",l="["+i+"]",c="[^"+t+o+"\\d+"+r+i+n+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",f="["+n+"]",p="(?:"+l+"|"+c+")",g="(?:"+f+"|"+c+")",y="(?:"+u+"(?:d|ll|m|re|s|t|ve))?",x="(?:"+u+"(?:D|LL|M|RE|S|T|VE))?",h="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",m="[\\ufe0e\\ufe0f]?",b="(?:\\u200d(?:"+["[^"+t+"]",s,d].join("|")+")"+m+h+")*",v="(?:"+["["+r+"]",s,d].join("|")+")"+(m+h+b),j=RegExp([f+"?"+l+"+"+y+"(?="+[a,f,"$"].join("|")+")",g+"+"+x+"(?="+[a,f+p,"$"].join("|")+")",f+"?"+p+"+"+y,f+"+"+x,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",v].join("|"),"g");e.exports=function(e){return e.match(j)||[]}},45881(e,t,r){var i=r(69968),n=r(95243),o=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,u=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=n(e))&&e.replace(o,i).replace(u,"")}},53142(e){e.exports=Array.isArray},80547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},51187(e,t,r){var i=r(87379),n=r(80547);e.exports=function(e){return"symbol"==typeof e||n(e)&&"[object Symbol]"==i(e)}},10750(e,t,r){e.exports=r(93640)(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})},95243(e,t,r){var i=r(52291);e.exports=function(e){return null==e?"":i(e)}},39850(e,t,r){var i=r(39546),n=r(15813),o=r(95243),u=r(10482);e.exports=function(e,t,r){return(e=o(e),void 0===(t=r?void 0:t))?n(e)?u(e):i(e):e.match(t)||[]}},58891(e,t,r){r.r(t),r.d(t,{initProject:()=>p});var i,n,o=r(99436),u=r(16928),a=r(73284),l=r(30155),c=r(27521),s=r(56493),d=r(77768),f=(i=o(function*(e,t){console.log(a.default.bold.cyan(`
2
+ Initialize BRICKS Project: ${t}
3
+ `));var r=yield(0,c.checkbox)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),i=yield(0,c.checkbox)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),n=e.output?u.resolve(e.output):u.join(process.cwd(),t),o=yield(0,c.input)({message:"Output directory:",default:n});return{githubActions:r.includes("githubActions"),agents:r.includes("agents"),claude:r.includes("claude"),gemini:r.includes("gemini"),install:i.includes("install"),git:i.includes("git"),output:o,outputAsTarget:!0}}),function(e,t){return i.apply(this,arguments)}),p=(n=o(function*(e,t,r){var i=(0,s.requireAuth)(),n=r.json,o=r.yes||n,c="application"===e?i.applicationProject:i.moduleProject,p=n?null:(0,l.default)(`Fetching ${e} info...`).start(),g="bricks-ctor";try{var y=yield c({id:t,buildApplicationOnly:!0});y?.files&&(g=(0,d.kU)(y.files)),p&&p.stop()}catch{p&&p.stop()}var x={...r};if(!o)try{var h=yield f(r,g);x={...r,...h}}catch{console.log(a.default.yellow("\nCancelled")),process.exit(0)}p=n?null:(0,l.default)(`Fetching ${e} project...`).start();var m=!!x.output;try{var b=yield(0,d.BZ)(e,t,{client:i,output:m?x.output:process.cwd(),outputAsTarget:m||!0===x.outputAsTarget,install:x.install,git:x.git,githubActions:x.githubActions,agents:x.agents,claude:x.claude,gemini:x.gemini});p&&p.succeed(`Project created: ${a.default.green(b.path)} (${b.files} files)`),n?console.log(JSON.stringify(b)):(console.log(""),console.log(a.default.bold.green("Project initialized successfully!")),console.log(""),console.log(a.default.bold("Next steps:")),console.log(a.default.gray(` cd ${u.basename(b.path)}`)),b.bunInstalled||console.log(a.default.gray(" bun install")),console.log(a.default.gray(" bun invoke-simulator")),console.log(""),console.log(a.default.gray(`For more information, see ${u.basename(b.path)}/README.md`)))}catch(t){n?console.error(JSON.stringify({error:t.message})):p?p.fail(`Failed to initialize ${e} project: ${t.message}`):console.error(a.default.red(`Failed to initialize ${e} project: ${t.message}`)),process.exit(1)}}),function(e,t,r){return n.apply(this,arguments)})},77768(e,t,r){r.d(t,{BZ:()=>b,KN:()=>x,kU:()=>y,o0:()=>m,oz:()=>h});var i,n,o,u,a=r(99436),l=r(16928),c=r(79896),s=r(35317),d=r(10750),f=e=>{try{return(0,s.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},p=(e,t,r)=>new Promise((i,n)=>{var o=[e,...t].join(" "),u=(0,s.spawn)(o,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];u.stderr.on("data",e=>a.push(e)),u.on("close",e=>{0===e?i():n(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),u.on("error",n)}),g=(i=a(function*(e,t){try{var i=(yield r.e(7456).then(r.bind(r,79491))).format;return(yield i(t,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,t){return i.apply(this,arguments)}),y=(e=[])=>{var t=e.find(e=>"application.json"===e.name);if(!t)return"bricks-ctor";try{var r=JSON.parse(t.input);return d(r.name||"bricks-ctor")}catch{return"bricks-ctor"}},x=(n=a(function*(e,t){var r;return Promise.all(e.map((r=a(function*(e){var r=l.join(t,e.name),i=e.input;return e.formatable&&(i=yield g(i,r)),{...e,filePath:r,content:i}}),function(e){return r.apply(this,arguments)})))}),function(e,t){return n.apply(this,arguments)}),h=e=>{e.forEach(e=>{c.mkdirSync(l.dirname(e.filePath),{recursive:!0}),c.writeFileSync(e.filePath,e.content)})},m=(o=a(function*(e,t={}){var r="function"==typeof t.onStatus?t.onStatus:()=>{},i=!1,n=!1;if(!1!==t.install&&f("bun")){r("Installing dependencies (bun install)...");try{yield p("bun",["install"],e),i=!0}catch{}}if(!1!==t.git&&f("git")){r("Initializing git repository...");try{yield p("git",["init"],e),yield p("git",["add","."],e),yield p("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],e),n=!0}catch{}}return{bunInstalled:i,gitInitialized:n}}),function(e){return o.apply(this,arguments)}),b=(u=a(function*(e,t,r){var i=r.client,n=r.output,o=r.outputAsTarget;if(!i)throw Error("client is required");if(!n)throw Error("output directory is required");var u=(e=>{for(var t=l.resolve(e);;){if(c.existsSync(l.join(t,"application.json"))||c.existsSync(l.join(t,"module.json")))return t;var r=l.dirname(t);if(r===t)return null;t=r}})(o?l.dirname(l.resolve(n)):n);if(u)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${u}). Choose a directory outside the project.`);var a="application"===e?i.applicationProject:i.moduleProject,s=yield a({id:t,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini});if(!s?.files)throw Error(`${e} project not found`);var d=y(s.files),f=o?l.resolve(n):l.resolve(n,d);if(c.existsSync(f))throw Error(`Directory already exists: ${f}`);c.mkdirSync(f,{recursive:!0}),h((yield x(s.files,f)));var p=yield m(f,r),g=p.bunInstalled,b=p.gitInitialized;return{success:!0,path:f,files:s.files.length,bunInstalled:g,gitInitialized:b}}),function(e,t,r){return u.apply(this,arguments)})}};