pi-web-kit 0.1.4 → 0.1.6

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 CHANGED
@@ -6,6 +6,23 @@ This project follows the spirit of [Keep a Changelog](https://keepachangelog.com
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.6] - 2026-06-06
10
+
11
+ ### Changed
12
+
13
+ - Extract install telemetry to separate `src/install-telemetry.ts` module for consistency with monorepo guidelines.
14
+ - Add root `index.ts` re-export and fix `pi.extensions` path to `./index.ts`.
15
+ - Update `peerDependencies` to use `*` for Pi core packages.
16
+ - Add Pi core packages to `devDependencies` for type checking.
17
+ - Update `author` field to full name.
18
+
19
+ ## [0.1.5] - 2026-05-20
20
+
21
+ ### Changed
22
+
23
+ - Moved package source to the `jvm/pi-mono` monorepo.
24
+ - Updated npm metadata to point at the monorepo package directory.
25
+
9
26
  ## [0.1.4] - 2026-05-10
10
27
 
11
28
  ### Fixed
package/CONTRIBUTING.md CHANGED
@@ -19,14 +19,14 @@ Install this checkout into a temporary Pi project:
19
19
  ```bash
20
20
  mkdir -p <test-project>
21
21
  cd <test-project>
22
- pi install -l /path/to/pi-web-kit
22
+ pi install -l /path/to/pi-mono/packages/pi-web-kit
23
23
  pi
24
24
  ```
25
25
 
26
26
  For a one-off run without changing settings:
27
27
 
28
28
  ```bash
29
- pi -e /path/to/pi-web-kit --web-provider-fetch markdown_new --print "Fetch https://example.com"
29
+ pi -e /path/to/pi-mono/packages/pi-web-kit --web-provider-fetch markdown_new --print "Fetch https://example.com"
30
30
  ```
31
31
 
32
32
  ## Pull request checklist
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pi-web-kit
2
2
 
