@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
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
* See changes: fix-resume-keeps-session-model (original gate),
|
|
22
22
|
* fix-default-model-new-session-entry-count (signal correction).
|
|
23
23
|
*/
|
|
24
|
+
/**
|
|
25
|
+
* Inputs to {@link shouldApplyDefaultModel}.
|
|
26
|
+
*/
|
|
24
27
|
export interface DefaultModelGateInput {
|
|
25
28
|
/** `event.reason` from the pi `session_start` event. */
|
|
26
29
|
reason: string | undefined;
|
|
@@ -37,6 +40,36 @@ export interface DefaultModelGateInput {
|
|
|
37
40
|
hasModelRegistry: boolean;
|
|
38
41
|
/** Whether `config.defaultModel` is set to a non-empty string. */
|
|
39
42
|
hasDefaultModel: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the pi process was launched with an explicit `--model` argument.
|
|
45
|
+
* An explicit model on the command line is authoritative — a "default"
|
|
46
|
+
* never overrides it. Derive it in the bridge via
|
|
47
|
+
* {@link hasExplicitModelArg}(process.argv).
|
|
48
|
+
* See change: fix-default-model-clobbers-explicit-model (issue #595).
|
|
49
|
+
*/
|
|
50
|
+
hasExplicitModel: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* True when the pi process argv carries an explicit `--model` flag.
|
|
55
|
+
*
|
|
56
|
+
* Exact-token match on `--model`, mirroring pi's own parser (`cli/args.js`:
|
|
57
|
+
* `arg === "--model"`, value in the next argv slot) — the `--model=x` equals
|
|
58
|
+
* form is not a pi flag, `--models` is a distinct flag, and there is no `-m`
|
|
59
|
+
* alias. The bridge runs inside the pi process, so the argv to pass is
|
|
60
|
+
* pi's own `process.argv` — this covers every spawner that passes `--model`
|
|
61
|
+
* (pi-subagents children, automation-plugin run spawns, worktree init hooks,
|
|
62
|
+
* and a user's manual `pi --model X`).
|
|
63
|
+
*
|
|
64
|
+
* Accepted fail-safe false-positives (pinned by tests): a trailing dangling
|
|
65
|
+
* `--model` with no value, a literal `--model` after `--`, and a `--model`
|
|
66
|
+
* swallowed as another flag's value all count as explicit — skipping the
|
|
67
|
+
* dashboard default is always safer than clobbering the caller's choice.
|
|
68
|
+
*
|
|
69
|
+
* See change: fix-default-model-clobbers-explicit-model (issue #595).
|
|
70
|
+
*/
|
|
71
|
+
export function hasExplicitModelArg(argv: string[]): boolean {
|
|
72
|
+
return argv.includes("--model");
|
|
40
73
|
}
|
|
41
74
|
|
|
42
75
|
export function shouldApplyDefaultModel(args: DefaultModelGateInput): boolean {
|
|
@@ -44,5 +77,10 @@ export function shouldApplyDefaultModel(args: DefaultModelGateInput): boolean {
|
|
|
44
77
|
if (args.entryCount !== 0) return false;
|
|
45
78
|
if (!args.hasModelRegistry) return false;
|
|
46
79
|
if (!args.hasDefaultModel) return false;
|
|
80
|
+
// An explicit `--model` on the launch command line is the spawner's resolved
|
|
81
|
+
// choice (subagent agent definition, automation run, worktree init hook, or
|
|
82
|
+
// the user) — the configured default never overrides it, matching plain pi
|
|
83
|
+
// CLI behavior. See change: fix-default-model-clobbers-explicit-model.
|
|
84
|
+
if (args.hasExplicitModel) return false;
|
|
47
85
|
return true;
|
|
48
86
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin, individually testable seams between `bridge.ts` and the poll-cost
|
|
3
|
+
* machinery (change: optimize-polling-hot-paths). `bridge.ts` opens a socket,
|
|
4
|
+
* mDNS and timers at load, so nothing here may import it; the bridge calls
|
|
5
|
+
* these, and `bridge-polling.test.ts` drives the real functions.
|
|
6
|
+
*/
|
|
7
|
+
import type { GitTracker } from "./git-tracker.js";
|
|
8
|
+
import { handleGitInfoRefresh, type PrStatusScheduler } from "./pr-status.js";
|
|
9
|
+
import type { ProcessScanScheduler } from "./process-scan-scheduler.js";
|
|
10
|
+
|
|
11
|
+
/** Delay that lets pi's `ctx.model` reflect a new model before it is read (same as `setModel`). */
|
|
12
|
+
const MODEL_SELECT_RECHECK_MS = 50;
|
|
13
|
+
|
|
14
|
+
/** Run and clear every registered disposable; one throwing never blocks the rest. */
|
|
15
|
+
export function drainDisposables(state: { disposables?: Array<() => void> }): void {
|
|
16
|
+
const list = state.disposables;
|
|
17
|
+
state.disposables = [];
|
|
18
|
+
if (!list) return;
|
|
19
|
+
for (const dispose of list) {
|
|
20
|
+
try {
|
|
21
|
+
dispose();
|
|
22
|
+
} catch {
|
|
23
|
+
/* best-effort teardown */
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Register `fn` once: a stable reference is added only when absent (survives a drain). */
|
|
29
|
+
export function ensureDisposable(state: { disposables?: Array<() => void> }, fn: () => void): void {
|
|
30
|
+
const list = (state.disposables ??= []);
|
|
31
|
+
if (!list.includes(fn)) list.push(fn);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Feed the forwarded pi lifecycle events to the adaptive process-scan cadence
|
|
36
|
+
* and to the git tracker (a non-read-only tool end requests a slow-lane probe).
|
|
37
|
+
*/
|
|
38
|
+
export function feedPollingEvent(
|
|
39
|
+
eventType: string,
|
|
40
|
+
event: { toolName?: string } | undefined,
|
|
41
|
+
deps: { processScan?: ProcessScanScheduler | null; gitTracker?: Pick<GitTracker, "onToolEnd"> | null },
|
|
42
|
+
): void {
|
|
43
|
+
switch (eventType) {
|
|
44
|
+
case "agent_start":
|
|
45
|
+
deps.processScan?.onAgentStart();
|
|
46
|
+
break;
|
|
47
|
+
case "agent_end":
|
|
48
|
+
deps.processScan?.onAgentEnd();
|
|
49
|
+
break;
|
|
50
|
+
case "tool_execution_start":
|
|
51
|
+
deps.processScan?.onToolStart();
|
|
52
|
+
break;
|
|
53
|
+
case "tool_execution_end":
|
|
54
|
+
deps.processScan?.onToolEnd(event?.toolName);
|
|
55
|
+
deps.gitTracker?.onToolEnd(event?.toolName);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* `git_info_refresh`: EVERY refresh invalidates the static facts and requests a
|
|
62
|
+
* fast probe; the PR scheduler keeps its own reason handling (unknown reasons
|
|
63
|
+
* are ignored there). Returns `true` when the message was consumed.
|
|
64
|
+
*/
|
|
65
|
+
export function routeGitInfoRefresh(
|
|
66
|
+
msg: { type?: unknown; reason?: unknown },
|
|
67
|
+
deps: { prStatus: Pick<PrStatusScheduler, "refresh">; gitTracker?: Pick<GitTracker, "refresh"> | null },
|
|
68
|
+
): boolean {
|
|
69
|
+
if (msg.type !== "git_info_refresh") return false;
|
|
70
|
+
deps.gitTracker?.refresh();
|
|
71
|
+
return handleGitInfoRefresh(msg, deps.prStatus);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `model_select`: re-check the model after pi's ctx has settled. */
|
|
75
|
+
export function scheduleModelRecheckOnSelect(
|
|
76
|
+
setTimer: (fn: () => void, ms: number) => unknown,
|
|
77
|
+
recheck: () => void,
|
|
78
|
+
): void {
|
|
79
|
+
setTimer(recheck, MODEL_SELECT_RECHECK_MS);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Owns the per-incarnation scan scheduler and git tracker so replacing one disposes the previous. */
|
|
83
|
+
export interface PollingHolder {
|
|
84
|
+
readonly processScan: ProcessScanScheduler | null;
|
|
85
|
+
readonly gitTracker: GitTracker | null;
|
|
86
|
+
/** Dispose the previous scan scheduler (schedules never stack) and hold `next`. */
|
|
87
|
+
replaceProcessScan(next: ProcessScanScheduler): void;
|
|
88
|
+
/** Dispose the previous tracker and hold `next`; returns it. */
|
|
89
|
+
replaceGitTracker(next: GitTracker): GitTracker;
|
|
90
|
+
/** Dispose and forget both (registered once as a bridge disposable). */
|
|
91
|
+
disposeAll(): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function createPollingHolder(): PollingHolder {
|
|
95
|
+
let processScan: ProcessScanScheduler | null = null;
|
|
96
|
+
let gitTracker: GitTracker | null = null;
|
|
97
|
+
return {
|
|
98
|
+
get processScan() {
|
|
99
|
+
return processScan;
|
|
100
|
+
},
|
|
101
|
+
get gitTracker() {
|
|
102
|
+
return gitTracker;
|
|
103
|
+
},
|
|
104
|
+
replaceProcessScan(next) {
|
|
105
|
+
processScan?.dispose();
|
|
106
|
+
processScan = next;
|
|
107
|
+
},
|
|
108
|
+
replaceGitTracker(next) {
|
|
109
|
+
gitTracker?.dispose();
|
|
110
|
+
gitTracker = next;
|
|
111
|
+
return next;
|
|
112
|
+
},
|
|
113
|
+
disposeAll() {
|
|
114
|
+
processScan?.dispose();
|
|
115
|
+
processScan = null;
|
|
116
|
+
gitTracker?.dispose();
|
|
117
|
+
gitTracker = null;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The slice of `BridgeState` the re-init teardown touches. */
|
|
123
|
+
export interface PreviousIncarnation {
|
|
124
|
+
cleanup?: () => void;
|
|
125
|
+
connections?: Array<{ disconnect(): void }>;
|
|
126
|
+
timers?: Array<ReturnType<typeof setInterval>>;
|
|
127
|
+
disposables?: Array<() => void>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Tear down what a previous bridge incarnation left behind (`/reload`, session
|
|
132
|
+
* replacement). Returns `false` — touching NOTHING — on a subagent re-entry, so
|
|
133
|
+
* a subagent loading the bridge in the parent's process never disposes the
|
|
134
|
+
* parent's schedulers, watchers or timers.
|
|
135
|
+
*/
|
|
136
|
+
export function teardownPreviousIncarnation(prev: PreviousIncarnation, isReentry: () => boolean): boolean {
|
|
137
|
+
if (isReentry()) return false;
|
|
138
|
+
prev.cleanup?.();
|
|
139
|
+
prev.cleanup = undefined;
|
|
140
|
+
// Disconnect ALL orphaned connections from previous bridge incarnations
|
|
141
|
+
for (const conn of prev.connections ?? []) conn.disconnect();
|
|
142
|
+
prev.connections = [];
|
|
143
|
+
// Clear ALL orphaned timers (clearInterval also clears timeouts)
|
|
144
|
+
for (const t of prev.timers ?? []) clearInterval(t);
|
|
145
|
+
prev.timers = [];
|
|
146
|
+
drainDisposables(prev);
|
|
147
|
+
return true;
|
|
148
|
+
}
|