@aliou/pi-linkup 0.3.1 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @aliou/pi-linkup
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e9fdef1: Replace `deep` boolean with `depth` enum on web-answer tool for consistency with web-search
8
+
9
+ ## 0.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 89a92f3: Add configurable system prompt guidance setting via /linkup:settings
14
+
15
+ ## 0.4.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 052fc2b: Add fast mode support to linkup_web_search tool. The depth parameter now accepts "fast", "standard", or "deep" modes:
20
+ - fast: Sub-second latency using pre-indexed atoms of information
21
+ - standard: Single iteration retrieval, balanced speed/depth (default)
22
+ - deep: Up to 10 iterations with chain-of-thought reasoning
23
+
24
+ ### Patch Changes
25
+
26
+ - a238ba7: Add User-Agent header to all Linkup API requests for attribution.
27
+
3
28
  ## 0.3.1
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Web search and content fetching extension for [Pi](https://buildwithpi.ai/) using the [Linkup API](https://linkup.so).
4
4
 
5
+
6
+
5
7
  ## Features
6
8
 
7
9
  - `linkup_web_search` - Search the web, get relevant sources with content
@@ -9,6 +11,10 @@ Web search and content fetching extension for [Pi](https://buildwithpi.ai/) usin
9
11
  - `linkup_web_fetch` - Extract clean markdown from URLs
10
12
  - `/linkup:balance` - Check API credit balance
11
13
 
14
+
15
+ https://github.com/user-attachments/assets/a0f131a4-d57c-4162-aeb5-ffc1a0a8d7ff
16
+
17
+
12
18
  ## Installation
13
19
 
14
20
  ### Get API Key
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-linkup",
3
- "version": "0.3.1",
3
+ "version": "0.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/aliou/pi-linkup"
@@ -17,11 +17,16 @@
17
17
  ],
18
18
  "video": "https://assets.aliou.me/pi-extensions/demos/pi-linkup.mp4"
19
19
  },
