@superblocksteam/cli 2.0.3-next.121 → 2.0.3-next.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ $ npm install -g @superblocksteam/cli
14
14
  $ superblocks COMMAND
15
15
  running command...
16
16
  $ superblocks (--version)
17
- @superblocksteam/cli/2.0.3-next.121 linux-x64 node-v20.19.0
17
+ @superblocksteam/cli/2.0.3-next.123 linux-x64 node-v20.19.0
18
18
  $ superblocks --help [COMMAND]
19
19
  USAGE
20
20
  $ superblocks COMMAND
package/dist/index.js CHANGED
@@ -47326,7 +47326,7 @@ var require_lodash = __commonJS({
47326
47326
  }
47327
47327
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
47328
47328
  });
47329
- function join12(array2, separator) {
47329
+ function join11(array2, separator) {
47330
47330
  return array2 == null ? "" : nativeJoin.call(array2, separator);
47331
47331
  }
47332
47332
  function last2(array2) {
@@ -49245,7 +49245,7 @@ var require_lodash = __commonJS({
49245
49245
  lodash.isUndefined = isUndefined2;
49246
49246
  lodash.isWeakMap = isWeakMap;
49247
49247
  lodash.isWeakSet = isWeakSet;
49248
- lodash.join = join12;
49248
+ lodash.join = join11;
49249
49249
  lodash.kebabCase = kebabCase;
49250
49250
  lodash.last = last2;
49251
49251
  lodash.lastIndexOf = lastIndexOf;
@@ -124570,8 +124570,8 @@ var require_cassandra_driver = __commonJS({
124570
124570
  }
124571
124571
  }));
124572
124572
  }
124573
- function isRequestValid(exec5, args, length) {
124574
- if (!exec5) return false;
124573
+ function isRequestValid(exec6, args, length) {
124574
+ if (!exec6) return false;
124575
124575
  if (args.length !== length || typeof args[length - 1] !== "function") return false;
124576
124576
  return true;
124577
124577
  }
@@ -128691,12 +128691,12 @@ var require_main = __commonJS({
128691
128691
  versions: [">=6.0.0"],
128692
128692
  file: "src/WorkerHandler.js"
128693
128693
  }, (workerHandlerPackage) => {
128694
- shimmer.wrap(workerHandlerPackage.prototype, "exec", (exec5) => function(_, path46) {
128694
+ shimmer.wrap(workerHandlerPackage.prototype, "exec", (exec6) => function(_, path46) {
128695
128695
  if (!testStartCh.hasSubscribers) {
128696
- return exec5.apply(this, arguments);
128696
+ return exec6.apply(this, arguments);
128697
128697
  }
128698
128698
  if (!path46?.length) {
128699
- return exec5.apply(this, arguments);
128699
+ return exec6.apply(this, arguments);
128700
128700
  }
128701
128701
  const [testSuiteAbsolutePath] = path46;
128702
128702
  const testSuiteAsyncResource = new AsyncResource("bound-anonymous-fn");
@@ -128717,7 +128717,7 @@ var require_main = __commonJS({
128717
128717
  });
128718
128718
  });
128719
128719
  try {
128720
- const promise = exec5.apply(this, arguments);
128720
+ const promise = exec6.apply(this, arguments);
128721
128721
  promise.then(
128722
128722
  (result) => {
128723
128723
  const status = result.failureCount === 0 ? "pass" : "fail";
@@ -135247,7 +135247,7 @@ var require_debugger = __commonJS({
135247
135247
  "use strict";
135248
135248
  init_cjs_shims();
135249
135249
  var { types: types2 } = __require("util");
135250
- var { join: join12 } = __require("path");
135250
+ var { join: join11 } = __require("path");
135251
135251
  var { Worker, MessageChannel: MessageChannel2, threadId: parentThreadId } = __require("worker_threads");
135252
135252
  var log = require_log2();
135253
135253
  var worker = null;
@@ -135281,7 +135281,7 @@ var require_debugger = __commonJS({
135281
135281
  });
135282
135282
  rcChannel.port2.on("messageerror", (err) => log.error('[debugger] received "messageerror" on RC port', err));
135283
135283
  worker = new Worker(
135284
- join12(__dirname, "devtools_client", "index.js"),
135284
+ join11(__dirname, "devtools_client", "index.js"),
135285
135285
  {
135286
135286
  execArgv: [],
135287
135287
  // Avoid worker thread inheriting the `-r` command line argument
@@ -143043,7 +143043,7 @@ var require_dynamic_instrumentation = __commonJS({
143043
143043
  "../../../../node_modules/.pnpm/dd-trace@5.49.0/node_modules/dd-trace/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js"(exports2, module2) {
143044
143044
  "use strict";
143045
143045
  init_cjs_shims();
143046
- var { join: join12 } = __require("path");
143046
+ var { join: join11 } = __require("path");
143047
143047
  var { Worker, threadId: parentThreadId } = __require("worker_threads");
143048
143048
  var { randomUUID: randomUUID4 } = __require("crypto");
143049
143049
  var log = require_log2();
@@ -143095,7 +143095,7 @@ var require_dynamic_instrumentation = __commonJS({
143095
143095
  const rcChannel = new MessageChannel();
143096
143096
  const configChannel = new MessageChannel();
143097
143097
  this.worker = new Worker(
143098
- join12(__dirname, "worker", "index.js"),
143098
+ join11(__dirname, "worker", "index.js"),
143099
143099
  {
143100
143100
  execArgv: [],
143101
143101
  // Not passing `NODE_OPTIONS` results in issues with yarn, which relies on NODE_OPTIONS
@@ -181804,7 +181804,7 @@ var require_util18 = __commonJS({
181804
181804
  return path46;
181805
181805
  });
181806
181806
  exports2.normalize = normalize3;
181807
- function join12(aRoot, aPath) {
181807
+ function join11(aRoot, aPath) {
181808
181808
  if (aRoot === "") {
181809
181809
  aRoot = ".";
181810
181810
  }
@@ -181836,7 +181836,7 @@ var require_util18 = __commonJS({
181836
181836
  }
181837
181837
  return joined;
181838
181838
  }
181839
- exports2.join = join12;
181839
+ exports2.join = join11;
181840
181840
  exports2.isAbsolute = function(aPath) {
181841
181841
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
181842
181842
  };
@@ -182009,7 +182009,7 @@ var require_util18 = __commonJS({
182009
182009
  parsed.path = parsed.path.substring(0, index + 1);
182010
182010
  }
182011
182011
  }
182012
- sourceURL = join12(urlGenerate(parsed), sourceURL);
182012
+ sourceURL = join11(urlGenerate(parsed), sourceURL);
182013
182013
  }
182014
182014
  return normalize3(sourceURL);
182015
182015
  }
@@ -184166,7 +184166,7 @@ var require_sourcemapper = __commonJS({
184166
184166
  var sourceMap = __importStar(require_source_map2());
184167
184167
  var logger_1 = require_logger2();
184168
184168
  var p_limit_1 = __importDefault(require_p_limit());
184169
- var readFile7 = fs26.promises.readFile;
184169
+ var readFile8 = fs26.promises.readFile;
184170
184170
  var CONCURRENCY = 10;
184171
184171
  var MAP_EXT = ".map";
184172
184172
  function error(msg) {
@@ -184180,7 +184180,7 @@ var require_sourcemapper = __commonJS({
184180
184180
  mapPath = path46.normalize(mapPath);
184181
184181
  let contents;
184182
184182
  try {
184183
- contents = await readFile7(mapPath, "utf8");
184183
+ contents = await readFile8(mapPath, "utf8");
184184
184184
  } catch (e) {
184185
184185
  throw error("Could not read source map file " + mapPath + ": " + e);
184186
184186
  }
@@ -279814,7 +279814,7 @@ var require_fs3 = __commonJS({
279814
279814
  };
279815
279815
  return data;
279816
279816
  }
279817
- var readFile7 = exports2.readFile = _gensync()({
279817
+ var readFile8 = exports2.readFile = _gensync()({
279818
279818
  sync: _fs().readFileSync,
279819
279819
  errback: _fs().readFile
279820
279820
  });
@@ -297779,7 +297779,7 @@ var require_view = __commonJS({
297779
297779
  var dirname9 = path46.dirname;
297780
297780
  var basename7 = path46.basename;
297781
297781
  var extname3 = path46.extname;
297782
- var join12 = path46.join;
297782
+ var join11 = path46.join;
297783
297783
  var resolve8 = path46.resolve;
297784
297784
  module2.exports = View;
297785
297785
  function View(name17, options8) {
@@ -297827,12 +297827,12 @@ var require_view = __commonJS({
297827
297827
  };
297828
297828
  View.prototype.resolve = function resolve9(dir, file) {
297829
297829
  var ext2 = this.ext;
297830
- var path47 = join12(dir, file);
297830
+ var path47 = join11(dir, file);
297831
297831
  var stat4 = tryStat(path47);
297832
297832
  if (stat4 && stat4.isFile()) {
297833
297833
  return path47;
297834
297834
  }
297835
- path47 = join12(dir, basename7(file, ext2), "index" + ext2);
297835
+ path47 = join11(dir, basename7(file, ext2), "index" + ext2);
297836
297836
  stat4 = tryStat(path47);
297837
297837
  if (stat4 && stat4.isFile()) {
297838
297838
  return path47;
@@ -298371,7 +298371,7 @@ var require_send = __commonJS({
298371
298371
  var Stream2 = __require("stream");
298372
298372
  var util7 = __require("util");
298373
298373
  var extname3 = path46.extname;
298374
- var join12 = path46.join;
298374
+ var join11 = path46.join;
298375
298375
  var normalize3 = path46.normalize;
298376
298376
  var resolve8 = path46.resolve;
298377
298377
  var sep2 = path46.sep;
@@ -298590,7 +298590,7 @@ var require_send = __commonJS({
298590
298590
  return res;
298591
298591
  }
298592
298592
  parts = path47.split(sep2);
298593
- path47 = normalize3(join12(root2, path47));
298593
+ path47 = normalize3(join11(root2, path47));
298594
298594
  } else {
298595
298595
  if (UP_PATH_REGEXP.test(path47)) {
298596
298596
  debug5('malicious path "%s"', path47);
@@ -298725,7 +298725,7 @@ var require_send = __commonJS({
298725
298725
  if (err) return self2.onStatError(err);
298726
298726
  return self2.error(404);
298727
298727
  }
298728
- var p = join12(path47, self2._index[i2]);
298728
+ var p = join11(path47, self2._index[i2]);
298729
298729
  debug5('stat "%s"', p);
298730
298730
  fs26.stat(p, function(err2, stat4) {
298731
298731
  if (err2) return next(err2);
@@ -308926,7 +308926,7 @@ var require_safe_stable_stringify = __commonJS({
308926
308926
  return circularValue;
308927
308927
  }
308928
308928
  let res = "";
308929
- let join12 = ",";
308929
+ let join11 = ",";
308930
308930
  const originalIndentation = indentation2;
308931
308931
  if (Array.isArray(value2)) {
308932
308932
  if (value2.length === 0) {
@@ -308940,7 +308940,7 @@ var require_safe_stable_stringify = __commonJS({
308940
308940
  indentation2 += spacer;
308941
308941
  res += `
308942
308942
  ${indentation2}`;
308943
- join12 = `,
308943
+ join11 = `,
308944
308944
  ${indentation2}`;
308945
308945
  }
308946
308946
  const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
@@ -308948,13 +308948,13 @@ ${indentation2}`;
308948
308948
  for (; i2 < maximumValuesToStringify - 1; i2++) {
308949
308949
  const tmp2 = stringifyFnReplacer(String(i2), value2, stack2, replacer, spacer, indentation2);
308950
308950
  res += tmp2 !== void 0 ? tmp2 : "null";
308951
- res += join12;
308951
+ res += join11;
308952
308952
  }
308953
308953
  const tmp = stringifyFnReplacer(String(i2), value2, stack2, replacer, spacer, indentation2);
308954
308954
  res += tmp !== void 0 ? tmp : "null";
308955
308955
  if (value2.length - 1 > maximumBreadth) {
308956
308956
  const removedKeys = value2.length - maximumBreadth - 1;
308957
- res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
308957
+ res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
308958
308958
  }
308959
308959
  if (spacer !== "") {
308960
308960
  res += `
@@ -308975,7 +308975,7 @@ ${originalIndentation}`;
308975
308975
  let separator = "";
308976
308976
  if (spacer !== "") {
308977
308977
  indentation2 += spacer;
308978
- join12 = `,
308978
+ join11 = `,
308979
308979
  ${indentation2}`;
308980
308980
  whitespace = " ";
308981
308981
  }
@@ -308989,13 +308989,13 @@ ${indentation2}`;
308989
308989
  const tmp = stringifyFnReplacer(key3, value2, stack2, replacer, spacer, indentation2);
308990
308990
  if (tmp !== void 0) {
308991
308991
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
308992
- separator = join12;
308992
+ separator = join11;
308993
308993
  }
308994
308994
  }
308995
308995
  if (keyLength > maximumBreadth) {
308996
308996
  const removedKeys = keyLength - maximumBreadth;
308997
308997
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
308998
- separator = join12;
308998
+ separator = join11;
308999
308999
  }
309000
309000
  if (spacer !== "" && separator.length > 1) {
309001
309001
  res = `
@@ -309036,7 +309036,7 @@ ${originalIndentation}`;
309036
309036
  }
309037
309037
  const originalIndentation = indentation2;
309038
309038
  let res = "";
309039
- let join12 = ",";
309039
+ let join11 = ",";
309040
309040
  if (Array.isArray(value2)) {
309041
309041
  if (value2.length === 0) {
309042
309042
  return "[]";
@@ -309049,7 +309049,7 @@ ${originalIndentation}`;
309049
309049
  indentation2 += spacer;
309050
309050
  res += `
309051
309051
  ${indentation2}`;
309052
- join12 = `,
309052
+ join11 = `,
309053
309053
  ${indentation2}`;
309054
309054
  }
309055
309055
  const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
@@ -309057,13 +309057,13 @@ ${indentation2}`;
309057
309057
  for (; i2 < maximumValuesToStringify - 1; i2++) {
309058
309058
  const tmp2 = stringifyArrayReplacer(String(i2), value2[i2], stack2, replacer, spacer, indentation2);
309059
309059
  res += tmp2 !== void 0 ? tmp2 : "null";
309060
- res += join12;
309060
+ res += join11;
309061
309061
  }
309062
309062
  const tmp = stringifyArrayReplacer(String(i2), value2[i2], stack2, replacer, spacer, indentation2);
309063
309063
  res += tmp !== void 0 ? tmp : "null";
309064
309064
  if (value2.length - 1 > maximumBreadth) {
309065
309065
  const removedKeys = value2.length - maximumBreadth - 1;
309066
- res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
309066
+ res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
309067
309067
  }
309068
309068
  if (spacer !== "") {
309069
309069
  res += `
@@ -309076,7 +309076,7 @@ ${originalIndentation}`;
309076
309076
  let whitespace = "";
309077
309077
  if (spacer !== "") {
309078
309078
  indentation2 += spacer;
309079
- join12 = `,
309079
+ join11 = `,
309080
309080
  ${indentation2}`;
309081
309081
  whitespace = " ";
309082
309082
  }
@@ -309085,7 +309085,7 @@ ${indentation2}`;
309085
309085
  const tmp = stringifyArrayReplacer(key3, value2[key3], stack2, replacer, spacer, indentation2);
309086
309086
  if (tmp !== void 0) {
309087
309087
  res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
309088
- separator = join12;
309088
+ separator = join11;
309089
309089
  }
309090
309090
  }
309091
309091
  if (spacer !== "" && separator.length > 1) {
@@ -309143,20 +309143,20 @@ ${originalIndentation}`;
309143
309143
  indentation2 += spacer;
309144
309144
  let res2 = `
309145
309145
  ${indentation2}`;
309146
- const join13 = `,
309146
+ const join12 = `,
309147
309147
  ${indentation2}`;
309148
309148
  const maximumValuesToStringify = Math.min(value2.length, maximumBreadth);
309149
309149
  let i2 = 0;
309150
309150
  for (; i2 < maximumValuesToStringify - 1; i2++) {
309151
309151
  const tmp2 = stringifyIndent(String(i2), value2[i2], stack2, spacer, indentation2);
309152
309152
  res2 += tmp2 !== void 0 ? tmp2 : "null";
309153
- res2 += join13;
309153
+ res2 += join12;
309154
309154
  }
309155
309155
  const tmp = stringifyIndent(String(i2), value2[i2], stack2, spacer, indentation2);
309156
309156
  res2 += tmp !== void 0 ? tmp : "null";
309157
309157
  if (value2.length - 1 > maximumBreadth) {
309158
309158
  const removedKeys = value2.length - maximumBreadth - 1;
309159
- res2 += `${join13}"... ${getItemCount(removedKeys)} not stringified"`;
309159
+ res2 += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
309160
309160
  }
309161
309161
  res2 += `
309162
309162
  ${originalIndentation}`;
@@ -309172,16 +309172,16 @@ ${originalIndentation}`;
309172
309172
  return '"[Object]"';
309173
309173
  }
309174
309174
  indentation2 += spacer;
309175
- const join12 = `,
309175
+ const join11 = `,
309176
309176
  ${indentation2}`;
309177
309177
  let res = "";
309178
309178
  let separator = "";
309179
309179
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
309180
309180
  if (isTypedArrayWithEntries(value2)) {
309181
- res += stringifyTypedArray(value2, join12, maximumBreadth);
309181
+ res += stringifyTypedArray(value2, join11, maximumBreadth);
309182
309182
  keys = keys.slice(value2.length);
309183
309183
  maximumPropertiesToStringify -= value2.length;
309184
- separator = join12;
309184
+ separator = join11;
309185
309185
  }
309186
309186
  if (deterministic) {
309187
309187
  keys = sort(keys, comparator);
@@ -309192,13 +309192,13 @@ ${indentation2}`;
309192
309192
  const tmp = stringifyIndent(key3, value2[key3], stack2, spacer, indentation2);
309193
309193
  if (tmp !== void 0) {
309194
309194
  res += `${separator}${strEscape(key3)}: ${tmp}`;
309195
- separator = join12;
309195
+ separator = join11;
309196
309196
  }
309197
309197
  }
309198
309198
  if (keyLength > maximumBreadth) {
309199
309199
  const removedKeys = keyLength - maximumBreadth;
309200
309200
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
309201
- separator = join12;
309201
+ separator = join11;
309202
309202
  }
309203
309203
  if (separator !== "") {
309204
309204
  res = `
@@ -310624,7 +310624,7 @@ var require_buffer_list = __commonJS({
310624
310624
  }
310625
310625
  }, {
310626
310626
  key: "join",
310627
- value: function join12(s) {
310627
+ value: function join11(s) {
310628
310628
  if (this.length === 0) return "";
310629
310629
  var p = this.head;
310630
310630
  var ret = "" + p.data;
@@ -329161,7 +329161,7 @@ var import_dd_trace = __toESM(require_dd_trace2(), 1);
329161
329161
  // ../sdk/package.json
329162
329162
  var package_default = {
329163
329163
  name: "@superblocksteam/sdk",
329164
- version: "2.0.3-next.121",
329164
+ version: "2.0.3-next.123",
329165
329165
  type: "module",
329166
329166
  description: "Superblocks JS SDK",
329167
329167
  homepage: "https://www.superblocks.com",
@@ -329192,8 +329192,8 @@ var package_default = {
329192
329192
  "@rollup/wasm-node": "^4.35.0",
329193
329193
  "@superblocksteam/bucketeer-sdk": "0.4.1",
329194
329194
  "@superblocksteam/shared": "^0.9081.0",
329195
- "@superblocksteam/util": "2.0.3-next.121",
329196
- "@superblocksteam/vite-plugin-file-sync": "2.0.3-next.121",
329195
+ "@superblocksteam/util": "2.0.3-next.123",
329196
+ "@superblocksteam/vite-plugin-file-sync": "2.0.3-next.123",
329197
329197
  "@vitejs/plugin-react": "^4.3.4",
329198
329198
  axios: "^1.4.0",
329199
329199
  chokidar: "^4.0.3",
@@ -354454,13 +354454,13 @@ Diff.prototype = {
354454
354454
  editLength++;
354455
354455
  }
354456
354456
  if (callback) {
354457
- (function exec5() {
354457
+ (function exec6() {
354458
354458
  setTimeout(function() {
354459
354459
  if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
354460
354460
  return callback();
354461
354461
  }
354462
354462
  if (!execEditLength()) {
354463
- exec5();
354463
+ exec6();
354464
354464
  }
354465
354465
  }, 0);
354466
354466
  })();
@@ -370311,6 +370311,13 @@ var fileSyncVitePlugin = (pluginParams, options8) => {
370311
370311
  return socket.call.aiSetDraftState({ hasDraft });
370312
370312
  });
370313
370313
  });
370314
+ aiService.on("generationCompleted", (hasDraft) => {
370315
+ if (hasDraft) {
370316
+ server.ws.send({
370317
+ type: "full-reload"
370318
+ });
370319
+ }
370320
+ });
370314
370321
  }
370315
370322
  const triggerRegisteredComponentUpdate = () => {
370316
370323
  const module2 = server.moduleGraph.getModuleById(resolvedVirtualRegisteredComponentsId);
@@ -370457,6 +370464,11 @@ var fileSyncVitePlugin = (pluginParams, options8) => {
370457
370464
  `
370458
370465
  );
370459
370466
  }
370467
+ },
370468
+ handleHotUpdate() {
370469
+ if (aiService?.isBusy()) {
370470
+ return [];
370471
+ }
370460
370472
  }
370461
370473
  };
370462
370474
  };
@@ -370882,7 +370894,7 @@ function ensureRelative(dir, path210) {
370882
370894
 
370883
370895
  // ../sdk/dist/dev-utils/cdn-url.mjs
370884
370896
  init_cjs_shims();
370885
- var DEFAULT_CDN_URL = "https://assets-cdn.superblocks.com/library/2.0.3-next.121";
370897
+ var DEFAULT_CDN_URL = "https://assets-cdn.superblocks.com/library/2.0.3-next.123";
370886
370898
 
370887
370899
  // ../sdk/dist/dev-utils/custom-build.mjs
370888
370900
  init_cjs_shims();
@@ -379767,6 +379779,67 @@ function createAnthropic(options8 = {}) {
379767
379779
  }
379768
379780
  var anthropic = createAnthropic();
379769
379781
 
379782
+ // ../../../vite-plugin-file-sync/dist/ai-service/app-interface/shell.js
379783
+ init_cjs_shims();
379784
+ import { exec } from "node:child_process";
379785
+ import { readFile as readFile4 } from "node:fs/promises";
379786
+ import * as path23 from "node:path";
379787
+ var AppShell = class {
379788
+ appRootDirPath;
379789
+ fsOperationQueue;
379790
+ constructor({ appRootDirPath, fsOperationQueue }) {
379791
+ this.appRootDirPath = appRootDirPath;
379792
+ this.fsOperationQueue = fsOperationQueue;
379793
+ }
379794
+ async readFiles(patterns, globOptions) {
379795
+ return await this.fsOperationQueue.enqueue(async () => {
379796
+ const files = await glob(patterns, {
379797
+ ignore: ["node_modules/**", "dist/**", "build/**", ".superblocks/**"],
379798
+ nodir: true,
379799
+ cwd: this.appRootDirPath,
379800
+ ...globOptions
379801
+ });
379802
+ return await Promise.all(files.map(async (file) => ({
379803
+ type: "file",
379804
+ filePath: path23.relative(this.appRootDirPath, file),
379805
+ content: await readFile4(file, "utf-8")
379806
+ })));
379807
+ });
379808
+ }
379809
+ async runTypecheck() {
379810
+ const checkForErrors = new Promise((resolve8) => {
379811
+ exec([
379812
+ "npx tsc",
379813
+ "--noEmit",
379814
+ // speed up marginal typecheck
379815
+ "--incremental",
379816
+ // expected format
379817
+ "--pretty false",
379818
+ // cache in separate file to avoid conflicts with vite or user ide
379819
+ "--tsBuildInfoFile .superblocks/app.tsbuildinfo"
379820
+ ].join(" "), {
379821
+ cwd: this.appRootDirPath,
379822
+ encoding: "utf-8"
379823
+ }, (_error, stdout, stderr) => {
379824
+ resolve8(stdout || stderr);
379825
+ });
379826
+ });
379827
+ const output = await checkForErrors;
379828
+ if (!output || typeof output !== "string") {
379829
+ return null;
379830
+ }
379831
+ const parsed = output.split("\n").reduce((acc, line3) => {
379832
+ const [filePath, _rest] = line3.split("(");
379833
+ if (filePath && filePath.trim() !== "") {
379834
+ acc[filePath] = [...acc[filePath] || [], line3];
379835
+ return acc;
379836
+ }
379837
+ return acc;
379838
+ }, {});
379839
+ return Object.keys(parsed).length > 0 ? parsed : null;
379840
+ }
379841
+ };
379842
+
379770
379843
  // ../../../vite-plugin-file-sync/dist/ai-service/artifacts/bolt.js
379771
379844
  init_cjs_shims();
379772
379845
  var BoltArtifactProcessor = class {
@@ -379809,12 +379882,12 @@ import { spawn as spawn2 } from "child_process";
379809
379882
  import { randomUUID } from "crypto";
379810
379883
  import * as fs12 from "fs/promises";
379811
379884
  import * as os3 from "os";
379812
- import * as path24 from "path";
379885
+ import * as path25 from "path";
379813
379886
 
379814
379887
  // ../../../ai-service-templates/reify-template.js
379815
379888
  init_cjs_shims();
379816
379889
  import fs11 from "fs";
379817
- import path23 from "path";
379890
+ import path24 from "path";
379818
379891
  function reifyTemplate(targetDirectoryPath, fileMap) {
379819
379892
  if (typeof targetDirectoryPath !== "string") {
379820
379893
  throw new Error("targetDirectoryPath must be a string.");
@@ -379822,14 +379895,14 @@ function reifyTemplate(targetDirectoryPath, fileMap) {
379822
379895
  if (typeof fileMap !== "object" || fileMap === null) {
379823
379896
  throw new Error("fileMap must be a non-null object.");
379824
379897
  }
379825
- const resolvedTargetDirectory = path23.resolve(targetDirectoryPath);
379898
+ const resolvedTargetDirectory = path24.resolve(targetDirectoryPath);
379826
379899
  console.log(`Recreating structure in: ${resolvedTargetDirectory}`);
379827
379900
  for (const relativeFilePath in fileMap) {
379828
379901
  if (Object.hasOwnProperty.call(fileMap, relativeFilePath)) {
379829
379902
  const content2 = fileMap[relativeFilePath];
379830
379903
  const fileContent = typeof content2 === "string" ? content2 : String(content2);
379831
- const absoluteFilePath = path23.join(resolvedTargetDirectory, relativeFilePath);
379832
- const directoryForFile = path23.dirname(absoluteFilePath);
379904
+ const absoluteFilePath = path24.join(resolvedTargetDirectory, relativeFilePath);
379905
+ const directoryForFile = path24.dirname(absoluteFilePath);
379833
379906
  try {
379834
379907
  if (!fs11.existsSync(directoryForFile)) {
379835
379908
  fs11.mkdirSync(directoryForFile, { recursive: true });
@@ -379865,7 +379938,7 @@ var TemplateRenderer = class {
379865
379938
  workDir;
379866
379939
  nodeModuleDirs;
379867
379940
  constructor({ prefetchNodeModules = false }) {
379868
- this.workDir = path24.join(os3.tmpdir(), `superblocks-ai-service`);
379941
+ this.workDir = path25.join(os3.tmpdir(), `superblocks-ai-service`);
379869
379942
  this.nodeModuleDirs = {};
379870
379943
  if (prefetchNodeModules) {
379871
379944
  for (const [templateName, template] of Object.entries(templates)) {
@@ -379880,11 +379953,11 @@ var TemplateRenderer = class {
379880
379953
  }
379881
379954
  const template = templates[templateName];
379882
379955
  const templateNodeModules = await this.templateModulesDir(templateName, template);
379883
- const templateDir = path24.join(this.workDir, templateName, `gen-${randomUUID()}`);
379956
+ const templateDir = path25.join(this.workDir, templateName, `gen-${randomUUID()}`);
379884
379957
  console.debug("Rendering template", templateName, "to", templateDir);
379885
379958
  reifyTemplate(templateDir, templates[templateName]);
379886
379959
  if (templateNodeModules) {
379887
- await fs12.cp(templateNodeModules, path24.join(templateDir, "node_modules"), {
379960
+ await fs12.cp(templateNodeModules, path25.join(templateDir, "node_modules"), {
379888
379961
  recursive: true
379889
379962
  });
379890
379963
  }
@@ -379900,16 +379973,16 @@ var TemplateRenderer = class {
379900
379973
  return this.nodeModuleDirs[templateName];
379901
379974
  }
379902
379975
  const packageJson = template["package.json"];
379903
- const dir = path24.join(this.workDir, templateName, SHARED_DIR);
379976
+ const dir = path25.join(this.workDir, templateName, SHARED_DIR);
379904
379977
  await fs12.mkdir(dir, { recursive: true });
379905
- await fs12.writeFile(path24.join(dir, "package.json"), packageJson, "utf-8");
379978
+ await fs12.writeFile(path25.join(dir, "package.json"), packageJson, "utf-8");
379906
379979
  const installDfd = new Promise((resolve8, reject) => {
379907
379980
  const child = spawn2("npm", ["install"], { cwd: dir });
379908
379981
  child.on("close", (code) => {
379909
379982
  if (code !== 0) {
379910
379983
  reject(new Error(`npm install failed with code ${code}`));
379911
379984
  }
379912
- resolve8(path24.join(dir, "node_modules"));
379985
+ resolve8(path25.join(dir, "node_modules"));
379913
379986
  });
379914
379987
  });
379915
379988
  this.nodeModuleDirs[templateName] = installDfd;
@@ -379933,7 +380006,6 @@ var USER_SENT_PROMPT = "userSentPrompt";
379933
380006
  var USER_ACCEPTED_DRAFT = "userAcceptedDraft";
379934
380007
  var USER_REJECTED_DRAFT = "userRejectedDraft";
379935
380008
  var AGENT_PLANNED = "agentPlanned";
379936
- var AGENT_REPORTED_ERROR_TO_USER = "agentReportedErrorToUser";
379937
380009
  var AGENT_NEEDS_USER_INPUT = "agentNeedsUserInput";
379938
380010
  var AGENT_GAVE_UP = "agentGaveUp";
379939
380011
  var LLM_REQUESTED_CONTEXT = "llmRequestedContext";
@@ -379953,7 +380025,7 @@ var transitions = {
379953
380025
  },
379954
380026
  [$.AgentPlanning]: {
379955
380027
  [AGENT_PLANNED]: $.LLMGenerating,
379956
- [AGENT_REPORTED_ERROR_TO_USER]: $.Idle,
380028
+ [AGENT_NEEDS_USER_INPUT]: $.AwaitingUser,
379957
380029
  [AGENT_GAVE_UP]: $.Dead
379958
380030
  },
379959
380031
  [$.LLMGenerating]: {
@@ -380033,8 +380105,6 @@ var FSM = class {
380033
380105
 
380034
380106
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/agent-planning.js
380035
380107
  init_cjs_shims();
380036
- import { readFile as readFile5 } from "node:fs/promises";
380037
- import * as path26 from "node:path";
380038
380108
 
380039
380109
  // ../../../vite-plugin-file-sync/dist/ai-service/const.js
380040
380110
  init_cjs_shims();
@@ -380429,7 +380499,7 @@ var getStaticPrompt = () => {
380429
380499
  init_cjs_shims();
380430
380500
  var import_util30 = __toESM(require_dist4(), 1);
380431
380501
  import * as fs13 from "fs/promises";
380432
- import * as path25 from "path";
380502
+ import * as path26 from "path";
380433
380503
 
380434
380504
  // ../../../vite-plugin-file-sync/dist/ai-service/transform/shared.js
380435
380505
  init_cjs_shims();
@@ -380495,9 +380565,9 @@ async function applyFileTransformations(files, transformers2) {
380495
380565
  for (const transformer of transformers2) {
380496
380566
  const matchingInput = {};
380497
380567
  for (const [key2, path46] of Object.entries(transformer.spec.src)) {
380498
- const exec5 = matchPath(path46);
380568
+ const exec6 = matchPath(path46);
380499
380569
  matchingInput[key2] = currentFiles.map((file) => {
380500
- const match3 = exec5(file.filePath);
380570
+ const match3 = exec6(file.filePath);
380501
380571
  return match3.matched ? {
380502
380572
  // we don't want individual transformers to know/rely on the path structure,
380503
380573
  // but we track it within this function for bookkeeping
@@ -380615,20 +380685,20 @@ var YamlToApiBuilderTransformer = class extends ApiBuilderTransformer {
380615
380685
  }
380616
380686
  async readMergedApi(pathParams) {
380617
380687
  const relativePath = renderPath(Paths.ApiYamls, pathParams);
380618
- const apiDir = path25.join(this.config.appRootDirPath, path25.dirname(relativePath));
380619
- const parentDir = path25.dirname(apiDir);
380688
+ const apiDir = path26.join(this.config.appRootDirPath, path26.dirname(relativePath));
380689
+ const parentDir = path26.dirname(apiDir);
380620
380690
  return (0, import_util30.readAppApiYamlFile)(parentDir, pathParams.apiName);
380621
380691
  }
380622
380692
  async transform(src6) {
380623
380693
  const targetDir = await this.renderTemplate();
380624
- const apisDir = path25.join(targetDir, "src/to-sdk");
380625
- let entryTemplate = await fs13.readFile(path25.join(apisDir, "__template__.ts"), "utf-8");
380694
+ const apisDir = path26.join(targetDir, "src/to-sdk");
380695
+ let entryTemplate = await fs13.readFile(path26.join(apisDir, "__template__.ts"), "utf-8");
380626
380696
  entryTemplate = entryTemplate.replace("const entities = [];", `const entities = ${JSON.stringify(this.config.entityNames)};`);
380627
380697
  for (const apiYaml of src6.apis) {
380628
380698
  const { api } = await this.readMergedApi(apiYaml.pathParams);
380629
380699
  const entry = entryTemplate.replace("const json = {};", `const json = ${JSON.stringify(api)};`);
380630
380700
  const fileName = `${apiYaml.pathParams.apiName}.ts`;
380631
- await fs13.writeFile(path25.join(apisDir, fileName), entry, "utf-8");
380701
+ await fs13.writeFile(path26.join(apisDir, fileName), entry, "utf-8");
380632
380702
  }
380633
380703
  const evalResult = await this.runEvaluation(targetDir);
380634
380704
  const pageNamesByApiName = src6.apis.reduce((acc, api) => {
@@ -380636,7 +380706,7 @@ var YamlToApiBuilderTransformer = class extends ApiBuilderTransformer {
380636
380706
  return acc;
380637
380707
  }, {});
380638
380708
  const sdkApis = Object.entries(evalResult).map(([apiFilePath, content2]) => {
380639
- const apiName = path25.basename(apiFilePath, ".js");
380709
+ const apiName = path26.basename(apiFilePath, ".js");
380640
380710
  const pageName = pageNamesByApiName[apiName];
380641
380711
  if (!pageName) {
380642
380712
  throw new Error(`Page name not found for api ${apiName}`);
@@ -380730,8 +380800,8 @@ ${newPrompt}`;
380730
380800
  request,
380731
380801
  systemPrompt,
380732
380802
  retryCount: 0
380733
- // TODO: might want to extract this fsm-wide and store retryCount in context
380734
380803
  });
380804
+ void params.appShell.runTypecheck();
380735
380805
  transitionTo({
380736
380806
  type: AGENT_PLANNED,
380737
380807
  systemPrompt,
@@ -380741,6 +380811,7 @@ ${newPrompt}`;
380741
380811
  }
380742
380812
  case LLM_ERRORED: {
380743
380813
  const { error } = event;
380814
+ console.error("LLM_ERRORED", error);
380744
380815
  switch (error.type) {
380745
380816
  case "overloaded_error":
380746
380817
  {
@@ -380797,6 +380868,40 @@ ${newPrompt}`;
380797
380868
  break;
380798
380869
  }
380799
380870
  case RUNTIME_REVIEW_ERRORED: {
380871
+ const { tsErrorsByPath } = event;
380872
+ const { debugCount = 0 } = getMeta() ?? {};
380873
+ if (debugCount >= 4) {
380874
+ transitionTo({
380875
+ type: AGENT_NEEDS_USER_INPUT,
380876
+ advice: "I've reached the maximum number of attempts to fix the errors. You may need to reject the changes and try again."
380877
+ });
380878
+ break;
380879
+ }
380880
+ const filePaths = Object.keys(tsErrorsByPath);
380881
+ sendUserMessage({
380882
+ text: debugCount === 0 ? "There are errors in the project. Let me address them." : "Still trying to fix the errors\u2026"
380883
+ });
380884
+ const systemPrompt = await createSystemPrompt(getMeta()?.request, params, filePaths);
380885
+ const diff2 = await params.draftInterface.getDraftDiff(filePaths);
380886
+ const debuggingPrompt = `The following TypeScript errors were found in the project:
380887
+ ---
380888
+ ${Object.values(tsErrorsByPath).map((errors) => errors.join("\n")).join("\n")}
380889
+ ---
380890
+
380891
+ Below is the diff of the changes made to the relevant files:
380892
+ ---
380893
+ ${diff2}
380894
+ ---
380895
+
380896
+ Address the errors and return the fixed code.`;
380897
+ updateMeta({
380898
+ debugCount: debugCount + 1
380899
+ });
380900
+ transitionTo({
380901
+ type: AGENT_PLANNED,
380902
+ systemPrompt,
380903
+ userPrompt: debuggingPrompt
380904
+ });
380800
380905
  break;
380801
380906
  }
380802
380907
  default:
@@ -380804,13 +380909,13 @@ ${newPrompt}`;
380804
380909
  }
380805
380910
  };
380806
380911
  };
380807
- var createSystemPrompt = async (request, params) => {
380808
- const { appRootDirPath, fsOperationQueue, templateRenderer, artifactProcessor } = params;
380809
- const appFiles = await readAppFiles(appRootDirPath, fsOperationQueue);
380912
+ var createSystemPrompt = async (request, params, appFilePatterns = ["**/*.{ts,tsx,yaml}"]) => {
380913
+ const { appShell, templateRenderer, artifactProcessor } = params;
380914
+ const appFiles = await params.appShell.readFiles(appFilePatterns);
380810
380915
  const transformedForPrompt = await applyFileTransformations(appFiles, [
380811
380916
  new YamlToApiBuilderTransformer({
380812
- appRootDirPath,
380813
- entityNames: request.promptContext?.entityNames ?? [],
380917
+ appRootDirPath: appShell.appRootDirPath,
380918
+ entityNames: request?.promptContext?.entityNames ?? [],
380814
380919
  skipCleanup: true,
380815
380920
  templateRenderer
380816
380921
  })
@@ -380819,9 +380924,9 @@ var createSystemPrompt = async (request, params) => {
380819
380924
  let systemPrompt = getStaticPrompt();
380820
380925
  systemPrompt = `${systemPrompt}
380821
380926
 
380822
- The current working directory is \`${appRootDirPath}\`.
380927
+ The current working directory is \`${appShell.appRootDirPath}\`.
380823
380928
  `;
380824
- const taggedIntegrations = request.promptContext?.integrations?.map((integration) => sdkIntegrationFromPromptContext(integration));
380929
+ const taggedIntegrations = request?.promptContext?.integrations?.map((integration) => sdkIntegrationFromPromptContext(integration));
380825
380930
  const sdkIntegrationsPromptContent = integrationsToSdkPromptContent(taggedIntegrations ?? []);
380826
380931
  if (sdkIntegrationsPromptContent.length > 0) {
380827
380932
  systemPrompt = `${systemPrompt}
@@ -380835,7 +380940,7 @@ ${sdkIntegrationsPromptContent.join("\n\n")}
380835
380940
  if (artifactContext) {
380836
380941
  systemPrompt = `${systemPrompt}
380837
380942
 
380838
- Below are all the files present in the project:
380943
+ Below are the relevant files present in the project:
380839
380944
  ---
380840
380945
  ${artifactContext.paths.join("\n")}
380841
380946
  ---
@@ -380855,30 +380960,32 @@ ${artifactContext.content}
380855
380960
  }
380856
380961
  return systemPrompt;
380857
380962
  };
380858
- var readAppFiles = async (appRootDirPath, fsOperationQueue) => {
380859
- return await fsOperationQueue.enqueue(async () => {
380860
- const files = await glob(path26.join(appRootDirPath, "**/*.{ts,tsx,yaml}"), {
380861
- ignore: ["node_modules/**", "dist/**", "build/**", ".superblocks/**"],
380862
- nodir: true
380863
- });
380864
- return await Promise.all(files.map(async (file) => ({
380865
- type: "file",
380866
- filePath: path26.relative(appRootDirPath, file),
380867
- content: await readFile5(file, "utf-8")
380868
- })));
380869
- });
380870
- };
380871
380963
 
380872
380964
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/awaiting-user.js
380873
380965
  init_cjs_shims();
380874
- var doAwaitingUser = (clark) => {
380966
+ var doAwaitingUser = (clark, { signals }) => {
380875
380967
  const sendUserCompletion = sendUserCompletionChannel(clark);
380968
+ const sendUserMessage = sendUserMessageChannel(clark);
380876
380969
  return async ({ event }) => {
380877
380970
  switch (event.type) {
380878
- case AGENT_NEEDS_USER_INPUT:
380971
+ case AGENT_NEEDS_USER_INPUT: {
380972
+ const { hasSuggestions = false } = clark.context;
380973
+ const { advice } = event;
380974
+ signals.emit("generationCompleted", hasSuggestions);
380975
+ void sendUserMessage({
380976
+ text: advice
380977
+ });
380978
+ void sendUserCompletion({ hasSuggestions });
380879
380979
  break;
380980
+ }
380880
380981
  case RUNTIME_REVIEW_FINISHED: {
380881
- const { hasSuggestions } = clark.context;
380982
+ const { hasSuggestions = false, summaryMessages = [] } = clark.context;
380983
+ signals.emit("generationCompleted", hasSuggestions);
380984
+ for (const message of summaryMessages) {
380985
+ void sendUserMessage({
380986
+ text: message
380987
+ });
380988
+ }
380882
380989
  void sendUserCompletion({ hasSuggestions });
380883
380990
  break;
380884
380991
  }
@@ -387859,6 +387966,8 @@ var doLLMGenerating = (clark, { anthropicProvider, artifactProcessor }) => {
387859
387966
  maxTokens: 32e3
387860
387967
  });
387861
387968
  let pendingArtifacts = false;
387969
+ let artifactChunk = null;
387970
+ const flushedAfterArtifacts = [];
387862
387971
  const resultBuffer = new BoltResultBuffer({
387863
387972
  onPending: async (type2) => {
387864
387973
  switch (type2) {
@@ -387871,17 +387980,21 @@ var doLLMGenerating = (clark, { anthropicProvider, artifactProcessor }) => {
387871
387980
  onFlush: async (type2, text2) => {
387872
387981
  switch (type2) {
387873
387982
  case BoltResultType.Text:
387874
- void sendUserMessage({ text: text2, type: "text" });
387983
+ if (artifactChunk) {
387984
+ flushedAfterArtifacts.push([type2, text2]);
387985
+ } else {
387986
+ void sendUserMessage({ text: text2, type: "text" });
387987
+ }
387875
387988
  break;
387876
387989
  case BoltResultType.Think:
387877
- void sendUserMessage({ text: text2, type: "reasoning" });
387990
+ if (artifactChunk) {
387991
+ flushedAfterArtifacts.push([type2, text2]);
387992
+ } else {
387993
+ void sendUserMessage({ text: text2, type: "reasoning" });
387994
+ }
387878
387995
  break;
387879
387996
  case BoltResultType.Artifact: {
387880
- const generated2 = artifactProcessor.extractFileArtifacts(text2);
387881
- transitionTo({
387882
- type: "llmFinished",
387883
- files: generated2
387884
- });
387997
+ artifactChunk = text2;
387885
387998
  break;
387886
387999
  }
387887
388000
  }
@@ -387906,6 +388019,7 @@ var doLLMGenerating = (clark, { anthropicProvider, artifactProcessor }) => {
387906
388019
  break;
387907
388020
  case "error":
387908
388021
  {
388022
+ console.error("LLM error chunk:", chunk);
387909
388023
  let error = {
387910
388024
  type: "unknown"
387911
388025
  };
@@ -387913,7 +388027,7 @@ var doLLMGenerating = (clark, { anthropicProvider, artifactProcessor }) => {
387913
388027
  error = chunk.error;
387914
388028
  }
387915
388029
  transitionTo({
387916
- type: "llmErrored",
388030
+ type: LLM_ERRORED,
387917
388031
  error
387918
388032
  });
387919
388033
  }
@@ -387924,13 +388038,23 @@ var doLLMGenerating = (clark, { anthropicProvider, artifactProcessor }) => {
387924
388038
  type: LLM_FINISHED_UNEXPECTEDLY,
387925
388039
  finishReason: chunk.finishReason
387926
388040
  });
387927
- } else if (!pendingArtifacts) {
388041
+ } else if (!pendingArtifacts || !artifactChunk) {
387928
388042
  transitionTo({
387929
388043
  type: APP_RUNTIME_UPDATED_WITHOUT_EDITS
387930
388044
  });
387931
388045
  void sendUserCompletion({
387932
388046
  hasSuggestions: false
387933
388047
  });
388048
+ } else {
388049
+ const generated2 = artifactProcessor.extractFileArtifacts(artifactChunk);
388050
+ const summaryMessages = flushedAfterArtifacts.filter(([type2]) => type2 === BoltResultType.Text).map(([_, text2]) => text2);
388051
+ clark.updateContext({
388052
+ summaryMessages
388053
+ });
388054
+ transitionTo({
388055
+ type: LLM_FINISHED,
388056
+ files: generated2
388057
+ });
387934
388058
  }
387935
388059
  break;
387936
388060
  case "tool-call":
@@ -388155,9 +388279,7 @@ var doPostProcessing = (clark, { applicationId, organizationId, draftInterface,
388155
388279
  new RemoveApiBuilderImportsTransformer(),
388156
388280
  new WorkaroundMissingSbApiTransformer()
388157
388281
  ]);
388158
- for (const file of transformed) {
388159
- await draftInterface.createDraftFile(file.filePath, file.content);
388160
- }
388282
+ await Promise.all(transformed.map((file) => draftInterface.createDraftFile(file.filePath, file.content)));
388161
388283
  transitionTo({
388162
388284
  type: POST_PROCESSING_FINISHED,
388163
388285
  files: transformed
@@ -388179,7 +388301,7 @@ var doPostProcessing = (clark, { applicationId, organizationId, draftInterface,
388179
388301
 
388180
388302
  // ../../../vite-plugin-file-sync/dist/ai-service/state-machine/handlers/runtime-reviewing.js
388181
388303
  init_cjs_shims();
388182
- var doRuntimeReviewing = (clark) => {
388304
+ var doRuntimeReviewing = (clark, params) => {
388183
388305
  const transitionTo = transitionFrom(clark);
388184
388306
  const sendUserMessage = sendUserMessageChannel(clark);
388185
388307
  return async ({ event }) => {
@@ -388198,9 +388320,18 @@ var doRuntimeReviewing = (clark) => {
388198
388320
  clark.updateContext({
388199
388321
  hasSuggestions: files.length > 0
388200
388322
  });
388201
- transitionTo({
388202
- type: RUNTIME_REVIEW_FINISHED
388203
- });
388323
+ const tsErrorsByPath = await params.appShell.runTypecheck();
388324
+ if (tsErrorsByPath) {
388325
+ console.log("tsErrorsByPath", tsErrorsByPath);
388326
+ transitionTo({
388327
+ type: RUNTIME_REVIEW_ERRORED,
388328
+ tsErrorsByPath
388329
+ });
388330
+ } else {
388331
+ transitionTo({
388332
+ type: RUNTIME_REVIEW_FINISHED
388333
+ });
388334
+ }
388204
388335
  }
388205
388336
  break;
388206
388337
  default:
@@ -388215,6 +388346,7 @@ var AiService = class extends EventEmitter10 {
388215
388346
  artifactProcessor;
388216
388347
  anthropicProvider;
388217
388348
  templateRenderer;
388349
+ appShell;
388218
388350
  clark;
388219
388351
  constructor(config2) {
388220
388352
  super();
@@ -388226,6 +388358,10 @@ var AiService = class extends EventEmitter10 {
388226
388358
  this.templateRenderer = new TemplateRenderer({
388227
388359
  prefetchNodeModules: true
388228
388360
  });
388361
+ this.appShell = new AppShell({
388362
+ appRootDirPath: config2.appRootDirPath,
388363
+ fsOperationQueue: config2.fsOperationQueue
388364
+ });
388229
388365
  this.clark = new FSM({
388230
388366
  transitions,
388231
388367
  initialState: ClarkStateNames.Idle,
@@ -388257,7 +388393,9 @@ var AiService = class extends EventEmitter10 {
388257
388393
  ...this.config,
388258
388394
  templateRenderer: this.templateRenderer,
388259
388395
  artifactProcessor: this.artifactProcessor,
388260
- anthropicProvider: this.anthropicProvider
388396
+ anthropicProvider: this.anthropicProvider,
388397
+ appShell: this.appShell,
388398
+ signals: this
388261
388399
  };
388262
388400
  const clarkStateHandlers = Object.fromEntries(Object.entries(clarkStateHandlerFactories).map(([state, handlerFactory]) => [state, handlerFactory(clark, params)]));
388263
388401
  return async (transition) => {
@@ -388275,7 +388413,7 @@ var AiService = class extends EventEmitter10 {
388275
388413
  if (this.clark.state === ClarkStateNames.Dead) {
388276
388414
  throw new Error("Service is unavailable");
388277
388415
  }
388278
- if (this.clark.state !== ClarkStateNames.Idle && this.clark.state !== ClarkStateNames.AwaitingUser) {
388416
+ if (this.isBusy()) {
388279
388417
  console.error("Service is busy. state:", this.clark.state);
388280
388418
  throw new Error("Service is busy");
388281
388419
  }
@@ -388310,21 +388448,8 @@ var AiService = class extends EventEmitter10 {
388310
388448
  const transitionTo = transitionFrom(this.clark);
388311
388449
  transitionTo({ type: USER_REJECTED_DRAFT });
388312
388450
  }
388313
- async handleRuntimeReport(_request, _peer) {
388314
- if (this.clark.state !== ClarkStateNames.RuntimeReviewing) {
388315
- throw new Error("Service is not in runtime review mode");
388316
- }
388317
- const transitionTo = transitionFrom(this.clark);
388318
- if (_request.error) {
388319
- transitionTo({
388320
- type: RUNTIME_REVIEW_ERRORED,
388321
- error: _request.error
388322
- });
388323
- } else {
388324
- transitionTo({
388325
- type: RUNTIME_REVIEW_FINISHED
388326
- });
388327
- }
388451
+ isBusy() {
388452
+ return this.clark.state !== ClarkStateNames.Idle && this.clark.state !== ClarkStateNames.AwaitingUser && this.clark.state !== ClarkStateNames.Dead;
388328
388453
  }
388329
388454
  };
388330
388455
 
@@ -388639,6 +388764,10 @@ async function discardAllDrafts(appRootDirPath) {
388639
388764
  return;
388640
388765
  }
388641
388766
  await discardDraftsInDirectory(draftsDir, appRootDirPath);
388767
+ await cleanUpDraftsDirectory(appRootDirPath);
388768
+ }
388769
+ async function cleanUpDraftsDirectory(appRootDirPath) {
388770
+ const draftsDir = getDraftsDirectoryPath(appRootDirPath);
388642
388771
  try {
388643
388772
  await fsp4.rm(draftsDir, { recursive: true });
388644
388773
  } catch {
@@ -388723,6 +388852,117 @@ async function getDraftInfo(appRootDirPath) {
388723
388852
  await scanDirectory(draftsDir);
388724
388853
  return { edits, additions };
388725
388854
  }
388855
+ async function generateDraftDiff(appRootDirPath, specificPaths = []) {
388856
+ const draftsDir = getDraftsDirectoryPath(appRootDirPath);
388857
+ try {
388858
+ await fsp4.access(draftsDir);
388859
+ } catch {
388860
+ return "No draft changes found.";
388861
+ }
388862
+ const diffLines2 = [];
388863
+ let { edits, additions } = await getDraftInfo(appRootDirPath);
388864
+ edits = edits.filter((edit) => specificPaths.length === 0 || specificPaths.some((path46) => edit.startsWith(path46)));
388865
+ additions = additions.filter((add) => specificPaths.length === 0 || specificPaths.some((path46) => add.startsWith(path46)));
388866
+ if (edits.length === 0 && additions.length === 0) {
388867
+ return "No draft changes found.";
388868
+ }
388869
+ for (const editPath of edits) {
388870
+ const originalPath = path28.join(appRootDirPath, editPath);
388871
+ const markerPath = getMarkerFilePath(originalPath, appRootDirPath, EDIT_EXT);
388872
+ try {
388873
+ const currentContent = await fsp4.readFile(originalPath, "utf8");
388874
+ const originalContent = await fsp4.readFile(markerPath, "utf8");
388875
+ diffLines2.push(`diff --git a/${editPath} b/${editPath}`);
388876
+ diffLines2.push(`index 0000000..1000000 100644`);
388877
+ diffLines2.push(`--- a/${editPath}`);
388878
+ diffLines2.push(`+++ b/${editPath}`);
388879
+ const unifiedDiff = generateUnifiedDiff(originalContent, currentContent);
388880
+ diffLines2.push(...unifiedDiff);
388881
+ diffLines2.push("");
388882
+ } catch (_error) {
388883
+ continue;
388884
+ }
388885
+ }
388886
+ for (const addPath of additions) {
388887
+ const filePath = path28.join(appRootDirPath, addPath);
388888
+ try {
388889
+ const content2 = await fsp4.readFile(filePath, "utf8");
388890
+ diffLines2.push(`diff --git a/${addPath} b/${addPath}`);
388891
+ diffLines2.push(`new file mode 100644`);
388892
+ diffLines2.push(`index 0000000..1000000`);
388893
+ diffLines2.push(`--- /dev/null`);
388894
+ diffLines2.push(`+++ b/${addPath}`);
388895
+ diffLines2.push(`@@ -0,0 +1,${content2.split("\n").length} @@`);
388896
+ const lines = content2.split("\n");
388897
+ for (const line3 of lines) {
388898
+ diffLines2.push(`+${line3}`);
388899
+ }
388900
+ diffLines2.push("");
388901
+ } catch (_error) {
388902
+ continue;
388903
+ }
388904
+ }
388905
+ if (diffLines2[diffLines2.length - 1] === "") {
388906
+ diffLines2.pop();
388907
+ }
388908
+ return diffLines2.join("\n");
388909
+ }
388910
+ function generateUnifiedDiff(originalContent, currentContent) {
388911
+ const originalLines = originalContent.split("\n");
388912
+ const currentLines = currentContent.split("\n");
388913
+ const diffLines2 = [];
388914
+ let hasChanges = false;
388915
+ const changes = [];
388916
+ let i2 = 0, j = 0;
388917
+ while (i2 < originalLines.length || j < currentLines.length) {
388918
+ if (i2 < originalLines.length && j < currentLines.length) {
388919
+ const originalLine = originalLines[i2] ?? "";
388920
+ const currentLine = currentLines[j] ?? "";
388921
+ if (originalLine === currentLine) {
388922
+ changes.push({ type: "context", line: originalLine });
388923
+ i2++;
388924
+ j++;
388925
+ } else {
388926
+ changes.push({ type: "remove", line: originalLine });
388927
+ changes.push({ type: "add", line: currentLine });
388928
+ i2++;
388929
+ j++;
388930
+ hasChanges = true;
388931
+ }
388932
+ } else if (i2 < originalLines.length) {
388933
+ const originalLine = originalLines[i2] ?? "";
388934
+ changes.push({ type: "remove", line: originalLine });
388935
+ i2++;
388936
+ hasChanges = true;
388937
+ } else {
388938
+ const currentLine = currentLines[j] ?? "";
388939
+ changes.push({ type: "add", line: currentLine });
388940
+ j++;
388941
+ hasChanges = true;
388942
+ }
388943
+ }
388944
+ if (!hasChanges) {
388945
+ return [];
388946
+ }
388947
+ const hunkStart = 1;
388948
+ const hunkOriginalCount = originalLines.length;
388949
+ const hunkCurrentCount = currentLines.length;
388950
+ diffLines2.push(`@@ -${hunkStart},${hunkOriginalCount} +${hunkStart},${hunkCurrentCount} @@`);
388951
+ for (const change of changes) {
388952
+ switch (change.type) {
388953
+ case "context":
388954
+ diffLines2.push(` ${change.line}`);
388955
+ break;
388956
+ case "remove":
388957
+ diffLines2.push(`-${change.line}`);
388958
+ break;
388959
+ case "add":
388960
+ diffLines2.push(`+${change.line}`);
388961
+ break;
388962
+ }
388963
+ }
388964
+ return diffLines2;
388965
+ }
388726
388966
 
388727
388967
  // ../../../vite-plugin-file-sync/dist/sync-service/hash-cache.js
388728
388968
  init_cjs_shims();
@@ -389052,6 +389292,8 @@ var SyncService = class extends EventEmitter11 {
389052
389292
  this.lastSyncedDirectoryHash = directoryHash;
389053
389293
  this.synchronizationStatus = SyncronizationStatus.IN_SYNC;
389054
389294
  logger3.info("[sync-service] Synchronization finished");
389295
+ await cleanUpDraftsDirectory(this.appRootDirPath);
389296
+ this.emit("draftStateChanged", false);
389055
389297
  } catch (err) {
389056
389298
  logger3.error("[sync-service] Error synchronizing application from the server", getErrorMeta(err));
389057
389299
  throw err;
@@ -389194,6 +389436,16 @@ var SyncService = class extends EventEmitter11 {
389194
389436
  return await getDraftInfo(this.appRootDirPath);
389195
389437
  });
389196
389438
  }
389439
+ /**
389440
+ * Gets a git-like diff representation of all draft changes.
389441
+ *
389442
+ * @returns A promise that resolves to a git-like diff string.
389443
+ */
389444
+ async getDraftDiff(specificPaths) {
389445
+ return this.fsOperation(async () => {
389446
+ return await generateDraftDiff(this.appRootDirPath, specificPaths);
389447
+ });
389448
+ }
389197
389449
  /**
389198
389450
  * Creates a draft edit or addition for a file.
389199
389451
  *
@@ -389203,7 +389455,7 @@ var SyncService = class extends EventEmitter11 {
389203
389455
  */
389204
389456
  async createDraftFile(filePath, draftContent) {
389205
389457
  const logger3 = getLogger();
389206
- this.fsOperation(async () => {
389458
+ await this.fsOperation(async () => {
389207
389459
  const fullPath = `${this.appRootDirPath}/${filePath}`;
389208
389460
  const type2 = await createDraft(fullPath, draftContent, this.appRootDirPath);
389209
389461
  if (type2 === "edit") {
@@ -389241,6 +389493,7 @@ var SyncService = class extends EventEmitter11 {
389241
389493
  await commitAllDrafts(this.appRootDirPath);
389242
389494
  logger3.info("[sync-service] Local draft changes committed");
389243
389495
  });
389496
+ this.uploadDirectory();
389244
389497
  this.emit("draftStateChanged", false);
389245
389498
  }
389246
389499
  async getRpcClient() {
@@ -389552,7 +389805,7 @@ function isMetadataYarnClassic(metadataPath) {
389552
389805
  // ../sdk/dist/cli-replacement/automatic-upgrades.js
389553
389806
  var import_gt = __toESM(require_gt(), 1);
389554
389807
  var import_valid = __toESM(require_valid(), 1);
389555
- var exec2 = promisify(child_process.exec);
389808
+ var exec3 = promisify(child_process.exec);
389556
389809
  var logger2 = getLogger2();
389557
389810
  async function getRemoteCliLibraryVersions(config2) {
389558
389811
  const { token: token2, superblocksBaseUrl, id: id2 } = config2;
@@ -389585,12 +389838,12 @@ async function installPackageVersions(pm, versions) {
389585
389838
  return;
389586
389839
  }
389587
389840
  const { command, args } = installCommand;
389588
- return await exec2(`${command} ${args.join(" ")}`);
389841
+ return await exec3(`${command} ${args.join(" ")}`);
389589
389842
  }
389590
389843
  async function findSuperblocksExecutable() {
389591
389844
  try {
389592
389845
  const command = process.platform === "win32" ? "where" : "which";
389593
- const { stdout } = await exec2(`${command} superblocks`);
389846
+ const { stdout } = await exec3(`${command} superblocks`);
389594
389847
  return stdout.trim();
389595
389848
  } catch {
389596
389849
  return void 0;
@@ -389608,7 +389861,7 @@ async function getLocalCliVersion() {
389608
389861
  if (!superblocksPath) {
389609
389862
  return void 0;
389610
389863
  }
389611
- const { stdout } = await exec2(`${superblocksPath} version --json`);
389864
+ const { stdout } = await exec3(`${superblocksPath} version --json`);
389612
389865
  const json2 = JSON.parse(stdout);
389613
389866
  return json2.cliVersion?.replace(/@superblocksteam\/cli(-ephemeral)?\//, "");
389614
389867
  } catch (error) {
@@ -389622,14 +389875,14 @@ async function getLocalPackageVersion(pm, pkg, global2) {
389622
389875
  try {
389623
389876
  switch (pm.agent) {
389624
389877
  case "npm": {
389625
- const { stdout } = await exec2(`npm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, {
389878
+ const { stdout } = await exec3(`npm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, {
389626
389879
  cwd: process.cwd()
389627
389880
  });
389628
389881
  const parsed = JSON.parse(stdout);
389629
389882
  return parsed.dependencies?.[`@superblocksteam/${pkg}`]?.version ?? parsed.devDependencies?.[`@superblocksteam/${pkg}`]?.version;
389630
389883
  }
389631
389884
  case "pnpm": {
389632
- const { stdout } = await exec2(`pnpm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, { cwd: process.cwd() });
389885
+ const { stdout } = await exec3(`pnpm list ${global2 ? "--global" : ""} @superblocksteam/${pkg} --json`, { cwd: process.cwd() });
389633
389886
  const parsed = JSON.parse(stdout);
389634
389887
  return parsed[0]?.dependencies?.[`@superblocksteam/${pkg}`]?.version ?? parsed[0]?.devDependencies?.[`@superblocksteam/${pkg}`]?.version;
389635
389888
  }
@@ -389649,7 +389902,7 @@ async function tryCliUpdateCommand(version2) {
389649
389902
  if (!superblocksPath) {
389650
389903
  return false;
389651
389904
  }
389652
- const { stdout } = await exec2(`${superblocksPath} update --version=${version2}`);
389905
+ const { stdout } = await exec3(`${superblocksPath} update --version=${version2}`);
389653
389906
  return !stdout.includes("not updatable");
389654
389907
  } catch (error) {
389655
389908
  if (isNativeError(error)) {
@@ -392899,7 +393152,7 @@ Would you like to also delete these resources from your filesystem?`
392899
393152
  // src/commands/components/create.mts
392900
393153
  init_cjs_shims();
392901
393154
  var import_util38 = __toESM(require_dist4(), 1);
392902
- import { exec as exec3 } from "node:child_process";
393155
+ import { exec as exec4 } from "node:child_process";
392903
393156
  import { randomUUID as randomUUID3 } from "node:crypto";
392904
393157
  import path34 from "node:path";
392905
393158
  import util5 from "node:util";
@@ -393297,7 +393550,7 @@ var CreateComponent = class _CreateComponent extends AuthenticatedApplicationCom
393297
393550
  if (isFirstTimeCreate) {
393298
393551
  ux2.action.start("Installing dependencies...");
393299
393552
  try {
393300
- await util5.promisify(exec3)("npm i");
393553
+ await util5.promisify(exec4)("npm i");
393301
393554
  } catch {
393302
393555
  ux2.action.stop();
393303
393556
  this.error(
@@ -394493,7 +394746,7 @@ var Login = class _Login extends Command5 {
394493
394746
 
394494
394747
  // src/commands/migrate.mts
394495
394748
  init_cjs_shims();
394496
- import { exec as exec4 } from "node:child_process";
394749
+ import { exec as exec5 } from "node:child_process";
394497
394750
  import path40 from "node:path";
394498
394751
  import util6 from "node:util";
394499
394752
  var import_util47 = __toESM(require_dist4(), 1);
@@ -394682,7 +394935,7 @@ var Migrate = class extends AuthenticatedCommand {
394682
394935
  const versionStr = packageJson.dependencies?.["@superblocksteam/custom-components"];
394683
394936
  if (!import_semver8.default.satisfies(this.config.version, versionStr)) {
394684
394937
  this.log("Migrating application dependencies...");
394685
- await util6.promisify(exec4)(
394938
+ await util6.promisify(exec5)(
394686
394939
  `npm install @superblocksteam/custom-components@${this.config.version}`,
394687
394940
  {
394688
394941
  cwd: path40.join(superblocksRootPath, applicationResource.location)
@@ -509,5 +509,5 @@
509
509
  "strict": true
510
510
  }
511
511
  },
512
- "version": "2.0.3-next.121"
512
+ "version": "2.0.3-next.123"
513
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/cli",
3
- "version": "2.0.3-next.121",
3
+ "version": "2.0.3-next.123",
4
4
  "type": "module",
5
5
  "description": "Official Superblocks CLI",
6
6
  "homepage": "https://www.superblocks.com",
@@ -42,9 +42,9 @@
42
42
  "devDependencies": {
43
43
  "@eslint/js": "^9.16.0",
44
44
  "@oclif/test": "^4.1.11",
45
- "@superblocksteam/sdk": "2.0.3-next.121",
45
+ "@superblocksteam/sdk": "2.0.3-next.123",
46
46
  "@superblocksteam/shared": "^0.9081.0",
47
- "@superblocksteam/util": "2.0.3-next.121",
47
+ "@superblocksteam/util": "2.0.3-next.123",
48
48
  "@types/babel__core": "^7.20.0",
49
49
  "@types/chai": "^4",
50
50
  "@types/fs-extra": "^11.0.1",