@demigodmode/pi-web-agent 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 +29 -0
- package/dist/extract/readability.js +17 -11
- package/dist/orchestration/candidate-selector.js +5 -4
- package/dist/orchestration/source-profile.d.ts +1 -0
- package/dist/orchestration/source-profile.js +3 -0
- package/package.json +1 -1
- package/scripts/patch-jiti-compat.mjs +37 -15
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,35 @@ The format is intentionally simple and release-oriented.
|
|
|
18
18
|
### Breaking
|
|
19
19
|
- None.
|
|
20
20
|
|
|
21
|
+
## [1.7.2] - 2026-08-12
|
|
22
|
+
### Added
|
|
23
|
+
- None.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- None.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- Candidate scoring now matches GitHub sources by parsed hostname instead of a `url.includes('github.com/')` substring check that could also match unrelated hosts like `evil.com/github.com/`.
|
|
30
|
+
- `decodeHtmlEntities` now decodes `&` last so an already-encoded entity such as `&lt;` no longer collapses into `<` (double-unescape).
|
|
31
|
+
- The CI workflow now sets an explicit read-only default `GITHUB_TOKEN` permission.
|
|
32
|
+
- Bumped transitive `postcss`, `undici`, and `brace-expansion` in the lockfile to clear reported advisories.
|
|
33
|
+
|
|
34
|
+
### Breaking
|
|
35
|
+
- None.
|
|
36
|
+
|
|
37
|
+
## [1.7.1] - 2026-07-31
|
|
38
|
+
### Added
|
|
39
|
+
- None.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- None.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
- The issue #34 Pi-loader compatibility patch now resolves hoisted and nested `tr46` and `cssstyle` installations correctly instead of assuming they live inside `pi-web-agent/node_modules`.
|
|
46
|
+
|
|
47
|
+
### Breaking
|
|
48
|
+
- None.
|
|
49
|
+
|
|
21
50
|
## [1.7.0] - 2026-07-17
|
|
22
51
|
### Added
|
|
23
52
|
- Exa is now available as a hosted search backend for `web_explore`, aimed at research-quality source discovery. Set `EXA_API_KEY` in the environment and choose `exa` from **Settings → Backends**. Closes #2.
|
|
@@ -25,18 +25,24 @@ export function extractReadableContent(html, maxLength = 4000) {
|
|
|
25
25
|
text
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
const NAMED_ENTITIES = {
|
|
29
|
+
' ': ' ',
|
|
30
|
+
'&': '&',
|
|
31
|
+
'<': '<',
|
|
32
|
+
'>': '>',
|
|
33
|
+
'"': '"'
|
|
34
|
+
};
|
|
28
35
|
function decodeHtmlEntities(text) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
.replace(/&#x([\da-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
|
|
36
|
+
// Single pass so each entity is decoded exactly once. A multi-pass decode
|
|
37
|
+
// rescans its own output, which double-unescapes either &lt; -> < or
|
|
38
|
+
// &amp; -> & depending on the pass order. One pass avoids both.
|
|
39
|
+
return text.replace(/&(?:#(\d+)|#x([\da-f]+)|nbsp|amp|lt|gt|quot);/gi, (match, dec, hex) => {
|
|
40
|
+
if (dec !== undefined)
|
|
41
|
+
return String.fromCharCode(Number(dec));
|
|
42
|
+
if (hex !== undefined)
|
|
43
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
44
|
+
return NAMED_ENTITIES[match.toLowerCase()] ?? match;
|
|
45
|
+
});
|
|
40
46
|
}
|
|
41
47
|
function extractTitle(html) {
|
|
42
48
|
const match = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { classifySourceProfile } from './source-profile.js';
|
|
1
|
+
import { classifySourceProfile, hostOf } from './source-profile.js';
|
|
2
2
|
function wantsDiscussionSources(query = '') {
|
|
3
3
|
return /reddit|forum|forums|discussion|thread|comments|community|user experience|people recommend/i.test(query);
|
|
4
4
|
}
|
|
5
5
|
function candidateScore(result, query) {
|
|
6
|
-
const
|
|
6
|
+
const host = hostOf(result.url);
|
|
7
|
+
const isGithub = host === 'github.com' || (host?.endsWith('.github.com') ?? false);
|
|
7
8
|
const profile = classifySourceProfile(result.url);
|
|
8
9
|
const wantsThreads = wantsDiscussionSources(query);
|
|
9
10
|
if (profile.kind === 'official-docs')
|
|
@@ -15,7 +16,7 @@ function candidateScore(result, query) {
|
|
|
15
16
|
return 2;
|
|
16
17
|
if (profile.kind === 'issue-thread')
|
|
17
18
|
return 3;
|
|
18
|
-
if (
|
|
19
|
+
if (isGithub)
|
|
19
20
|
return 4;
|
|
20
21
|
if (profile.kind === 'package-page')
|
|
21
22
|
return 6;
|
|
@@ -23,7 +24,7 @@ function candidateScore(result, query) {
|
|
|
23
24
|
}
|
|
24
25
|
if (profile.kind === 'issue-thread')
|
|
25
26
|
return 2;
|
|
26
|
-
if (
|
|
27
|
+
if (isGithub)
|
|
27
28
|
return 3;
|
|
28
29
|
if (profile.kind === 'package-page')
|
|
29
30
|
return 5;
|
|
@@ -10,6 +10,9 @@ function parseUrl(rawUrl) {
|
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
export function hostOf(rawUrl) {
|
|
14
|
+
return parseUrl(rawUrl)?.hostname.toLowerCase().replace(/^www\./, '');
|
|
15
|
+
}
|
|
13
16
|
function isOfficialApi(host, path) {
|
|
14
17
|
return ((host === 'playwright.dev' && path.startsWith('/docs/api/')) ||
|
|
15
18
|
(host === 'vitest.dev' && path.startsWith('/config/')));
|
package/package.json
CHANGED
|
@@ -11,14 +11,30 @@
|
|
|
11
11
|
// Safe to run multiple times and safe to no-op if the target files or
|
|
12
12
|
// patterns are missing (e.g. a future dependency bump changes the shape).
|
|
13
13
|
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
14
|
-
import {
|
|
15
|
-
import { dirname, join } from "node:path";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const resolveFromHere = createRequire(import.meta.url).resolve;
|
|
18
|
+
|
|
19
|
+
function findPackageRoot(entryFile, packageName) {
|
|
20
|
+
let directory = dirname(entryFile);
|
|
21
|
+
while (true) {
|
|
22
|
+
const manifestFile = join(directory, "package.json");
|
|
23
|
+
if (existsSync(manifestFile)) {
|
|
24
|
+
const manifest = JSON.parse(readFileSync(manifestFile, "utf8"));
|
|
25
|
+
if (manifest.name === packageName) return directory;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const parent = dirname(directory);
|
|
29
|
+
if (parent === directory) {
|
|
30
|
+
throw new Error(`could not find the ${packageName} package root from ${entryFile}`);
|
|
31
|
+
}
|
|
32
|
+
directory = parent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
|
|
20
36
|
function patchTr46() {
|
|
21
|
-
const file =
|
|
37
|
+
const file = resolveFromHere("tr46");
|
|
22
38
|
if (!existsSync(file)) {
|
|
23
39
|
console.debug("patch-jiti-compat: tr46/index.js not found, skipping");
|
|
24
40
|
return;
|
|
@@ -45,13 +61,14 @@ module.exports[Symbol.iterator] = Set.prototype[Symbol.iterator].bind(module.exp
|
|
|
45
61
|
`;
|
|
46
62
|
|
|
47
63
|
function patchCssstyleSetExports() {
|
|
64
|
+
const packageRoot = findPackageRoot(resolveFromHere("cssstyle"), "cssstyle");
|
|
48
65
|
const files = [
|
|
49
|
-
join(
|
|
50
|
-
join(
|
|
51
|
-
join(
|
|
66
|
+
join(packageRoot, "lib", "allExtraProperties.js"),
|
|
67
|
+
join(packageRoot, "lib", "generated", "allProperties.js"),
|
|
68
|
+
join(packageRoot, "lib", "generated", "implementedProperties.js"),
|
|
52
69
|
];
|
|
53
70
|
for (const file of files) {
|
|
54
|
-
const label = `cssstyle/${file.
|
|
71
|
+
const label = `cssstyle/${relative(packageRoot, file).split(sep).join("/")}`;
|
|
55
72
|
if (!existsSync(file)) {
|
|
56
73
|
console.debug(`patch-jiti-compat: ${label} not found, skipping`);
|
|
57
74
|
continue;
|
|
@@ -67,10 +84,15 @@ function patchCssstyleSetExports() {
|
|
|
67
84
|
}
|
|
68
85
|
}
|
|
69
86
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} catch (err) {
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
function runBestEffort(label, patch) {
|
|
88
|
+
try {
|
|
89
|
+
patch();
|
|
90
|
+
} catch (err) {
|
|
91
|
+
// Never fail the install over a best-effort compat patch.
|
|
92
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
93
|
+
console.warn(`patch-jiti-compat: ${label} skipped, non-fatal error: ${message}`);
|
|
94
|
+
}
|
|
76
95
|
}
|
|
96
|
+
|
|
97
|
+
runBestEffort("tr46", patchTr46);
|
|
98
|
+
runBestEffort("cssstyle", patchCssstyleSetExports);
|