3
- Context-efficient web search and fetch tools for [Pi](https://github.com/badlogic/pi-mono): `web_search` and `web_fetch`.
3
+ Context-efficient web search and fetch tools for [Pi](https://pi.dev): `web_search` and `web_fetch`.
4
4
 
5
5
  `pi-web-kit` provides provider-backed search and page fetching with bounded output, chunked reads, URL validation, and an in-memory fetch cache designed for agent workflows.
6
6
 
@@ -22,28 +22,22 @@ Install from npm:
22
22
  pi install npm:pi-web-kit
23
23
  ```
24
24
 
25
- Install from GitHub:
26
-
27
- ```bash
28
- pi install git:github.com/jvm/pi-web-kit
29
- ```
30
-
31
25
  Install project-locally with Pi's `-l` flag:
32
26
 
33
27
  ```bash
34
- pi install -l git:github.com/jvm/pi-web-kit
28
+ pi install -l npm:pi-web-kit
35
29
  ```
36
30
 
37
- During local development from this repository:
31
+ During local development from this monorepo:
38
32
 
39
33
  ```bash
40
- pi install /path/to/pi-web-kit
34
+ pi install /path/to/pi-mono/packages/pi-web-kit
41
35
  ```
42
36
 
43
37
  For a one-off test run without installing:
44
38
 
45
39
  ```bash
46
- pi -e /path/to/pi-web-kit --web-provider-fetch markdown_new --print "Fetch https://example.com"
40
+ pi -e /path/to/pi-mono/packages/pi-web-kit --web-provider-fetch markdown_new --print "Fetch https://example.com"
47
41
  ```
48
42
 
49
43
  This is an npm-compatible TypeScript Pi package. Bun is not required.
@@ -1,6 +1,3 @@
1
- import { readFileSync } from "node:fs";
2
- import { mkdir, writeFile } from "node:fs/promises";
3
- import { join } from "node:path";
4
1
  import { type ExtensionAPI, getAgentDir } from "@earendil-works/pi-coding-agent";
5
2
  import { Text } from "@earendil-works/pi-tui";
6
3
  import { Type } from "typebox";
@@ -12,12 +9,7 @@ import { createFetchProvider, createSearchProvider } from "../src/providers/inde
12
9
  import { mapFetchResults } from "../src/providers/fallback.js";
13
10
  import type { FetchProviderName, SearchProviderName, WebFetchResult } from "../src/types.js";
14
11
  import { canonicalWebUrl, normalizeUrlInput } from "../src/urls.js";
15
-
16
- const PACKAGE_NAME = "pi-web-kit";
17
- const INSTALL_TELEMETRY_URL = "https://mocito.dev/api/report-install";
18
- const INSTALL_TELEMETRY_TIMEOUT_MS = 5000;
19
-
20
- type InstallTelemetryState = { lastReportedVersion?: string };
12
+ import { reportInstallTelemetry } from "../src/install-telemetry.js";
21
13
 
22
14
  export default function (pi: ExtensionAPI) {
23
15
  void reportInstallTelemetry();
@@ -168,64 +160,6 @@ function buildFetchDescription(provider: FetchProviderName): string {
168
160
  return `Fetch URL content with startup provider '${provider}'. Results are cached by URL/options; use offset/limit to read long pages in chunks. Restart/reload pi after provider changes.`;
169
161
  }
170
162
 
171
- function readJsonFile(path: string): unknown {
172
- try {
173
- return JSON.parse(readFileSync(path, "utf8"));
174
- } catch {
175
- return {};
176
- }
177
- }
178
-
179
- function isTruthyEnvFlag(value: string | undefined): boolean {
180
- if (!value) return false;
181
- return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
182
- }
183
-
184
- function isInstallTelemetryEnabled(): boolean {
185
- if (isTruthyEnvFlag(process.env.PI_OFFLINE)) return false;
186
- if (isTruthyEnvFlag(process.env.CI) || isTruthyEnvFlag(process.env.GITHUB_ACTIONS)) return false;
187
- if (process.env.PI_TELEMETRY !== undefined) return isTruthyEnvFlag(process.env.PI_TELEMETRY);
188
- const settings = readJsonFile(join(getAgentDir(), "settings.json")) as { enableInstallTelemetry?: unknown };
189
- return settings.enableInstallTelemetry !== false;
190
- }
191
-
192
- function getPackageVersion(): string {
193
- try {
194
- const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version?: unknown };
195
- return typeof packageJson.version === "string" && packageJson.version.length > 0 ? packageJson.version : "0.0.0";
196
- } catch {
197
- return "0.0.0";
198
- }
199
- }
200
-
201
- function getInstallTelemetryUserAgent(version: string): string {
202
- const runtimeVersions = process.versions as NodeJS.ProcessVersions & { bun?: string };
203
- const runtime = runtimeVersions.bun ? `bun/${runtimeVersions.bun}` : `node/${process.version}`;
204
- return `${PACKAGE_NAME}/${version} (${process.platform}; ${runtime}; ${process.arch})`;
205
- }
206
-
207
- export async function reportInstallTelemetry(): Promise<void> {
208
- try {
209
- if (!isInstallTelemetryEnabled()) return;
210
-
211
- const version = getPackageVersion();
212
- const telemetryDir = join(getAgentDir(), "extensions");
213
- const statePath = join(telemetryDir, "pi-web-kit-install.json");
214
- const state = readJsonFile(statePath) as InstallTelemetryState;
215
- if (state.lastReportedVersion === version) return;
216
-
217
- await mkdir(telemetryDir, { recursive: true });
218
- await writeFile(statePath, `${JSON.stringify({ lastReportedVersion: version }, null, 2)}\n`);
219
-
220
- const params = new URLSearchParams({ tool: PACKAGE_NAME, version });
221
- await fetch(`${INSTALL_TELEMETRY_URL}?${params.toString()}`, {
222
- headers: { "User-Agent": getInstallTelemetryUserAgent(version) },
223
- signal: AbortSignal.timeout(INSTALL_TELEMETRY_TIMEOUT_MS),
224
- });
225
- } catch {
226
- // Best-effort install telemetry: ignore settings, filesystem, and network failures.
227
- }
228
- }
229
163
 
230
164
  function normalizeQueries(params: Record<string, any>): string[] {
231
165
  const raw = Array.isArray(params.queries) ? params.queries : params.query ? [params.query] : [];
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./extensions/index.js";
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "pi-web-kit",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Context-efficient web search and fetch tools for Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "author": "jvm",
7
+ "author": "Jose Mocito",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/jvm/pi-web-kit.git"
10
+ "url": "git+https://github.com/jvm/pi-mono.git",
11
+ "directory": "packages/pi-web-kit"
11
12
  },
12
13
  "bugs": {
13
- "url": "https://github.com/jvm/pi-web-kit/issues"
14
+ "url": "https://github.com/jvm/pi-mono/issues"
14
15
  },
15
- "homepage": "https://github.com/jvm/pi-web-kit#readme",
16
+ "homepage": "https://github.com/jvm/pi-mono/tree/main/packages/pi-web-kit#readme",
16
17
  "keywords": [
17
18
  "pi-package",
18
19
  "pi-extension",
@@ -27,10 +28,11 @@
27
28
  },
28
29
  "pi": {
29
30
  "extensions": [
30
- "./extensions/index.ts"
31
+ "./index.ts"
31
32
  ]
32
33
  },
33
34
  "files": [
35
+ "index.ts",
34
36
  "extensions",
35
37
  "src",
36
38
  "README.md",
@@ -53,8 +55,12 @@
53
55
  "typebox": "*"
54
56
  },
55
57
  "devDependencies": {
58
+ "@earendil-works/pi-ai": "^0.75.4",
59
+ "@earendil-works/pi-coding-agent": "^0.75.4",
60
+ "@earendil-works/pi-tui": "^0.75.4",
56
61
  "@types/node": "^25.6.2",
57
62
  "tsx": "^4.21.0",
63
+ "typebox": "^1.1.33",
58
64
  "typescript": "^6.0.3"
59
65
  },
60
66
  "publishConfig": {
@@ -0,0 +1,69 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
5
+
6
+ const PACKAGE_NAME = "pi-web-kit";
7
+ const INSTALL_TELEMETRY_URL = "https://mocito.dev/api/report-install";
8
+ const INSTALL_TELEMETRY_TIMEOUT_MS = 5000;
9
+
10
+ type InstallTelemetryState = { lastReportedVersion?: string };
11
+
12
+ function readJsonFile(path: string): unknown {
13
+ try {
14
+ return JSON.parse(readFileSync(path, "utf8"));
15
+ } catch {
16
+ return {};
17
+ }
18
+ }
19
+
20
+ function isTruthyEnvFlag(value: string | undefined): boolean {
21
+ if (!value) return false;
22
+ return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
23
+ }
24
+
25
+ function isInstallTelemetryEnabled(): boolean {
26
+ if (isTruthyEnvFlag(process.env.PI_OFFLINE)) return false;
27
+ if (isTruthyEnvFlag(process.env.CI) || isTruthyEnvFlag(process.env.GITHUB_ACTIONS)) return false;
28
+ if (process.env.PI_TELEMETRY !== undefined) return isTruthyEnvFlag(process.env.PI_TELEMETRY);
29
+ const settings = readJsonFile(join(getAgentDir(), "settings.json")) as { enableInstallTelemetry?: unknown };
30
+ return settings.enableInstallTelemetry !== false;
31
+ }
32
+
33
+ function getPackageVersion(): string {
34
+ try {
35
+ const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version?: unknown };
36
+ return typeof packageJson.version === "string" && packageJson.version.length > 0 ? packageJson.version : "0.0.0";
37
+ } catch {
38
+ return "0.0.0";
39
+ }
40
+ }
41
+
42
+ function getInstallTelemetryUserAgent(version: string): string {
43
+ const runtimeVersions = process.versions as NodeJS.ProcessVersions & { bun?: string };
44
+ const runtime = runtimeVersions.bun ? `bun/${runtimeVersions.bun}` : `node/${process.version}`;
45
+ return `${PACKAGE_NAME}/${version} (${process.platform}; ${runtime}; ${process.arch})`;
46
+ }
47
+
48
+ export async function reportInstallTelemetry(): Promise<void> {
49
+ try {
50
+ if (!isInstallTelemetryEnabled()) return;
51
+
52
+ const version = getPackageVersion();
53
+ const telemetryDir = join(getAgentDir(), "extensions");
54
+ const statePath = join(telemetryDir, "pi-web-kit-install.json");
55
+ const state = readJsonFile(statePath) as InstallTelemetryState;
56
+ if (state.lastReportedVersion === version) return;
57
+
58
+ await mkdir(telemetryDir, { recursive: true });
59
+ await writeFile(statePath, `${JSON.stringify({ lastReportedVersion: version }, null, 2)}\n`);
60
+
61
+ const params = new URLSearchParams({ tool: PACKAGE_NAME, version });
62
+ await fetch(`${INSTALL_TELEMETRY_URL}?${params.toString()}`, {
63
+ headers: { "User-Agent": getInstallTelemetryUserAgent(version) },
64
+ signal: AbortSignal.timeout(INSTALL_TELEMETRY_TIMEOUT_MS),
65
+ });
66
+ } catch {
67
+ // Best-effort install telemetry: ignore settings, filesystem, and network failures.
68
+ }
69
+ }