opencode-codebase-index 0.17.0 → 0.17.1

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/dist/index.cjs CHANGED
@@ -655,467 +655,6 @@ var require_ignore = __commonJS({
655
655
  }
656
656
  });
657
657
 
658
- // node_modules/tiktoken/tiktoken_bg.cjs
659
- var require_tiktoken_bg = __commonJS({
660
- "node_modules/tiktoken/tiktoken_bg.cjs"(exports2, module3) {
661
- "use strict";
662
- var wasm;
663
- module3.exports.__wbg_set_wasm = function(val) {
664
- wasm = val;
665
- };
666
- var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module3.require)("util").TextDecoder : TextDecoder;
667
- var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
668
- cachedTextDecoder.decode();
669
- var cachedUint8ArrayMemory0 = null;
670
- function getUint8ArrayMemory0() {
671
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
672
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
673
- }
674
- return cachedUint8ArrayMemory0;
675
- }
676
- function getStringFromWasm0(ptr, len) {
677
- ptr = ptr >>> 0;
678
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
679
- }
680
- var heap = new Array(128).fill(void 0);
681
- heap.push(void 0, null, true, false);
682
- var heap_next = heap.length;
683
- function addHeapObject(obj) {
684
- if (heap_next === heap.length) heap.push(heap.length + 1);
685
- const idx = heap_next;
686
- heap_next = heap[idx];
687
- heap[idx] = obj;
688
- return idx;
689
- }
690
- function handleError(f, args) {
691
- try {
692
- return f.apply(this, args);
693
- } catch (e) {
694
- wasm.__wbindgen_export_0(addHeapObject(e));
695
- }
696
- }
697
- function getObject(idx) {
698
- return heap[idx];
699
- }
700
- function dropObject(idx) {
701
- if (idx < 132) return;
702
- heap[idx] = heap_next;
703
- heap_next = idx;
704
- }
705
- function takeObject(idx) {
706
- const ret = getObject(idx);
707
- dropObject(idx);
708
- return ret;
709
- }
710
- var WASM_VECTOR_LEN = 0;
711
- var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module3.require)("util").TextEncoder : TextEncoder;
712
- var cachedTextEncoder = new lTextEncoder("utf-8");
713
- var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
714
- return cachedTextEncoder.encodeInto(arg, view);
715
- } : function(arg, view) {
716
- const buf = cachedTextEncoder.encode(arg);
717
- view.set(buf);
718
- return {
719
- read: arg.length,
720
- written: buf.length
721
- };
722
- };
723
- function passStringToWasm0(arg, malloc, realloc) {
724
- if (realloc === void 0) {
725
- const buf = cachedTextEncoder.encode(arg);
726
- const ptr2 = malloc(buf.length, 1) >>> 0;
727
- getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
728
- WASM_VECTOR_LEN = buf.length;
729
- return ptr2;
730
- }
731
- let len = arg.length;
732
- let ptr = malloc(len, 1) >>> 0;
733
- const mem = getUint8ArrayMemory0();
734
- let offset = 0;
735
- for (; offset < len; offset++) {
736
- const code = arg.charCodeAt(offset);
737
- if (code > 127) break;
738
- mem[ptr + offset] = code;
739
- }
740
- if (offset !== len) {
741
- if (offset !== 0) {
742
- arg = arg.slice(offset);
743
- }
744
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
745
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
746
- const ret = encodeString(arg, view);
747
- offset += ret.written;
748
- ptr = realloc(ptr, len, offset, 1) >>> 0;
749
- }
750
- WASM_VECTOR_LEN = offset;
751
- return ptr;
752
- }
753
- function isLikeNone(x) {
754
- return x === void 0 || x === null;
755
- }
756
- var cachedDataViewMemory0 = null;
757
- function getDataViewMemory0() {
758
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
759
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
760
- }
761
- return cachedDataViewMemory0;
762
- }
763
- var cachedUint32ArrayMemory0 = null;
764
- function getUint32ArrayMemory0() {
765
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
766
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
767
- }
768
- return cachedUint32ArrayMemory0;
769
- }
770
- function getArrayU32FromWasm0(ptr, len) {
771
- ptr = ptr >>> 0;
772
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
773
- }
774
- function passArray8ToWasm0(arg, malloc) {
775
- const ptr = malloc(arg.length * 1, 1) >>> 0;
776
- getUint8ArrayMemory0().set(arg, ptr / 1);
777
- WASM_VECTOR_LEN = arg.length;
778
- return ptr;
779
- }
780
- function passArray32ToWasm0(arg, malloc) {
781
- const ptr = malloc(arg.length * 4, 4) >>> 0;
782
- getUint32ArrayMemory0().set(arg, ptr / 4);
783
- WASM_VECTOR_LEN = arg.length;
784
- return ptr;
785
- }
786
- function getArrayU8FromWasm0(ptr, len) {
787
- ptr = ptr >>> 0;
788
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
789
- }
790
- module3.exports.get_encoding = function(encoding, extend_special_tokens) {
791
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
792
- try {
793
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
794
- const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
795
- const len0 = WASM_VECTOR_LEN;
796
- wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
797
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
798
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
799
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
800
- if (r2) {
801
- throw takeObject(r1);
802
- }
803
- return Tiktoken.__wrap(r0);
804
- } finally {
805
- wasm.__wbindgen_add_to_stack_pointer(16);
806
- }
807
- };
808
- module3.exports.encoding_for_model = function(model, extend_special_tokens) {
809
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
810
- try {
811
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
812
- const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
813
- const len0 = WASM_VECTOR_LEN;
814
- wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
815
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
816
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
817
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
818
- if (r2) {
819
- throw takeObject(r1);
820
- }
821
- return Tiktoken.__wrap(r0);
822
- } finally {
823
- wasm.__wbindgen_add_to_stack_pointer(16);
824
- }
825
- };
826
- module3.exports.get_encoding_name_for_model = function(model) {
827
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
828
- let deferred3_0;
829
- let deferred3_1;
830
- try {
831
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
832
- const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
833
- const len0 = WASM_VECTOR_LEN;
834
- wasm.get_encoding_name_for_model(retptr, ptr0, len0);
835
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
836
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
837
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
838
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
839
- var ptr2 = r0;
840
- var len2 = r1;
841
- if (r3) {
842
- ptr2 = 0;
843
- len2 = 0;
844
- throw takeObject(r2);
845
- }
846
- deferred3_0 = ptr2;
847
- deferred3_1 = len2;
848
- return getStringFromWasm0(ptr2, len2);
849
- } finally {
850
- wasm.__wbindgen_add_to_stack_pointer(16);
851
- wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
852
- }
853
- };
854
- var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
855
- }, unregister: () => {
856
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
857
- var Tiktoken = class _Tiktoken {
858
- /**
859
- * @param {string} tiktoken_bfe
860
- * @param {any} special_tokens
861
- * @param {string} pat_str
862
- */
863
- constructor(tiktoken_bfe, special_tokens, pat_str) {
864
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
865
- const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
866
- const len0 = WASM_VECTOR_LEN;
867
- const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
868
- const len1 = WASM_VECTOR_LEN;
869
- const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
870
- this.__wbg_ptr = ret >>> 0;
871
- TiktokenFinalization.register(this, this.__wbg_ptr, this);
872
- return this;
873
- }
874
- /** @returns {string | undefined} */
875
- get name() {
876
- try {
877
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
878
- wasm.tiktoken_name(retptr, this.__wbg_ptr);
879
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
880
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
881
- let v1;
882
- if (r0 !== 0) {
883
- v1 = getStringFromWasm0(r0, r1).slice();
884
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
885
- }
886
- return v1;
887
- } finally {
888
- wasm.__wbindgen_add_to_stack_pointer(16);
889
- }
890
- }
891
- static __wrap(ptr) {
892
- ptr = ptr >>> 0;
893
- const obj = Object.create(_Tiktoken.prototype);
894
- obj.__wbg_ptr = ptr;
895
- TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
896
- return obj;
897
- }
898
- __destroy_into_raw() {
899
- const ptr = this.__wbg_ptr;
900
- this.__wbg_ptr = 0;
901
- TiktokenFinalization.unregister(this);
902
- return ptr;
903
- }
904
- free() {
905
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
906
- const ptr = this.__destroy_into_raw();
907
- wasm.__wbg_tiktoken_free(ptr, 0);
908
- }
909
- /**
910
- * @param {string} text
911
- * @param {any} allowed_special
912
- * @param {any} disallowed_special
913
- * @returns {Uint32Array}
914
- */
915
- encode(text, allowed_special, disallowed_special) {
916
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
917
- try {
918
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
919
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
920
- const len0 = WASM_VECTOR_LEN;
921
- wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
922
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
923
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
924
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
925
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
926
- if (r3) {
927
- throw takeObject(r2);
928
- }
929
- var v2 = getArrayU32FromWasm0(r0, r1).slice();
930
- wasm.__wbindgen_export_3(r0, r1 * 4, 4);
931
- return v2;
932
- } finally {
933
- wasm.__wbindgen_add_to_stack_pointer(16);
934
- }
935
- }
936
- /**
937
- * @param {string} text
938
- * @returns {Uint32Array}
939
- */
940
- encode_ordinary(text) {
941
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
942
- try {
943
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
944
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
945
- const len0 = WASM_VECTOR_LEN;
946
- wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
947
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
948
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
949
- var v2 = getArrayU32FromWasm0(r0, r1).slice();
950
- wasm.__wbindgen_export_3(r0, r1 * 4, 4);
951
- return v2;
952
- } finally {
953
- wasm.__wbindgen_add_to_stack_pointer(16);
954
- }
955
- }
956
- /**
957
- * @param {string} text
958
- * @param {any} allowed_special
959
- * @param {any} disallowed_special
960
- * @returns {any}
961
- */
962
- encode_with_unstable(text, allowed_special, disallowed_special) {
963
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
964
- try {
965
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
966
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
967
- const len0 = WASM_VECTOR_LEN;
968
- wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
969
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
970
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
971
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
972
- if (r2) {
973
- throw takeObject(r1);
974
- }
975
- return takeObject(r0);
976
- } finally {
977
- wasm.__wbindgen_add_to_stack_pointer(16);
978
- }
979
- }
980
- /**
981
- * @param {Uint8Array} bytes
982
- * @returns {number}
983
- */
984
- encode_single_token(bytes) {
985
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
986
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
987
- const len0 = WASM_VECTOR_LEN;
988
- const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
989
- return ret >>> 0;
990
- }
991
- /**
992
- * @param {Uint32Array} tokens
993
- * @returns {Uint8Array}
994
- */
995
- decode(tokens) {
996
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
997
- try {
998
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
999
- const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
1000
- const len0 = WASM_VECTOR_LEN;
1001
- wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
1002
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1003
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1004
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
1005
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
1006
- return v2;
1007
- } finally {
1008
- wasm.__wbindgen_add_to_stack_pointer(16);
1009
- }
1010
- }
1011
- /**
1012
- * @param {number} token
1013
- * @returns {Uint8Array}
1014
- */
1015
- decode_single_token_bytes(token) {
1016
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
1017
- try {
1018
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1019
- wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
1020
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1021
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1022
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
1023
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
1024
- return v1;
1025
- } finally {
1026
- wasm.__wbindgen_add_to_stack_pointer(16);
1027
- }
1028
- }
1029
- /** @returns {any} */
1030
- token_byte_values() {
1031
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
1032
- const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
1033
- return takeObject(ret);
1034
- }
1035
- };
1036
- module3.exports.Tiktoken = Tiktoken;
1037
- module3.exports.__wbg_parse_def2e24ef1252aff = function() {
1038
- return handleError(function(arg0, arg1) {
1039
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1040
- return addHeapObject(ret);
1041
- }, arguments);
1042
- };
1043
- module3.exports.__wbg_stringify_f7ed6987935b4a24 = function() {
1044
- return handleError(function(arg0) {
1045
- const ret = JSON.stringify(getObject(arg0));
1046
- return addHeapObject(ret);
1047
- }, arguments);
1048
- };
1049
- module3.exports.__wbindgen_error_new = function(arg0, arg1) {
1050
- const ret = new Error(getStringFromWasm0(arg0, arg1));
1051
- return addHeapObject(ret);
1052
- };
1053
- module3.exports.__wbindgen_is_undefined = function(arg0) {
1054
- const ret = getObject(arg0) === void 0;
1055
- return ret;
1056
- };
1057
- module3.exports.__wbindgen_object_drop_ref = function(arg0) {
1058
- takeObject(arg0);
1059
- };
1060
- module3.exports.__wbindgen_string_get = function(arg0, arg1) {
1061
- if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
1062
- const obj = getObject(arg1);
1063
- const ret = typeof obj === "string" ? obj : void 0;
1064
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1065
- var len1 = WASM_VECTOR_LEN;
1066
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1067
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1068
- };
1069
- module3.exports.__wbindgen_throw = function(arg0, arg1) {
1070
- throw new Error(getStringFromWasm0(arg0, arg1));
1071
- };
1072
- }
1073
- });
1074
-
1075
- // node_modules/tiktoken/tiktoken.cjs
1076
- var require_tiktoken = __commonJS({
1077
- "node_modules/tiktoken/tiktoken.cjs"(exports2) {
1078
- "use strict";
1079
- var wasm = require_tiktoken_bg();
1080
- var imports = {};
1081
- imports["./tiktoken_bg.js"] = wasm;
1082
- var path24 = require("path");
1083
- var fs = require("fs");
1084
- var candidates = __dirname.split(path24.sep).reduce((memo, _, index, array) => {
1085
- const prefix = array.slice(0, index + 1).join(path24.sep) + path24.sep;
1086
- if (!prefix.includes("node_modules" + path24.sep)) {
1087
- memo.unshift(
1088
- path24.join(
1089
- prefix,
1090
- "node_modules",
1091
- "tiktoken",
1092
- "",
1093
- "./tiktoken_bg.wasm"
1094
- )
1095
- );
1096
- }
1097
- return memo;
1098
- }, []);
1099
- candidates.unshift(path24.join(__dirname, "./tiktoken_bg.wasm"));
1100
- var bytes = null;
1101
- for (const candidate of candidates) {
1102
- try {
1103
- bytes = fs.readFileSync(candidate);
1104
- break;
1105
- } catch {
1106
- }
1107
- }
1108
- if (bytes == null) throw new Error("Missing tiktoken_bg.wasm");
1109
- var wasmModule = new WebAssembly.Module(bytes);
1110
- var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
1111
- wasm.__wbg_set_wasm(wasmInstance.exports);
1112
- exports2["get_encoding"] = wasm["get_encoding"];
1113
- exports2["encoding_for_model"] = wasm["encoding_for_model"];
1114
- exports2["get_encoding_name_for_model"] = wasm["get_encoding_name_for_model"];
1115
- exports2["Tiktoken"] = wasm["Tiktoken"];
1116
- }
1117
- });
1118
-
1119
658
  // src/index.ts
1120
659
  var index_exports = {};
1121
660
  __export(index_exports, {
@@ -10459,7 +9998,7 @@ function findKnowledgeBasePathIndex(knowledgeBases, inputPath, projectRoot) {
10459
9998
  }
10460
9999
 
10461
10000
  // src/tools/utils.ts
10462
- var import_tiktoken = __toESM(require_tiktoken(), 1);
10001
+ var import_tiktoken = require("tiktoken");
10463
10002
  var MIN_CONTEXT_PACK_TOKEN_BUDGET = 128;
10464
10003
  var MAX_CONTEXT_PACK_TOKEN_BUDGET = 4e3;
10465
10004
  var DEFAULT_CONTEXT_PACK_TOKEN_BUDGET = 1200;