@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.
- package/CHANGELOG.md +107 -89
- package/LICENSE +21 -21
- package/README.md +73 -262
- package/{cdp.mjs → bin/cdp.mjs} +1004 -1004
- package/{coding-task.mjs → bin/coding-task.mjs} +392 -392
- package/{launch.mjs → bin/launch.mjs} +288 -288
- package/{search.mjs → bin/search.mjs} +1482 -1436
- package/extractors/bing-copilot.mjs +167 -167
- package/extractors/common.mjs +237 -237
- package/extractors/consent.mjs +273 -273
- package/extractors/google-ai.mjs +156 -156
- package/extractors/perplexity.mjs +141 -141
- package/extractors/selectors.mjs +52 -52
- package/index.ts +18 -18
- package/package.json +46 -49
- package/skills/greedy-search/SKILL.md +117 -117
- package/src/fetcher.mjs +589 -589
- package/src/formatters/coding.ts +68 -68
- package/src/formatters/sources.ts +116 -116
- package/src/formatters/synthesis.ts +91 -91
- package/src/github.mjs +323 -323
- package/src/utils/content.mjs +56 -56
- package/src/utils/helpers.ts +40 -40
package/src/utils/content.mjs
CHANGED
|
@@ -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
|
+
}
|
package/src/utils/helpers.ts
CHANGED
|
@@ -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
|
+
}
|