snow-ai 0.5.16 → 0.5.17

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/bundle/cli.mjs CHANGED
@@ -46526,6 +46526,12 @@ var init_codebaseConfig = __esm({
46526
46526
  batch: {
46527
46527
  maxLines: 10,
46528
46528
  concurrency: 3
46529
+ },
46530
+ chunking: {
46531
+ maxLinesPerChunk: 200,
46532
+ minLinesPerChunk: 10,
46533
+ minCharsPerChunk: 20,
46534
+ overlapLines: 20
46529
46535
  }
46530
46536
  };
46531
46537
  getConfigDir = () => {
@@ -46540,7 +46546,7 @@ var init_codebaseConfig = __esm({
46540
46546
  return path7.join(getConfigDir(), "codebase.json");
46541
46547
  };
46542
46548
  loadCodebaseConfig = () => {
46543
- var _a21, _b14, _c6, _d4, _e2, _f, _g;
46549
+ var _a21, _b14, _c6, _d4, _e2, _f, _g, _h, _i, _j, _k;
46544
46550
  try {
46545
46551
  const configPath = getConfigPath();
46546
46552
  if (!fs7.existsSync(configPath)) {
@@ -46561,6 +46567,12 @@ var init_codebaseConfig = __esm({
46561
46567
  batch: {
46562
46568
  maxLines: ((_f = config3.batch) == null ? void 0 : _f.maxLines) ?? DEFAULT_CONFIG.batch.maxLines,
46563
46569
  concurrency: ((_g = config3.batch) == null ? void 0 : _g.concurrency) ?? DEFAULT_CONFIG.batch.concurrency
46570
+ },
46571
+ chunking: {
46572
+ maxLinesPerChunk: ((_h = config3.chunking) == null ? void 0 : _h.maxLinesPerChunk) ?? DEFAULT_CONFIG.chunking.maxLinesPerChunk,
46573
+ minLinesPerChunk: ((_i = config3.chunking) == null ? void 0 : _i.minLinesPerChunk) ?? DEFAULT_CONFIG.chunking.minLinesPerChunk,
46574
+ minCharsPerChunk: ((_j = config3.chunking) == null ? void 0 : _j.minCharsPerChunk) ?? DEFAULT_CONFIG.chunking.minCharsPerChunk,
46575
+ overlapLines: ((_k = config3.chunking) == null ? void 0 : _k.overlapLines) ?? DEFAULT_CONFIG.chunking.overlapLines
46564
46576
  }
46565
46577
  };
46566
46578
  } catch (error) {
@@ -81023,6 +81035,15 @@ var init_en = __esm({
81023
81035
  validationDimensionsPositive: "Embedding dimensions must be greater than 0",
81024
81036
  validationMaxLinesPositive: "Batch max lines must be greater than 0",
81025
81037
  validationConcurrencyPositive: "Batch concurrency must be greater than 0",
81038
+ validationMaxLinesPerChunkPositive: "Max lines per chunk must be greater than 0",
81039
+ validationMinLinesPerChunkPositive: "Min lines per chunk must be greater than 0",
81040
+ validationMinCharsPerChunkPositive: "Min characters per chunk must be greater than 0",
81041
+ validationOverlapLinesNonNegative: "Overlap lines must be non-negative",
81042
+ validationOverlapLessThanMaxLines: "Overlap lines must be less than max lines per chunk",
81043
+ chunkingMaxLinesPerChunk: "Max Lines Per Chunk:",
81044
+ chunkingMinLinesPerChunk: "Min Lines Per Chunk:",
81045
+ chunkingMinCharsPerChunk: "Min Characters Per Chunk:",
81046
+ chunkingOverlapLines: "Overlap Lines:",
81026
81047
  saveError: "Failed to save configuration"
81027
81048
  },
81028
81049
  systemPromptConfig: {
@@ -81918,6 +81939,15 @@ var init_zh = __esm({
81918
81939
  validationDimensionsPositive: "\u5D4C\u5165\u7EF4\u5EA6\u5FC5\u987B\u5927\u4E8E 0",
81919
81940
  validationMaxLinesPositive: "\u6279\u5904\u7406\u6700\u5927\u884C\u6570\u5FC5\u987B\u5927\u4E8E 0",
81920
81941
  validationConcurrencyPositive: "\u6279\u5904\u7406\u5E76\u53D1\u6570\u5FC5\u987B\u5927\u4E8E 0",
81942
+ validationMaxLinesPerChunkPositive: "\u6BCF\u5757\u6700\u5927\u884C\u6570\u5FC5\u987B\u5927\u4E8E 0",
81943
+ validationMinLinesPerChunkPositive: "\u6BCF\u5757\u6700\u5C0F\u884C\u6570\u5FC5\u987B\u5927\u4E8E 0",
81944
+ validationMinCharsPerChunkPositive: "\u6BCF\u5757\u6700\u5C0F\u5B57\u7B26\u6570\u5FC5\u987B\u5927\u4E8E 0",
81945
+ validationOverlapLinesNonNegative: "\u91CD\u53E0\u884C\u6570\u5FC5\u987B\u4E3A\u975E\u8D1F\u6570",
81946
+ validationOverlapLessThanMaxLines: "\u91CD\u53E0\u884C\u6570\u5FC5\u987B\u5C0F\u4E8E\u6BCF\u5757\u6700\u5927\u884C\u6570",
81947
+ chunkingMaxLinesPerChunk: "\u6BCF\u5757\u6700\u5927\u884C\u6570:",
81948
+ chunkingMinLinesPerChunk: "\u6BCF\u5757\u6700\u5C0F\u884C\u6570:",
81949
+ chunkingMinCharsPerChunk: "\u6BCF\u5757\u6700\u5C0F\u5B57\u7B26\u6570:",
81950
+ chunkingOverlapLines: "\u91CD\u53E0\u884C\u6570:",
81921
81951
  saveError: "\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25"
81922
81952
  },
81923
81953
  systemPromptConfig: {
@@ -82813,6 +82843,15 @@ var init_zh_TW = __esm({
82813
82843
  validationDimensionsPositive: "\u5D4C\u5165\u7DAD\u5EA6\u5FC5\u9808\u5927\u65BC 0",
82814
82844
  validationMaxLinesPositive: "\u6279\u6B21\u8655\u7406\u6700\u5927\u884C\u6578\u5FC5\u9808\u5927\u65BC 0",
82815
82845
  validationConcurrencyPositive: "\u6279\u6B21\u8655\u7406\u4E26\u884C\u6578\u5FC5\u9808\u5927\u65BC 0",
82846
+ validationMaxLinesPerChunkPositive: "\u6BCF\u584A\u6700\u5927\u884C\u6578\u5FC5\u9808\u5927\u65BC 0",
82847
+ validationMinLinesPerChunkPositive: "\u6BCF\u584A\u6700\u5C0F\u884C\u6578\u5FC5\u9808\u5927\u65BC 0",
82848
+ validationMinCharsPerChunkPositive: "\u6BCF\u584A\u6700\u5C0F\u5B57\u5143\u6578\u5FC5\u9808\u5927\u65BC 0",
82849
+ validationOverlapLinesNonNegative: "\u91CD\u758A\u884C\u6578\u5FC5\u9808\u70BA\u975E\u8CA0\u6578",
82850
+ validationOverlapLessThanMaxLines: "\u91CD\u758A\u884C\u6578\u5FC5\u9808\u5C0F\u65BC\u6BCF\u584A\u6700\u5927\u884C\u6578",
82851
+ chunkingMaxLinesPerChunk: "\u6BCF\u584A\u6700\u5927\u884C\u6578:",
82852
+ chunkingMinLinesPerChunk: "\u6BCF\u584A\u6700\u5C0F\u884C\u6578:",
82853
+ chunkingMinCharsPerChunk: "\u6BCF\u584A\u6700\u5C0F\u5B57\u5143\u6578:",
82854
+ chunkingOverlapLines: "\u91CD\u758A\u884C\u6578:",
82816
82855
  saveError: "\u5132\u5B58\u914D\u7F6E\u5931\u6557"
82817
82856
  },
82818
82857
  systemPromptConfig: {
@@ -83703,6 +83742,15 @@ var init_ja = __esm({
83703
83742
  validationDimensionsPositive: "\u57CB\u3081\u8FBC\u307F\u6B21\u5143\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83704
83743
  validationMaxLinesPositive: "\u30D0\u30C3\u30C1\u6700\u5927\u884C\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83705
83744
  validationConcurrencyPositive: "\u30D0\u30C3\u30C1\u4E26\u884C\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83745
+ validationMaxLinesPerChunkPositive: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5927\u884C\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83746
+ validationMinLinesPerChunkPositive: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5C0F\u884C\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83747
+ validationMinCharsPerChunkPositive: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5C0F\u6587\u5B57\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83748
+ validationOverlapLinesNonNegative: "\u91CD\u8907\u884C\u6570\u306F0\u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83749
+ validationOverlapLessThanMaxLines: "\u91CD\u8907\u884C\u6570\u306F\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5927\u884C\u6570\u3088\u308A\u5C0F\u3055\u304F\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
83750
+ chunkingMaxLinesPerChunk: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5927\u884C\u6570:",
83751
+ chunkingMinLinesPerChunk: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5C0F\u884C\u6570:",
83752
+ chunkingMinCharsPerChunk: "\u30C1\u30E3\u30F3\u30AF\u3042\u305F\u308A\u306E\u6700\u5C0F\u6587\u5B57\u6570:",
83753
+ chunkingOverlapLines: "\u91CD\u8907\u884C\u6570:",
83706
83754
  saveError: "\u69CB\u6210\u306E\u4FDD\u5B58\u306B\u5931\u6557"
83707
83755
  },
83708
83756
  systemPromptConfig: {
@@ -84593,6 +84641,15 @@ var init_ko = __esm({
84593
84641
  validationDimensionsPositive: "\uC784\uBCA0\uB529 \uCC28\uC6D0\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84594
84642
  validationMaxLinesPositive: "\uBC30\uCE58 \uCD5C\uB300 \uB77C\uC778 \uC218\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84595
84643
  validationConcurrencyPositive: "\uBC30\uCE58 \uB3D9\uC2DC\uC131\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84644
+ validationMaxLinesPerChunkPositive: "\uCCAD\uD06C\uB2F9 \uCD5C\uB300 \uB77C\uC778 \uC218\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84645
+ validationMinLinesPerChunkPositive: "\uCCAD\uD06C\uB2F9 \uCD5C\uC18C \uB77C\uC778 \uC218\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84646
+ validationMinCharsPerChunkPositive: "\uCCAD\uD06C\uB2F9 \uCD5C\uC18C \uBB38\uC790 \uC218\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4",
84647
+ validationOverlapLinesNonNegative: "\uC911\uCCA9 \uB77C\uC778 \uC218\uB294 \uC74C\uC218\uAC00 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4",
84648
+ validationOverlapLessThanMaxLines: "\uC911\uCCA9 \uB77C\uC778 \uC218\uB294 \uCCAD\uD06C\uB2F9 \uCD5C\uB300 \uB77C\uC778 \uC218\uBCF4\uB2E4 \uC791\uC544\uC57C \uD569\uB2C8\uB2E4",
84649
+ chunkingMaxLinesPerChunk: "\uCCAD\uD06C\uB2F9 \uCD5C\uB300 \uB77C\uC778 \uC218:",
84650
+ chunkingMinLinesPerChunk: "\uCCAD\uD06C\uB2F9 \uCD5C\uC18C \uB77C\uC778 \uC218:",
84651
+ chunkingMinCharsPerChunk: "\uCCAD\uD06C\uB2F9 \uCD5C\uC18C \uBB38\uC790 \uC218:",
84652
+ chunkingOverlapLines: "\uC911\uCCA9 \uB77C\uC778 \uC218:",
84596
84653
  saveError: "\uAD6C\uC131 \uC800\uC7A5 \uC2E4\uD328"
84597
84654
  },
84598
84655
  systemPromptConfig: {
@@ -85483,6 +85540,15 @@ var init_es = __esm({
85483
85540
  validationDimensionsPositive: "Las dimensiones de incrustaci\xF3n deben ser mayores que 0",
85484
85541
  validationMaxLinesPositive: "El m\xE1ximo de l\xEDneas por lote debe ser mayor que 0",
85485
85542
  validationConcurrencyPositive: "La concurrencia de lote debe ser mayor que 0",
85543
+ validationMaxLinesPerChunkPositive: "Las l\xEDneas m\xE1ximas por fragmento deben ser mayores que 0",
85544
+ validationMinLinesPerChunkPositive: "Las l\xEDneas m\xEDnimas por fragmento deben ser mayores que 0",
85545
+ validationMinCharsPerChunkPositive: "Los caracteres m\xEDnimos por fragmento deben ser mayores que 0",
85546
+ validationOverlapLinesNonNegative: "Las l\xEDneas de superposici\xF3n deben ser no negativas",
85547
+ validationOverlapLessThanMaxLines: "Las l\xEDneas de superposici\xF3n deben ser menores que las l\xEDneas m\xE1ximas por fragmento",
85548
+ chunkingMaxLinesPerChunk: "L\xEDneas M\xE1ximas por Fragmento:",
85549
+ chunkingMinLinesPerChunk: "L\xEDneas M\xEDnimas por Fragmento:",
85550
+ chunkingMinCharsPerChunk: "Caracteres M\xEDnimos por Fragmento:",
85551
+ chunkingOverlapLines: "L\xEDneas de Superposici\xF3n:",
85486
85552
  saveError: "Error al guardar la configuraci\xF3n"
85487
85553
  },
85488
85554
  systemPromptConfig: {
@@ -440787,6 +440853,10 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440787
440853
  const [embeddingDimensions, setEmbeddingDimensions] = (0, import_react68.useState)(1536);
440788
440854
  const [batchMaxLines, setBatchMaxLines] = (0, import_react68.useState)(10);
440789
440855
  const [batchConcurrency, setBatchConcurrency] = (0, import_react68.useState)(1);
440856
+ const [chunkingMaxLinesPerChunk, setChunkingMaxLinesPerChunk] = (0, import_react68.useState)(200);
440857
+ const [chunkingMinLinesPerChunk, setChunkingMinLinesPerChunk] = (0, import_react68.useState)(10);
440858
+ const [chunkingMinCharsPerChunk, setChunkingMinCharsPerChunk] = (0, import_react68.useState)(20);
440859
+ const [chunkingOverlapLines, setChunkingOverlapLines] = (0, import_react68.useState)(20);
440790
440860
  const [currentField, setCurrentField] = (0, import_react68.useState)("enabled");
440791
440861
  const [isEditing, setIsEditing] = (0, import_react68.useState)(false);
440792
440862
  const [errors, setErrors] = (0, import_react68.useState)([]);
@@ -440800,10 +440870,14 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440800
440870
  "embeddingApiKey",
440801
440871
  "embeddingDimensions",
440802
440872
  "batchMaxLines",
440803
- "batchConcurrency"
440873
+ "batchConcurrency",
440874
+ "chunkingMaxLinesPerChunk",
440875
+ "chunkingMinLinesPerChunk",
440876
+ "chunkingMinCharsPerChunk",
440877
+ "chunkingOverlapLines"
440804
440878
  ];
440805
440879
  const embeddingTypeOptions = [
440806
- { label: "Jina", value: "jina" },
440880
+ { label: "Jina & OpenAI", value: "jina" },
440807
440881
  { label: "Ollama", value: "ollama" }
440808
440882
  ];
440809
440883
  const currentFieldIndex = allFields.indexOf(currentField);
@@ -440822,6 +440896,10 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440822
440896
  setEmbeddingDimensions(config3.embedding.dimensions);
440823
440897
  setBatchMaxLines(config3.batch.maxLines);
440824
440898
  setBatchConcurrency(config3.batch.concurrency);
440899
+ setChunkingMaxLinesPerChunk(config3.chunking.maxLinesPerChunk);
440900
+ setChunkingMinLinesPerChunk(config3.chunking.minLinesPerChunk);
440901
+ setChunkingMinCharsPerChunk(config3.chunking.minCharsPerChunk);
440902
+ setChunkingOverlapLines(config3.chunking.overlapLines);
440825
440903
  };
440826
440904
  const saveConfiguration = () => {
440827
440905
  const validationErrors = [];
@@ -440841,6 +440919,21 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440841
440919
  if (batchConcurrency <= 0) {
440842
440920
  validationErrors.push(t.codebaseConfig.validationConcurrencyPositive);
440843
440921
  }
440922
+ if (chunkingMaxLinesPerChunk <= 0) {
440923
+ validationErrors.push(t.codebaseConfig.validationMaxLinesPerChunkPositive);
440924
+ }
440925
+ if (chunkingMinLinesPerChunk <= 0) {
440926
+ validationErrors.push(t.codebaseConfig.validationMinLinesPerChunkPositive);
440927
+ }
440928
+ if (chunkingMinCharsPerChunk <= 0) {
440929
+ validationErrors.push(t.codebaseConfig.validationMinCharsPerChunkPositive);
440930
+ }
440931
+ if (chunkingOverlapLines < 0) {
440932
+ validationErrors.push(t.codebaseConfig.validationOverlapLinesNonNegative);
440933
+ }
440934
+ if (chunkingOverlapLines >= chunkingMaxLinesPerChunk) {
440935
+ validationErrors.push(t.codebaseConfig.validationOverlapLessThanMaxLines);
440936
+ }
440844
440937
  }
440845
440938
  if (validationErrors.length > 0) {
440846
440939
  setErrors(validationErrors);
@@ -440860,6 +440953,12 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440860
440953
  batch: {
440861
440954
  maxLines: batchMaxLines,
440862
440955
  concurrency: batchConcurrency
440956
+ },
440957
+ chunking: {
440958
+ maxLinesPerChunk: chunkingMaxLinesPerChunk,
440959
+ minLinesPerChunk: chunkingMinLinesPerChunk,
440960
+ minCharsPerChunk: chunkingMinCharsPerChunk,
440961
+ overlapLines: chunkingOverlapLines
440863
440962
  }
440864
440963
  };
440865
440964
  saveCodebaseConfig(config3);
@@ -440948,9 +441047,7 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
440948
441047
  { color: theme14.colors.menuSecondary },
440949
441048
  ((_a21 = embeddingTypeOptions.find((opt) => opt.value === embeddingType)) == null ? void 0 : _a21.label) || t.codebaseConfig.notSet,
440950
441049
  " ",
440951
- "(",
440952
- t.codebaseConfig.toggleHint,
440953
- ")"
441050
+ t.codebaseConfig.toggleHint
440954
441051
  )
440955
441052
  )
440956
441053
  );
@@ -441119,6 +441216,126 @@ function CodeBaseConfigScreen({ onBack, onSave, inlineMode = false }) {
441119
441216
  import_react68.default.createElement(Text, { color: theme14.colors.menuSecondary }, batchConcurrency)
441120
441217
  )
441121
441218
  );
441219
+ case "chunkingMaxLinesPerChunk":
441220
+ return import_react68.default.createElement(
441221
+ Box_default,
441222
+ { key: field, flexDirection: "column" },
441223
+ import_react68.default.createElement(
441224
+ Text,
441225
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
441226
+ isActive ? "\u276F " : " ",
441227
+ t.codebaseConfig.chunkingMaxLinesPerChunk
441228
+ ),
441229
+ isCurrentlyEditing && import_react68.default.createElement(
441230
+ Box_default,
441231
+ { marginLeft: 3 },
441232
+ import_react68.default.createElement(
441233
+ Text,
441234
+ { color: theme14.colors.menuInfo },
441235
+ import_react68.default.createElement(build_default2, { value: chunkingMaxLinesPerChunk.toString(), onChange: (value) => {
441236
+ const num = parseInt(stripFocusArtifacts4(value) || "0");
441237
+ if (!isNaN(num)) {
441238
+ setChunkingMaxLinesPerChunk(num);
441239
+ }
441240
+ }, onSubmit: () => setIsEditing(false) })
441241
+ )
441242
+ ),
441243
+ !isCurrentlyEditing && import_react68.default.createElement(
441244
+ Box_default,
441245
+ { marginLeft: 3 },
441246
+ import_react68.default.createElement(Text, { color: theme14.colors.menuSecondary }, chunkingMaxLinesPerChunk)
441247
+ )
441248
+ );
441249
+ case "chunkingMinLinesPerChunk":
441250
+ return import_react68.default.createElement(
441251
+ Box_default,
441252
+ { key: field, flexDirection: "column" },
441253
+ import_react68.default.createElement(
441254
+ Text,
441255
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
441256
+ isActive ? "\u276F " : " ",
441257
+ t.codebaseConfig.chunkingMinLinesPerChunk
441258
+ ),
441259
+ isCurrentlyEditing && import_react68.default.createElement(
441260
+ Box_default,
441261
+ { marginLeft: 3 },
441262
+ import_react68.default.createElement(
441263
+ Text,
441264
+ { color: theme14.colors.menuInfo },
441265
+ import_react68.default.createElement(build_default2, { value: chunkingMinLinesPerChunk.toString(), onChange: (value) => {
441266
+ const num = parseInt(stripFocusArtifacts4(value) || "0");
441267
+ if (!isNaN(num)) {
441268
+ setChunkingMinLinesPerChunk(num);
441269
+ }
441270
+ }, onSubmit: () => setIsEditing(false) })
441271
+ )
441272
+ ),
441273
+ !isCurrentlyEditing && import_react68.default.createElement(
441274
+ Box_default,
441275
+ { marginLeft: 3 },
441276
+ import_react68.default.createElement(Text, { color: theme14.colors.menuSecondary }, chunkingMinLinesPerChunk)
441277
+ )
441278
+ );
441279
+ case "chunkingMinCharsPerChunk":
441280
+ return import_react68.default.createElement(
441281
+ Box_default,
441282
+ { key: field, flexDirection: "column" },
441283
+ import_react68.default.createElement(
441284
+ Text,
441285
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
441286
+ isActive ? "\u276F " : " ",
441287
+ t.codebaseConfig.chunkingMinCharsPerChunk
441288
+ ),
441289
+ isCurrentlyEditing && import_react68.default.createElement(
441290
+ Box_default,
441291
+ { marginLeft: 3 },
441292
+ import_react68.default.createElement(
441293
+ Text,
441294
+ { color: theme14.colors.menuInfo },
441295
+ import_react68.default.createElement(build_default2, { value: chunkingMinCharsPerChunk.toString(), onChange: (value) => {
441296
+ const num = parseInt(stripFocusArtifacts4(value) || "0");
441297
+ if (!isNaN(num)) {
441298
+ setChunkingMinCharsPerChunk(num);
441299
+ }
441300
+ }, onSubmit: () => setIsEditing(false) })
441301
+ )
441302
+ ),
441303
+ !isCurrentlyEditing && import_react68.default.createElement(
441304
+ Box_default,
441305
+ { marginLeft: 3 },
441306
+ import_react68.default.createElement(Text, { color: theme14.colors.menuSecondary }, chunkingMinCharsPerChunk)
441307
+ )
441308
+ );
441309
+ case "chunkingOverlapLines":
441310
+ return import_react68.default.createElement(
441311
+ Box_default,
441312
+ { key: field, flexDirection: "column" },
441313
+ import_react68.default.createElement(
441314
+ Text,
441315
+ { color: isActive ? theme14.colors.menuSelected : theme14.colors.menuNormal },
441316
+ isActive ? "\u276F " : " ",
441317
+ t.codebaseConfig.chunkingOverlapLines
441318
+ ),
441319
+ isCurrentlyEditing && import_react68.default.createElement(
441320
+ Box_default,
441321
+ { marginLeft: 3 },
441322
+ import_react68.default.createElement(
441323
+ Text,
441324
+ { color: theme14.colors.menuInfo },
441325
+ import_react68.default.createElement(build_default2, { value: chunkingOverlapLines.toString(), onChange: (value) => {
441326
+ const num = parseInt(stripFocusArtifacts4(value) || "0");
441327
+ if (!isNaN(num)) {
441328
+ setChunkingOverlapLines(num);
441329
+ }
441330
+ }, onSubmit: () => setIsEditing(false) })
441331
+ )
441332
+ ),
441333
+ !isCurrentlyEditing && import_react68.default.createElement(
441334
+ Box_default,
441335
+ { marginLeft: 3 },
441336
+ import_react68.default.createElement(Text, { color: theme14.colors.menuSecondary }, chunkingOverlapLines)
441337
+ )
441338
+ );
441122
441339
  default:
441123
441340
  return null;
441124
441341
  }
@@ -528918,9 +529135,9 @@ var init_hashBasedSnapshot = __esm({
528918
529135
  }
528919
529136
  }
528920
529137
  /**
528921
- * Scan directory recursively and collect file states WITH CONTENT
529138
+ * Scan directory recursively and collect file states (metadata only, no content)
528922
529139
  */
528923
- async scanDirectory(dirPath, workspaceRoot, fileStates) {
529140
+ async scanDirectory(dirPath, workspaceRoot, fileStates, includeContent = false) {
528924
529141
  try {
528925
529142
  const entries = await fs36.readdir(dirPath, { withFileTypes: true });
528926
529143
  for (const entry of entries) {
@@ -528930,19 +529147,26 @@ var init_hashBasedSnapshot = __esm({
528930
529147
  continue;
528931
529148
  }
528932
529149
  if (entry.isDirectory()) {
528933
- await this.scanDirectory(fullPath, workspaceRoot, fileStates);
529150
+ await this.scanDirectory(fullPath, workspaceRoot, fileStates, includeContent);
528934
529151
  } else if (entry.isFile()) {
528935
529152
  try {
528936
529153
  const stats = await fs36.stat(fullPath);
528937
- const content = await fs36.readFile(fullPath, "utf-8");
528938
- const hash = crypto4.createHash("sha256").update(content).digest("hex");
529154
+ let content = "";
529155
+ let hash = "";
529156
+ if (includeContent) {
529157
+ content = await fs36.readFile(fullPath, "utf-8");
529158
+ hash = crypto4.createHash("sha256").update(content).digest("hex");
529159
+ } else {
529160
+ const buffer = await fs36.readFile(fullPath);
529161
+ hash = crypto4.createHash("sha256").update(buffer).digest("hex");
529162
+ }
528939
529163
  fileStates.set(relativePath, {
528940
529164
  path: relativePath,
528941
529165
  hash,
528942
529166
  size: stats.size,
528943
529167
  mtime: stats.mtimeMs,
528944
- content
528945
- // CRITICAL: Store original content for rollback
529168
+ content: includeContent ? content : ""
529169
+ // Only store content if requested
528946
529170
  });
528947
529171
  } catch (error) {
528948
529172
  }
@@ -528977,7 +529201,8 @@ var init_hashBasedSnapshot = __esm({
528977
529201
  */
528978
529202
  async createSnapshot(sessionId, messageIndex, workspaceRoot = process.cwd()) {
528979
529203
  const beforeStateMap = await this.scanWorkspace(workspaceRoot);
528980
- this.activeSnapshots.set(messageIndex, {
529204
+ const snapshotKey = `${sessionId}:${messageIndex}`;
529205
+ this.activeSnapshots.set(snapshotKey, {
528981
529206
  metadata: {
528982
529207
  sessionId,
528983
529208
  messageIndex,
@@ -528987,25 +529212,31 @@ var init_hashBasedSnapshot = __esm({
528987
529212
  },
528988
529213
  beforeStateMap
528989
529214
  });
528990
- logger.info(`[Snapshot] Created snapshot for message ${messageIndex}`);
529215
+ logger.info(`[Snapshot] Created snapshot for session ${sessionId} message ${messageIndex}`);
528991
529216
  }
528992
529217
  /**
528993
529218
  * Commit snapshot after message processing
528994
529219
  * Compares current workspace state with snapshot and saves changes
528995
- * @param messageIndex The message index to commit (if not provided, commits the oldest snapshot)
529220
+ * @param sessionId The session ID (required for session isolation)
529221
+ * @param messageIndex The message index to commit (if not provided, commits the oldest snapshot for this session)
528996
529222
  * @returns Object with fileCount and messageIndex, or null if no active snapshot
528997
529223
  */
528998
- async commitSnapshot(messageIndex) {
529224
+ async commitSnapshot(sessionId, messageIndex) {
528999
529225
  if (messageIndex === void 0) {
529000
529226
  const keys2 = Array.from(this.activeSnapshots.keys());
529001
- if (keys2.length === 0) {
529227
+ const sessionKeys = keys2.filter((key) => key.startsWith(`${sessionId}:`)).map((key) => {
529228
+ const parts = key.split(":");
529229
+ return parseInt(parts[1] || "0", 10);
529230
+ }).filter((index) => !isNaN(index));
529231
+ if (sessionKeys.length === 0) {
529002
529232
  return null;
529003
529233
  }
529004
- messageIndex = Math.min(...keys2);
529234
+ messageIndex = Math.min(...sessionKeys);
529005
529235
  }
529006
- const snapshot = this.activeSnapshots.get(messageIndex);
529236
+ const snapshotKey = `${sessionId}:${messageIndex}`;
529237
+ const snapshot = this.activeSnapshots.get(snapshotKey);
529007
529238
  if (!snapshot) {
529008
- logger.warn(`[Snapshot] No active snapshot found for message ${messageIndex}`);
529239
+ logger.warn(`[Snapshot] No active snapshot found for session ${sessionId} message ${messageIndex}`);
529009
529240
  return null;
529010
529241
  }
529011
529242
  const { metadata, beforeStateMap } = snapshot;
@@ -529033,21 +529264,25 @@ var init_hashBasedSnapshot = __esm({
529033
529264
  });
529034
529265
  }
529035
529266
  } else if (beforeState.hash !== afterState.hash) {
529036
- changedFiles.push({
529037
- path: relativePath,
529038
- content: beforeState.content ?? null,
529039
- // FIXED: Use stored original content
529040
- existed: true,
529041
- hash: beforeState.hash
529042
- });
529267
+ try {
529268
+ const content = await fs36.readFile(fullPath, "utf-8");
529269
+ changedFiles.push({
529270
+ path: relativePath,
529271
+ content,
529272
+ existed: true,
529273
+ hash: beforeState.hash
529274
+ });
529275
+ } catch (error) {
529276
+ logger.warn(`Failed to read modified file ${relativePath}:`, error);
529277
+ }
529043
529278
  }
529044
529279
  }
529045
529280
  for (const [relativePath, afterState] of afterStateMap) {
529046
529281
  if (!beforeStateMap.has(relativePath)) {
529047
529282
  changedFiles.push({
529048
529283
  path: relativePath,
529049
- content: afterState.content ?? null,
529050
- // Save new file content
529284
+ content: null,
529285
+ // No need to store content for new files
529051
529286
  existed: false,
529052
529287
  hash: afterState.hash
529053
529288
  });
@@ -529056,11 +529291,11 @@ var init_hashBasedSnapshot = __esm({
529056
529291
  if (changedFiles.length > 0) {
529057
529292
  metadata.backups = changedFiles;
529058
529293
  await this.saveSnapshotMetadata(metadata);
529059
- logger.info(`[Snapshot] Committed: ${changedFiles.length} files changed for message ${messageIndex}`);
529294
+ logger.info(`[Snapshot] Committed: ${changedFiles.length} files changed for session ${sessionId} message ${messageIndex}`);
529060
529295
  } else {
529061
- logger.info(`[Snapshot] No changes detected for message ${messageIndex}`);
529296
+ logger.info(`[Snapshot] No changes detected for session ${sessionId} message ${messageIndex}`);
529062
529297
  }
529063
- this.activeSnapshots.delete(messageIndex);
529298
+ this.activeSnapshots.delete(snapshotKey);
529064
529299
  return { fileCount: changedFiles.length, messageIndex };
529065
529300
  }
529066
529301
  /**
@@ -529124,32 +529359,36 @@ var init_hashBasedSnapshot = __esm({
529124
529359
  }
529125
529360
  /**
529126
529361
  * Rollback to a specific message index
529362
+ * Uses streaming approach to minimize memory usage
529127
529363
  */
529128
529364
  async rollbackToMessageIndex(sessionId, targetMessageIndex, selectedFiles) {
529129
529365
  await this.ensureSnapshotsDir();
529130
529366
  try {
529131
529367
  const files = await fs36.readdir(this.snapshotsDir);
529132
- const snapshots = [];
529368
+ const snapshotFiles = [];
529133
529369
  for (const file of files) {
529134
529370
  if (file.startsWith(sessionId) && file.endsWith(".json")) {
529135
529371
  const snapshotPath = path44.join(this.snapshotsDir, file);
529136
529372
  const content = await fs36.readFile(snapshotPath, "utf-8");
529137
529373
  const metadata = JSON.parse(content);
529138
- snapshots.push({
529139
- messageIndex: metadata.messageIndex,
529140
- path: snapshotPath,
529141
- metadata
529142
- });
529374
+ if (metadata.messageIndex >= targetMessageIndex) {
529375
+ snapshotFiles.push({
529376
+ messageIndex: metadata.messageIndex,
529377
+ path: snapshotPath
529378
+ });
529379
+ }
529143
529380
  }
529144
529381
  }
529145
- const snapshotsToRollback = snapshots.filter((s) => s.messageIndex >= targetMessageIndex).sort((a, b) => b.messageIndex - a.messageIndex);
529382
+ snapshotFiles.sort((a, b) => b.messageIndex - a.messageIndex);
529146
529383
  let totalFilesRolledBack = 0;
529147
- for (const snapshot of snapshotsToRollback) {
529148
- for (const backup of snapshot.metadata.backups) {
529384
+ for (const snapshotFile of snapshotFiles) {
529385
+ const content = await fs36.readFile(snapshotFile.path, "utf-8");
529386
+ const metadata = JSON.parse(content);
529387
+ for (const backup of metadata.backups) {
529149
529388
  if (selectedFiles && selectedFiles.length > 0 && !selectedFiles.includes(backup.path)) {
529150
529389
  continue;
529151
529390
  }
529152
- const fullPath = path44.join(snapshot.metadata.workspaceRoot, backup.path);
529391
+ const fullPath = path44.join(metadata.workspaceRoot, backup.path);
529153
529392
  try {
529154
529393
  if (backup.existed && backup.content !== null) {
529155
529394
  await fs36.writeFile(fullPath, backup.content, "utf-8");
@@ -530552,6 +530791,8 @@ async function handleConversationWithTools(options3) {
530552
530791
  let reasoningAccumulator = "";
530553
530792
  let chunkCount = 0;
530554
530793
  let currentTokenCount = 0;
530794
+ let lastTokenUpdateTime = 0;
530795
+ const TOKEN_UPDATE_INTERVAL = 100;
530555
530796
  const currentSession2 = sessionManager.getCurrentSession();
530556
530797
  const cacheKey = currentSession2 == null ? void 0 : currentSession2.id;
530557
530798
  const onRetry = (error, attempt, nextDelay) => {
@@ -530631,7 +530872,11 @@ async function handleConversationWithTools(options3) {
530631
530872
  try {
530632
530873
  const deltaTokens = encoder.encode(chunk2.delta);
530633
530874
  currentTokenCount += deltaTokens.length;
530634
- setStreamTokenCount(currentTokenCount);
530875
+ const now = Date.now();
530876
+ if (now - lastTokenUpdateTime >= TOKEN_UPDATE_INTERVAL) {
530877
+ setStreamTokenCount(currentTokenCount);
530878
+ lastTokenUpdateTime = now;
530879
+ }
530635
530880
  } catch (e) {
530636
530881
  }
530637
530882
  } else if (chunk2.type === "content" && chunk2.content) {
@@ -530640,7 +530885,11 @@ async function handleConversationWithTools(options3) {
530640
530885
  try {
530641
530886
  const deltaTokens = encoder.encode(chunk2.content);
530642
530887
  currentTokenCount += deltaTokens.length;
530643
- setStreamTokenCount(currentTokenCount);
530888
+ const now = Date.now();
530889
+ if (now - lastTokenUpdateTime >= TOKEN_UPDATE_INTERVAL) {
530890
+ setStreamTokenCount(currentTokenCount);
530891
+ lastTokenUpdateTime = now;
530892
+ }
530644
530893
  } catch (e) {
530645
530894
  }
530646
530895
  } else if (chunk2.type === "tool_call_delta" && chunk2.delta) {
@@ -530649,7 +530898,11 @@ async function handleConversationWithTools(options3) {
530649
530898
  try {
530650
530899
  const deltaTokens = encoder.encode(chunk2.delta);
530651
530900
  currentTokenCount += deltaTokens.length;
530652
- setStreamTokenCount(currentTokenCount);
530901
+ const now = Date.now();
530902
+ if (now - lastTokenUpdateTime >= TOKEN_UPDATE_INTERVAL) {
530903
+ setStreamTokenCount(currentTokenCount);
530904
+ lastTokenUpdateTime = now;
530905
+ }
530653
530906
  } catch (e) {
530654
530907
  }
530655
530908
  } else if (chunk2.type === "tool_calls" && chunk2.tool_calls) {
@@ -531517,13 +531770,13 @@ async function handleConversationWithTools(options3) {
531517
531770
  if (options3.setIsStreaming) {
531518
531771
  options3.setIsStreaming(false);
531519
531772
  }
531520
- while (true) {
531521
- const result2 = await hashBasedSnapshotManager.commitSnapshot();
531522
- if (!result2)
531523
- break;
531524
- if (result2.fileCount > 0 && options3.setSnapshotFileCount) {
531525
- const session2 = sessionManager.getCurrentSession();
531526
- if (session2) {
531773
+ const session2 = sessionManager.getCurrentSession();
531774
+ if (session2) {
531775
+ while (true) {
531776
+ const result2 = await hashBasedSnapshotManager.commitSnapshot(session2.id);
531777
+ if (!result2)
531778
+ break;
531779
+ if (result2.fileCount > 0 && options3.setSnapshotFileCount) {
531527
531780
  options3.setSnapshotFileCount((prev) => {
531528
531781
  const newCounts = new Map(prev);
531529
531782
  newCounts.set(result2.messageIndex, result2.fileCount);
@@ -532095,9 +532348,12 @@ ${errorMsg}`,
532095
532348
  setCurrentModel: streamingState.setCurrentModel
532096
532349
  });
532097
532350
  } finally {
532098
- const result2 = await hashBasedSnapshotManager.commitSnapshot(messages.length);
532351
+ const session2 = sessionManager.getCurrentSession();
532352
+ let result2 = null;
532353
+ if (session2) {
532354
+ result2 = await hashBasedSnapshotManager.commitSnapshot(session2.id, messages.length);
532355
+ }
532099
532356
  if (result2 && result2.fileCount > 0) {
532100
- const session2 = sessionManager.getCurrentSession();
532101
532357
  if (session2) {
532102
532358
  const newCounts = new Map(snapshotState.snapshotFileCount);
532103
532359
  newCounts.set(result2.messageIndex, result2.fileCount);
@@ -532282,9 +532538,12 @@ ${errorMsg}`,
532282
532538
  setCurrentModel: streamingState.setCurrentModel
532283
532539
  });
532284
532540
  } finally {
532285
- const result2 = await hashBasedSnapshotManager.commitSnapshot();
532541
+ const session = sessionManager.getCurrentSession();
532542
+ let result2 = null;
532543
+ if (session) {
532544
+ result2 = await hashBasedSnapshotManager.commitSnapshot(session.id);
532545
+ }
532286
532546
  if (result2 && result2.fileCount > 0) {
532287
- const session = sessionManager.getCurrentSession();
532288
532547
  if (session) {
532289
532548
  const newCounts = new Map(snapshotState.snapshotFileCount);
532290
532549
  newCounts.set(result2.messageIndex, result2.fileCount);
@@ -535176,10 +535435,7 @@ var init_codebaseIndexAgent = __esm({
535176
535435
  splitIntoChunks(content, filePath) {
535177
535436
  const lines = content.split("\n");
535178
535437
  const chunks = [];
535179
- const maxLinesPerChunk = 100;
535180
- const minLinesPerChunk = 5;
535181
- const minCharsPerChunk = 50;
535182
- const overlapLines = 10;
535438
+ const { maxLinesPerChunk, minLinesPerChunk, minCharsPerChunk, overlapLines } = this.config.chunking;
535183
535439
  for (let i = 0; i < lines.length; i += maxLinesPerChunk - overlapLines) {
535184
535440
  const startLine = i;
535185
535441
  const endLine = Math.min(i + maxLinesPerChunk, lines.length);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.5.16",
3
+ "version": "0.5.17",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.5.16",
3
+ "version": "0.5.17",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {