@ryan_nookpi/pi-extension-clipboard 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/index.ts +49 -51
  2. package/package.json +11 -1
package/index.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * Ask the LLM: "write me a draft reply and put it into clipboard!"
10
10
  */
11
11
 
12
- import { defineTool, type ExtensionAPI } from "@mariozechner/pi-coding-agent";
12
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
13
13
  import { Type } from "@sinclair/typebox";
14
14
 
15
15
  /**
@@ -36,61 +36,59 @@ function copyToClipboard(text: string): void {
36
36
  process.stdout.write(osc52);
37
37
  }
38
38
 
39
- const copyToClipboardTool = defineTool({
40
- name: "copy_to_clipboard",
41
- label: "Copy to Clipboard",
42
- description:
43
- "Copy text to the user's system clipboard. Use this when the user asks you to " +
44
- "put something in their clipboard, write a draft reply to clipboard, or copy any " +
45
- "generated text for easy pasting. The text will be available for pasting immediately.",
46
- parameters: Type.Object({
47
- text: Type.String({
48
- description: "The text to copy to the clipboard",
39
+ export default function clipboardExtension(pi: ExtensionAPI): void {
40
+ pi.registerTool({
41
+ name: "copy_to_clipboard",
42
+ label: "Copy to Clipboard",
43
+ description:
44
+ "Copy text to the user's system clipboard. Use this when the user asks you to " +
45
+ "put something in their clipboard, write a draft reply to clipboard, or copy any " +
46
+ "generated text for easy pasting. The text will be available for pasting immediately.",
47
+ parameters: Type.Object({
48
+ text: Type.String({
49
+ description: "The text to copy to the clipboard",
50
+ }),
49
51
  }),
50
- }),
51
- async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
52
- const { text } = params;
52
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
53
+ const { text } = params;
53
54
 
54
- if (!text || text.trim().length === 0) {
55
- return {
56
- content: [{ type: "text", text: "Error: No text provided to copy." }],
57
- details: { success: false, error: "empty_text" },
58
- };
59
- }
55
+ if (!text || text.trim().length === 0) {
56
+ return {
57
+ content: [{ type: "text", text: "Error: No text provided to copy." }],
58
+ details: { success: false, error: "empty_text" },
59
+ };
60
+ }
60
61
 
61
- try {
62
- copyToClipboard(text);
62
+ try {
63
+ copyToClipboard(text);
63
64
 
64
- const preview = text.length > 100 ? `${text.slice(0, 100)}...` : text;
65
- const charCount = text.length;
65
+ const preview = text.length > 100 ? `${text.slice(0, 100)}...` : text;
66
+ const charCount = text.length;
66
67
 
67
- if (ctx.hasUI) {
68
- ctx.ui.notify(`Copied ${charCount} characters to clipboard`, "info");
69
- }
68
+ if (ctx.hasUI) {
69
+ ctx.ui.notify(`Copied ${charCount} characters to clipboard`, "info");
70
+ }
70
71
 
71
- return {
72
- content: [
73
- {
74
- type: "text",
75
- text: `Successfully copied ${charCount} characters to clipboard.\n\nPreview:\n${preview}`,
72
+ return {
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: `Successfully copied ${charCount} characters to clipboard.\n\nPreview:\n${preview}`,
77
+ },
78
+ ],
79
+ details: {
80
+ success: true,
81
+ characterCount: charCount,
82
+ preview,
76
83
  },
77
- ],
78
- details: {
79
- success: true,
80
- characterCount: charCount,
81
- preview,
82
- },
83
- };
84
- } catch (error) {
85
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
86
- return {
87
- content: [{ type: "text", text: `Failed to copy to clipboard: ${errorMessage}` }],
88
- details: { success: false, error: errorMessage },
89
- };
90
- }
91
- },
92
- });
93
-
94
- export default function clipboardExtension(pi: ExtensionAPI): void {
95
- pi.registerTool(copyToClipboardTool);
84
+ };
85
+ } catch (error) {
86
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
87
+ return {
88
+ content: [{ type: "text", text: `Failed to copy to clipboard: ${errorMessage}` }],
89
+ details: { success: false, error: errorMessage },
90
+ };
91
+ }
92
+ },
93
+ });
96
94
  }
package/package.json CHANGED
@@ -1,7 +1,17 @@
1
1
  {
2
2
  "name": "@ryan_nookpi/pi-extension-clipboard",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Clipboard copy tool extension for pi using OSC52 escape sequences.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Jonghakseo/pi-extension.git",
9
+ "directory": "packages/clipboard"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Jonghakseo/pi-extension/issues"
13
+ },
14
+ "homepage": "https://github.com/Jonghakseo/pi-extension/tree/main/packages/clipboard#readme",
5
15
  "type": "module",
6
16
  "keywords": [
7
17
  "pi-package"