@yawlabs/ctxlint 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,466 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ __commonJS,
4
+ __require
5
+ } from "./chunk-ZXMDA7VB.js";
6
+
7
+ // node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken_bg.cjs
8
+ var require_tiktoken_bg = __commonJS({
9
+ "node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken_bg.cjs"(exports, module) {
10
+ "use strict";
11
+ var wasm;
12
+ module.exports.__wbg_set_wasm = function(val) {
13
+ wasm = val;
14
+ };
15
+ var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
16
+ var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
17
+ cachedTextDecoder.decode();
18
+ var cachedUint8ArrayMemory0 = null;
19
+ function getUint8ArrayMemory0() {
20
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
21
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
22
+ }
23
+ return cachedUint8ArrayMemory0;
24
+ }
25
+ function getStringFromWasm0(ptr, len) {
26
+ ptr = ptr >>> 0;
27
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
28
+ }
29
+ var heap = new Array(128).fill(void 0);
30
+ heap.push(void 0, null, true, false);
31
+ var heap_next = heap.length;
32
+ function addHeapObject(obj) {
33
+ if (heap_next === heap.length) heap.push(heap.length + 1);
34
+ const idx = heap_next;
35
+ heap_next = heap[idx];
36
+ heap[idx] = obj;
37
+ return idx;
38
+ }
39
+ function handleError(f, args) {
40
+ try {
41
+ return f.apply(this, args);
42
+ } catch (e) {
43
+ wasm.__wbindgen_export_0(addHeapObject(e));
44
+ }
45
+ }
46
+ function getObject(idx) {
47
+ return heap[idx];
48
+ }
49
+ function dropObject(idx) {
50
+ if (idx < 132) return;
51
+ heap[idx] = heap_next;
52
+ heap_next = idx;
53
+ }
54
+ function takeObject(idx) {
55
+ const ret = getObject(idx);
56
+ dropObject(idx);
57
+ return ret;
58
+ }
59
+ var WASM_VECTOR_LEN = 0;
60
+ var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
61
+ var cachedTextEncoder = new lTextEncoder("utf-8");
62
+ var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
63
+ return cachedTextEncoder.encodeInto(arg, view);
64
+ } : function(arg, view) {
65
+ const buf = cachedTextEncoder.encode(arg);
66
+ view.set(buf);
67
+ return {
68
+ read: arg.length,
69
+ written: buf.length
70
+ };
71
+ };
72
+ function passStringToWasm0(arg, malloc, realloc) {
73
+ if (realloc === void 0) {
74
+ const buf = cachedTextEncoder.encode(arg);
75
+ const ptr2 = malloc(buf.length, 1) >>> 0;
76
+ getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
77
+ WASM_VECTOR_LEN = buf.length;
78
+ return ptr2;
79
+ }
80
+ let len = arg.length;
81
+ let ptr = malloc(len, 1) >>> 0;
82
+ const mem = getUint8ArrayMemory0();
83
+ let offset = 0;
84
+ for (; offset < len; offset++) {
85
+ const code = arg.charCodeAt(offset);
86
+ if (code > 127) break;
87
+ mem[ptr + offset] = code;
88
+ }
89
+ if (offset !== len) {
90
+ if (offset !== 0) {
91
+ arg = arg.slice(offset);
92
+ }
93
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
94
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
95
+ const ret = encodeString(arg, view);
96
+ offset += ret.written;
97
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
98
+ }
99
+ WASM_VECTOR_LEN = offset;
100
+ return ptr;
101
+ }
102
+ function isLikeNone(x) {
103
+ return x === void 0 || x === null;
104
+ }
105
+ var cachedDataViewMemory0 = null;
106
+ function getDataViewMemory0() {
107
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
108
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
109
+ }
110
+ return cachedDataViewMemory0;
111
+ }
112
+ var cachedUint32ArrayMemory0 = null;
113
+ function getUint32ArrayMemory0() {
114
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
115
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
116
+ }
117
+ return cachedUint32ArrayMemory0;
118
+ }
119
+ function getArrayU32FromWasm0(ptr, len) {
120
+ ptr = ptr >>> 0;
121
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
122
+ }
123
+ function passArray8ToWasm0(arg, malloc) {
124
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
125
+ getUint8ArrayMemory0().set(arg, ptr / 1);
126
+ WASM_VECTOR_LEN = arg.length;
127
+ return ptr;
128
+ }
129
+ function passArray32ToWasm0(arg, malloc) {
130
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
131
+ getUint32ArrayMemory0().set(arg, ptr / 4);
132
+ WASM_VECTOR_LEN = arg.length;
133
+ return ptr;
134
+ }
135
+ function getArrayU8FromWasm0(ptr, len) {
136
+ ptr = ptr >>> 0;
137
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
138
+ }
139
+ module.exports.get_encoding = function(encoding, extend_special_tokens) {
140
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
141
+ try {
142
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
143
+ const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
144
+ const len0 = WASM_VECTOR_LEN;
145
+ wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
146
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
147
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
148
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
149
+ if (r2) {
150
+ throw takeObject(r1);
151
+ }
152
+ return Tiktoken.__wrap(r0);
153
+ } finally {
154
+ wasm.__wbindgen_add_to_stack_pointer(16);
155
+ }
156
+ };
157
+ module.exports.encoding_for_model = function(model, extend_special_tokens) {
158
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
159
+ try {
160
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
161
+ const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
162
+ const len0 = WASM_VECTOR_LEN;
163
+ wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
164
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
165
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
166
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
167
+ if (r2) {
168
+ throw takeObject(r1);
169
+ }
170
+ return Tiktoken.__wrap(r0);
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ }
174
+ };
175
+ module.exports.get_encoding_name_for_model = function(model) {
176
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
177
+ let deferred3_0;
178
+ let deferred3_1;
179
+ try {
180
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
181
+ const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ wasm.get_encoding_name_for_model(retptr, ptr0, len0);
184
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
185
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
186
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
187
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
188
+ var ptr2 = r0;
189
+ var len2 = r1;
190
+ if (r3) {
191
+ ptr2 = 0;
192
+ len2 = 0;
193
+ throw takeObject(r2);
194
+ }
195
+ deferred3_0 = ptr2;
196
+ deferred3_1 = len2;
197
+ return getStringFromWasm0(ptr2, len2);
198
+ } finally {
199
+ wasm.__wbindgen_add_to_stack_pointer(16);
200
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
201
+ }
202
+ };
203
+ var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
204
+ }, unregister: () => {
205
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
206
+ var Tiktoken = class _Tiktoken {
207
+ /**
208
+ * @param {string} tiktoken_bfe
209
+ * @param {any} special_tokens
210
+ * @param {string} pat_str
211
+ */
212
+ constructor(tiktoken_bfe, special_tokens, pat_str) {
213
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
214
+ const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
217
+ const len1 = WASM_VECTOR_LEN;
218
+ const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
219
+ this.__wbg_ptr = ret >>> 0;
220
+ TiktokenFinalization.register(this, this.__wbg_ptr, this);
221
+ return this;
222
+ }
223
+ /** @returns {string | undefined} */
224
+ get name() {
225
+ try {
226
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
227
+ wasm.tiktoken_name(retptr, this.__wbg_ptr);
228
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
229
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
230
+ let v1;
231
+ if (r0 !== 0) {
232
+ v1 = getStringFromWasm0(r0, r1).slice();
233
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
234
+ }
235
+ return v1;
236
+ } finally {
237
+ wasm.__wbindgen_add_to_stack_pointer(16);
238
+ }
239
+ }
240
+ static __wrap(ptr) {
241
+ ptr = ptr >>> 0;
242
+ const obj = Object.create(_Tiktoken.prototype);
243
+ obj.__wbg_ptr = ptr;
244
+ TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
245
+ return obj;
246
+ }
247
+ __destroy_into_raw() {
248
+ const ptr = this.__wbg_ptr;
249
+ this.__wbg_ptr = 0;
250
+ TiktokenFinalization.unregister(this);
251
+ return ptr;
252
+ }
253
+ free() {
254
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
255
+ const ptr = this.__destroy_into_raw();
256
+ wasm.__wbg_tiktoken_free(ptr, 0);
257
+ }
258
+ /**
259
+ * @param {string} text
260
+ * @param {any} allowed_special
261
+ * @param {any} disallowed_special
262
+ * @returns {Uint32Array}
263
+ */
264
+ encode(text, allowed_special, disallowed_special) {
265
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
266
+ try {
267
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
268
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
271
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
272
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
273
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
274
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
275
+ if (r3) {
276
+ throw takeObject(r2);
277
+ }
278
+ var v2 = getArrayU32FromWasm0(r0, r1).slice();
279
+ wasm.__wbindgen_export_3(r0, r1 * 4, 4);
280
+ return v2;
281
+ } finally {
282
+ wasm.__wbindgen_add_to_stack_pointer(16);
283
+ }
284
+ }
285
+ /**
286
+ * @param {string} text
287
+ * @returns {Uint32Array}
288
+ */
289
+ encode_ordinary(text) {
290
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
291
+ try {
292
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
293
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
296
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
297
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
298
+ var v2 = getArrayU32FromWasm0(r0, r1).slice();
299
+ wasm.__wbindgen_export_3(r0, r1 * 4, 4);
300
+ return v2;
301
+ } finally {
302
+ wasm.__wbindgen_add_to_stack_pointer(16);
303
+ }
304
+ }
305
+ /**
306
+ * @param {string} text
307
+ * @param {any} allowed_special
308
+ * @param {any} disallowed_special
309
+ * @returns {any}
310
+ */
311
+ encode_with_unstable(text, allowed_special, disallowed_special) {
312
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
313
+ try {
314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
316
+ const len0 = WASM_VECTOR_LEN;
317
+ wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
318
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
319
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
320
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
321
+ if (r2) {
322
+ throw takeObject(r1);
323
+ }
324
+ return takeObject(r0);
325
+ } finally {
326
+ wasm.__wbindgen_add_to_stack_pointer(16);
327
+ }
328
+ }
329
+ /**
330
+ * @param {Uint8Array} bytes
331
+ * @returns {number}
332
+ */
333
+ encode_single_token(bytes) {
334
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
335
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
336
+ const len0 = WASM_VECTOR_LEN;
337
+ const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
338
+ return ret >>> 0;
339
+ }
340
+ /**
341
+ * @param {Uint32Array} tokens
342
+ * @returns {Uint8Array}
343
+ */
344
+ decode(tokens) {
345
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
346
+ try {
347
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
348
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
349
+ const len0 = WASM_VECTOR_LEN;
350
+ wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
351
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
352
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
353
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
354
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
355
+ return v2;
356
+ } finally {
357
+ wasm.__wbindgen_add_to_stack_pointer(16);
358
+ }
359
+ }
360
+ /**
361
+ * @param {number} token
362
+ * @returns {Uint8Array}
363
+ */
364
+ decode_single_token_bytes(token) {
365
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
366
+ try {
367
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
368
+ wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
369
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
370
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
371
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
372
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
373
+ return v1;
374
+ } finally {
375
+ wasm.__wbindgen_add_to_stack_pointer(16);
376
+ }
377
+ }
378
+ /** @returns {any} */
379
+ token_byte_values() {
380
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
381
+ const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
382
+ return takeObject(ret);
383
+ }
384
+ };
385
+ module.exports.Tiktoken = Tiktoken;
386
+ module.exports.__wbg_parse_def2e24ef1252aff = function() {
387
+ return handleError(function(arg0, arg1) {
388
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
389
+ return addHeapObject(ret);
390
+ }, arguments);
391
+ };
392
+ module.exports.__wbg_stringify_f7ed6987935b4a24 = function() {
393
+ return handleError(function(arg0) {
394
+ const ret = JSON.stringify(getObject(arg0));
395
+ return addHeapObject(ret);
396
+ }, arguments);
397
+ };
398
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
399
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
400
+ return addHeapObject(ret);
401
+ };
402
+ module.exports.__wbindgen_is_undefined = function(arg0) {
403
+ const ret = getObject(arg0) === void 0;
404
+ return ret;
405
+ };
406
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
407
+ takeObject(arg0);
408
+ };
409
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
410
+ if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
411
+ const obj = getObject(arg1);
412
+ const ret = typeof obj === "string" ? obj : void 0;
413
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
414
+ var len1 = WASM_VECTOR_LEN;
415
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
416
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
417
+ };
418
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
419
+ throw new Error(getStringFromWasm0(arg0, arg1));
420
+ };
421
+ }
422
+ });
423
+
424
+ // node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken.cjs
425
+ var require_tiktoken = __commonJS({
426
+ "node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken.cjs"(exports) {
427
+ var wasm = require_tiktoken_bg();
428
+ var imports = {};
429
+ imports["./tiktoken_bg.js"] = wasm;
430
+ var path = __require("path");
431
+ var fs = __require("fs");
432
+ var candidates = __dirname.split(path.sep).reduce((memo, _, index, array) => {
433
+ const prefix = array.slice(0, index + 1).join(path.sep) + path.sep;
434
+ if (!prefix.includes("node_modules" + path.sep)) {
435
+ memo.unshift(
436
+ path.join(
437
+ prefix,
438
+ "node_modules",
439
+ "tiktoken",
440
+ "",
441
+ "./tiktoken_bg.wasm"
442
+ )
443
+ );
444
+ }
445
+ return memo;
446
+ }, []);
447
+ candidates.unshift(path.join(__dirname, "./tiktoken_bg.wasm"));
448
+ var bytes = null;
449
+ for (const candidate of candidates) {
450
+ try {
451
+ bytes = fs.readFileSync(candidate);
452
+ break;
453
+ } catch {
454
+ }
455
+ }
456
+ if (bytes == null) throw new Error("Missing tiktoken_bg.wasm");
457
+ var wasmModule = new WebAssembly.Module(bytes);
458
+ var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
459
+ wasm.__wbg_set_wasm(wasmInstance.exports);
460
+ exports["get_encoding"] = wasm["get_encoding"];
461
+ exports["encoding_for_model"] = wasm["encoding_for_model"];
462
+ exports["get_encoding_name_for_model"] = wasm["get_encoding_name_for_model"];
463
+ exports["Tiktoken"] = wasm["Tiktoken"];
464
+ }
465
+ });
466
+ export default require_tiktoken();