@zhexin/pi-deepseek 0.0.0-stage → 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jiang zhexin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # Pi DeepSeek Enhancement
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ DeepSeek Enhancement Extension for the [Pi](https://pi.dev) coding agent.
4
+
5
+ Include **web search/fetch** tools. Nothing more.
6
+
7
+ Most extensions I've tried seem to be compensating for something. Config that fights pi's philosophy, feature lists that look like a spaceship's dashboard, and UIs that assume you wanted a personal assistant.
8
+
9
+ This one does less. On purpose.
10
+
11
+ ## Features
12
+
13
+ - **Boring code.** Small, readable TypeScript. Auditing it takes less time than reading this README.
14
+ - **Boring config.** No config files, no opinionated defaults. Set one API key, get on with your life.
15
+ - **Invisible.** No new commands, no UI surface, no surprises. If you didn't know it was installed, you'd never notice.
16
+
17
+ ## Quick Start
18
+
19
+ ### Installation
20
+
21
+ ```bash
22
+ pi install npm:@zhexin/pi-deepseek
23
+ ```
24
+
25
+ ### Setup Your DeepSeek API Key
26
+
27
+ ```bash
28
+ pi auth login deepseek
29
+ ```
30
+
31
+ ## LICENSE
32
+
33
+ MIT
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./src/index.ts";
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@zhexin/pi-deepseek",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "DeepSeek Enhancement for Pi",
4
+ "version": "0.0.2",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "pi-package",
9
+ "deepseek",
10
+ "web-access"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/jiang-zhexin/pi-pi.git",
15
+ "directory": "packages/deepseek"
16
+ },
17
+ "homepage": "https://github.com/jiang-zhexin/pi-pi/tree/HEAD/packages/deepseek#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/jiang-zhexin/pi-pi/issues"
20
+ },
21
+ "files": [
22
+ "src/*",
23
+ "index.ts"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public",
27
+ "registry": "https://registry.npmjs.org/"
28
+ },
29
+ "exports": {
30
+ ".": "./index.ts"
31
+ },
32
+ "peerDependencies": {
33
+ "@earendil-works/pi-coding-agent": "*",
34
+ "typebox": "*"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "@earendil-works/pi-coding-agent": {
38
+ "optional": true
39
+ },
40
+ "typebox": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "pi": {
45
+ "extensions": [
46
+ "./index.ts"
47
+ ]
48
+ }
49
+ }
package/src/index.ts ADDED
@@ -0,0 +1,108 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { Static } from "typebox";
3
+
4
+ import { fetchInput, fetchOutput, searchInput, searchOutput } from "./schema.ts";
5
+
6
+ const unauthorized = new Error("Unauthorized. Run `/login deepseek` to authenticate.");
7
+
8
+ async function resolveDeepSeekRequest(ctx: ExtensionContext, path: string) {
9
+ const authResult = await ctx.modelRegistry.getProviderAuth("deepseek");
10
+ const apiKey = authResult?.auth.apiKey;
11
+ if (apiKey === undefined) throw unauthorized;
12
+
13
+ const baseUrl =
14
+ authResult?.auth.baseUrl ??
15
+ ctx.modelRegistry.getProvider("deepseek")?.baseUrl ??
16
+ "https://api.deepseek.com";
17
+
18
+ return {
19
+ url: new URL(path, baseUrl),
20
+ headers: {
21
+ ...authResult?.auth.headers,
22
+ Authorization: `Bearer ${apiKey}`,
23
+ "Content-Type": "application/json",
24
+ },
25
+ };
26
+ }
27
+
28
+ export default function (pi: ExtensionAPI): void {
29
+ pi.registerTool({
30
+ name: "web-search",
31
+ label: "DeepSeek Web Search",
32
+ description: "Search web pages for a query and return structured results.",
33
+ parameters: searchInput,
34
+ outputSchema: searchOutput,
35
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
36
+ const { url, headers } = await resolveDeepSeekRequest(ctx, "/v1/tools/search");
37
+
38
+ const response = await fetch(url, {
39
+ method: "POST",
40
+ headers,
41
+ body: JSON.stringify(params),
42
+ signal: signal ?? null,
43
+ });
44
+
45
+ if (!response.ok) {
46
+ if (response.status === 401) throw unauthorized;
47
+
48
+ const errorText = await response.text().catch(() => "");
49
+ throw new Error(
50
+ `DeepSeek Search API error (status ${response.status}): ${errorText || response.statusText}`,
51
+ );
52
+ }
53
+
54
+ const data = (await response.json()) as Static<typeof searchOutput>;
55
+ const formatted = data.results
56
+ .map((r, i) =>
57
+ [
58
+ `${i + 1}. ${r.title}`,
59
+ ` URL: ${r.url}`,
60
+ ...(r.date ? [` Date: ${r.date}`] : []),
61
+ r.summary || r.snippet,
62
+ ...(r.content ? [r.content] : []),
63
+ ].join("\n"),
64
+ )
65
+ .join("\n\n");
66
+
67
+ return {
68
+ content: [{ type: "text", text: formatted || "No results found." }],
69
+ structuredContent: data,
70
+ details: {},
71
+ };
72
+ },
73
+ });
74
+
75
+ pi.registerTool({
76
+ name: "web-fetch",
77
+ label: "DeepSeek Web Fetch",
78
+ description: "Fetch a single web page and return its content as Markdown.",
79
+ parameters: fetchInput,
80
+ outputSchema: fetchOutput,
81
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
82
+ const { url, headers } = await resolveDeepSeekRequest(ctx, "/v1/tools/fetch");
83
+
84
+ const response = await fetch(url, {
85
+ method: "POST",
86
+ headers,
87
+ body: JSON.stringify(params),
88
+ signal: signal ?? null,
89
+ });
90
+
91
+ if (!response.ok) {
92
+ if (response.status === 401) throw unauthorized;
93
+
94
+ const errorText = await response.text().catch(() => "");
95
+ throw new Error(
96
+ `DeepSeek Fetch API error (status ${response.status}): ${errorText || response.statusText}`,
97
+ );
98
+ }
99
+
100
+ const data = (await response.json()) as Static<typeof fetchOutput>;
101
+ return {
102
+ content: [{ type: "text", text: `Title: ${data.title}\n\n${data.content}` }],
103
+ structuredContent: data,
104
+ details: {},
105
+ };
106
+ },
107
+ });
108
+ }
package/src/schema.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { Type } from "typebox";
2
+
3
+ export const searchInput = Type.Object({
4
+ query: Type.String({
5
+ minLength: 1,
6
+ maxLength: 128,
7
+ description:
8
+ "Supports site:, -site:, excluded terms, quoted phrases, lang:, after:, and before: operators.",
9
+ }),
10
+ count: Type.Optional(
11
+ Type.Integer({
12
+ minimum: 1,
13
+ maximum: 50,
14
+ default: 10,
15
+ description: "The number of results to return",
16
+ }),
17
+ ),
18
+ ori_question: Type.Optional(
19
+ Type.String({
20
+ minLength: 1,
21
+ maxLength: 128,
22
+ description: "The user's question that triggered the search to improve query understanding",
23
+ }),
24
+ ),
25
+ localization: Type.Optional(
26
+ Type.String({
27
+ description: "An IP address used to localize search results.",
28
+ }),
29
+ ),
30
+ need_content: Type.Optional(
31
+ Type.Boolean({
32
+ description: "Include full page content when available",
33
+ }),
34
+ ),
35
+ });
36
+
37
+ export const searchOutput = Type.Object({
38
+ results: Type.Array(
39
+ Type.Object({
40
+ rerank_score: Type.Number(),
41
+ title: Type.String(),
42
+ url: Type.String(),
43
+ snippet: Type.String(),
44
+ summary: Type.String(),
45
+ content: Type.String(),
46
+ site_name: Type.Union([Type.String(), Type.Null()]),
47
+ site_icon: Type.Union([Type.String(), Type.Null()]),
48
+ date: Type.Union([Type.String(), Type.Null()]),
49
+ authority: Type.Integer(),
50
+ }),
51
+ ),
52
+ });
53
+
54
+ export const fetchInput = Type.Object({
55
+ url: Type.String({
56
+ minLength: 1,
57
+ maxLength: 8192,
58
+ description: "The page URL to fetch",
59
+ }),
60
+ });
61
+
62
+ export const fetchOutput = Type.Object({
63
+ title: Type.String(),
64
+ content: Type.String(),
65
+ });