@apmantza/greedysearch-pi 1.7.0 → 1.7.2

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.
@@ -1,56 +1,56 @@
1
- // src/utils/content.mjs - Content trimming utilities
2
-
3
- /**
4
- * Trim large content keeping head + tail with separator
5
- * Better than simple truncation which loses end content (often conclusions/examples)
6
- * @param {string} content - Content to trim
7
- * @param {number} maxChars - Maximum characters to keep
8
- * @returns {string} - Trimmed content
9
- */
10
- export function trimContentHeadTail(content, maxChars = 8000) {
11
- if (!content || content.length <= maxChars) {
12
- return content;
13
- }
14
-
15
- const marker = "\n\n[...content trimmed...]\n\n";
16
- const budget = maxChars - marker.length;
17
-
18
- // Allocate 75% to head, 25% to tail
19
- const headSize = Math.floor(budget * 0.75);
20
- const tailSize = budget - headSize;
21
-
22
- // Find clean break points (at newline if possible)
23
- let headEnd = headSize;
24
- while (headEnd > headSize - 100 && content[headEnd] !== "\n") {
25
- headEnd--;
26
- }
27
- if (headEnd <= headSize - 100) headEnd = headSize; // No newline found
28
-
29
- let tailStart = content.length - tailSize;
30
- while (
31
- tailStart < content.length - tailSize + 100 &&
32
- content[tailStart] !== "\n"
33
- ) {
34
- tailStart++;
35
- }
36
- if (tailStart >= content.length - tailSize + 100)
37
- tailStart = content.length - tailSize;
38
-
39
- const head = content.slice(0, headEnd).trimEnd();
40
- const tail = content.slice(tailStart).trimStart();
41
-
42
- return `${head}${marker}${tail}`;
43
- }
44
-
45
- /**
46
- * Simple truncation (existing behavior) for when head+tail isn't appropriate
47
- * @param {string} content - Content to truncate
48
- * @param {number} maxChars - Maximum characters
49
- * @returns {string} - Truncated content
50
- */
51
- export function truncateContent(content, maxChars = 8000) {
52
- if (!content || content.length <= maxChars) {
53
- return content;
54
- }
55
- return content.slice(0, maxChars).replace(/\s+\S*$/, "") + "...";
56
- }
1
+ // src/utils/content.mjs - Content trimming utilities
2
+
3
+ /**
4
+ * Trim large content keeping head + tail with separator
5
+ * Better than simple truncation which loses end content (often conclusions/examples)
6
+ * @param {string} content - Content to trim
7
+ * @param {number} maxChars - Maximum characters to keep
8
+ * @returns {string} - Trimmed content
9
+ */
10
+ export function trimContentHeadTail(content, maxChars = 8000) {
11
+ if (!content || content.length <= maxChars) {
12
+ return content;
13
+ }
14
+
15
+ const marker = "\n\n[...content trimmed...]\n\n";
16
+ const budget = maxChars - marker.length;
17
+
18
+ // Allocate 75% to head, 25% to tail
19
+ const headSize = Math.floor(budget * 0.75);
20
+ const tailSize = budget - headSize;
21
+
22
+ // Find clean break points (at newline if possible)
23
+ let headEnd = headSize;
24
+ while (headEnd > headSize - 100 && content[headEnd] !== "\n") {
25
+ headEnd--;
26
+ }
27
+ if (headEnd <= headSize - 100) headEnd = headSize; // No newline found
28
+
29
+ let tailStart = content.length - tailSize;
30
+ while (
31
+ tailStart < content.length - tailSize + 100 &&
32
+ content[tailStart] !== "\n"
33
+ ) {
34
+ tailStart++;
35
+ }
36
+ if (tailStart >= content.length - tailSize + 100)
37
+ tailStart = content.length - tailSize;
38
+
39
+ const head = content.slice(0, headEnd).trimEnd();
40
+ const tail = content.slice(tailStart).trimStart();
41
+
42
+ return `${head}${marker}${tail}`;
43
+ }
44
+
45
+ /**
46
+ * Simple truncation (existing behavior) for when head+tail isn't appropriate
47
+ * @param {string} content - Content to truncate
48
+ * @param {number} maxChars - Maximum characters
49
+ * @returns {string} - Truncated content
50
+ */
51
+ export function truncateContent(content, maxChars = 8000) {
52
+ if (!content || content.length <= maxChars) {
53
+ return content;
54
+ }
55
+ return content.slice(0, maxChars).replace(/\s+\S*$/, "") + "...";
56
+ }
@@ -1,40 +1,40 @@
1
- /**
2
- * Utility helpers for formatting
3
- * Consolidated from single-use functions in index.ts
4
- */
5
-
6
- /**
7
- * Format engine name for display
8
- * Replaces 'bing' with 'Bing Copilot', etc.
9
- */
10
- export function formatEngineName(engine: string): string {
11
- const displayNames: Record<string, string> = {
12
- bing: "Bing Copilot",
13
- google: "Google AI",
14
- gemini: "Gemini",
15
- copilot: "Copilot",
16
- perplexity: "Perplexity",
17
- };
18
-
19
- return (
20
- displayNames[engine] ??
21
- engine.charAt(0).toUpperCase() + engine.slice(1)
22
- );
23
- }
24
-
25
- /**
26
- * Humanize source type labels
27
- */
28
- export function humanizeSourceType(sourceType: string): string {
29
- if (!sourceType) return "";
30
- if (sourceType === "official-docs") return "official docs";
31
- return sourceType.replace(/-/g, " ");
32
- }
33
-
34
- /**
35
- * Format agreement level with proper capitalization
36
- */
37
- export function formatAgreementLevel(level: string): string {
38
- if (!level) return "Mixed";
39
- return level.charAt(0).toUpperCase() + level.slice(1);
40
- }
1
+ /**
2
+ * Utility helpers for formatting
3
+ * Consolidated from single-use functions in index.ts
4
+ */
5
+
6
+ /**
7
+ * Format engine name for display
8
+ * Replaces 'bing' with 'Bing Copilot', etc.
9
+ */
10
+ export function formatEngineName(engine: string): string {
11
+ const displayNames: Record<string, string> = {
12
+ bing: "Bing Copilot",
13
+ google: "Google AI",
14
+ gemini: "Gemini",
15
+ copilot: "Copilot",
16
+ perplexity: "Perplexity",
17
+ };
18
+
19
+ return (
20
+ displayNames[engine] ??
21
+ engine.charAt(0).toUpperCase() + engine.slice(1)
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Humanize source type labels
27
+ */
28
+ export function humanizeSourceType(sourceType: string): string {
29
+ if (!sourceType) return "";
30
+ if (sourceType === "official-docs") return "official docs";
31
+ return sourceType.replace(/-/g, " ");
32
+ }
33
+
34
+ /**
35
+ * Format agreement level with proper capitalization
36
+ */
37
+ export function formatAgreementLevel(level: string): string {
38
+ if (!level) return "Mixed";
39
+ return level.charAt(0).toUpperCase() + level.slice(1);
40
+ }