Commit f52f374
committed
feat: improve readFileTool safeguard with character-based limiting and i18n
- Replace line-based limiting with character-based limiting to handle files with very long lines
- Move threshold constants to packages/types/src/file-limits.ts for better organization
- Add readLinesWithCharLimit function that truncates at complete line boundaries
- Optimize file reading to avoid double reads when checking token count
- Add i18n support for safeguard notice messages in all 18 supported languages
- Update tests to match new character-based implementation
- Safeguard now limits by character count (200KB default) instead of line count
- Ensures files are never truncated in the middle of a line1 parent 89790bc commit f52f374
File tree
24 files changed
+501
-50
lines changed- packages/types/src
- src
- core/tools
- __tests__
- i18n/locales
- ca
- de
- en
- es
- fr
- hi
- id
- it
- ja
- ko
- nl
- pl
- pt-BR
- ru
- tr
- vi
- zh-CN
- zh-TW
- integrations/misc
- __tests__
24 files changed
+501
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
658 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
659 | 669 | | |
660 | 670 | | |
661 | 671 | | |
| |||
685 | 695 | | |
686 | 696 | | |
687 | 697 | | |
688 | | - | |
| 698 | + | |
689 | 699 | | |
690 | 700 | | |
691 | | - | |
692 | | - | |
| 701 | + | |
693 | 702 | | |
694 | 703 | | |
695 | 704 | | |
| |||
725 | 734 | | |
726 | 735 | | |
727 | 736 | | |
728 | | - | |
| 737 | + | |
| 738 | + | |
729 | 739 | | |
730 | 740 | | |
731 | 741 | | |
| |||
765 | 775 | | |
766 | 776 | | |
767 | 777 | | |
768 | | - | |
| 778 | + | |
| 779 | + | |
769 | 780 | | |
770 | 781 | | |
771 | 782 | | |
| |||
778 | 789 | | |
779 | 790 | | |
780 | 791 | | |
781 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
782 | 801 | | |
783 | 802 | | |
784 | 803 | | |
| |||
825 | 844 | | |
826 | 845 | | |
827 | 846 | | |
828 | | - | |
| 847 | + | |
829 | 848 | | |
830 | | - | |
831 | | - | |
832 | | - | |
| 849 | + | |
| 850 | + | |
833 | 851 | | |
834 | 852 | | |
835 | 853 | | |
| |||
861 | 879 | | |
862 | 880 | | |
863 | 881 | | |
864 | | - | |
| 882 | + | |
865 | 883 | | |
| 884 | + | |
| 885 | + | |
866 | 886 | | |
867 | 887 | | |
868 | 888 | | |
| |||
955 | 975 | | |
956 | 976 | | |
957 | 977 | | |
958 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
959 | 985 | | |
960 | | - | |
961 | | - | |
| 986 | + | |
| 987 | + | |
962 | 988 | | |
963 | 989 | | |
964 | 990 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| |||
519 | 528 | | |
520 | 529 | | |
521 | 530 | | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | 531 | | |
528 | 532 | | |
529 | | - | |
| 533 | + | |
| 534 | + | |
530 | 535 | | |
531 | 536 | | |
532 | 537 | | |
533 | 538 | | |
534 | | - | |
| 539 | + | |
| 540 | + | |
535 | 541 | | |
536 | 542 | | |
537 | 543 | | |
| |||
541 | 547 | | |
542 | 548 | | |
543 | 549 | | |
544 | | - | |
| 550 | + | |
| 551 | + | |
545 | 552 | | |
546 | 553 | | |
547 | 554 | | |
548 | 555 | | |
549 | | - | |
550 | | - | |
| 556 | + | |
| 557 | + | |
551 | 558 | | |
| 559 | + | |
552 | 560 | | |
553 | 561 | | |
554 | 562 | | |
555 | 563 | | |
556 | 564 | | |
557 | 565 | | |
558 | | - | |
559 | | - | |
560 | 566 | | |
561 | 567 | | |
562 | 568 | | |
| |||
566 | 572 | | |
567 | 573 | | |
568 | 574 | | |
569 | | - | |
570 | | - | |
571 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
572 | 594 | | |
573 | | - | |
574 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
575 | 601 | | |
576 | 602 | | |
577 | 603 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments