send-to-pi 1.0.0 → 1.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/README.md +11 -3
- package/README_CN.md +12 -5
- package/chrome-extension/background.js +16 -14
- package/chrome-extension/manifest.json +2 -2
- package/package.json +2 -1
- package/scripts/start-win.vbs +1 -2
- package/server/bin/send-to-pi.js +23 -0
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> Seamlessly bridge your web browser to the [Pi Coding Agent](https://github.com/earendil-works/pi-coding-agent). Send snippets, articles, or links directly into your Pi terminal prompt with one right-click.
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/send-to-pi)
|
|
7
8
|
[](https://opensource.org/licenses/MIT)
|
|
8
9
|
[](https://nodejs.org/)
|
|
9
10
|
[]()
|
|
@@ -62,10 +63,10 @@ sequenceDiagram
|
|
|
62
63
|
You can install it directly via Pi's built-in package manager:
|
|
63
64
|
|
|
64
65
|
```bash
|
|
65
|
-
pi install
|
|
66
|
+
pi install npm:send-to-pi
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
*(
|
|
69
|
+
*(Or from GitHub: `pi install git:github.com/Wude-m/send-to-pi`)*
|
|
69
70
|
|
|
70
71
|
### Step 2: Start the Bridge Daemon
|
|
71
72
|
The bridge daemon runs in the background on your machine:
|
|
@@ -83,9 +84,16 @@ npm start
|
|
|
83
84
|
*(Tip: macOS users can run `bash scripts/start-mac.sh` to run in background. Windows users can double-click `scripts/start-win.vbs` for silent background execution.)*
|
|
84
85
|
|
|
85
86
|
### Step 3: Load the Chrome Extension
|
|
87
|
+
You don't need to hunt for the folder manually! Just run:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx send-to-pi extension
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This will print the exact folder path and **automatically open the extension directory in your file manager**. Then:
|
|
86
94
|
1. Open Google Chrome or Microsoft Edge and navigate to `chrome://extensions/`.
|
|
87
95
|
2. Toggle on **Developer mode** in the top-right corner.
|
|
88
|
-
3. Click **Load unpacked** and select the
|
|
96
|
+
3. Click **Load unpacked** and select the folder that just opened.
|
|
89
97
|
4. You're all set!
|
|
90
98
|
|
|
91
99
|
---
|
package/README_CN.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> 让你的网页浏览器与 [Pi 终端编程助手](https://github.com/earendil-works/pi-coding-agent) 无缝打通。在网页上选中文字、链接或页面,一键右键直达终端输入框,自动排版并预填上下文。
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/send-to-pi)
|
|
7
8
|
[](https://opensource.org/licenses/MIT)
|
|
8
9
|
[](https://nodejs.org/)
|
|
9
10
|
[]()
|
|
@@ -62,10 +63,10 @@ sequenceDiagram
|
|
|
62
63
|
你可以直接使用 Pi 内置的包管理器一键安装:
|
|
63
64
|
|
|
64
65
|
```bash
|
|
65
|
-
pi install
|
|
66
|
+
pi install npm:send-to-pi
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
*(
|
|
69
|
+
*(或者通过 GitHub 安装: `pi install git:github.com/Wude-m/send-to-pi`)*
|
|
69
70
|
|
|
70
71
|
### 第二步:启动 Bridge 守护进程
|
|
71
72
|
调度守护进程负责在后台监听浏览器请求并在需要时唤醒终端:
|
|
@@ -85,10 +86,16 @@ npm start
|
|
|
85
86
|
> - **Windows 用户**:双击 `scripts/start-win.vbs` 即可无黑框后台静默运行。
|
|
86
87
|
|
|
87
88
|
### 第三步:加载 Chrome 浏览器扩展
|
|
88
|
-
|
|
89
|
+
你完全不需要手动去翻找目录,只需在终端运行:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx send-to-pi extension
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
该命令会打印出扩展目录并**自动在系统文件管理器中打开该文件夹**。然后:
|
|
96
|
+
1. 打开 Chrome 或 Edge 浏览器,访问 `chrome://extensions/`;
|
|
89
97
|
2. 开启右上角的 **“开发者模式”**(Developer mode);
|
|
90
|
-
3. 点击左上角的 **“加载已解压的扩展程序”**(Load unpacked
|
|
91
|
-
4. 选择本仓库的 `chrome-extension` 目录即可!
|
|
98
|
+
3. 点击左上角的 **“加载已解压的扩展程序”**(Load unpacked),选择刚刚为你弹出的文件夹即可!
|
|
92
99
|
|
|
93
100
|
---
|
|
94
101
|
|
|
@@ -36,22 +36,24 @@ async function getBridgeUrl() {
|
|
|
36
36
|
|
|
37
37
|
// 注册右键菜单
|
|
38
38
|
chrome.runtime.onInstalled.addListener(() => {
|
|
39
|
-
chrome.contextMenus.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
chrome.contextMenus.removeAll(() => {
|
|
40
|
+
chrome.contextMenus.create({
|
|
41
|
+
id: "send_selection",
|
|
42
|
+
title: i18n.menuSelection,
|
|
43
|
+
contexts: ["selection"],
|
|
44
|
+
});
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
chrome.contextMenus.create({
|
|
47
|
+
id: "send_page",
|
|
48
|
+
title: i18n.menuPage,
|
|
49
|
+
contexts: ["page"],
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
chrome.contextMenus.create({
|
|
53
|
+
id: "send_link",
|
|
54
|
+
title: i18n.menuLink,
|
|
55
|
+
contexts: ["link"],
|
|
56
|
+
});
|
|
55
57
|
});
|
|
56
58
|
});
|
|
57
59
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
|
-
"name": "Send to Pi",
|
|
4
|
-
"version": "1.0.
|
|
3
|
+
"name": "Send to Pi (发送给 Pi)",
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "Send webpage snippets, URLs, or articles directly to your local Pi coding agent terminal.",
|
|
6
6
|
"permissions": [
|
|
7
7
|
"contextMenus",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "send-to-pi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Send webpage snippets, URLs, or articles directly to your local Pi coding agent terminal.",
|
|
5
5
|
"main": "server/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node server/src/index.js",
|
|
11
11
|
"status": "node server/bin/send-to-pi.js status",
|
|
12
|
+
"extension": "node server/bin/send-to-pi.js extension",
|
|
12
13
|
"test": "node server/bin/send-to-pi.js --help"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|
package/scripts/start-win.vbs
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Set WshShell = CreateObject("WScript.Shell")
|
|
3
3
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
4
4
|
|
|
5
|
-
' 获取项目根目录
|
|
6
5
|
scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
|
|
7
6
|
rootDir = fso.GetParentFolderName(scriptDir)
|
|
8
7
|
targetScript = rootDir & "\server\src\index.js"
|
|
9
8
|
|
|
10
9
|
' 0 = 隐藏黑框静默运行
|
|
11
|
-
WshShell.Run "node """ & targetScript & """", 0, False
|
|
10
|
+
WshShell.Run "cmd.exe /c node """ & targetScript & """", 0, False
|
package/server/bin/send-to-pi.js
CHANGED
|
@@ -48,6 +48,28 @@ if (command === 'status' || command === 'check') {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
req.end();
|
|
51
|
+
} else if (command === 'extension' || command === 'ext' || command === 'open-extension') {
|
|
52
|
+
const path = require('path');
|
|
53
|
+
const { spawn } = require('child_process');
|
|
54
|
+
const extDir = path.resolve(__dirname, '../../chrome-extension');
|
|
55
|
+
|
|
56
|
+
console.log(`\n📦 Chrome Extension folder:`);
|
|
57
|
+
console.log(` ${extDir}\n`);
|
|
58
|
+
console.log(`👉 Quick steps to load into Chrome / Edge:`);
|
|
59
|
+
console.log(` 1. Open chrome://extensions/ in your browser`);
|
|
60
|
+
console.log(` 2. Toggle on "Developer mode" in the top-right corner`);
|
|
61
|
+
console.log(` 3. Click "Load unpacked" and select the folder opened above!\n`);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
if (process.platform === 'win32') {
|
|
65
|
+
spawn('explorer.exe', [extDir], { detached: true, stdio: 'ignore' }).unref();
|
|
66
|
+
} else if (process.platform === 'darwin') {
|
|
67
|
+
spawn('open', [extDir], { detached: true, stdio: 'ignore' }).unref();
|
|
68
|
+
} else {
|
|
69
|
+
spawn('xdg-open', [extDir], { detached: true, stdio: 'ignore' }).unref();
|
|
70
|
+
}
|
|
71
|
+
} catch (_e) {}
|
|
72
|
+
process.exit(0);
|
|
51
73
|
} else if (command === 'help' || command === '--help' || command === '-h') {
|
|
52
74
|
console.log(`
|
|
53
75
|
Usage: send-to-pi [command] [options]
|
|
@@ -55,6 +77,7 @@ Usage: send-to-pi [command] [options]
|
|
|
55
77
|
Commands:
|
|
56
78
|
start Start the bridge daemon (default)
|
|
57
79
|
status Check if the bridge daemon is running
|
|
80
|
+
extension Open the Chrome extension folder to load in browser
|
|
58
81
|
help Show this help message
|
|
59
82
|
|
|
60
83
|
Options via Environment Variables:
|