@holistics/cli-core 2.1.15 → 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 -127
  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.15";
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 = {};
@@ -75876,8 +75877,6 @@ var iE2 = (e, t) => {
75876
75877
  };
75877
75878
  };
75878
75879
  function jh2(e) {
75879
- if (import_lodash.isNil(e))
75880
- return;
75881
75880
  const t = {};
75882
75881
  Object.values(e.fields.field ?? {}).forEach((i2, a) => {
75883
75882
  const s2 = {
@@ -82570,6 +82569,87 @@ var A1 = (e, t = {}) => (e.options.childIdxForDynamicProp = true, e.registerCust
82570
82569
  e.setDefinitionAtPath(r.create(`/modules/${fc2}/${n}`), o);
82571
82570
  }), PM(e, t), e);
82572
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
+
82573
82653
  // src/commands/aml/userAttributes.ts
82574
82654
  var SUPPORTED_TYPES = [
82575
82655
  "date",
@@ -82635,6 +82715,40 @@ function buildUserAttributes(custom = []) {
82635
82715
  custom.forEach(({ name, type: type2 }) => byName.set(name, { name, type: type2 }));
82636
82716
  return Array.from(byName.values());
82637
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
+ }
82638
82752
 
82639
82753
  // src/commands/aml/common.ts
82640
82754
  var program2;
@@ -82644,7 +82758,7 @@ function getProgram() {
82644
82758
  async function expandPaths(paths) {
82645
82759
  const expansions = paths.map(async (p2) => {
82646
82760
  try {
82647
- const stat = fs11.statSync(p2);
82761
+ const stat = fs12.statSync(p2);
82648
82762
  if (stat.isFile()) {
82649
82763
  return [p2];
82650
82764
  }
@@ -82669,7 +82783,7 @@ function readAmlFiles(rootPath) {
82669
82783
  const files = import_fast_glob.default.sync(`${rootPath}/**/*.aml`, { onlyFiles: true, dot: true });
82670
82784
  return files.map((filePath) => ({
82671
82785
  filePath,
82672
- content: fs11.readFileSync(filePath, "utf-8")
82786
+ content: fs12.readFileSync(filePath, "utf-8")
82673
82787
  }));
82674
82788
  }
82675
82789
  function initAMLProgram(rootPath, userAttributes) {
@@ -82678,7 +82792,7 @@ function initAMLProgram(rootPath, userAttributes) {
82678
82792
  try {
82679
82793
  const amlFiles = readAmlFiles(rootPath);
82680
82794
  amlFiles.forEach(({ filePath, content }) => {
82681
- const relativePath = path7.relative(rootPath, filePath);
82795
+ const relativePath = path8.relative(rootPath, filePath);
82682
82796
  program2.setFileContent(r.create(relativePath), content);
82683
82797
  });
82684
82798
  } catch {
@@ -82694,7 +82808,7 @@ function compileAMLFiles(files, options2) {
82694
82808
  const filteredFiles = files.filter((file) => file.endsWith(".aml"));
82695
82809
  const interpretStart = performance.now();
82696
82810
  const interpretedFiles = filteredFiles.map((file, index) => {
82697
- const result = program2.interpretFile(r.create(path7.relative(rootPath, file)));
82811
+ const result = program2.interpretFile(r.create(path8.relative(rootPath, file)));
82698
82812
  renderProgressBar(index + 1, filteredFiles.length, "Compiling AML", interpretStart);
82699
82813
  return result;
82700
82814
  });
@@ -82725,7 +82839,7 @@ function compileAMLFiles(files, options2) {
82725
82839
  }
82726
82840
 
82727
82841
  // src/commands/aml/validators/pipeline.ts
82728
- import path8 from "path";
82842
+ import path9 from "path";
82729
82843
 
82730
82844
  // ../amql/dist/amql.es.js
82731
82845
  var import_lodash2 = __toESM(require_lodash(), 1);
@@ -84368,7 +84482,7 @@ function _03() {
84368
84482
  ["partial", Vn3],
84369
84483
  ["partialRight", Qt3],
84370
84484
  ["rearg", kt4]
84371
- ], 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([
84372
84486
  xt4 + "?" + Xu3 + "+" + zu3 + "(?=" + [Wu3, xt4, "$"].join("|") + ")",
84373
84487
  Is2 + "+" + qu3 + "(?=" + [Wu3, xt4 + $u3, "$"].join("|") + ")",
84374
84488
  xt4 + "?" + $u3 + "+" + zu3,
@@ -84714,7 +84828,7 @@ function _03() {
84714
84828
  return g2.split("");
84715
84829
  }
84716
84830
  function Qs3(g2) {
84717
- return g2.match(os6) || [];
84831
+ return g2.match(os7) || [];
84718
84832
  }
84719
84833
  function ao3(g2, T2, v2) {
84720
84834
  var I3;
@@ -87596,7 +87710,7 @@ function _03() {
87596
87710
  if (Mu3.test(m2))
87597
87711
  throw new N(L2);
87598
87712
  });
87599
- 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 + "]") + `
87600
87714
  `;
87601
87715
  n.replace(P2, function(m2, G4, W2, On4, _n5, Rn4) {
87602
87716
  return W2 || (W2 = On4), y2 += n.slice(A, Rn4).replace(gs3, ic3), G4 && (p2 = true, y2 += `' +
@@ -128035,7 +128149,7 @@ var rs3 = {
128035
128149
  function It5(e10) {
128036
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");
128037
128151
  }
128038
- var os6 = /* @__PURE__ */ new Map([
128152
+ var os7 = /* @__PURE__ */ new Map([
128039
128153
  [o.TO_WINDOWS_TIMEZONE, ([e10]) => rs3[e10?.toString() ?? ""] ?? e10?.toString() ?? ""],
128040
128154
  [o.ADD_TIME_ZONE, ([e10, t], n) => {
128041
128155
  let r3 = n.opSql(o.TO_WINDOWS_TIMEZONE, [t]);
@@ -128398,7 +128512,7 @@ var ds3 = (e10, t) => {
128398
128512
  ${D3([...new Set(r3)].join(`,
128399
128513
  `))}`;
128400
128514
  };
128401
- var fs12 = {
128515
+ var fs13 = {
128402
128516
  dataSource: "sqlserver",
128403
128517
  col: (e10) => `[${e10}]`,
128404
128518
  hTypeToDbType: ss3,
@@ -128412,7 +128526,7 @@ var fs12 = {
128412
128526
  orderByClause: Ts3,
128413
128527
  limitClause: () => "",
128414
128528
  datetimeFormat: "yyyy-MM-dd HH:mm:ss.ffffff",
128415
- operationOverrides: os6,
128529
+ operationOverrides: os7,
128416
128530
  transformers: is3
128417
128531
  };
128418
128532
  function J3(e10) {
@@ -128596,7 +128710,7 @@ var Is2 = /* @__PURE__ */ new Map([
128596
128710
  ["oracledb", ns3],
128597
128711
  ["prestodb", Xo3],
128598
128712
  ["redshift", zo3],
128599
- ["sqlserver", fs12],
128713
+ ["sqlserver", fs13],
128600
128714
  ["snowflake", $s3]
128601
128715
  ]);
128602
128716
  function We4(e10) {
@@ -130554,7 +130668,7 @@ function parseValidatorsOption(value) {
130554
130668
  function interpretFiles(program3, files, rootPath) {
130555
130669
  const service = new E_;
130556
130670
  service.program = program3;
130557
- 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) => {
130558
130672
  const result = program3.interpretFileJson(r.create(file));
130559
130673
  if (!result.isOk())
130560
130674
  return [];
@@ -130591,7 +130705,7 @@ function runValidators(program3, files, rootPath, option, config) {
130591
130705
  }
130592
130706
 
130593
130707
  // src/commands/aml/validators/format.ts
130594
- import * as path9 from "node:path";
130708
+ import * as path10 from "node:path";
130595
130709
  import { pathToFileURL } from "node:url";
130596
130710
  var AQL_ERR_REF_LINK = "https://docs.holistics.io/reference/aql/error-reference";
130597
130711
  var BADGE_TEXT_WIDTH = "WARNING-1234".length;
@@ -130768,11 +130882,11 @@ function renderChildList(node, childPrefix, hasMore = false) {
130768
130882
  return blocks2.flatMap((block, i3) => i3 === 0 ? block : [spacer, ...block]);
130769
130883
  }
130770
130884
  function fileHyperlink(filePath) {
130771
- const abs = path9.resolve(filePath);
130885
+ const abs = path10.resolve(filePath);
130772
130886
  return hyperlink(pathToFileURL(abs).href, paint(COLORS.filepath, filePath));
130773
130887
  }
130774
130888
  function fileBreakdownLink(filePath) {
130775
- const abs = path9.resolve(filePath);
130889
+ const abs = path10.resolve(filePath);
130776
130890
  return hyperlink(pathToFileURL(abs).href, filePath);
130777
130891
  }
130778
130892
  function truncateMessage(msg, width) {
@@ -130938,6 +131052,7 @@ function formatSummarizeReport(reports) {
130938
131052
 
130939
131053
  // src/commands/aml/compile.ts
130940
131054
  async function compile2(paths, rootPath, outDir, userAttributes = [], validation = {}) {
131055
+ await loadServerUserAttributes(userAttributes);
130941
131056
  const filePaths = await expandPaths(paths);
130942
131057
  const interpretedFiles = compileAMLFiles(filePaths, {
130943
131058
  userAttributes,
@@ -130945,16 +131060,16 @@ async function compile2(paths, rootPath, outDir, userAttributes = [], validation
130945
131060
  });
130946
131061
  if (outDir) {
130947
131062
  const cwd = rootPath ?? process.cwd();
130948
- const dir = path10.resolve(outDir);
130949
- if (!fs13.existsSync(dir)) {
130950
- fs13.mkdirSync(dir, { recursive: true });
131063
+ const dir = path11.resolve(outDir);
131064
+ if (!fs14.existsSync(dir)) {
131065
+ fs14.mkdirSync(dir, { recursive: true });
130951
131066
  }
130952
131067
  Object.entries(interpretedFiles).forEach(([filePath, content]) => {
130953
- const relativePath = path10.relative(cwd, `${filePath}.json`);
130954
- const outPath = path10.join(outDir, relativePath);
131068
+ const relativePath = path11.relative(cwd, `${filePath}.json`);
131069
+ const outPath = path11.join(outDir, relativePath);
130955
131070
  consolePrint.log(`Writing to ${relativePath}`);
130956
- fs13.mkdirSync(path10.dirname(outPath), { recursive: true });
130957
- 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));
130958
131073
  });
130959
131074
  } else {
130960
131075
  consolePrint.log(JSON.stringify(interpretedFiles, null, 2));
@@ -130977,6 +131092,7 @@ var compile_default = command4;
130977
131092
 
130978
131093
  // src/commands/aml/validate.ts
130979
131094
  async function validate2(paths, rootPath, userAttributes = [], validation = {}) {
131095
+ await loadServerUserAttributes(userAttributes);
130980
131096
  const filePaths = await expandPaths(paths);
130981
131097
  compileAMLFiles(filePaths, { rootPath, userAttributes });
130982
131098
  const reports = runValidators(getProgram(), filePaths, rootPath ?? process.cwd(), { userAttributes }, validation);
@@ -131007,29 +131123,29 @@ var command6 = new Command("aml").description("AML-related commands").addCommand
131007
131123
  var aml_default = command6;
131008
131124
 
131009
131125
  // src/commands/mcp.ts
131010
- import fs15 from "fs";
131011
- import path13 from "path";
131126
+ import fs16 from "fs";
131127
+ import path14 from "path";
131012
131128
 
131013
131129
  // src/commands/code_sync/lock_state.ts
131014
- import crypto3 from "crypto";
131015
- import fs14 from "fs";
131130
+ import crypto4 from "crypto";
131131
+ import fs15 from "fs";
131016
131132
  import fsp from "fs/promises";
131017
- import os7 from "os";
131018
- import path11 from "path";
131019
- 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");
131020
131136
  function getStateDir(repoPath) {
131021
- const resolved = path11.resolve(repoPath);
131022
- const hash = crypto3.createHash("sha256").update(resolved).digest("hex").slice(0, 16);
131023
- 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);
131024
131140
  }
131025
131141
  function getPidPath(repoPath) {
131026
- return path11.join(getStateDir(repoPath), "sync.pid");
131142
+ return path12.join(getStateDir(repoPath), "sync.pid");
131027
131143
  }
131028
131144
  function getStatePath(repoPath) {
131029
- return path11.join(getStateDir(repoPath), "state.json");
131145
+ return path12.join(getStateDir(repoPath), "state.json");
131030
131146
  }
131031
131147
  function getLogPath(repoPath) {
131032
- return path11.join(getStateDir(repoPath), "sync.log");
131148
+ return path12.join(getStateDir(repoPath), "sync.log");
131033
131149
  }
131034
131150
  async function ensureStateDir(repoPath) {
131035
131151
  const dir = getStateDir(repoPath);
@@ -131049,7 +131165,7 @@ function isPidAlive(pid) {
131049
131165
  function readPid(repoPath) {
131050
131166
  const file = getPidPath(repoPath);
131051
131167
  try {
131052
- const raw = fs14.readFileSync(file, "utf-8").trim();
131168
+ const raw = fs15.readFileSync(file, "utf-8").trim();
131053
131169
  const pid = parseInt(raw);
131054
131170
  return Number.isFinite(pid) && pid > 0 ? pid : null;
131055
131171
  } catch (err) {
@@ -131173,7 +131289,7 @@ async function checkHealth(repoPath, thresholdMs = DEFAULT_STALENESS_THRESHOLD_M
131173
131289
  }
131174
131290
 
131175
131291
  // src/commands/code_sync/status.ts
131176
- import path12 from "path";
131292
+ import path13 from "path";
131177
131293
  var DEFAULT_STATUS_WAIT_TIMEOUT_MS = parseInt(process.env.CODE_SYNC_STATUS_WAIT_TIMEOUT_MS || "30000");
131178
131294
  var DEFAULT_STATUS_WAIT_POLL_MS = 200;
131179
131295
  function formatAge(iso) {
@@ -131244,7 +131360,7 @@ async function waitForFreshCycle(resolvedPath, out = log, options2 = {}) {
131244
131360
  return 1;
131245
131361
  }
131246
131362
  async function runSyncStatus(repoPath, options2 = {}) {
131247
- const resolvedPath = path12.resolve(repoPath);
131363
+ const resolvedPath = path13.resolve(repoPath);
131248
131364
  if (options2.wait) {
131249
131365
  return waitForFreshCycle(resolvedPath);
131250
131366
  }
@@ -131341,7 +131457,7 @@ async function printToolSchema(toolName, env) {
131341
131457
  }
131342
131458
  async function ensureSyncFresh() {
131343
131459
  const cwd = process.cwd();
131344
- if (!fs15.existsSync(path13.join(cwd, ".git"))) {
131460
+ if (!fs16.existsSync(path14.join(cwd, ".git"))) {
131345
131461
  consolePrint.warn(`⚠ Not inside a git repo (${cwd}); cannot verify whether cloud reflects local code.`);
131346
131462
  consolePrint.warn(" cd into your Holistics project before running mcp to enable sync checks.");
131347
131463
  return;
@@ -131421,83 +131537,6 @@ var mcp_default = command7;
131421
131537
  // src/commands/code_sync/sync.ts
131422
131538
  import path21 from "path";
131423
131539
 
131424
- // src/commands/code_sync/api.ts
131425
- import os8 from "os";
131426
-
131427
- // src/commands/code_sync/file_ops.ts
131428
- import crypto4 from "crypto";
131429
- import fs16 from "fs/promises";
131430
- import path14 from "path";
131431
- var MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
131432
- async function getFileSize(basePath, relativePath) {
131433
- const stat = await fs16.stat(path14.join(basePath, relativePath));
131434
- return stat.size;
131435
- }
131436
- function computeGitHash(content) {
131437
- const buf2 = Buffer.from(content, "utf-8");
131438
- const header = `blob ${buf2.length}\x00`;
131439
- return crypto4.createHash("sha1").update(header).update(buf2).digest("hex");
131440
- }
131441
- async function readFileContent(basePath, relativePath) {
131442
- return fs16.readFile(path14.join(basePath, relativePath), "utf-8");
131443
- }
131444
- async function writeFileContent(basePath, relativePath, content) {
131445
- const fullPath = path14.join(basePath, relativePath);
131446
- await fs16.mkdir(path14.dirname(fullPath), { recursive: true });
131447
- await fs16.writeFile(fullPath, content, "utf-8");
131448
- }
131449
- async function deleteLocalFile(basePath, relativePath) {
131450
- try {
131451
- await fs16.unlink(path14.join(basePath, relativePath));
131452
- } catch (err) {
131453
- if (err.code !== "ENOENT")
131454
- throw err;
131455
- }
131456
- }
131457
-
131458
- // src/commands/code_sync/api.ts
131459
- var BASE_API = "/api/v2/aml_studio";
131460
- var CLI_METADATA = {
131461
- origin: "cli",
131462
- hostname: os8.hostname().replace(/\.local$/, "")
131463
- };
131464
- async function fetchProjects() {
131465
- const data = await get(`${BASE_API}/projects`, {}, "Failed to fetch projects");
131466
- return data.data;
131467
- }
131468
- async function fetchRepoStatus(projectId, gitFetch) {
131469
- const data = await getJson(`${BASE_API}/projects/${projectId}/repositories/status`, { git_fetch: gitFetch }, "Failed to fetch repository status");
131470
- return data.data;
131471
- }
131472
- async function fetchBackedFilesMeta(projectId) {
131473
- const data = await get(`${BASE_API}/projects/${projectId}/repositories/all_files`, {}, "Failed to fetch backend files");
131474
- const inner = data.data;
131475
- return inner.files ?? inner;
131476
- }
131477
- async function pushFiles(projectId, files) {
131478
- const accepted = [];
131479
- for (const f3 of files) {
131480
- const size = Buffer.byteLength(f3.content, "utf-8");
131481
- if (size > MAX_FILE_SIZE_BYTES) {
131482
- log(fmt.yellow(` ⚠ Skipping ${f3.file_path}: exceeds ${MAX_FILE_SIZE_BYTES} byte limit (${size} bytes)`));
131483
- continue;
131484
- }
131485
- accepted.push(f3);
131486
- }
131487
- if (accepted.length === 0) {
131488
- return { status: "ok", data: { success: [], failure: [] } };
131489
- }
131490
- const data = await postJson(`${BASE_API}/repositories/write_files_with_status`, { project_id: projectId, files: accepted, metadata: CLI_METADATA }, "Failed to push files");
131491
- return data;
131492
- }
131493
- async function pullFiles(projectId, filePaths) {
131494
- const data = await postJson(`${BASE_API}/projects/${projectId}/repositories/batch_read_file`, { file_paths: filePaths }, "Failed to pull files");
131495
- return data.data.files;
131496
- }
131497
- async function removeFile(projectId, filePath) {
131498
- await postJson(`${BASE_API}/projects/${projectId}/repositories/remove`, { file_path: filePath, metadata: CLI_METADATA }, "Failed to remove file");
131499
- }
131500
-
131501
131540
  // src/commands/code_sync/hash_ledger.ts
131502
131541
  class HashLedger {
131503
131542
  map = new Map;
@@ -136866,6 +136905,14 @@ var command8 = new Command("sync-code").description("Sync local AML code with Ho
136866
136905
  var sync_default = command8;
136867
136906
 
136868
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
+ });
136869
136916
  function addDocumentationHelp(command9) {
136870
136917
  command9.addHelpText("after", `
136871
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.15",
4
+ "version": "2.2.0",
5
5
  "bin": {
6
6
  "holistics": "./bin/holistics.js"
7
7
  },