@blackbelt-technology/pi-dashboard-extension 0.8.0 → 0.9.0
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/.pi/skills/browser/SKILL.md +69 -28
- package/.pi/skills/browser/UPSTREAM.md +6 -3
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/own-browser.md +7 -1
- package/.pi/skills/doctor/SKILL.md +1 -0
- package/.pi/skills/doctor/_lib/checks.ts +133 -0
- package/.pi/skills/doctor/_lib/derive-tokens.ts +4 -0
- package/.pi/skills/doctor/modules/apple-tools.md +2 -1
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +40 -27
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/package.json +19 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +21 -19
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge.ts +954 -248
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +77 -31
- package/src/connection.ts +481 -16
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +32 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +31 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +3 -0
- package/src/path-gate/decide.ts +149 -0
- package/src/path-gate/grant-cache.ts +71 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +307 -0
- package/src/path-gate/index.ts +155 -0
- package/src/path-gate/resolve.ts +126 -0
- package/src/path-gate/roots.ts +137 -0
- package/src/path-gate/suppression.ts +27 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +2 -10
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/prompt-bus.ts +13 -0
- package/src/provider-register.ts +6 -0
- package/src/retry-tracker.ts +0 -7
- package/src/role-manager.ts +22 -95
- package/src/role-model-tools.ts +6 -0
- package/src/server-auto-start.ts +192 -23
- package/src/server-launcher.ts +70 -34
- package/src/session-move.ts +4 -4
- package/src/session-sync.ts +51 -15
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/terminal-reload.ts +298 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/project-init/dox-doctrine.md +0 -146
- package/src/agent-settled.ts +0 -90
- package/src/transcript-request-guard.ts +0 -76
package/src/canvas-tool.ts
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Registered at runtime (session_start) like `ask_user` to avoid static
|
|
18
18
|
* tool-name conflicts.
|
|
19
|
+
*
|
|
20
|
+
* Cwd-independence (change: update-pi-core-0-85-adopt-apis, task 5.1): the
|
|
21
|
+
* tool is intentionally cwd-independent — `execute` validates the raw shape
|
|
22
|
+
* only and resolves no filesystem path, so `ctx.cwd` is never consulted. The
|
|
23
|
+
* cwd-anchored normalization happens server-side.
|
|
19
24
|
*/
|
|
20
25
|
|
|
21
26
|
import { validateCanvasDeclareShape } from "@blackbelt-technology/pi-dashboard-shared/canvas-declare.js";
|
package/src/command-handler.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { readdirSync, readFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { join, relative } from "node:path";
|
|
7
|
+
import { resolveDashboardPorts } from "@blackbelt-technology/pi-dashboard-shared/config.js";
|
|
7
8
|
import { imageBlockData, imageBlockMime } from "@blackbelt-technology/pi-dashboard-shared/image-block.js";
|
|
8
9
|
import { diffOr } from "@blackbelt-technology/pi-dashboard-shared/platform/git.js";
|
|
9
10
|
import type {
|
|
@@ -202,13 +203,39 @@ export function searchFiles(cwd: string, query: string, opts?: { regex?: boolean
|
|
|
202
203
|
*
|
|
203
204
|
* `ok: false` carries the operator-facing reason so the terminal
|
|
204
205
|
* `command_feedback` says WHY nothing reloaded instead of claiming success.
|
|
205
|
-
*
|
|
206
|
+
* `handedOff` means the terminal feedback is owned by someone else — the
|
|
207
|
+
* bridge instance loaded by an in-process reload reports `completed` after it
|
|
208
|
+
* re-registers — so the requesting side must emit nothing.
|
|
209
|
+
*
|
|
210
|
+
* See change: fix-out-of-band-reload, fix-terminal-session-dashboard-reload.
|
|
206
211
|
*/
|
|
207
|
-
export type ReloadOutcome =
|
|
212
|
+
export type ReloadOutcome =
|
|
213
|
+
| { ok: true; handedOff?: false }
|
|
214
|
+
| { ok: true; handedOff: true }
|
|
215
|
+
| { ok: false; reason: string };
|
|
216
|
+
|
|
217
|
+
/** Reason emitted when the bridge has no reload path for this session. */
|
|
218
|
+
const NO_RELOAD_PATH_REASON =
|
|
219
|
+
"No dashboard reload path for this session — run /reload in the pi TUI.";
|
|
220
|
+
|
|
221
|
+
/** A dashboard reload for this session is still in flight. */
|
|
222
|
+
export const RELOAD_IN_PROGRESS_REASON = "A reload is already in progress for this session.";
|
|
223
|
+
|
|
224
|
+
/** The self-dispatched reload command never reached its handler. */
|
|
225
|
+
export const RELOAD_DID_NOT_RUN_REASON =
|
|
226
|
+
"The reload command did not run — is the dashboard extension still loaded? See the pi terminal.";
|
|
208
227
|
|
|
209
|
-
/**
|
|
210
|
-
export const
|
|
211
|
-
"
|
|
228
|
+
/** `ctx.reload()` settled without pi re-running `session_start{reason:"reload"}`. */
|
|
229
|
+
export const PI_DID_NOT_RELOAD_REASON =
|
|
230
|
+
"pi did not reload — session busy or reload failed; see the pi terminal.";
|
|
231
|
+
|
|
232
|
+
/** The pending-reload slot vanished or was replaced before completion was proven. */
|
|
233
|
+
export const RELOAD_SUPERSEDED_REASON =
|
|
234
|
+
"The reload was superseded before completion could be confirmed — see the pi terminal.";
|
|
235
|
+
|
|
236
|
+
/** The reload did not finish within the bridge's bound. */
|
|
237
|
+
export const RELOAD_TIMEOUT_REASON =
|
|
238
|
+
"The reload did not finish within 60 s — see the pi terminal.";
|
|
212
239
|
|
|
213
240
|
/** Parsed result from parseSendPrompt */
|
|
214
241
|
export type ParsedPrompt =
|
|
@@ -233,6 +260,19 @@ const MANAGEMENT_COMMAND_EVENTS: Record<string, {
|
|
|
233
260
|
dataFn: (args: string) => Record<string, unknown>;
|
|
234
261
|
}> = {};
|
|
235
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Team sessions (add-team-plugin D7): the guard extension confines TOOL calls, but a prompt the bridge
|
|
265
|
+
* turns into a host action (`!cmd` bash, `/slash` extension commands, reload, new, model, shutdown,
|
|
266
|
+
* management) never reaches `tool_call`. Such a session's owner could run unconfined bash by typing
|
|
267
|
+
* `!id`. The spawn projects `PI_EXT_TEAM_TOOLS` into the pi process, so the bridge refuses those routes
|
|
268
|
+
* there; plain prompts, `/compact` and the dashboard-internal retry stay available.
|
|
269
|
+
*/
|
|
270
|
+
export function isTeamConfinedSession(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
271
|
+
return typeof env.PI_EXT_TEAM_TOOLS === "string";
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const TEAM_ALLOWED_PARSED: ReadonlySet<ParsedPrompt["type"]> = new Set(["passthrough", "compact", "retry"]);
|
|
275
|
+
|
|
236
276
|
/** Parse input text to detect pi internal command prefixes */
|
|
237
277
|
export function parseSendPrompt(text: string): ParsedPrompt {
|
|
238
278
|
// 1. Check !! (must check before !)
|
|
@@ -370,19 +410,18 @@ export function createCommandHandler(
|
|
|
370
410
|
/**
|
|
371
411
|
* Trigger session reload (extensions, settings, skills, etc.).
|
|
372
412
|
*
|
|
373
|
-
* Returns whether a reload ACTUALLY ran
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* caller emit an unconditional `completed`.
|
|
413
|
+
* Returns whether a reload ACTUALLY ran, so the caller never emits an
|
|
414
|
+
* unconditional `completed`. The bridge self-dispatches its
|
|
415
|
+
* `/__dashboard_reload <token>` command in-process and
|
|
416
|
+
* resolves `{ok:true, handedOff:true}` on success: the RELOADED bridge
|
|
417
|
+
* instance reports `completed` after re-registering, because this
|
|
418
|
+
* instance's connection is torn down by the reload. On `handedOff` the
|
|
419
|
+
* handler emits nothing.
|
|
381
420
|
*
|
|
382
|
-
* ASYNC by contract:
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
421
|
+
* ASYNC by contract: a rejection that lands after we have already
|
|
422
|
+
* emitted `completed` would be a false success. The handler awaits it.
|
|
423
|
+
* See change: fix-out-of-band-reload (design.md D5),
|
|
424
|
+
* fix-terminal-session-dashboard-reload (D4).
|
|
386
425
|
*/
|
|
387
426
|
reload?: () => Promise<ReloadOutcome>;
|
|
388
427
|
/** Spawn a new session in the same cwd */
|
|
@@ -520,6 +559,11 @@ export function createCommandHandler(
|
|
|
520
559
|
case "send_prompt": {
|
|
521
560
|
const parsed = parseSendPrompt(msg.text);
|
|
522
561
|
|
|
562
|
+
if (isTeamConfinedSession() && !TEAM_ALLOWED_PARSED.has(parsed.type)) {
|
|
563
|
+
options?.eventSink?.({ type: "prompt_received", sessionId, fresh: false });
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
|
|
523
567
|
// Non-turn commands (bash/compact/shutdown/reload/new/model/mgmt)
|
|
524
568
|
// return early below and never produce a user `message_start`, so an
|
|
525
569
|
// optimistic idle `pendingPrompt` bubble would hang until the 30s
|
|
@@ -574,6 +618,9 @@ export function createCommandHandler(
|
|
|
574
618
|
outcome = { ok: false, reason: `Reload failed: ${reason}` };
|
|
575
619
|
}
|
|
576
620
|
}
|
|
621
|
+
// The reloaded bridge owns the terminal feedback.
|
|
622
|
+
// See change: fix-terminal-session-dashboard-reload (D4).
|
|
623
|
+
if (outcome.ok && outcome.handedOff) return undefined;
|
|
577
624
|
options?.eventSink?.({
|
|
578
625
|
type: "event_forward",
|
|
579
626
|
sessionId,
|
|
@@ -670,7 +717,6 @@ export function createCommandHandler(
|
|
|
670
717
|
parsed.text,
|
|
671
718
|
sessionId,
|
|
672
719
|
options?.eventSink,
|
|
673
|
-
undefined, // connection — absent in non-bridge path
|
|
674
720
|
msg.delivery,
|
|
675
721
|
);
|
|
676
722
|
// Exec-mode slash template (executable: bash): run as bash, no LLM.
|
|
@@ -1129,26 +1175,26 @@ function sendUserMessageWithImages(
|
|
|
1129
1175
|
|
|
1130
1176
|
/**
|
|
1131
1177
|
* Resolve the dashboard HTTP port, in precedence order:
|
|
1132
|
-
* 1. `PI_DASHBOARD_PORT` / `DASHBOARD_PORT` env — set by the
|
|
1133
|
-
*
|
|
1134
|
-
* server
|
|
1135
|
-
* `
|
|
1178
|
+
* 1. `PI_DASHBOARD_PORT` / `DASHBOARD_PORT` env — set by the session's
|
|
1179
|
+
* RUNTIME environment (e.g. the docker harness compose env). The
|
|
1180
|
+
* dashboard server does NOT inject these into spawned sessions; it
|
|
1181
|
+
* pins them via `PI_DASHBOARD_URL` / `PI_DASHBOARD_SOCKET` instead.
|
|
1136
1182
|
* 2. `~/.pi/dashboard/config.json` `port` — normal local installs write it.
|
|
1137
|
-
* 3.
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1183
|
+
* 3. The shared default.
|
|
1184
|
+
* Delegates to the shared `resolveDashboardPorts` so this path and the
|
|
1185
|
+
* bridge's auto-start port resolution cannot drift.
|
|
1186
|
+
* Note: `PI_DASHBOARD_URL` is the gateway (ws) endpoint, NOT the HTTP port,
|
|
1187
|
+
* so it is deliberately not consulted here.
|
|
1188
|
+
* See change: add-dashboard-slash-commands, fix-bridge-autostart-port-resolution.
|
|
1140
1189
|
*/
|
|
1141
1190
|
function resolveDashboardPort(): number {
|
|
1142
|
-
|
|
1143
|
-
const n = Number(v);
|
|
1144
|
-
if (v && Number.isFinite(n) && n > 0) return n;
|
|
1145
|
-
}
|
|
1191
|
+
let fileConfig: { port?: number } = {};
|
|
1146
1192
|
try {
|
|
1147
1193
|
const raw = readFileSync(join(homedir(), ".pi", "dashboard", "config.json"), "utf-8");
|
|
1148
1194
|
const parsed = JSON.parse(raw);
|
|
1149
|
-
if (typeof parsed?.port === "number"
|
|
1195
|
+
if (typeof parsed?.port === "number") fileConfig = { port: parsed.port };
|
|
1150
1196
|
} catch { /* missing / unparseable config */ }
|
|
1151
|
-
return
|
|
1197
|
+
return resolveDashboardPorts(process.env, fileConfig).port;
|
|
1152
1198
|
}
|
|
1153
1199
|
|
|
1154
1200
|
/**
|