@aliou/pi-linkup 0.2.0 → 0.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @aliou/pi-linkup
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1d1dc94: Add demo video URL for the Pi package browser.
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - e57f6fe: Enhanced balance command to show remaining requests per operation type (standard search, deep search, fetch with/without JS) using a themed custom message renderer instead of a transient notification.
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-linkup",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/aliou/pi-linkup"
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "skills": [
16
16
  "./skills"
17
- ]
17
+ ],
18
+ "video": "https://assets.aliou.me/pi-extensions/demos/pi-linkup.mp4"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@biomejs/biome": "^2.3.13",
@@ -9,10 +9,12 @@ export function registerBalanceCommand(pi: ExtensionAPI) {
9
9
 
10
10
  try {
11
11
  const response = await client.getBalance();
12
- ctx.ui.notify(
13
- `Linkup Balance: ${response.balance.toFixed(2)} credits`,
14
- "info",
15
- );
12
+ pi.sendMessage({
13
+ customType: "linkup-balance",
14
+ content: `Linkup Balance: ${response.balance.toFixed(2)} credits`,
15
+ display: true,
16
+ details: { balance: response.balance },
17
+ });
16
18
  } catch (error) {
17
19
  const message =
18
20
  error instanceof Error ? error.message : "Unknown error";
@@ -0,0 +1,45 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ import { Box, Text } from "@mariozechner/pi-tui";
3
+ import { LINKUP_PRICING } from "../types";
4
+
5
+ export function registerBalanceRenderer(pi: ExtensionAPI) {
6
+ pi.registerMessageRenderer("linkup-balance", (message, _options, theme) => {
7
+ const details = message.details as { balance: number };
8
+ const balance = details.balance;
9
+
10
+ // Build header line
11
+ const header = [
12
+ theme.fg("accent", "Linkup"),
13
+ theme.fg("muted", " · "),
14
+ theme.fg("muted", `${balance} credits`),
15
+ ].join("");
16
+
17
+ // Calculate remaining requests for each operation type
18
+ const remaining = {
19
+ standardSearch: Math.floor(balance / LINKUP_PRICING.standardSearch),
20
+ deepSearch: Math.floor(balance / LINKUP_PRICING.deepSearch),
21
+ fetchNoJs: Math.floor(balance / LINKUP_PRICING.fetchNoJs),
22
+ fetchWithJs: Math.floor(balance / LINKUP_PRICING.fetchWithJs),
23
+ };
24
+
25
+ // Format number with locale string and ~ prefix
26
+ const fmt = (num: number): string => `~${num.toLocaleString()}`;
27
+
28
+ // Table rows with right-aligned numbers (padded to 7 chars)
29
+ const row = (num: number, label: string) =>
30
+ `${theme.fg("accent", fmt(num).padStart(7))} ${theme.fg("dim", label)}`;
31
+
32
+ const lines = [
33
+ header,
34
+ "",
35
+ row(remaining.standardSearch, "standard searches"),
36
+ row(remaining.deepSearch, "deep searches"),
37
+ row(remaining.fetchNoJs, "fetches (no JS)"),
38
+ row(remaining.fetchWithJs, "fetches (with JS)"),
39
+ ].join("\n");
40
+
41
+ const box = new Box(1, 1, (t) => theme.bg("customMessageBg", t));
42
+ box.addChild(new Text(lines, 0, 0));
43
+ return box;
44
+ });
45
+ }
@@ -0,0 +1,6 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ import { registerBalanceRenderer } from "./balance-renderer";
3
+
4
+ export function registerRenderers(pi: ExtensionAPI) {
5
+ registerBalanceRenderer(pi);
6
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
2
  import { registerBalanceCommand } from "./commands/balance";
3
+ import { registerRenderers } from "./components";
3
4
  import { registerWebAnswerTool } from "./tools/web-answer";
4
5
  import { registerWebFetchTool } from "./tools/web-fetch";
5
6
  import { registerWebSearchTool } from "./tools/web-search";
@@ -30,4 +31,7 @@ export default function (pi: ExtensionAPI) {
30
31
 
31
32
  // Register commands
32
33
  registerBalanceCommand(pi);
34
+
35
+ // Register renderers
36
+ registerRenderers(pi);
33
37
  }
package/src/types.ts CHANGED
@@ -32,3 +32,14 @@ export interface LinkupErrorResponse {
32
32
  message?: string;
33
33
  };
34
34
  }
35
+
36
+ /**
37
+ * Credit cost per request by operation type.
38
+ * Source: https://docs.linkup.so/pages/documentation/development/pricing
39
+ */
40
+ export const LINKUP_PRICING = {
41
+ standardSearch: 0.005,
42
+ deepSearch: 0.05,
43
+ fetchNoJs: 0.001,
44
+ fetchWithJs: 0.005,
45
+ } as const;