@fugood/bricks-cli 2.25.0-beta.77 → 2.25.0-beta.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/1010.js +1 -1
- package/lib/1708.js +7 -7
- package/lib/2486.js +1 -1
- package/lib/3976.js +3 -3
- package/lib/6194.js +2 -2
- package/lib/6818.js +1 -1
- package/lib/{8117.js → 7233.js} +56 -56
- package/lib/7511.js +1 -1
- package/lib/index.js +13 -13
- package/package.json +5 -5
package/lib/2486.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(9866),a.e(6645),a.e(4479),a.e(7648),a.e(853),a.e(1010),a.e(
|
|
1
|
+
export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(9866),a.e(6645),a.e(4479),a.e(7648),a.e(853),a.e(1010),a.e(7233)]).then(a.bind(a,63288)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),k=(e,r,a)=>({severity:e,code:r,message:a}),h=(o=t(function*({version:e="2.25.0-beta.78",mcpCheck:r=u}={}){var a=(0,p.getCurrentProfile)(),i=(0,p.getCurrentProfileSource)(),o=(0,n.getConnectionContext)(a),t=o.tokenInfo,h=o.auth,d=o.baseUrl,v=o.activityLogBaseUrl,m=[],w={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:p.CONFIG_PATH,baseUrl:d,activityLogBaseUrl:v},auth:{available:!!h,source:h?"config":"missing",kind:h?.kind||null,workspaceId:t?.workspaceId||null,workspaceName:t?.workspaceName||null,createdAt:t?.createdAt||null,tokenPreview:h?.kind==="token"?(0,l.$l)(h.token):null},connectivity:{workspace:{ok:!1,skipped:!h,error:null}},capabilities:{zeroArgMode:(0,c.isInteractiveTerminal)()?"interactive":"help",mcp:{available:!1,error:null}},issues:m};if(h)try{var b=yield(0,s.createClient)(d,h).workspace();w.connectivity.workspace={ok:!0,skipped:!1,error:null,id:b?._id||t.workspaceId||null,name:b?.name||t.workspaceName||null},w.auth.workspaceId=b?._id||w.auth.workspaceId,w.auth.workspaceName=b?.name||w.auth.workspaceName}catch(e){w.connectivity.workspace={ok:!1,skipped:!1,error:e.message},m.push(k("error","workspace_unreachable",`Workspace query failed for ${d}: ${e.message}`))}else m.push(k("warning","auth_missing","No usable credential for the current profile."));var f=yield r();return w.capabilities.mcp={available:f.available,error:f.error||null},f.available||m.push(k("warning","mcp_unavailable",`MCP stdio server is unavailable: ${f.error||"Unknown error"}`)),w.ok=0===m.length,w}),function(){return o.apply(this,arguments)}),d=(e,r,a)=>`${e.padEnd(14)} ${r}${a?` ${a}`:""}`,v=e=>{var r=[];if(r.push("BRICKS CLI Doctor"),r.push("─".repeat(60)),r.push(d("CLI","OK",`bricks v${e.cli.version}`)),r.push(d("Profile","OK",`${e.profile.name} (${e.profile.source})`)),r.push(d("BRICKS API","OK",e.config.baseUrl)),r.push(d("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace",i=[e.auth.source,e.auth.kind,e.auth.tokenPreview].filter(Boolean).join(", ");r.push(d("Auth","OK",i?`${a} (${i})`:a))}else r.push(d("Auth","WARN","No usable credential for the current profile"));if(e.connectivity.workspace.skipped)r.push(d("Workspace","WARN","Skipped because no credential is available"));else if(e.connectivity.workspace.ok){var o=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";r.push(d("Workspace","OK",o))}else r.push(d("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?r.push(d("MCP","OK","STDIO server import is available")):r.push(d("MCP","WARN",e.capabilities.mcp.error)),r.push(d("Zero-arg mode",((e,r=!1)=>e?"OK":r?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(r.push("─".repeat(60)),r.push("Issues"),e.issues.forEach(e=>{r.push(`- [${e.severity}] ${e.message}`)})),r.join("\n")}}};
|
package/lib/3976.js
CHANGED
|
@@ -2,13 +2,13 @@ export const __rspack_esm_id=3976;export const __rspack_esm_ids=[3976];export co
|
|
|
2
2
|
# MCP entry-editing audit log
|
|
3
3
|
${l}
|
|
4
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}
|
|
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:()=>eT});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),N=r(79491),T=r(51455),J=r(76760),Y=r(84867),M=r(54452),z=r(98009),H=r(3540),q=e([N]);function K(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(K=function(){return!!e})()}N=(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,T.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,T.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=(e=>{var t=new Set;for(var r of e.program.body){if(R.isImportDeclaration(r)){r.specifiers.forEach(e=>t.add(e.local.name));continue}R.isExportNamedDeclaration(r)&&R.isVariableDeclaration(r.declaration)&&r.declaration.declarations.forEach(e=>{R.isIdentifier(e.id)&&t.add(e.id.name)})}return t})(e.ast),o=r;if(n.has(o)){for(var s=1;n.has(`${o}${s}`);)s+=1;o=`${o}${s}`}var l=R.importDeclaration([R.importNamespaceSpecifier(R.identifier(o))],R.stringLiteral(t));return(0,z.Pb)(e.ast,l),o})(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,T.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,N.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,T.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
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
7
|
${i}
|
|
8
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,
|
|
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,T.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
10
|
|
|
11
11
|
export const dataCalculation = [
|
|
12
12
|
${a}
|
|
13
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)}})}};
|
|
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,T.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,T.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,T.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,T.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,T.rm)(r.parsed.absPath,{force:!0}),yield(0,T.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()},eN=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 eT(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(eN).describe("Initial script inputs. Input keys must be unique.").optional(),outputs:Y.YO(eN).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)}})}};
|