@holistics/cli-core 2.1.16 → 2.2.0

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 (2) hide show
  1. package/dist/commands.js +174 -125
  2. package/package.json +1 -1
package/dist/commands.js CHANGED
@@ -27399,7 +27399,7 @@ var require_dist3 = __commonJS((exports2) => {
27399
27399
  exports2.default = deferred;
27400
27400
  });
27401
27401
  // package.json
27402
- var version = "2.1.16";
27402
+ var version = "2.2.0";
27403
27403
 
27404
27404
  // ../../node_modules/.pnpm/@commander-js+extra-typings@13.1.0_commander@13.1.0/node_modules/@commander-js/extra-typings/esm.mjs
27405
27405
  var import__ = __toESM(require_extra_typings(), 1);
@@ -40051,6 +40051,7 @@ var LOG_RETENTION_DAYS = 30;
40051
40051
  var LOG_FILE_PREFIX = "cli-error-";
40052
40052
  var LOG_FILE_SUFFIX = ".log";
40053
40053
  var runLogPath;
40054
+ var invokedCommand = process.argv.slice(2).join(" ");
40054
40055
  var c = {
40055
40056
  reset: "\x1B[0m",
40056
40057
  bold: "\x1B[1m",
@@ -40108,7 +40109,7 @@ function truncateLog(s) {
40108
40109
  function removeStackTraceLogArgs(...args) {
40109
40110
  if (args.some((arg) => arg instanceof Error)) {
40110
40111
  const noStackTraceMsg = args.map((arg) => arg instanceof Error ? `${arg.name}: ${arg.message}` : String(arg)).join(" ");
40111
- return noStackTraceMsg;
40112
+ return [noStackTraceMsg];
40112
40113
  }
40113
40114
  return args;
40114
40115
  }
@@ -40116,7 +40117,7 @@ async function logErrorToFile(...args) {
40116
40117
  return new Promise((resolve) => {
40117
40118
  try {
40118
40119
  const message = args.map((arg) => arg instanceof Error ? formatError2(arg) : String(arg)).join(" ");
40119
- const line = `[${new Date().toISOString()}] ${message}
40120
+ const line = `[${new Date().toISOString()}] [${invokedCommand}] ${message}
40120
40121
  `;
40121
40122
  fs2.appendFile(getRunLogPath(), line, { mode: 384 }, () => resolve());
40122
40123
  } catch {
@@ -40128,7 +40129,7 @@ function log(...args) {
40128
40129
  console.log(...args);
40129
40130
  }
40130
40131
  async function logErr(...args) {
40131
- console.error(removeStackTraceLogArgs(...args));
40132
+ console.error(...removeStackTraceLogArgs(...args));
40132
40133
  await logErrorToFile(...args);
40133
40134
  }
40134
40135
  async function logErrWithTruncate(s) {
@@ -42794,13 +42795,13 @@ For agents:
42794
42795
  var auth_default = command3;
42795
42796
 
42796
42797
  // src/commands/aml/compile.ts
42797
- import * as fs13 from "fs";
42798
- import * as path10 from "path";
42798
+ import * as fs14 from "fs";
42799
+ import * as path11 from "path";
42799
42800
 
42800
42801
  // src/commands/aml/common.ts
42801
42802
  var import_fast_glob = __toESM(require_out4(), 1);
42802
- import fs11 from "fs";
42803
- import path7 from "path";
42803
+ import fs12 from "fs";
42804
+ import path8 from "path";
42804
42805
 
42805
42806
  // ../../node_modules/.pnpm/@holistics+aml@7.4.3/node_modules/@holistics/aml/dist/aml.es.js
42806
42807
  var exports_aml_es = {};
@@ -82568,6 +82569,87 @@ var A1 = (e, t = {}) => (e.options.childIdxForDynamicProp = true, e.registerCust
82568
82569
  e.setDefinitionAtPath(r.create(`/modules/${fc2}/${n}`), o);
82569
82570
  }), PM(e, t), e);
82570
82571
 
82572
+ // src/api/amlStudioApi.ts
82573
+ import os6 from "os";
82574
+
82575
+ // src/commands/code_sync/file_ops.ts
82576
+ import crypto3 from "crypto";
82577
+ import fs11 from "fs/promises";
82578
+ import path7 from "path";
82579
+ var MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
82580
+ async function getFileSize(basePath, relativePath) {
82581
+ const stat = await fs11.stat(path7.join(basePath, relativePath));
82582
+ return stat.size;
82583
+ }
82584
+ function computeGitHash(content) {
82585
+ const buf2 = Buffer.from(content, "utf-8");
82586
+ const header = `blob ${buf2.length}\x00`;
82587
+ return crypto3.createHash("sha1").update(header).update(buf2).digest("hex");
82588
+ }
82589
+ async function readFileContent(basePath, relativePath) {
82590
+ return fs11.readFile(path7.join(basePath, relativePath), "utf-8");
82591
+ }
82592
+ async function writeFileContent(basePath, relativePath, content) {
82593
+ const fullPath = path7.join(basePath, relativePath);
82594
+ await fs11.mkdir(path7.dirname(fullPath), { recursive: true });
82595
+ await fs11.writeFile(fullPath, content, "utf-8");
82596
+ }
82597
+ async function deleteLocalFile(basePath, relativePath) {
82598
+ try {
82599
+ await fs11.unlink(path7.join(basePath, relativePath));
82600
+ } catch (err) {
82601
+ if (err.code !== "ENOENT")
82602
+ throw err;
82603
+ }
82604
+ }
82605
+
82606
+ // src/api/amlStudioApi.ts
82607
+ var BASE_API = "/api/v2/aml_studio";
82608
+ var CLI_METADATA = {
82609
+ origin: "cli",
82610
+ hostname: os6.hostname().replace(/\.local$/, "")
82611
+ };
82612
+ async function fetchProjects() {
82613
+ const data = await get(`${BASE_API}/projects`, {}, "Failed to fetch projects");
82614
+ return data.data;
82615
+ }
82616
+ async function fetchAmlRuntimeEnv(projectId) {
82617
+ const resp = await getJson(`${BASE_API}/projects/aml_runtime_env`, { project_id: projectId }, "Failed to fetch AML runtime environment");
82618
+ return resp.runtime_env;
82619
+ }
82620
+ async function fetchRepoStatus(projectId, gitFetch) {
82621
+ const data = await getJson(`${BASE_API}/projects/${projectId}/repositories/status`, { git_fetch: gitFetch }, "Failed to fetch repository status");
82622
+ return data.data;
82623
+ }
82624
+ async function fetchBackedFilesMeta(projectId) {
82625
+ const data = await get(`${BASE_API}/projects/${projectId}/repositories/all_files`, {}, "Failed to fetch backend files");
82626
+ const inner = data.data;
82627
+ return inner.files ?? inner;
82628
+ }
82629
+ async function pushFiles(projectId, files) {
82630
+ const accepted = [];
82631
+ for (const f2 of files) {
82632
+ const size = Buffer.byteLength(f2.content, "utf-8");
82633
+ if (size > MAX_FILE_SIZE_BYTES) {
82634
+ log(fmt.yellow(` ⚠ Skipping ${f2.file_path}: exceeds ${MAX_FILE_SIZE_BYTES} byte limit (${size} bytes)`));
82635
+ continue;
82636
+ }
82637
+ accepted.push(f2);
82638
+ }
82639
+ if (accepted.length === 0) {
82640
+ return { status: "ok", data: { success: [], failure: [] } };
82641
+ }
82642
+ const data = await postJson(`${BASE_API}/repositories/write_files_with_status`, { project_id: projectId, files: accepted, metadata: CLI_METADATA }, "Failed to push files");
82643
+ return data;
82644
+ }
82645
+ async function pullFiles(projectId, filePaths) {
82646
+ const data = await postJson(`${BASE_API}/projects/${projectId}/repositories/batch_read_file`, { file_paths: filePaths }, "Failed to pull files");
82647
+ return data.data.files;
82648
+ }
82649
+ async function removeFile(projectId, filePath) {
82650
+ await postJson(`${BASE_API}/projects/${projectId}/repositories/remove`, { file_path: filePath, metadata: CLI_METADATA }, "Failed to remove file");
82651
+ }
82652
+
82571
82653
  // src/commands/aml/userAttributes.ts
82572
82654
  var SUPPORTED_TYPES = [
82573
82655
  "date",
@@ -82633,6 +82715,40 @@ function buildUserAttributes(custom = []) {
82633
82715
  custom.forEach(({ name, type: type2 }) => byName.set(name, { name, type: type2 }));
82634
82716
  return Array.from(byName.values());
82635
82717
  }
82718
+ async function fetchUserAttributes() {
82719
+ const projects = await fetchProjects();
82720
+ const project = projects[0];
82721
+ if (!project)
82722
+ throw new Error("No Holistics project found");
82723
+ const runtimeEnv = await fetchAmlRuntimeEnv(project.id);
82724
+ return Object.entries(runtimeEnv.current_user).map(([name, [value, type2]]) => ({ name, type: type2, value }));
82725
+ }
82726
+ async function loadServerUserAttributes(inputUserAttributes) {
82727
+ const existing = readAuthConfig();
82728
+ if (!hasStoredAuth(existing)) {
82729
+ return;
82730
+ }
82731
+ let fetchedUserAttributes = [];
82732
+ try {
82733
+ fetchedUserAttributes = await fetchUserAttributes();
82734
+ } catch (error) {
82735
+ logErr(`Warning: failed to fetch user attributes from server: ${error.message}. Skipping.`);
82736
+ return;
82737
+ }
82738
+ const inputNames = new Set(inputUserAttributes.map((ua3) => ua3.name));
82739
+ const addedUserAttributes = [];
82740
+ fetchedUserAttributes.filter((ua3) => !inputNames.has(ua3.name)).forEach((ua3) => {
82741
+ if (!SUPPORTED_TYPES.includes(ua3.type)) {
82742
+ logErr(`Warning: skipping user attribute "${ua3.name}" from config — unsupported type "${ua3.type}". Supported types: ${SUPPORTED_TYPES.join(", ")}.`);
82743
+ return;
82744
+ }
82745
+ inputUserAttributes.push({ name: ua3.name, type: ua3.type, value: ua3.value });
82746
+ addedUserAttributes.push(ua3);
82747
+ });
82748
+ if (addedUserAttributes.length > 0) {
82749
+ logErr(fmt.dim(`Use ${addedUserAttributes.length} user attribute(s) on server: ${addedUserAttributes.map((ua3) => ua3.name).join(", ")}`));
82750
+ }
82751
+ }
82636
82752
 
82637
82753
  // src/commands/aml/common.ts
82638
82754
  var program2;
@@ -82642,7 +82758,7 @@ function getProgram() {
82642
82758
  async function expandPaths(paths) {
82643
82759
  const expansions = paths.map(async (p2) => {
82644
82760
  try {
82645
- const stat = fs11.statSync(p2);
82761
+ const stat = fs12.statSync(p2);
82646
82762
  if (stat.isFile()) {
82647
82763
  return [p2];
82648
82764
  }
@@ -82667,7 +82783,7 @@ function readAmlFiles(rootPath) {
82667
82783
  const files = import_fast_glob.default.sync(`${rootPath}/**/*.aml`, { onlyFiles: true, dot: true });
82668
82784
  return files.map((filePath) => ({
82669
82785
  filePath,
82670
- content: fs11.readFileSync(filePath, "utf-8")
82786
+ content: fs12.readFileSync(filePath, "utf-8")
82671
82787
  }));
82672
82788
  }
82673
82789
  function initAMLProgram(rootPath, userAttributes) {
@@ -82676,7 +82792,7 @@ function initAMLProgram(rootPath, userAttributes) {
82676
82792
  try {
82677
82793
  const amlFiles = readAmlFiles(rootPath);
82678
82794
  amlFiles.forEach(({ filePath, content }) => {
82679
- const relativePath = path7.relative(rootPath, filePath);
82795
+ const relativePath = path8.relative(rootPath, filePath);
82680
82796
  program2.setFileContent(r.create(relativePath), content);
82681
82797
  });
82682
82798
  } catch {
@@ -82692,7 +82808,7 @@ function compileAMLFiles(files, options2) {
82692
82808
  const filteredFiles = files.filter((file) => file.endsWith(".aml"));
82693
82809
  const interpretStart = performance.now();
82694
82810
  const interpretedFiles = filteredFiles.map((file, index) => {
82695
- const result = program2.interpretFile(r.create(path7.relative(rootPath, file)));
82811
+ const result = program2.interpretFile(r.create(path8.relative(rootPath, file)));
82696
82812
  renderProgressBar(index + 1, filteredFiles.length, "Compiling AML", interpretStart);
82697
82813
  return result;
82698
82814
  });
@@ -82723,7 +82839,7 @@ function compileAMLFiles(files, options2) {
82723
82839
  }
82724
82840
 
82725
82841
  // src/commands/aml/validators/pipeline.ts
82726
- import path8 from "path";
82842
+ import path9 from "path";
82727
82843
 
82728
82844
  // ../amql/dist/amql.es.js
82729
82845
  var import_lodash2 = __toESM(require_lodash(), 1);
@@ -84366,7 +84482,7 @@ function _03() {
84366
84482
  ["partial", Vn3],
84367
84483
  ["partialRight", Qt3],
84368
84484
  ["rearg", kt4]
84369
- ], mt4 = "[object Arguments]", we4 = "[object Array]", Ff3 = "[object AsyncFunction]", jt4 = "[object Boolean]", ne2 = "[object Date]", Wf3 = "[object DOMException]", me4 = "[object Error]", Ce3 = "[object Function]", Lu3 = "[object GeneratorFunction]", Mn4 = "[object Map]", te3 = "[object Number]", Hf3 = "[object Null]", $n4 = "[object Object]", wu3 = "[object Promise]", Xf3 = "[object Proxy]", ee3 = "[object RegExp]", Nn3 = "[object Set]", re3 = "[object String]", xe2 = "[object Symbol]", Kf3 = "[object Undefined]", ie3 = "[object WeakMap]", Vf3 = "[object WeakSet]", ue4 = "[object ArrayBuffer]", Ct4 = "[object DataView]", wr4 = "[object Float32Array]", mr4 = "[object Float64Array]", Cr3 = "[object Int8Array]", xr4 = "[object Int16Array]", Mr4 = "[object Int32Array]", Nr5 = "[object Uint8Array]", br3 = "[object Uint8ClampedArray]", Br4 = "[object Uint16Array]", Ur4 = "[object Uint32Array]", Yf3 = /\b__p \+= '';/g, $f3 = /\b(__p \+=) '' \+/g, zf3 = /(__e\(.*?\)|\b__t\)) \+\n'';/g, mu3 = /&(?:amp|lt|gt|quot|#39);/g, Cu3 = /[&<>"']/g, qf3 = RegExp(mu3.source), Zf3 = RegExp(Cu3.source), Jf3 = /<%-([\s\S]+?)%>/g, Qf3 = /<%([\s\S]+?)%>/g, xu3 = /<%=([\s\S]+?)%>/g, kf3 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, jf3 = /^\w*$/, ns3 = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, Dr4 = /[\\^$.*+?()[\]{}|]/g, ts3 = RegExp(Dr4.source), Gr4 = /^\s+/, es3 = /\s/, rs3 = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, is3 = /\{\n\/\* \[wrapped with (.+)\] \*/, us3 = /,? & /, os6 = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, Mu3 = /[()=,{}\[\]\/\s]/, as3 = /\\(\\)?/g, fs12 = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Nu3 = /\w*$/, ss3 = /^[-+]0x[0-9a-f]+$/i, cs3 = /^0b[01]+$/i, ls3 = /^\[object .+?Constructor\]$/, _s3 = /^0o[0-7]+$/i, hs3 = /^(?:0|[1-9]\d*)$/, ps3 = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Me2 = /($^)/, gs3 = /['\n\r\u2028\u2029\\]/g, Ne3 = "\\ud800-\\udfff", ds3 = "\\u0300-\\u036f", Es3 = "\\ufe20-\\ufe2f", vs2 = "\\u20d0-\\u20ff", bu3 = ds3 + Es3 + vs2, Bu3 = "\\u2700-\\u27bf", Uu3 = "a-z\\xdf-\\xf6\\xf8-\\xff", Ts3 = "\\xac\\xb1\\xd7\\xf7", As2 = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Ss3 = "\\u2000-\\u206f", Os2 = " \\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", Du3 = "A-Z\\xc0-\\xd6\\xd8-\\xde", Gu3 = "\\ufe0e\\ufe0f", Fu3 = Ts3 + As2 + Ss3 + Os2, Fr4 = "['’]", Rs2 = "[" + Ne3 + "]", Wu3 = "[" + Fu3 + "]", be3 = "[" + bu3 + "]", Hu3 = "\\d+", ys3 = "[" + Bu3 + "]", Xu3 = "[" + Uu3 + "]", Ku3 = "[^" + Ne3 + Fu3 + Hu3 + Bu3 + Uu3 + Du3 + "]", Wr4 = "\\ud83c[\\udffb-\\udfff]", Ps3 = "(?:" + be3 + "|" + Wr4 + ")", Vu3 = "[^" + Ne3 + "]", Hr4 = "(?:\\ud83c[\\udde6-\\uddff]){2}", Xr4 = "[\\ud800-\\udbff][\\udc00-\\udfff]", xt4 = "[" + Du3 + "]", Yu3 = "\\u200d", $u3 = "(?:" + Xu3 + "|" + Ku3 + ")", Is2 = "(?:" + xt4 + "|" + Ku3 + ")", zu3 = "(?:" + Fr4 + "(?:d|ll|m|re|s|t|ve))?", qu3 = "(?:" + Fr4 + "(?:D|LL|M|RE|S|T|VE))?", Zu3 = Ps3 + "?", Ju3 = "[" + Gu3 + "]?", Ls2 = "(?:" + Yu3 + "(?:" + [Vu3, Hr4, Xr4].join("|") + ")" + Ju3 + Zu3 + ")*", ws2 = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", ms3 = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", Qu3 = Ju3 + Zu3 + Ls2, Cs3 = "(?:" + [ys3, Hr4, Xr4].join("|") + ")" + Qu3, xs2 = "(?:" + [Vu3 + be3 + "?", be3, Hr4, Xr4, Rs2].join("|") + ")", Ms2 = RegExp(Fr4, "g"), Ns2 = RegExp(be3, "g"), Kr4 = RegExp(Wr4 + "(?=" + Wr4 + ")|" + xs2 + Qu3, "g"), bs3 = RegExp([
84485
+ ], mt4 = "[object Arguments]", we4 = "[object Array]", Ff3 = "[object AsyncFunction]", jt4 = "[object Boolean]", ne2 = "[object Date]", Wf3 = "[object DOMException]", me4 = "[object Error]", Ce3 = "[object Function]", Lu3 = "[object GeneratorFunction]", Mn4 = "[object Map]", te3 = "[object Number]", Hf3 = "[object Null]", $n4 = "[object Object]", wu3 = "[object Promise]", Xf3 = "[object Proxy]", ee3 = "[object RegExp]", Nn3 = "[object Set]", re3 = "[object String]", xe2 = "[object Symbol]", Kf3 = "[object Undefined]", ie3 = "[object WeakMap]", Vf3 = "[object WeakSet]", ue4 = "[object ArrayBuffer]", Ct4 = "[object DataView]", wr4 = "[object Float32Array]", mr4 = "[object Float64Array]", Cr3 = "[object Int8Array]", xr4 = "[object Int16Array]", Mr4 = "[object Int32Array]", Nr5 = "[object Uint8Array]", br3 = "[object Uint8ClampedArray]", Br4 = "[object Uint16Array]", Ur4 = "[object Uint32Array]", Yf3 = /\b__p \+= '';/g, $f3 = /\b(__p \+=) '' \+/g, zf3 = /(__e\(.*?\)|\b__t\)) \+\n'';/g, mu3 = /&(?:amp|lt|gt|quot|#39);/g, Cu3 = /[&<>"']/g, qf3 = RegExp(mu3.source), Zf3 = RegExp(Cu3.source), Jf3 = /<%-([\s\S]+?)%>/g, Qf3 = /<%([\s\S]+?)%>/g, xu3 = /<%=([\s\S]+?)%>/g, kf3 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, jf3 = /^\w*$/, ns3 = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, Dr4 = /[\\^$.*+?()[\]{}|]/g, ts3 = RegExp(Dr4.source), Gr4 = /^\s+/, es3 = /\s/, rs3 = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, is3 = /\{\n\/\* \[wrapped with (.+)\] \*/, us3 = /,? & /, os7 = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, Mu3 = /[()=,{}\[\]\/\s]/, as3 = /\\(\\)?/g, fs13 = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Nu3 = /\w*$/, ss3 = /^[-+]0x[0-9a-f]+$/i, cs3 = /^0b[01]+$/i, ls3 = /^\[object .+?Constructor\]$/, _s3 = /^0o[0-7]+$/i, hs3 = /^(?:0|[1-9]\d*)$/, ps3 = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Me2 = /($^)/, gs3 = /['\n\r\u2028\u2029\\]/g, Ne3 = "\\ud800-\\udfff", ds3 = "\\u0300-\\u036f", Es3 = "\\ufe20-\\ufe2f", vs2 = "\\u20d0-\\u20ff", bu3 = ds3 + Es3 + vs2, Bu3 = "\\u2700-\\u27bf", Uu3 = "a-z\\xdf-\\xf6\\xf8-\\xff", Ts3 = "\\xac\\xb1\\xd7\\xf7", As2 = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Ss3 = "\\u2000-\\u206f", Os2 = " \\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", Du3 = "A-Z\\xc0-\\xd6\\xd8-\\xde", Gu3 = "\\ufe0e\\ufe0f", Fu3 = Ts3 + As2 + Ss3 + Os2, Fr4 = "['’]", Rs2 = "[" + Ne3 + "]", Wu3 = "[" + Fu3 + "]", be3 = "[" + bu3 + "]", Hu3 = "\\d+", ys3 = "[" + Bu3 + "]", Xu3 = "[" + Uu3 + "]", Ku3 = "[^" + Ne3 + Fu3 + Hu3 + Bu3 + Uu3 + Du3 + "]", Wr4 = "\\ud83c[\\udffb-\\udfff]", Ps3 = "(?:" + be3 + "|" + Wr4 + ")", Vu3 = "[^" + Ne3 + "]", Hr4 = "(?:\\ud83c[\\udde6-\\uddff]){2}", Xr4 = "[\\ud800-\\udbff][\\udc00-\\udfff]", xt4 = "[" + Du3 + "]", Yu3 = "\\u200d", $u3 = "(?:" + Xu3 + "|" + Ku3 + ")", Is2 = "(?:" + xt4 + "|" + Ku3 + ")", zu3 = "(?:" + Fr4 + "(?:d|ll|m|re|s|t|ve))?", qu3 = "(?:" + Fr4 + "(?:D|LL|M|RE|S|T|VE))?", Zu3 = Ps3 + "?", Ju3 = "[" + Gu3 + "]?", Ls2 = "(?:" + Yu3 + "(?:" + [Vu3, Hr4, Xr4].join("|") + ")" + Ju3 + Zu3 + ")*", ws2 = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", ms3 = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", Qu3 = Ju3 + Zu3 + Ls2, Cs3 = "(?:" + [ys3, Hr4, Xr4].join("|") + ")" + Qu3, xs2 = "(?:" + [Vu3 + be3 + "?", be3, Hr4, Xr4, Rs2].join("|") + ")", Ms2 = RegExp(Fr4, "g"), Ns2 = RegExp(be3, "g"), Kr4 = RegExp(Wr4 + "(?=" + Wr4 + ")|" + xs2 + Qu3, "g"), bs3 = RegExp([
84370
84486
  xt4 + "?" + Xu3 + "+" + zu3 + "(?=" + [Wu3, xt4, "$"].join("|") + ")",
84371
84487
  Is2 + "+" + qu3 + "(?=" + [Wu3, xt4 + $u3, "$"].join("|") + ")",
84372
84488
  xt4 + "?" + $u3 + "+" + zu3,
@@ -84712,7 +84828,7 @@ function _03() {
84712
84828
  return g2.split("");
84713
84829
  }
84714
84830
  function Qs3(g2) {
84715
- return g2.match(os6) || [];
84831
+ return g2.match(os7) || [];
84716
84832
  }
84717
84833
  function ao3(g2, T2, v2) {
84718
84834
  var I3;
@@ -87594,7 +87710,7 @@ function _03() {
87594
87710
  if (Mu3.test(m2))
87595
87711
  throw new N(L2);
87596
87712
  });
87597
- var p2, d, A = 0, S3 = t.interpolate || Me2, y2 = "__p += '", P2 = ti2((t.escape || Me2).source + "|" + S3.source + "|" + (S3 === xu3 ? fs12 : Me2).source + "|" + (t.evaluate || Me2).source + "|$", "g"), w2 = "//# sourceURL=" + (X3.call(t, "sourceURL") ? (t.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++Gs3 + "]") + `
87713
+ var p2, d, A = 0, S3 = t.interpolate || Me2, y2 = "__p += '", P2 = ti2((t.escape || Me2).source + "|" + S3.source + "|" + (S3 === xu3 ? fs13 : Me2).source + "|" + (t.evaluate || Me2).source + "|$", "g"), w2 = "//# sourceURL=" + (X3.call(t, "sourceURL") ? (t.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++Gs3 + "]") + `
87598
87714
  `;
87599
87715
  n.replace(P2, function(m2, G4, W2, On4, _n5, Rn4) {
87600
87716
  return W2 || (W2 = On4), y2 += n.slice(A, Rn4).replace(gs3, ic3), G4 && (p2 = true, y2 += `' +
@@ -128033,7 +128149,7 @@ var rs3 = {
128033
128149
  function It5(e10) {
128034
128150
  return e10.replace(/(%[YyqmBbAadHIMSpLf%])?([^%]*)/g, '$1"$2"').replace(/""/g, "").replace(/%Y/g, "yyyy").replace(/%y/g, "yy").replace(/%q/g, '"q"').replace(/%m/g, "MM").replace(/%B/g, "MMMM").replace(/%b/g, "MMM").replace(/%A/g, "dddd").replace(/%a/g, "ddd").replace(/%d/g, "dd").replace(/%H/g, "HH").replace(/%I/g, "hh").replace(/%M/g, "mm").replace(/%S/g, "ss").replace(/%p/g, "tt").replace(/%L/g, "fff").replace(/%f/g, "ffffff");
128035
128151
  }
128036
- var os6 = /* @__PURE__ */ new Map([
128152
+ var os7 = /* @__PURE__ */ new Map([
128037
128153
  [o.TO_WINDOWS_TIMEZONE, ([e10]) => rs3[e10?.toString() ?? ""] ?? e10?.toString() ?? ""],
128038
128154
  [o.ADD_TIME_ZONE, ([e10, t], n) => {
128039
128155
  let r3 = n.opSql(o.TO_WINDOWS_TIMEZONE, [t]);
@@ -128396,7 +128512,7 @@ var ds3 = (e10, t) => {
128396
128512
  ${D3([...new Set(r3)].join(`,
128397
128513
  `))}`;
128398
128514
  };
128399
- var fs12 = {
128515
+ var fs13 = {
128400
128516
  dataSource: "sqlserver",
128401
128517
  col: (e10) => `[${e10}]`,
128402
128518
  hTypeToDbType: ss3,
@@ -128410,7 +128526,7 @@ var fs12 = {
128410
128526
  orderByClause: Ts3,
128411
128527
  limitClause: () => "",
128412
128528
  datetimeFormat: "yyyy-MM-dd HH:mm:ss.ffffff",
128413
- operationOverrides: os6,
128529
+ operationOverrides: os7,
128414
128530
  transformers: is3
128415
128531
  };
128416
128532
  function J3(e10) {
@@ -128594,7 +128710,7 @@ var Is2 = /* @__PURE__ */ new Map([
128594
128710
  ["oracledb", ns3],
128595
128711
  ["prestodb", Xo3],
128596
128712
  ["redshift", zo3],
128597
- ["sqlserver", fs12],
128713
+ ["sqlserver", fs13],
128598
128714
  ["snowflake", $s3]
128599
128715
  ]);
128600
128716
  function We4(e10) {
@@ -130552,7 +130668,7 @@ function parseValidatorsOption(value) {
130552
130668
  function interpretFiles(program3, files, rootPath) {
130553
130669
  const service = new E_;
130554
130670
  service.program = program3;
130555
- return files.filter((file) => file.endsWith(".aml")).map((file) => path8.relative(rootPath, file)).flatMap((file) => {
130671
+ return files.filter((file) => file.endsWith(".aml")).map((file) => path9.relative(rootPath, file)).flatMap((file) => {
130556
130672
  const result = program3.interpretFileJson(r.create(file));
130557
130673
  if (!result.isOk())
130558
130674
  return [];
@@ -130589,7 +130705,7 @@ function runValidators(program3, files, rootPath, option, config) {
130589
130705
  }
130590
130706
 
130591
130707
  // src/commands/aml/validators/format.ts
130592
- import * as path9 from "node:path";
130708
+ import * as path10 from "node:path";
130593
130709
  import { pathToFileURL } from "node:url";
130594
130710
  var AQL_ERR_REF_LINK = "https://docs.holistics.io/reference/aql/error-reference";
130595
130711
  var BADGE_TEXT_WIDTH = "WARNING-1234".length;
@@ -130766,11 +130882,11 @@ function renderChildList(node, childPrefix, hasMore = false) {
130766
130882
  return blocks2.flatMap((block, i3) => i3 === 0 ? block : [spacer, ...block]);
130767
130883
  }
130768
130884
  function fileHyperlink(filePath) {
130769
- const abs = path9.resolve(filePath);
130885
+ const abs = path10.resolve(filePath);
130770
130886
  return hyperlink(pathToFileURL(abs).href, paint(COLORS.filepath, filePath));
130771
130887
  }
130772
130888
  function fileBreakdownLink(filePath) {
130773
- const abs = path9.resolve(filePath);
130889
+ const abs = path10.resolve(filePath);
130774
130890
  return hyperlink(pathToFileURL(abs).href, filePath);
130775
130891
  }
130776
130892
  function truncateMessage(msg, width) {
@@ -130936,6 +131052,7 @@ function formatSummarizeReport(reports) {
130936
131052
 
130937
131053
  // src/commands/aml/compile.ts
130938
131054
  async function compile2(paths, rootPath, outDir, userAttributes = [], validation = {}) {
131055
+ await loadServerUserAttributes(userAttributes);
130939
131056
  const filePaths = await expandPaths(paths);
130940
131057
  const interpretedFiles = compileAMLFiles(filePaths, {
130941
131058
  userAttributes,
@@ -130943,16 +131060,16 @@ async function compile2(paths, rootPath, outDir, userAttributes = [], validation
130943
131060
  });
130944
131061
  if (outDir) {
130945
131062
  const cwd = rootPath ?? process.cwd();
130946
- const dir = path10.resolve(outDir);
130947
- if (!fs13.existsSync(dir)) {
130948
- fs13.mkdirSync(dir, { recursive: true });
131063
+ const dir = path11.resolve(outDir);
131064
+ if (!fs14.existsSync(dir)) {
131065
+ fs14.mkdirSync(dir, { recursive: true });
130949
131066
  }
130950
131067
  Object.entries(interpretedFiles).forEach(([filePath, content]) => {
130951
- const relativePath = path10.relative(cwd, `${filePath}.json`);
130952
- const outPath = path10.join(outDir, relativePath);
131068
+ const relativePath = path11.relative(cwd, `${filePath}.json`);
131069
+ const outPath = path11.join(outDir, relativePath);
130953
131070
  consolePrint.log(`Writing to ${relativePath}`);
130954
- fs13.mkdirSync(path10.dirname(outPath), { recursive: true });
130955
- fs13.writeFileSync(outPath, JSON.stringify(content, null, 2));
131071
+ fs14.mkdirSync(path11.dirname(outPath), { recursive: true });
131072
+ fs14.writeFileSync(outPath, JSON.stringify(content, null, 2));
130956
131073
  });
130957
131074
  } else {
130958
131075
  consolePrint.log(JSON.stringify(interpretedFiles, null, 2));
@@ -130975,6 +131092,7 @@ var compile_default = command4;
130975
131092
 
130976
131093
  // src/commands/aml/validate.ts
130977
131094
  async function validate2(paths, rootPath, userAttributes = [], validation = {}) {
131095
+ await loadServerUserAttributes(userAttributes);
130978
131096
  const filePaths = await expandPaths(paths);
130979
131097
  compileAMLFiles(filePaths, { rootPath, userAttributes });
130980
131098
  const reports = runValidators(getProgram(), filePaths, rootPath ?? process.cwd(), { userAttributes }, validation);
@@ -131005,29 +131123,29 @@ var command6 = new Command("aml").description("AML-related commands").addCommand
131005
131123
  var aml_default = command6;
131006
131124
 
131007
131125
  // src/commands/mcp.ts
131008
- import fs15 from "fs";
131009
- import path13 from "path";
131126
+ import fs16 from "fs";
131127
+ import path14 from "path";
131010
131128
 
131011
131129
  // src/commands/code_sync/lock_state.ts
131012
- import crypto3 from "crypto";
131013
- import fs14 from "fs";
131130
+ import crypto4 from "crypto";
131131
+ import fs15 from "fs";
131014
131132
  import fsp from "fs/promises";
131015
- import os7 from "os";
131016
- import path11 from "path";
131017
- var STATE_DIR_ROOT = path11.join(os7.homedir(), ".holistics", "sync");
131133
+ import os8 from "os";
131134
+ import path12 from "path";
131135
+ var STATE_DIR_ROOT = path12.join(os8.homedir(), ".holistics", "sync");
131018
131136
  function getStateDir(repoPath) {
131019
- const resolved = path11.resolve(repoPath);
131020
- const hash = crypto3.createHash("sha256").update(resolved).digest("hex").slice(0, 16);
131021
- return path11.join(STATE_DIR_ROOT, hash);
131137
+ const resolved = path12.resolve(repoPath);
131138
+ const hash = crypto4.createHash("sha256").update(resolved).digest("hex").slice(0, 16);
131139
+ return path12.join(STATE_DIR_ROOT, hash);
131022
131140
  }
131023
131141
  function getPidPath(repoPath) {
131024
- return path11.join(getStateDir(repoPath), "sync.pid");
131142
+ return path12.join(getStateDir(repoPath), "sync.pid");
131025
131143
  }
131026
131144
  function getStatePath(repoPath) {
131027
- return path11.join(getStateDir(repoPath), "state.json");
131145
+ return path12.join(getStateDir(repoPath), "state.json");
131028
131146
  }
131029
131147
  function getLogPath(repoPath) {
131030
- return path11.join(getStateDir(repoPath), "sync.log");
131148
+ return path12.join(getStateDir(repoPath), "sync.log");
131031
131149
  }
131032
131150
  async function ensureStateDir(repoPath) {
131033
131151
  const dir = getStateDir(repoPath);
@@ -131047,7 +131165,7 @@ function isPidAlive(pid) {
131047
131165
  function readPid(repoPath) {
131048
131166
  const file = getPidPath(repoPath);
131049
131167
  try {
131050
- const raw = fs14.readFileSync(file, "utf-8").trim();
131168
+ const raw = fs15.readFileSync(file, "utf-8").trim();
131051
131169
  const pid = parseInt(raw);
131052
131170
  return Number.isFinite(pid) && pid > 0 ? pid : null;
131053
131171
  } catch (err) {
@@ -131171,7 +131289,7 @@ async function checkHealth(repoPath, thresholdMs = DEFAULT_STALENESS_THRESHOLD_M
131171
131289
  }
131172
131290
 
131173
131291
  // src/commands/code_sync/status.ts
131174
- import path12 from "path";
131292
+ import path13 from "path";
131175
131293
  var DEFAULT_STATUS_WAIT_TIMEOUT_MS = parseInt(process.env.CODE_SYNC_STATUS_WAIT_TIMEOUT_MS || "30000");
131176
131294
  var DEFAULT_STATUS_WAIT_POLL_MS = 200;
131177
131295
  function formatAge(iso) {
@@ -131242,7 +131360,7 @@ async function waitForFreshCycle(resolvedPath, out = log, options2 = {}) {
131242
131360
  return 1;
131243
131361
  }
131244
131362
  async function runSyncStatus(repoPath, options2 = {}) {
131245
- const resolvedPath = path12.resolve(repoPath);
131363
+ const resolvedPath = path13.resolve(repoPath);
131246
131364
  if (options2.wait) {
131247
131365
  return waitForFreshCycle(resolvedPath);
131248
131366
  }
@@ -131339,7 +131457,7 @@ async function printToolSchema(toolName, env) {
131339
131457
  }
131340
131458
  async function ensureSyncFresh() {
131341
131459
  const cwd = process.cwd();
131342
- if (!fs15.existsSync(path13.join(cwd, ".git"))) {
131460
+ if (!fs16.existsSync(path14.join(cwd, ".git"))) {
131343
131461
  consolePrint.warn(`⚠ Not inside a git repo (${cwd}); cannot verify whether cloud reflects local code.`);
131344
131462
  consolePrint.warn(" cd into your Holistics project before running mcp to enable sync checks.");
131345
131463
  return;
@@ -131419,83 +131537,6 @@ var mcp_default = command7;
131419
131537
  // src/commands/code_sync/sync.ts
131420
131538
  import path21 from "path";
131421
131539
 
131422
- // src/commands/code_sync/api.ts
131423
- import os8 from "os";
131424
-
131425
- // src/commands/code_sync/file_ops.ts
131426
- import crypto4 from "crypto";
131427
- import fs16 from "fs/promises";
131428
- import path14 from "path";
131429
- var MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
131430
- async function getFileSize(basePath, relativePath) {
131431
- const stat = await fs16.stat(path14.join(basePath, relativePath));
131432
- return stat.size;
131433
- }
131434
- function computeGitHash(content) {
131435
- const buf2 = Buffer.from(content, "utf-8");
131436
- const header = `blob ${buf2.length}\x00`;
131437
- return crypto4.createHash("sha1").update(header).update(buf2).digest("hex");
131438
- }
131439
- async function readFileContent(basePath, relativePath) {
131440
- return fs16.readFile(path14.join(basePath, relativePath), "utf-8");
131441
- }
131442
- async function writeFileContent(basePath, relativePath, content) {
131443
- const fullPath = path14.join(basePath, relativePath);
131444
- await fs16.mkdir(path14.dirname(fullPath), { recursive: true });
131445
- await fs16.writeFile(fullPath, content, "utf-8");
131446
- }
131447
- async function deleteLocalFile(basePath, relativePath) {
131448
- try {
131449
- await fs16.unlink(path14.join(basePath, relativePath));
131450
- } catch (err) {
131451
- if (err.code !== "ENOENT")
131452
- throw err;
131453
- }
131454
- }
131455
-
131456
- // src/commands/code_sync/api.ts
131457
- var BASE_API = "/api/v2/aml_studio";
131458
- var CLI_METADATA = {
131459
- origin: "cli",
131460
- hostname: os8.hostname().replace(/\.local$/, "")
131461
- };
131462
- async function fetchProjects() {
131463
- const data = await get(`${BASE_API}/projects`, {}, "Failed to fetch projects");
131464
- return data.data;
131465
- }
131466
- async function fetchRepoStatus(projectId, gitFetch) {
131467
- const data = await getJson(`${BASE_API}/projects/${projectId}/repositories/status`, { git_fetch: gitFetch }, "Failed to fetch repository status");
131468
- return data.data;
131469
- }
131470
- async function fetchBackedFilesMeta(projectId) {
131471
- const data = await get(`${BASE_API}/projects/${projectId}/repositories/all_files`, {}, "Failed to fetch backend files");
131472
- const inner = data.data;
131473
- return inner.files ?? inner;
131474
- }
131475
- async function pushFiles(projectId, files) {
131476
- const accepted = [];
131477
- for (const f3 of files) {
131478
- const size = Buffer.byteLength(f3.content, "utf-8");
131479
- if (size > MAX_FILE_SIZE_BYTES) {
131480
- log(fmt.yellow(` ⚠ Skipping ${f3.file_path}: exceeds ${MAX_FILE_SIZE_BYTES} byte limit (${size} bytes)`));
131481
- continue;
131482
- }
131483
- accepted.push(f3);
131484
- }
131485
- if (accepted.length === 0) {
131486
- return { status: "ok", data: { success: [], failure: [] } };
131487
- }
131488
- const data = await postJson(`${BASE_API}/repositories/write_files_with_status`, { project_id: projectId, files: accepted, metadata: CLI_METADATA }, "Failed to push files");
131489
- return data;
131490
- }
131491
- async function pullFiles(projectId, filePaths) {
131492
- const data = await postJson(`${BASE_API}/projects/${projectId}/repositories/batch_read_file`, { file_paths: filePaths }, "Failed to pull files");
131493
- return data.data.files;
131494
- }
131495
- async function removeFile(projectId, filePath) {
131496
- await postJson(`${BASE_API}/projects/${projectId}/repositories/remove`, { file_path: filePath, metadata: CLI_METADATA }, "Failed to remove file");
131497
- }
131498
-
131499
131540
  // src/commands/code_sync/hash_ledger.ts
131500
131541
  class HashLedger {
131501
131542
  map = new Map;
@@ -136864,6 +136905,14 @@ var command8 = new Command("sync-code").description("Sync local AML code with Ho
136864
136905
  var sync_default = command8;
136865
136906
 
136866
136907
  // src/commands.ts
136908
+ process.on("uncaughtException", async (err) => {
136909
+ await logErr(err);
136910
+ process.exit(1);
136911
+ });
136912
+ process.on("unhandledRejection", async (reason) => {
136913
+ await logErr(reason instanceof Error ? reason : new Error(String(reason)));
136914
+ process.exit(1);
136915
+ });
136867
136916
  function addDocumentationHelp(command9) {
136868
136917
  command9.addHelpText("after", `
136869
136918
  See documentation at: https://docs.holistics.io/docs/cli`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@holistics/cli-core",
3
3
  "type": "module",
4
- "version": "2.1.16",
4
+ "version": "2.2.0",
5
5
  "bin": {
6
6
  "holistics": "./bin/holistics.js"
7
7
  },