@averyyy/pi-client 0.80.3-piclient.8 → 0.80.3-piclient.9

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/bin/web.js +49 -3
  2. package/package.json +2 -2
package/bin/web.js CHANGED
@@ -1,10 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from "node:child_process";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { homedir } from "node:os";
3
5
  import { dirname, join } from "node:path";
4
6
  import { fileURLToPath } from "node:url";
5
7
 
6
8
  const defaultPort = "1838";
7
9
  const defaultPiServerUrl = "http://127.0.0.1:4217";
10
+ const tauCodexPackage = "@averyyy/pi-tau-codex";
11
+ const tauCodexInstallTarget = "npm:@averyyy/pi-tau-codex";
12
+ const tauCodexGitTarget = "git:github.com/Averyyy/pi-tau-codex";
8
13
 
9
14
  export async function runPiClientWeb(args = process.argv.slice(2)) {
10
15
  const parsed = parseArgs(args);
@@ -13,6 +18,11 @@ export async function runPiClientWeb(args = process.argv.slice(2)) {
13
18
  return 0;
14
19
  }
15
20
 
21
+ if (!hasTauCodexExtensionInstalled(process.env)) {
22
+ printInstallRequired();
23
+ return 1;
24
+ }
25
+
16
26
  process.title = "pi-client web";
17
27
  const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
18
28
  const port = parsed.port;
@@ -23,7 +33,6 @@ export async function runPiClientWeb(args = process.argv.slice(2)) {
23
33
  });
24
34
 
25
35
  console.log(`pi-client web uses Tau at http://${host}:${port}`);
26
- console.log("If Tau is not installed, run: pi install npm:tau-mirror or pi-client install npm:tau-mirror");
27
36
 
28
37
  return await new Promise((resolve, reject) => {
29
38
  child.once("error", reject);
@@ -44,6 +53,35 @@ export function piClientWebEnv(env = process.env, options) {
44
53
  };
45
54
  }
46
55
 
56
+ export function hasTauCodexExtensionInstalled(env = process.env) {
57
+ if (env.TAU_STATIC_DIR) return true;
58
+ const settingsPath = env.PI_CODING_AGENT_SETTINGS_PATH ?? join(
59
+ env.PI_CODING_AGENT_DIR ?? join(env.HOME ?? homedir(), ".pi", "agent"),
60
+ "settings.json",
61
+ );
62
+ if (!existsSync(settingsPath)) return false;
63
+ const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
64
+ const packages = Array.isArray(settings.packages) ? settings.packages : [];
65
+ return packages.some(packageSpecMatchesTauCodex);
66
+ }
67
+
68
+ function packageSpecMatchesTauCodex(spec) {
69
+ if (typeof spec === "string") return specMatchesTauCodex(spec);
70
+ if (!spec || typeof spec !== "object") return false;
71
+ return ["source", "package", "name", "spec"].some((key) => specMatchesTauCodex(spec[key]));
72
+ }
73
+
74
+ function specMatchesTauCodex(spec) {
75
+ return typeof spec === "string" && (
76
+ spec === tauCodexPackage ||
77
+ spec === tauCodexInstallTarget ||
78
+ spec.startsWith(`${tauCodexPackage}@`) ||
79
+ spec.startsWith(`${tauCodexInstallTarget}@`) ||
80
+ spec === tauCodexGitTarget ||
81
+ spec.includes("github.com/Averyyy/pi-tau-codex")
82
+ );
83
+ }
84
+
47
85
  function parseArgs(args) {
48
86
  let port = process.env.TAU_MIRROR_PORT ?? defaultPort;
49
87
  const clientArgs = [];
@@ -99,7 +137,15 @@ Environment:
99
137
  TAU_MIRROR_PORT Tau port (default: ${defaultPort})
100
138
 
101
139
  Tau must be installed in the shared Pi agent settings:
102
- pi install npm:tau-mirror
103
- # or: pi-client install npm:tau-mirror
140
+ pi-client install npm:@averyyy/pi-tau-codex
141
+ # or: pi install npm:@averyyy/pi-tau-codex
142
+ # dev fallback: pi-client install git:github.com/Averyyy/pi-tau-codex
104
143
  `);
105
144
  }
145
+
146
+ function printInstallRequired() {
147
+ console.error(`请安装 ${tauCodexPackage}:`);
148
+ console.error(" pi-client install npm:@averyyy/pi-tau-codex");
149
+ console.error(" # or: pi install npm:@averyyy/pi-tau-codex");
150
+ console.error(" # dev fallback: pi-client install git:github.com/Averyyy/pi-tau-codex");
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@averyyy/pi-client",
3
- "version": "0.80.3-piclient.8",
3
+ "version": "0.80.3-piclient.9",
4
4
  "description": "Lightweight CLI wrapper that connects to a pi-server instance",
5
5
  "type": "module",
6
6
  "piClient": {
@@ -25,7 +25,7 @@
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@earendil-works/pi-coding-agent": "npm:@averyyy/pi-coding-agent@0.80.3-piclient.8"
28
+ "@earendil-works/pi-coding-agent": "npm:@averyyy/pi-coding-agent@0.80.3-piclient.9"
29
29
  },
30
30
  "devDependencies": {
31
31
  "shx": "0.4.0",