pi-webapp 0.1.8 → 0.1.10
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/bin/npm-command.d.mts +2 -0
- package/bin/npm-command.mjs +36 -0
- package/bin/pi-webapp.mjs +5 -2
- package/dist/extension.js +22 -17
- package/docs/sentry.md +60 -1
- package/package.json +5 -3
- package/web/dist/assets/app-B2Ac56ic.js +0 -2
- package/web/dist/assets/app.js +6 -8
- package/web/dist/assets/asciidoc-fDuF7HNn.js +0 -2
- package/web/dist/assets/bat-CIKKTCO7.js +0 -2
- package/web/dist/assets/bibtex-D13O2Wvh.js +0 -2
- package/web/dist/assets/c-BxgHfdNM.js +0 -2
- package/web/dist/assets/clojure-CiHGeAtp.js +0 -2
- package/web/dist/assets/cmake-DmzJtVCe.js +0 -2
- package/web/dist/assets/cpp-WTsyTmWk.js +0 -2
- package/web/dist/assets/csharp-BusYHIEz.js +0 -2
- package/web/dist/assets/css-D-q0lhfR.js +0 -2
- package/web/dist/assets/csv-DFLln536.js +0 -2
- package/web/dist/assets/dart-CafiI-9_.js +0 -2
- package/web/dist/assets/diff-Br1ISN9_.js +0 -2
- package/web/dist/assets/dotenv-CIz2XDph.js +0 -2
- package/web/dist/assets/elixir-DRaGIFOe.js +0 -2
- package/web/dist/assets/erlang-NGps-vi9.js +0 -2
- package/web/dist/assets/fish-ByHW6pZw.js +0 -2
- package/web/dist/assets/fsharp-BOBx9XdV.js +0 -2
- package/web/dist/assets/go-BeHf35-M.js +0 -2
- package/web/dist/assets/graphql-DvPK7yuL.js +0 -2
- package/web/dist/assets/groovy-zjY2ZfG0.js +0 -2
- package/web/dist/assets/haskell-CMvfT32Y.js +0 -2
- package/web/dist/assets/hcl-RKiXyu-a.js +0 -2
- package/web/dist/assets/html-DsaiN7Ee.js +0 -2
- package/web/dist/assets/html-derivative-CADUTaWI.js +0 -2
- package/web/dist/assets/http-B5WHvjtS.js +0 -2
- package/web/dist/assets/ini-DuzuNcum.js +0 -2
- package/web/dist/assets/java-K8yEFi64.js +0 -2
- package/web/dist/assets/javascript-D_ijBMSX.js +0 -2
- package/web/dist/assets/julia-BCSipsbD.js +0 -2
- package/web/dist/assets/kotlin-BSbocnsc.js +0 -2
- package/web/dist/assets/latex-B2rh6wcV.js +0 -2
- package/web/dist/assets/less-DrDudO82.js +0 -2
- package/web/dist/assets/log-ljR8DmTe.js +0 -2
- package/web/dist/assets/lua-DyIUvKwX.js +0 -2
- package/web/dist/assets/make-D75dUjYA.js +0 -2
- package/web/dist/assets/markdown-CW047eNb.js +0 -2
- package/web/dist/assets/mdx-XsqTTZB4.js +0 -2
- package/web/dist/assets/nix-CipIrdNI.js +0 -2
- package/web/dist/assets/perl-D7RI67n_.js +0 -2
- package/web/dist/assets/php-s52DiJil.js +0 -2
- package/web/dist/assets/powershell-jgDnaG9I.js +0 -2
- package/web/dist/assets/proto-BIjSd36w.js +0 -2
- package/web/dist/assets/python-D7_Ztkaq.js +0 -2
- package/web/dist/assets/r-CJzV5ecV.js +0 -2
- package/web/dist/assets/rst-CN3AX0Wt.js +0 -2
- package/web/dist/assets/ruby-TeaxAh4o.js +0 -2
- package/web/dist/assets/rust-DSBpfBj6.js +0 -2
- package/web/dist/assets/scala-C5J7wQ_u.js +0 -2
- package/web/dist/assets/scss-Ce0Xtdy1.js +0 -2
- package/web/dist/assets/sql-B8q9hRYB.js +0 -2
- package/web/dist/assets/svelte-D-qO2kbs.js +0 -2
- package/web/dist/assets/swift-BYyWkiAC.js +0 -2
- package/web/dist/assets/system-verilog-DeQRavVp.js +0 -2
- package/web/dist/assets/telemetry-client-BUyFe34_.js +0 -2
- package/web/dist/assets/toml-D4Tpftfr.js +0 -2
- package/web/dist/assets/vb-CT8kYl35.js +0 -2
- package/web/dist/assets/verilog-CRrcH6Pt.js +0 -2
- package/web/dist/assets/vue-xQhdtb6A.js +0 -2
- package/web/dist/assets/xml-DCBoxqhY.js +0 -2
- package/web/dist/assets/yaml-jmrW97Mk.js +0 -2
- package/web/src/ui/README.md +15 -0
- package/web/src/ui/shared/README.md +25 -0
- package/THIRD_PARTY_LICENSE.txt +0 -24
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
function npmEntry(path) {
|
|
5
|
+
if (!path) return null;
|
|
6
|
+
try {
|
|
7
|
+
const real = realpathSync(path);
|
|
8
|
+
return basename(real) === "npm-cli.js" && statSync(real).isFile() ? real : null;
|
|
9
|
+
} catch { return null; }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Find npm's JavaScript entry point without relying on executable shell shims. */
|
|
13
|
+
export function resolveNpmCli({ execPath = process.execPath, env = process.env } = {}) {
|
|
14
|
+
const inherited = npmEntry(env.npm_execpath);
|
|
15
|
+
if (inherited) return inherited;
|
|
16
|
+
|
|
17
|
+
const directories = new Set([dirname(execPath)]);
|
|
18
|
+
try { directories.add(dirname(realpathSync(execPath))); } catch { /* Try the original path. */ }
|
|
19
|
+
const searchPath = Object.entries(env).find(([key]) => key.toLowerCase() === "path")?.[1] ?? "";
|
|
20
|
+
for (const directory of searchPath.split(delimiter).filter(Boolean)) directories.add(resolve(directory));
|
|
21
|
+
for (const directory of directories) {
|
|
22
|
+
for (const candidate of [
|
|
23
|
+
join(directory, "node_modules", "npm", "bin", "npm-cli.js"),
|
|
24
|
+
join(directory, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
|
|
25
|
+
join(directory, "npm"),
|
|
26
|
+
]) {
|
|
27
|
+
const cli = npmEntry(candidate);
|
|
28
|
+
if (cli) return cli;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error("找不到 npm 入口 npm-cli.js;请安装包含 npm 的 Node.js,或将 npm 所在目录加入 PATH 后重启服务。");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function npmCommand(args) {
|
|
35
|
+
return { file: process.execPath, args: [resolveNpmCli(), ...args] };
|
|
36
|
+
}
|
package/bin/pi-webapp.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { delimiter, dirname, join, resolve } from "node:path";
|
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import spawn from "cross-spawn";
|
|
10
10
|
import { openWebPage } from "./open-web-page.mjs";
|
|
11
|
+
import { npmCommand } from "./npm-command.mjs";
|
|
11
12
|
|
|
12
13
|
const minimum = [0, 87, 1];
|
|
13
14
|
const launcher = fileURLToPath(import.meta.url);
|
|
@@ -47,13 +48,15 @@ function probe(command) {
|
|
|
47
48
|
|
|
48
49
|
function installPi() {
|
|
49
50
|
console.error("未找到 Pi,正在通过 npm 安装 @earendil-works/pi-coding-agent …");
|
|
50
|
-
const
|
|
51
|
+
const install = npmCommand(["install", "-g", "--ignore-scripts", "@earendil-works/pi-coding-agent"]);
|
|
52
|
+
const result = spawn.sync(install.file, install.args, { stdio: "inherit", windowsHide: true });
|
|
51
53
|
if (result.error || result.status !== 0) {
|
|
52
54
|
throw new Error(`Pi 安装失败。请手动运行 npm install -g --ignore-scripts @earendil-works/pi-coding-agent${result.error ? `(${result.error.message})` : ""}`);
|
|
53
55
|
}
|
|
54
56
|
const inPath = probe("pi");
|
|
55
57
|
if (inPath) return inPath;
|
|
56
|
-
const
|
|
58
|
+
const prefixCommand = npmCommand(["prefix", "-g"]);
|
|
59
|
+
const prefix = spawn.sync(prefixCommand.file, prefixCommand.args, { encoding: "utf8", windowsHide: true });
|
|
57
60
|
if (prefix.status === 0) {
|
|
58
61
|
const installed = process.platform === "win32" ? join(prefix.stdout.trim(), "pi.cmd") : join(prefix.stdout.trim(), "bin", "pi");
|
|
59
62
|
if (existsSync(installed)) return probe(installed);
|