ping-a-human-pi 0.1.0 → 0.1.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/README.md +1 -0
- package/bin/pah +35 -2
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ A standalone command (no pi required) for pinging a human from any terminal:
|
|
|
36
36
|
pah ping "build finished" # fire-and-forget notification
|
|
37
37
|
pah notify "deploy started" # alias for ping
|
|
38
38
|
pah ask "ship to prod?" # waits and prints the human's reply
|
|
39
|
+
pah --version # CLI version + the ping-a-human server version
|
|
39
40
|
pah help
|
|
40
41
|
```
|
|
41
42
|
|
package/bin/pah
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* pah ping [message...] send a Telegram notification (fire-and-forget)
|
|
6
6
|
* pah notify [message...] alias for `ping`
|
|
7
7
|
* pah ask <question...> ask a human and print their reply (waits)
|
|
8
|
+
* pah --version print the CLI and server versions
|
|
8
9
|
* pah help show usage
|
|
9
10
|
*
|
|
10
11
|
* Reads server config from ~/.pi/agent/ping-a-human.json if present
|
|
@@ -14,11 +15,23 @@
|
|
|
14
15
|
import { spawn } from "node:child_process";
|
|
15
16
|
import { readFileSync } from "node:fs";
|
|
16
17
|
import { homedir } from "node:os";
|
|
17
|
-
import { join } from "node:path";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
18
20
|
|
|
19
21
|
const PROTOCOL_VERSION = "2024-11-05";
|
|
20
22
|
const TIMEOUT_MS = 600_000;
|
|
21
23
|
|
|
24
|
+
/** This CLI's version, read from ping-a-human-pi's package.json (bin/ -> ../). */
|
|
25
|
+
function cliVersion() {
|
|
26
|
+
try {
|
|
27
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8"));
|
|
29
|
+
return pkg.version ?? "unknown";
|
|
30
|
+
} catch {
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
function loadServer() {
|
|
23
36
|
const candidates = [process.env.PING_A_HUMAN_PI_CONFIG, join(homedir(), ".pi", "agent", "ping-a-human.json")].filter(Boolean);
|
|
24
37
|
for (const path of candidates) {
|
|
@@ -48,6 +61,8 @@ class McpClient {
|
|
|
48
61
|
this.env = env;
|
|
49
62
|
}
|
|
50
63
|
|
|
64
|
+
serverInfo = null;
|
|
65
|
+
|
|
51
66
|
async start() {
|
|
52
67
|
this.#proc = spawn(this.command, this.args, { env: { ...process.env, ...(this.env ?? {}) }, stdio: ["pipe", "pipe", "pipe"] });
|
|
53
68
|
this.#proc.on("error", (e) => this.#failAll(new Error(`ping-a-human: ${e.message}`)));
|
|
@@ -56,7 +71,8 @@ class McpClient {
|
|
|
56
71
|
this.#proc.stdout.on("data", (c) => this.#onData(c));
|
|
57
72
|
this.#proc.stderr.setEncoding("utf8");
|
|
58
73
|
this.#proc.stderr.on("data", () => {});
|
|
59
|
-
await this.#req("initialize", { protocolVersion: PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: "pah-cli", version: "1.0.0" } });
|
|
74
|
+
const init = await this.#req("initialize", { protocolVersion: PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: "pah-cli", version: "1.0.0" } });
|
|
75
|
+
this.serverInfo = init?.serverInfo ?? null;
|
|
60
76
|
this.#notify("notifications/initialized");
|
|
61
77
|
}
|
|
62
78
|
|
|
@@ -129,6 +145,7 @@ function usage() {
|
|
|
129
145
|
' pah ping [message...] send a notification (fire-and-forget)',
|
|
130
146
|
' pah notify [message...] alias for ping',
|
|
131
147
|
' pah ask <question...> ask a human and print their reply (waits)',
|
|
148
|
+
" pah --version print the CLI and server versions",
|
|
132
149
|
" pah help show this help",
|
|
133
150
|
"",
|
|
134
151
|
"Examples:",
|
|
@@ -148,6 +165,22 @@ async function main() {
|
|
|
148
165
|
process.exit(cmd ? 0 : 1);
|
|
149
166
|
}
|
|
150
167
|
|
|
168
|
+
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
169
|
+
process.stdout.write(`pah (ping-a-human-pi) ${cliVersion()}\n`);
|
|
170
|
+
// Best-effort: also report the ping-a-human server version it launches.
|
|
171
|
+
const client = new McpClient(loadServer());
|
|
172
|
+
try {
|
|
173
|
+
await client.start();
|
|
174
|
+
const v = client.serverInfo?.version;
|
|
175
|
+
process.stdout.write(`ping-a-human server ${v ?? "unknown"}\n`);
|
|
176
|
+
} catch (err) {
|
|
177
|
+
process.stdout.write(`ping-a-human server unavailable (${err.message})\n`);
|
|
178
|
+
} finally {
|
|
179
|
+
client.stop();
|
|
180
|
+
}
|
|
181
|
+
process.exit(0);
|
|
182
|
+
}
|
|
183
|
+
|
|
151
184
|
const client = new McpClient(loadServer());
|
|
152
185
|
try {
|
|
153
186
|
await client.start();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ping-a-human-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Human-in-the-loop and notifications for the pi coding agent, powered by ping-a-human. One command: npx ping-a-human-pi.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,15 @@
|
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=18"
|
|
18
18
|
},
|
|
19
|
-
"keywords": [
|
|
19
|
+
"keywords": [
|
|
20
|
+
"pi-package",
|
|
21
|
+
"pi",
|
|
22
|
+
"mcp",
|
|
23
|
+
"ping-a-human",
|
|
24
|
+
"human-in-the-loop",
|
|
25
|
+
"notifications",
|
|
26
|
+
"cli"
|
|
27
|
+
],
|
|
20
28
|
"repository": {
|
|
21
29
|
"type": "git",
|
|
22
30
|
"url": "git+https://github.com/startriseio/ping-a-human.git",
|
|
@@ -28,7 +36,9 @@
|
|
|
28
36
|
},
|
|
29
37
|
"license": "MIT",
|
|
30
38
|
"pi": {
|
|
31
|
-
"extensions": [
|
|
39
|
+
"extensions": [
|
|
40
|
+
"./extension"
|
|
41
|
+
]
|
|
32
42
|
},
|
|
33
43
|
"peerDependencies": {
|
|
34
44
|
"@earendil-works/pi-coding-agent": "*",
|