@aliou/pi-linkup 0.4.0 → 0.6.1
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 +18 -0
- package/package.json +6 -3
- package/skills/linkup/SKILL.md +4 -1
- package/src/client.ts +9 -1
- package/src/commands/settings.ts +43 -0
- package/src/config.ts +25 -0
- package/src/guidance.ts +28 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/system-prompt.ts +17 -0
- package/src/index.ts +11 -1
- package/src/tools/web-answer.ts +6 -11
- package/src/tools/web-search.ts +3 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @aliou/pi-linkup
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d45c015: fix: move @aliou/pi-utils-settings from devDependencies to dependencies
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e9fdef1: Replace `deep` boolean with `depth` enum on web-answer tool for consistency with web-search
|
|
14
|
+
|
|
15
|
+
## 0.5.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 89a92f3: Add configurable system prompt guidance setting via /linkup:settings
|
|
20
|
+
|
|
3
21
|
## 0.4.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-linkup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/aliou/pi-linkup"
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
],
|
|
18
18
|
"video": "https://assets.aliou.me/pi-extensions/demos/pi-linkup.mp4"
|
|
19
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@aliou/pi-utils-settings": "^0.2.1"
|
|
22
|
+
},
|
|
20
23
|
"peerDependencies": {
|
|
21
|
-
"@mariozechner/pi-
|
|
22
|
-
"@mariozechner/pi-
|
|
24
|
+
"@mariozechner/pi-ai": ">=0.52.7",
|
|
25
|
+
"@mariozechner/pi-coding-agent": ">=0.52.7"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@biomejs/biome": "^2.3.13",
|
package/skills/linkup/SKILL.md
CHANGED
|
@@ -30,9 +30,12 @@ linkup_web_search(query: string, depth?: "fast" | "standard" | "deep")
|
|
|
30
30
|
Get a synthesized answer with source citations.
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
linkup_web_answer(query: string,
|
|
33
|
+
linkup_web_answer(query: string, depth?: "fast" | "standard" | "deep")
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
- `query`: Be specific and detailed.
|
|
37
|
+
- `depth`: Same depth modes as `linkup_web_search`. Default: "standard".
|
|
38
|
+
|
|
36
39
|
**Use when:** Need a direct answer to a specific question, quick facts with citations.
|
|
37
40
|
|
|
38
41
|
### linkup_web_fetch
|
package/src/client.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StringEnum } from "@mariozechner/pi-ai";
|
|
1
2
|
import packageJson from "../package.json" with { type: "json" };
|
|
2
3
|
|
|
3
4
|
import type {
|
|
@@ -10,6 +11,13 @@ import type {
|
|
|
10
11
|
|
|
11
12
|
const BASE_URL = "https://api.linkup.so/v1";
|
|
12
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
|
+
|
|
13
21
|
export class LinkupClient {
|
|
14
22
|
private apiKey: string;
|
|
15
23
|
|
|
@@ -44,7 +52,7 @@ export class LinkupClient {
|
|
|
44
52
|
|
|
45
53
|
async search(params: {
|
|
46
54
|
query: string;
|
|
47
|
-
depth:
|
|
55
|
+
depth: SearchDepthType;
|
|
48
56
|
outputType: "searchResults" | "sourcedAnswer";
|
|
49
57
|
}): Promise<LinkupSearchResponse | LinkupSourcedAnswerResponse> {
|
|
50
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);
|
package/src/guidance.ts
ADDED
|
@@ -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
|
}
|
package/src/tools/web-answer.ts
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
85
|
-
text += theme.fg("dim",
|
|
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
|
},
|
package/src/tools/web-search.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { StringEnum } from "@mariozechner/pi-ai";
|
|
2
1
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
3
2
|
import { Text } from "@mariozechner/pi-tui";
|
|
4
3
|
import { Type } from "@sinclair/typebox";
|
|
5
|
-
import { getClient } from "../client";
|
|
4
|
+
import { getClient, SearchDepth, type SearchDepthType } from "../client";
|
|
6
5
|
import type { LinkupSearchResponse, LinkupSearchResult } from "../types";
|
|
7
6
|
|
|
8
7
|
interface WebSearchDetails {
|
|
@@ -23,12 +22,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
|
|
|
23
22
|
description:
|
|
24
23
|
"The search query. Be specific and detailed for best results.",
|
|
25
24
|
}),
|
|
26
|
-
depth: Type.Optional(
|
|
27
|
-
StringEnum(["deep", "standard", "fast"], {
|
|
28
|
-
description:
|
|
29
|
-
"Search depth: 'fast' for sub-second quick facts, 'standard' (default) for balanced speed/depth, 'deep' for comprehensive multi-step research (slower).",
|
|
30
|
-
}),
|
|
31
|
-
),
|
|
25
|
+
depth: Type.Optional(SearchDepth),
|
|
32
26
|
}),
|
|
33
27
|
|
|
34
28
|
async execute(_toolCallId, params, _signal, onUpdate, _ctx) {
|
|
@@ -47,7 +41,7 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
|
|
|
47
41
|
|
|
48
42
|
const response = (await client.search({
|
|
49
43
|
query: params.query,
|
|
50
|
-
depth: (params.depth ?? "standard") as
|
|
44
|
+
depth: (params.depth ?? "standard") as SearchDepthType,
|
|
51
45
|
outputType: "searchResults",
|
|
52
46
|
})) as LinkupSearchResponse;
|
|
53
47
|
|