pi-sdk-web 0.3.7 → 0.3.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.
- package/dist/cli.js +32 -0
- package/dist/static/app.js +5 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,8 +8,40 @@
|
|
|
8
8
|
* pi-web help Show this help
|
|
9
9
|
*/
|
|
10
10
|
import { SettingsManager, createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, getAgentDir, resolveModelScopeWithDiagnostics, } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
11
14
|
import { findSessionByName, listSessions, loadBuiltinExtensions } from "./session.js";
|
|
12
15
|
import { PiWebServer } from "./server.js";
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Pretend to be Pi for in-process extensions.
|
|
18
|
+
//
|
|
19
|
+
// Extensions loaded into this process (magic-context historian/dreamer, etc.)
|
|
20
|
+
// derive "how to spawn a Pi subagent" from process.argv[1] — the host entry
|
|
21
|
+
// script (resolvePiInvocation reuses it when it exists on disk). pi-web's own
|
|
22
|
+
// bin is NOT Pi, so without this a subagent would re-exec the web server.
|
|
23
|
+
// Point argv[1] at the real Pi CLI that pi-sdk-web depends on: extension
|
|
24
|
+
// subagents then spawn Pi exactly as they would from a TUI Pi host.
|
|
25
|
+
//
|
|
26
|
+
// Safe because: pi-sdk-web parses its own args via process.argv.slice(2);
|
|
27
|
+
// Pi's core modules never read argv[1] (only Pi's own CLI entries do, which
|
|
28
|
+
// pi-web never invokes); magic-context's createRequire(argv[1]) module
|
|
29
|
+
// resolution still finds @earendil-works/pi-coding-agent (it sits inside
|
|
30
|
+
// pi-sdk-web/node_modules).
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
const PI_CLI_ENTRY = (() => {
|
|
33
|
+
try {
|
|
34
|
+
const mainEntry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
|
|
35
|
+
const candidate = join(dirname(mainEntry), "cli.js");
|
|
36
|
+
return existsSync(candidate) ? candidate : undefined;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
if (PI_CLI_ENTRY && process.argv[1] !== PI_CLI_ENTRY) {
|
|
43
|
+
process.argv[1] = PI_CLI_ENTRY;
|
|
44
|
+
}
|
|
13
45
|
const DEFAULT_PORT = 4080;
|
|
14
46
|
const DOC = `pi-web - browser Web access for Pi (via Pi SDK)
|
|
15
47
|
|
package/dist/static/app.js
CHANGED
|
@@ -1773,7 +1773,10 @@ class PiWebClient {
|
|
|
1773
1773
|
];
|
|
1774
1774
|
const filtered = commands
|
|
1775
1775
|
.filter((c) => {
|
|
1776
|
-
|
|
1776
|
+
// Match against the raw command name (with skill:/prompt prefixes, e.g.
|
|
1777
|
+
// "skill:meeting-discuss") so typing "/skill" surfaces every skill
|
|
1778
|
+
// command instead of only ones whose bare name contains "skill".
|
|
1779
|
+
const name = (c.name || '').toLowerCase();
|
|
1777
1780
|
const desc = (c.description || c.source || '').toLowerCase();
|
|
1778
1781
|
return name.includes(query) || desc.includes(query);
|
|
1779
1782
|
})
|
|
@@ -1781,7 +1784,7 @@ class PiWebClient {
|
|
|
1781
1784
|
// Exact-name match first, then name-prefix, then name-contains,
|
|
1782
1785
|
// then description-contains (avoids unrelated commands flooding the list)
|
|
1783
1786
|
const score = (c) => {
|
|
1784
|
-
const name = (c.name || '').
|
|
1787
|
+
const name = (c.name || '').toLowerCase();
|
|
1785
1788
|
if (name === query) return 0;
|
|
1786
1789
|
if (name.startsWith(query)) return 1;
|
|
1787
1790
|
if (name.includes(query)) return 2;
|