20
+ "peerDependencies": {
21
+ "@mariozechner/pi-ai": ">=0.52.7",
22
+ "@mariozechner/pi-coding-agent": ">=0.52.7"
23
+ },
20
24
  "devDependencies": {
25
+ "@aliou/pi-utils-settings": "^0.2.1",
21
26
  "@biomejs/biome": "^2.3.13",
22
27
  "@changesets/cli": "^2.27.11",
23
- "@mariozechner/pi-coding-agent": "0.51.0",
24
- "@mariozechner/pi-tui": "0.51.0",
28
+ "@mariozechner/pi-coding-agent": "0.52.7",
29
+ "@mariozechner/pi-tui": "0.52.7",
25
30
  "@sinclair/typebox": "^0.34.48",
26
31
  "@types/node": "^25.0.10",
27
32
  "husky": "^9.1.7",
@@ -14,11 +14,14 @@ Web search and content fetching tools powered by Linkup API.
14
14
  Search the web and get sources with content snippets.
15
15
 
16
16
  ```
17
- linkup_web_search(query: string, deep?: boolean)
17
+ linkup_web_search(query: string, depth?: "fast" | "standard" | "deep")
18
18
  ```
19
19
 
20
20
  - `query`: Be specific and detailed. Include context like dates, locations, company names.
21
- - `deep`: Use for complex research requiring multiple searches. Default: false (faster).
21
+ - `depth`: Search depth mode. Default: "standard".
22
+ - `fast`: Sub-second latency, uses pre-indexed "atoms of information". Best for quick facts and simple lookups.
23
+ - `standard`: Single iteration retrieval. Balanced speed and depth for most queries.
24
+ - `deep`: Up to 10 iterations with chain-of-thought reasoning. Best for complex multi-step research (slower).
22
25
 
23
26
  **Use when:** Discovering information across multiple sources, researching topics, comparing perspectives.
24
27
 
@@ -27,9 +30,12 @@ linkup_web_search(query: string, deep?: boolean)
27
30
  Get a synthesized answer with source citations.
28
31
 
29
32
  ```
30
- linkup_web_answer(query: string, deep?: boolean)
33
+ linkup_web_answer(query: string, depth?: "fast" | "standard" | "deep")
31
34
  ```
32
35
 
36
+ - `query`: Be specific and detailed.
37
+ - `depth`: Same depth modes as `linkup_web_search`. Default: "standard".
38
+
33
39
  **Use when:** Need a direct answer to a specific question, quick facts with citations.
34
40
 
35
41
  ### linkup_web_fetch
@@ -68,18 +74,23 @@ linkup_web_fetch(url: string, renderJs?: boolean)
68
74
  - Location: "French company Total", "US market"
69
75
  - Specifics: company names, version numbers, exact terms
70
76
 
71
- ## When to Use Deep Mode
77
+ ## Depth Mode Selection
78
+
79
+ **Fast:** Sub-second responses for quick facts, simple lookups, known facts.
72
80
 
73
- **Standard (default):** Simple questions, quick lookups, known topics.
81
+ **Standard (default):** Single iteration, balanced speed/depth for most queries.
74
82
 
75
83
  **Deep:** Complex research, multi-step queries, comprehensive coverage needed.
76
84
 
77
85
  ```
78
- // Standard - one search is enough
79
- linkup_web_search("Node.js 22 release date")
86
+ // Fast - instant facts, sub-second
87
+ linkup_web_search("Node.js 22 release date", depth: "fast")
88
+
89
+ // Standard - balanced, one search iteration
90
+ linkup_web_search("React useEffect cleanup best practices")
80
91
 
81
- // Deep - needs multiple searches
82
- linkup_web_search("comparison of Rust web frameworks performance benchmarks 2025", deep: true)
92
+ // Deep - complex research, multiple iterations
93
+ linkup_web_search("comparison of Rust web frameworks performance benchmarks 2025", depth: "deep")
83
94
  ```
84
95
 
85
96
  ## Common Patterns
package/src/client.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { StringEnum } from "@mariozechner/pi-ai";
2
+ import packageJson from "../package.json" with { type: "json" };
3
+
1
4
  import type {
2
5
  LinkupBalanceResponse,
3
6
  LinkupErrorResponse,
@@ -8,6 +11,13 @@ import type {
8
11
 
9
12
  const BASE_URL = "https://api.linkup.so/v1";
10
13
 
14
+ export const SearchDepth = StringEnum(["fast", "standard", "deep"], {
15
+ description:
16
+ "Search depth: 'fast' for sub-second quick facts, 'standard' (default) for balanced speed/depth, 'deep' for comprehensive multi-step research (slower).",
17
+ });
18
+
19
+ export type SearchDepthType = "fast" | "standard" | "deep";
20
+
11
21
  export class LinkupClient {
12
22
  private apiKey: string;
13
23
 
@@ -24,6 +34,7 @@ export class LinkupClient {
24
34
  headers: {
25
35
  Authorization: `Bearer ${this.apiKey}`,
26
36
  "Content-Type": "application/json",
37
+ "User-Agent": `pi-linkup/${packageJson.version} (+https://github.com/aliou/pi-linkup)`,
27
38
  ...options.headers,
28
39
  },
29
40
  });
@@ -41,7 +52,7 @@ export class LinkupClient {
41
52
 
42
53
  async search(params: {
43
54
  query: string;
44
- depth: "standard" | "deep";
55
+ depth: SearchDepthType;
45
56
  outputType: "searchResults" | "sourcedAnswer";
46
57
  }): Promise<LinkupSearchResponse | LinkupSourcedAnswerResponse> {
47
58
  return this.request("/search", {
@@ -0,0 +1,43 @@
1
+ import {
2
+ registerSettingsCommand,
3
+ type SettingsSection,
4
+ } from "@aliou/pi-utils-settings";
5
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
6
+ import {
7
+ configLoader,
8
+ type LinkupConfig,
9
+ type ResolvedLinkupConfig,
10
+ } from "../config";
11
+
12
+ export function registerLinkupSettings(pi: ExtensionAPI): void {
13
+ registerSettingsCommand<LinkupConfig, ResolvedLinkupConfig>(pi, {
14
+ commandName: "linkup:settings",
15
+ commandDescription: "Configure Linkup extension settings",
16
+ title: "Linkup Settings",
17
+ configStore: configLoader,
18
+ buildSections: (
19
+ tabConfig: LinkupConfig | null,
20
+ resolved: ResolvedLinkupConfig,
21
+ ): SettingsSection[] => {
22
+ return [
23
+ {
24
+ label: "System Prompt",
25
+ items: [
26
+ {
27
+ id: "systemPromptGuidance",
28
+ label: "Append search guidance",
29
+ description:
30
+ "Add Linkup usage guidance to the system prompt so the model knows when and how to use web search and fetch tools",
31
+ currentValue:
32
+ (tabConfig?.systemPromptGuidance ??
33
+ resolved.systemPromptGuidance)
34
+ ? "enabled"
35
+ : "disabled",
36
+ values: ["enabled", "disabled"],
37
+ },
38
+ ],
39
+ },
40
+ ];
41
+ },
42
+ });
43
+ }
package/src/config.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { ConfigLoader } from "@aliou/pi-utils-settings";
2
+
3
+ /**
4
+ * Raw config shape (what gets saved to disk).
5
+ * All fields optional -- only overrides are stored.
6
+ */
7
+ export interface LinkupConfig {
8
+ systemPromptGuidance?: boolean;
9
+ }
10
+
11
+ /**
12
+ * Resolved config (defaults merged in).
13
+ */
14
+ export interface ResolvedLinkupConfig {
15
+ systemPromptGuidance: boolean;
16
+ }
17
+
18
+ const DEFAULTS: ResolvedLinkupConfig = {
19
+ systemPromptGuidance: false,
20
+ };
21
+
22
+ export const configLoader = new ConfigLoader<
23
+ LinkupConfig,
24
+ ResolvedLinkupConfig
25
+ >("pi-linkup", DEFAULTS);
@@ -0,0 +1,28 @@
1
+ /**
2
+ * System prompt guidance for Linkup tools.
3
+ * Appended to the system prompt when the setting is enabled.
4
+ */
5
+ export const LINKUP_GUIDANCE = `
6
+ ## Linkup
7
+
8
+ Use the Linkup tools for web search and content fetching. Three tools are available: linkup_web_search (discovery), linkup_web_answer (direct answers), linkup_web_fetch (URL content extraction).
9
+
10
+ **Tool selection:**
11
+ - Find information across sources: \`linkup_web_search\`
12
+ - Get a direct answer with sources: \`linkup_web_answer\`
13
+ - Read content from a known URL: \`linkup_web_fetch\`
14
+
15
+ **Search depth modes (linkup_web_search, linkup_web_answer):**
16
+ - \`fast\`: Sub-second, pre-indexed facts. Use for quick lookups.
17
+ - \`standard\` (default): Single iteration, balanced speed/depth.
18
+ - \`deep\`: Multi-iteration with chain-of-thought. Use for complex research.
19
+
20
+ **Query tips:**
21
+ - Be specific: "Microsoft fiscal year 2024 total revenue" not "Microsoft revenue"
22
+ - Add context: dates, version numbers, company names, locations
23
+
24
+ **Common patterns:**
25
+ 1. Research: \`linkup_web_search\` to discover, then \`linkup_web_fetch\` on promising URLs
26
+ 2. Quick facts: \`linkup_web_answer\` for direct answer with citations
27
+ 3. Documentation: \`linkup_web_fetch\` on known URL (set \`renderJs: false\` for static pages)
28
+ `;
@@ -0,0 +1 @@
1
+ export { registerGuidance } from "./system-prompt";
@@ -0,0 +1,17 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ import { configLoader } from "../config";
3
+ import { LINKUP_GUIDANCE } from "../guidance";
4
+
5
+ /**
6
+ * Register the system prompt hook to inject Linkup guidance when enabled.
7
+ */
8
+ export function registerGuidance(pi: ExtensionAPI) {
9
+ pi.on("before_agent_start", async (event) => {
10
+ const config = configLoader.getConfig();
11
+ if (!config.systemPromptGuidance) return;
12
+
13
+ return {
14
+ systemPrompt: `${event.systemPrompt}\n${LINKUP_GUIDANCE}`,
15
+ };
16
+ });
17
+ }
package/src/index.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
2
  import { registerBalanceCommand } from "./commands/balance";
3
+ import { registerLinkupSettings } from "./commands/settings";
3
4
  import { registerRenderers } from "./components";
5
+ import { configLoader } from "./config";
6
+ import { registerGuidance } from "./hooks";
4
7
  import { registerWebAnswerTool } from "./tools/web-answer";
5
8
  import { registerWebFetchTool } from "./tools/web-fetch";
6
9
  import { registerWebSearchTool } from "./tools/web-search";
7
10
 
8
- export default function (pi: ExtensionAPI) {
11
+ export default async function (pi: ExtensionAPI) {
9
12
  const hasApiKey = !!process.env.LINKUP_API_KEY;
10
13
 
11
14
  if (!hasApiKey) {
@@ -24,6 +27,9 @@ export default function (pi: ExtensionAPI) {
24
27
  return;
25
28
  }
26
29
 
30
+ // Load config
31
+ await configLoader.load();
32
+
27
33
  // Register tools
28
34
  registerWebSearchTool(pi);
29
35
  registerWebAnswerTool(pi);
@@ -31,7 +37,11 @@ export default function (pi: ExtensionAPI) {
31
37
 
32
38
  // Register commands
33
39
  registerBalanceCommand(pi);
40
+ registerLinkupSettings(pi);
34
41
 
35
42
  // Register renderers
36
43
  registerRenderers(pi);
44
+
45
+ // Register hooks
46
+ registerGuidance(pi);
37
47
  }
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
2
  import { Text } from "@mariozechner/pi-tui";
3
3
  import { Type } from "@sinclair/typebox";
4
- import { getClient } from "../client";
4
+ import { getClient, SearchDepth, type SearchDepthType } from "../client";
5
5
  import type { LinkupSource, LinkupSourcedAnswerResponse } from "../types";
6
6
 
7
7
  interface WebAnswerDetails {
@@ -23,12 +23,7 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
23
23
  description:
24
24
  "The question to answer. Be specific and detailed for best results.",
25
25
  }),
26
- deep: Type.Optional(
27
- Type.Boolean({
28
- description:
29
- "Use deep search for more comprehensive answer (slower). Default: false (standard search).",
30
- }),
31
- ),
26
+ depth: Type.Optional(SearchDepth),
32
27
  }),
33
28
 
34
29
  async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
@@ -39,7 +34,7 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
39
34
  content: [
40
35
  {
41
36
  type: "text",
42
- text: `Searching for answer${params.deep ? " (deep mode)" : ""}...`,
37
+ text: `Searching for answer${params.depth && params.depth !== "standard" ? ` (${params.depth} mode)` : ""}...`,
43
38
  },
44
39
  ],
45
40
  details: {},
@@ -47,7 +42,7 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
47
42
 
48
43
  const response = (await client.search({
49
44
  query: params.query,
50
- depth: params.deep ? "deep" : "standard",
45
+ depth: (params.depth ?? "standard") as SearchDepthType,
51
46
  outputType: "sourcedAnswer",
52
47
  })) as LinkupSourcedAnswerResponse;
53
48
 
@@ -81,8 +76,8 @@ export function registerWebAnswerTool(pi: ExtensionAPI) {
81
76
  renderCall(args, theme) {
82
77
  let text = theme.fg("toolTitle", theme.bold("Linkup: WebAnswer "));
83
78
  text += theme.fg("accent", `"${args.query}"`);
84
- if (args.deep) {
85
- text += theme.fg("dim", " (deep)");
79
+ if (args.depth && args.depth !== "standard") {
80
+ text += theme.fg("dim", ` (${args.depth})`);
86
81
  }
87
82
  return new Text(text, 0, 0);
88
83
  },
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
2
  import { Text } from "@mariozechner/pi-tui";
3
3
  import { Type } from "@sinclair/typebox";
4
- import { getClient } from "../client";
4
+ import { getClient, SearchDepth, type SearchDepthType } from "../client";
5
5
  import type { LinkupSearchResponse, LinkupSearchResult } from "../types";
6
6
 
7
7
  interface WebSearchDetails {
@@ -22,12 +22,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
22
22
  description:
23
23
  "The search query. Be specific and detailed for best results.",
24
24
  }),
25
- deep: Type.Optional(
26
- Type.Boolean({
27
- description:
28
- "Use deep search for comprehensive results (slower). Default: false (standard search).",
29
- }),
30
- ),
25
+ depth: Type.Optional(SearchDepth),
31
26
  }),
32
27
 
33
28
  async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
@@ -38,7 +33,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
38
33
  content: [
39
34
  {
40
35
  type: "text",
41
- text: `Searching${params.deep ? " (deep mode)" : ""}...`,
36
+ text: `Searching${params.depth && params.depth !== "standard" ? ` (${params.depth} mode)` : ""}...`,
42
37
  },
43
38
  ],
44
39
  details: {},
@@ -46,7 +41,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
46
41
 
47
42
  const response = (await client.search({
48
43
  query: params.query,
49
- depth: params.deep ? "deep" : "standard",
44
+ depth: (params.depth ?? "standard") as SearchDepthType,
50
45
  outputType: "searchResults",
51
46
  })) as LinkupSearchResponse;
52
47
 
@@ -77,8 +72,8 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
77
72
  renderCall(args, theme) {
78
73
  let text = theme.fg("toolTitle", theme.bold("Linkup: WebSearch "));
79
74
  text += theme.fg("accent", `"${args.query}"`);
80
- if (args.deep) {
81
- text += theme.fg("dim", " (deep)");
75
+ if (args.depth && args.depth !== "standard") {
76
+ text += theme.fg("dim", ` (${args.depth})`);
82
77
  }
83
78
  return new Text(text, 0, 0);
84
79
  },