@mrclrchtr/supi-web 1.14.2 → 1.15.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.
- package/README.md +8 -4
- package/node_modules/@mrclrchtr/supi-core/package.json +12 -3
- package/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +1 -1
- package/package.json +24 -5
- package/src/api.ts +10 -0
- package/src/context7-client.ts +13 -3
- package/src/docs.ts +295 -156
- package/src/fetch.ts +174 -92
- package/src/index.ts +10 -0
- package/src/temp-file.ts +6 -5
- package/src/tool/guidance.ts +34 -0
- package/src/tool/output.ts +50 -0
- package/src/tool/render.ts +63 -0
- package/src/tool/tool-specs.ts +107 -0
- package/src/web.ts +150 -78
- package/src/tool/web-docs-fetch-guidance.ts +0 -11
- package/src/tool/web-docs-search-guidance.ts +0 -10
- package/src/tool/web-fetch-md-guidance.ts +0 -41
package/README.md
CHANGED
|
@@ -26,7 +26,10 @@ pi install ./packages/supi-web
|
|
|
26
26
|
|
|
27
27
|
## What you get
|
|
28
28
|
|
|
29
|
-
After install, pi gets three tools
|
|
29
|
+
After install, pi gets three tools.
|
|
30
|
+
|
|
31
|
+
In PI's TUI, these tools now render a collapsed summary by default; expand the tool row to reveal the full inline output.
|
|
32
|
+
|
|
30
33
|
|
|
31
34
|
| Tool | Purpose |
|
|
32
35
|
|------|---------|
|
|
@@ -50,7 +53,7 @@ Fetches a public URL and returns clean Markdown.
|
|
|
50
53
|
### Output modes
|
|
51
54
|
|
|
52
55
|
- **`auto`** — returns Markdown inline if ≤15,000 characters; otherwise writes to a temporary file and returns the path
|
|
53
|
-
- **`inline`** —
|
|
56
|
+
- **`inline`** — returns Markdown inline, truncated to PI's model-visible output limit when necessary
|
|
54
57
|
- **`file`** — always writes to a temporary file and returns the path
|
|
55
58
|
|
|
56
59
|
### Behavior
|
|
@@ -58,6 +61,7 @@ Fetches a public URL and returns clean Markdown.
|
|
|
58
61
|
- Only accepts real `http://` or `https://` URLs
|
|
59
62
|
- Access-controlled pages (login, paywall) should be skipped — ask the user for an allowed source instead
|
|
60
63
|
- Plain-text responses are wrapped in fenced code blocks
|
|
64
|
+
- Model-visible inline output is truncated to 2,000 lines or 50KB; full truncated output is saved to a temp file
|
|
61
65
|
- Links and images are absolutized by default; set `abs_links: false` to keep them relative
|
|
62
66
|
|
|
63
67
|
## `web_docs_search`
|
|
@@ -71,7 +75,7 @@ Searches Context7 for library IDs before fetching documentation.
|
|
|
71
75
|
| `library_name` | string | ✓ | Library name to search for (e.g. `"react"`, `"next.js"`) |
|
|
72
76
|
| `query` | string | ✓ | What you're trying to do — used for relevance ranking |
|
|
73
77
|
|
|
74
|
-
Results return as a Markdown table with library ID, name, description, trust score, benchmark score, snippet count, and
|
|
78
|
+
Results return as a compact Markdown table with library ID, name, description, trust score, benchmark score, snippet count, and shortened version lists (top 10 matches shown).
|
|
75
79
|
|
|
76
80
|
## `web_docs_fetch`
|
|
77
81
|
|
|
@@ -85,7 +89,7 @@ Retrieves documentation context for a known Context7 library.
|
|
|
85
89
|
| `query` | string | ✓ | — | Specific question about the library |
|
|
86
90
|
| `raw` | boolean | — | `false` | When `true`, returns JSON-serialized snippet objects instead of Markdown |
|
|
87
91
|
|
|
88
|
-
Default mode returns pre-formatted Markdown. Set `raw: true` when you need structured JSON for programmatic use.
|
|
92
|
+
Default mode returns pre-formatted Markdown. Set `raw: true` when you need structured JSON for programmatic use. Large model-visible responses are truncated to 2,000 lines or 50KB with the full response saved to a temp file.
|
|
89
93
|
|
|
90
94
|
## Typical workflow
|
|
91
95
|
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/mrclrchtr/supi.git"
|
|
8
|
+
"url": "git+https://github.com/mrclrchtr/supi.git",
|
|
9
|
+
"directory": "packages/supi-core"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/mrclrchtr/supi/tree/main/packages/supi-core#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mrclrchtr/supi/issues"
|
|
9
14
|
},
|
|
10
15
|
"publishConfig": {
|
|
11
16
|
"access": "public"
|
|
12
17
|
},
|
|
13
18
|
"keywords": [
|
|
14
19
|
"pi",
|
|
15
|
-
"pi-coding-agent"
|
|
20
|
+
"pi-coding-agent",
|
|
21
|
+
"supi",
|
|
22
|
+
"extension-utils",
|
|
23
|
+
"settings",
|
|
24
|
+
"configuration"
|
|
16
25
|
],
|
|
17
26
|
"files": [
|
|
18
27
|
"src/**/*.ts",
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "SuPi Web extension — fetch web pages as clean Markdown (web_fetch_md) and library docs via Context7 (web_docs_search, web_docs_fetch)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/mrclrchtr/supi.git"
|
|
8
|
+
"url": "git+https://github.com/mrclrchtr/supi.git",
|
|
9
|
+
"directory": "packages/supi-web"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/mrclrchtr/supi/tree/main/packages/supi-web#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mrclrchtr/supi/issues"
|
|
9
14
|
},
|
|
10
15
|
"publishConfig": {
|
|
11
16
|
"access": "public"
|
|
@@ -13,7 +18,13 @@
|
|
|
13
18
|
"keywords": [
|
|
14
19
|
"pi-package",
|
|
15
20
|
"pi",
|
|
16
|
-
"pi-coding-agent"
|
|
21
|
+
"pi-coding-agent",
|
|
22
|
+
"pi-extension",
|
|
23
|
+
"web-fetch",
|
|
24
|
+
"markdown",
|
|
25
|
+
"context7",
|
|
26
|
+
"documentation",
|
|
27
|
+
"readability"
|
|
17
28
|
],
|
|
18
29
|
"files": [
|
|
19
30
|
"src/**/*.ts",
|
|
@@ -24,19 +35,27 @@
|
|
|
24
35
|
"@mozilla/readability": "^0.6.0",
|
|
25
36
|
"turndown": "^7.2.0",
|
|
26
37
|
"turndown-plugin-gfm": "^1.0.2",
|
|
27
|
-
"@mrclrchtr/supi-core": "1.
|
|
38
|
+
"@mrclrchtr/supi-core": "1.15.0"
|
|
28
39
|
},
|
|
29
40
|
"bundledDependencies": [
|
|
30
41
|
"@mrclrchtr/supi-core"
|
|
31
42
|
],
|
|
32
43
|
"peerDependencies": {
|
|
44
|
+
"@earendil-works/pi-ai": "*",
|
|
33
45
|
"@earendil-works/pi-coding-agent": "*",
|
|
46
|
+
"@earendil-works/pi-tui": "*",
|
|
34
47
|
"typebox": "*"
|
|
35
48
|
},
|
|
36
49
|
"peerDependenciesMeta": {
|
|
50
|
+
"@earendil-works/pi-ai": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
37
53
|
"@earendil-works/pi-coding-agent": {
|
|
38
54
|
"optional": true
|
|
39
55
|
},
|
|
56
|
+
"@earendil-works/pi-tui": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
40
59
|
"typebox": {
|
|
41
60
|
"optional": true
|
|
42
61
|
}
|
|
@@ -45,7 +64,7 @@
|
|
|
45
64
|
"extensions": [
|
|
46
65
|
"./src/extension.ts"
|
|
47
66
|
],
|
|
48
|
-
"image": "https://raw.githubusercontent.com/mrclrchtr/supi/main/
|
|
67
|
+
"image": "https://raw.githubusercontent.com/mrclrchtr/supi/main/screenshots/supi-web.png"
|
|
49
68
|
},
|
|
50
69
|
"main": "src/api.ts",
|
|
51
70
|
"exports": {
|
package/src/api.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* SuPi Web extension — public API exports.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
export type { Context7RequestOptions } from "./context7-client.ts";
|
|
5
6
|
export { htmlToMarkdown, wrapAsCodeBlock } from "./convert.ts";
|
|
6
7
|
export { default as docsExtension } from "./docs.ts";
|
|
7
8
|
export {
|
|
@@ -11,4 +12,13 @@ export {
|
|
|
11
12
|
fetchWithNegotiation,
|
|
12
13
|
isValidHttpUrl,
|
|
13
14
|
} from "./fetch.ts";
|
|
15
|
+
export {
|
|
16
|
+
WEB_FETCH_INLINE_MAX_CHARS,
|
|
17
|
+
WEB_TOOL_NAMES,
|
|
18
|
+
WEB_TOOL_SPECS,
|
|
19
|
+
type WebDocsFetchInput,
|
|
20
|
+
type WebDocsSearchInput,
|
|
21
|
+
type WebFetchMdInput,
|
|
22
|
+
type WebToolName,
|
|
23
|
+
} from "./tool/tool-specs.ts";
|
|
14
24
|
export { default } from "./web.ts";
|
package/src/context7-client.ts
CHANGED
|
@@ -31,6 +31,11 @@ export interface DocSnippet {
|
|
|
31
31
|
source: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Request options shared by Context7 REST calls. */
|
|
35
|
+
export interface Context7RequestOptions {
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
function authHeaders(): Record<string, string> {
|
|
35
40
|
const apiKey = process.env.CONTEXT7_API_KEY;
|
|
36
41
|
return apiKey ? { Authorization: `Bearer ${apiKey}` } : {};
|
|
@@ -86,12 +91,16 @@ function mapSearchResult(r: ApiSearchResult): SearchResult {
|
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
export async function searchLibrary(
|
|
94
|
+
export async function searchLibrary(
|
|
95
|
+
query: string,
|
|
96
|
+
libraryName: string,
|
|
97
|
+
options: Context7RequestOptions = {},
|
|
98
|
+
): Promise<SearchResult[]> {
|
|
90
99
|
const url = new URL(`${BASE_URL}/v2/libs/search`);
|
|
91
100
|
url.searchParams.set("query", query);
|
|
92
101
|
url.searchParams.set("libraryName", libraryName);
|
|
93
102
|
|
|
94
|
-
const response = await fetch(url, { headers: authHeaders() });
|
|
103
|
+
const response = await fetch(url, { headers: authHeaders(), signal: options.signal });
|
|
95
104
|
|
|
96
105
|
if (!response.ok) {
|
|
97
106
|
throw new Context7Error(await parseErrorResponse(response));
|
|
@@ -105,12 +114,13 @@ export async function getContext(
|
|
|
105
114
|
query: string,
|
|
106
115
|
libraryId: string,
|
|
107
116
|
raw?: boolean,
|
|
117
|
+
options: Context7RequestOptions = {},
|
|
108
118
|
): Promise<string | DocSnippet[]> {
|
|
109
119
|
const url = new URL(`${BASE_URL}/v2/context`);
|
|
110
120
|
url.searchParams.set("query", query);
|
|
111
121
|
url.searchParams.set("libraryId", libraryId);
|
|
112
122
|
|
|
113
|
-
const response = await fetch(url, { headers: authHeaders() });
|
|
123
|
+
const response = await fetch(url, { headers: authHeaders(), signal: options.signal });
|
|
114
124
|
|
|
115
125
|
if (!response.ok) {
|
|
116
126
|
throw new Context7Error(await parseErrorResponse(response));
|