gentle-pi 5.0.0 → 5.1.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/README.md +1 -1
- package/assets/agents/gentle-ai-explore.md +3 -6
- package/assets/agents/gentle-ai-verify.md +1 -1
- package/assets/agents/gentle-ai-worker.md +9 -9
- package/assets/agents/jd-fix-agent.md +1 -1
- package/assets/agents/jd-judge-a.md +0 -1
- package/assets/agents/jd-judge-b.md +0 -1
- package/assets/migrations/agent-body-history.json +6 -0
- package/assets/orchestrator-full-delegation.md +1 -1
- package/assets/orchestrator-maintenance.md +11 -0
- package/assets/orchestrator-quota-recovery.md +1 -1
- package/assets/orchestrator-skills.md +10 -0
- package/assets/orchestrator-verification.md +9 -7
- package/assets/orchestrator.md +1 -1
- package/bin/gentle-shell.mjs +67 -15
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +10 -10
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/manifest.json +5 -5
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/orchestration/pi.md +5 -3
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/routing/pi.md +1 -1
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/lens.schema.json +3 -3
- package/contracts/review-provider-contract-mirror/v1.7.0/bundle/vectors/lens.json +1 -0
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-roles.baseline.json +3 -3
- package/docs/bundled-install.md +2 -2
- package/docs/delegated-verification.md +8 -4
- package/docs/desktop-feed.md +15 -6
- package/docs/desktop-rpc.md +44 -20
- package/docs/gentle-shell-desktop.md +10 -3
- package/docs/gentle-shell.md +17 -13
- package/docs/install-wizard.md +2 -2
- package/docs/odd-preparation-continuity.md +2 -2
- package/docs/permission-modes.md +10 -2
- package/docs/readme-reference.md +46 -11
- package/docs/session-profile-format.md +33 -7
- package/docs/work-continuity.md +7 -7
- package/docs/yolo-mode.md +1 -1
- package/extensions/child-context.ts +2 -11
- package/extensions/gentle-agents.ts +47 -28
- package/extensions/gentle-ai.ts +573 -353
- package/extensions/gentle-desktop-feed.ts +13 -3
- package/extensions/gentle-fast.ts +9 -2
- package/extensions/gentle-shell.ts +142 -55
- package/extensions/gentle-tps.ts +5 -0
- package/extensions/quiet-tools.ts +13 -22
- package/extensions/skill-registry.ts +9 -1
- package/herdr/mods/gentle-agents/snapshot.js +30 -23
- package/herdr/mods/gentle-chat/feed.js +6 -0
- package/herdr/mods/gentle-chat/main.js +76 -16
- package/herdr/mods/gentle-chat/session.js +13 -5
- package/herdr/mods/gentle-chat/snapshot.js +30 -23
- package/herdr/mods/gentle-chat/ui.js +7 -1
- package/herdr/mods/gentle-inspector/main.js +2 -0
- package/herdr/mods/gentle-inspector/snapshot.js +30 -23
- package/herdr/mods/gentle-palette/main.js +1 -1
- package/herdr/mods/gentle-palette/snapshot.js +30 -23
- package/herdr/mods/gentle-pane/snapshot.js +30 -23
- package/herdr/mods/gentle-sidebar/snapshot.js +30 -23
- package/herdr/mods/gentle-spaces/snapshot.js +30 -23
- package/herdr/mods/gentle-status/snapshot.js +30 -23
- package/herdr/mods/gentle-tabs/main.js +3 -2
- package/herdr/mods/gentle-tabs/new-tab.js +9 -0
- package/herdr/mods/gentle-tabs/snapshot.js +30 -23
- package/herdr/mods/gentle-tokens/snapshot.js +30 -23
- package/lib/agent-profiles.ts +50 -10
- package/lib/agents-config.ts +59 -4
- package/lib/agents-runner.ts +34 -1
- package/lib/auto-permission-runtime.ts +2 -1
- package/lib/background-jobs-tools.ts +24 -16
- package/lib/claude-bridge-config.ts +41 -0
- package/lib/desktop-agent-definitions-service.ts +10 -6
- package/lib/desktop-command-rpc.ts +71 -0
- package/lib/desktop-feed-sources.ts +44 -1
- package/lib/desktop-feed.ts +41 -29
- package/lib/desktop-rpc-agent-definitions.ts +7 -3
- package/lib/desktop-rpc-changes.ts +13 -4
- package/lib/desktop-rpc-config.ts +106 -3
- package/lib/exploration-budget.ts +3 -7
- package/lib/gentle-design.ts +23 -4
- package/lib/gentle-shell-desktop.ts +85 -0
- package/lib/gentle-shell-launcher.ts +106 -3
- package/lib/mcp-config.ts +214 -0
- package/lib/native-review-cli.ts +78 -34
- package/lib/odd-phase-inference.ts +1 -1
- package/lib/orchestrator-mode-policy.ts +25 -12
- package/lib/path-consent-fence.ts +113 -0
- package/lib/pi-settings.ts +157 -0
- package/lib/review-continuation-registry.ts +7 -20
- package/lib/review-coordinator.ts +5 -0
- package/lib/review-host-relay.ts +2 -35
- package/lib/review-integration-v2.ts +31 -12
- package/lib/sensitive-paths.ts +22 -2
- package/lib/session-profile-freeze.ts +11 -4
- package/lib/session-worktree-registry.ts +11 -5
- package/lib/shell-card.ts +27 -1
- package/lib/shell-changes-view.ts +6 -2
- package/lib/shell-changes.ts +94 -37
- package/lib/shell-git-worker.ts +158 -0
- package/lib/shell-idle-changes.ts +88 -0
- package/lib/shell-untracked-cache.ts +142 -0
- package/lib/shell-untracked-lines.ts +178 -0
- package/lib/tps-policy.ts +85 -0
- package/lib/vim-editor-adapter.ts +3 -2
- package/lib/voice-artifacts.ts +8 -1
- package/lib/voice-install.ts +7 -3
- package/lib/yolo-session-policy.ts +2 -2
- package/package.json +1 -1
- package/runtime/gentle-shell-desktop.mjs +85 -0
- package/runtime/gentle-shell-launcher.mjs +106 -3
- package/runtime/native-review-cli.mjs +77 -33
- package/runtime/review-integration-v2.mjs +31 -12
- package/runtime/sensitive-paths.mjs +22 -2
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/main-channel.mjs +27 -7
- package/scripts/verify-package-files.mjs +13 -12
- package/skills/rdd-defect-workflow/SKILL.md +2 -2
- package/tests/agent-profiles-workflow.test.ts +102 -0
- package/tests/agents-config.test.ts +1 -2
- package/tests/agents-protocol.test.ts +1 -1
- package/tests/agents-runner.test.ts +94 -2
- package/tests/append-system-prompt-route.test.ts +16 -11
- package/tests/auto-permission-runtime.test.ts +4 -4
- package/tests/bounded-stop-contract.test.ts +50 -62
- package/tests/child-context-files.test.ts +6 -6
- package/tests/child-web-package.test.ts +1 -1
- package/tests/controlled-engineering-editor.test.ts +192 -0
- package/tests/controlled-engineering-launch.test.ts +136 -0
- package/tests/controlled-engineering.test.ts +244 -0
- package/tests/delivery-b-rendered-surfaces.test.ts +1 -1
- package/tests/desktop-feed-tool-summaries.test.ts +1 -1
- package/tests/desktop-feed-transcript.test.ts +17 -0
- package/tests/desktop-feed.test.ts +141 -7
- package/tests/desktop-liveness.test.ts +125 -0
- package/tests/desktop-persona.test.ts +17 -0
- package/tests/desktop-rpc-agent-definitions.test.ts +23 -2
- package/tests/desktop-rpc-changes.test.ts +80 -3
- package/tests/desktop-rpc-config-mcp-fidelity.test.ts +106 -0
- package/tests/desktop-rpc-config-readonly-stores.test.ts +458 -0
- package/tests/desktop-rpc-config.test.ts +5 -2
- package/tests/desktop-rpc-design.test.ts +21 -0
- package/tests/desktop-rpc-session-snapshot-commands.test.ts +50 -0
- package/tests/desktop-session-switch.test.ts +237 -0
- package/tests/desktop-target-session.test.ts +104 -0
- package/tests/destructive-command-guard.test.ts +187 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +73 -9
- package/tests/exploration-budget.test.ts +2 -26
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +14 -10
- package/tests/full-delegation-closure.test.ts +19 -9
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agents.test.ts +214 -9
- package/tests/gentle-ai-exploration-budget.test.ts +3 -2
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai.test.ts +29 -5
- package/tests/gentle-chat-read-failure.test.ts +74 -0
- package/tests/gentle-chat-session-read.test.ts +127 -0
- package/tests/gentle-design.test.ts +39 -0
- package/tests/gentle-shell-desktop.test.ts +108 -0
- package/tests/gentle-shell-launcher-auto-provision.test.ts +152 -0
- package/tests/gentle-shell-launcher-machine-output.test.ts +356 -0
- package/tests/gentle-shell.test.ts +93 -12
- package/tests/gentle-tps.test.ts +57 -0
- package/tests/independent-recovery-delivery.test.ts +15 -13
- package/tests/installer-preflight.test.ts +3 -2
- package/tests/job-turn-end-texts.test.ts +57 -0
- package/tests/lazy-module-contradictions-contract.test.ts +1 -2
- package/tests/main-channel.test.ts +12 -1
- package/tests/maintainer/desktop-rpc.maintest.ts +2 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +113 -1
- package/tests/no-self-pause-contract.test.ts +8 -7
- package/tests/odd-phase-inference.test.ts +2 -2
- package/tests/odd-routing-canonical-ratchet.test.ts +1 -1
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +5 -5
- package/tests/orchestrator-skills-inline-contract.test.ts +26 -0
- package/tests/package-manifest.test.ts +11 -16
- package/tests/packaged-agent-codemode.test.ts +79 -0
- package/tests/path-consent-fence.test.ts +326 -0
- package/tests/pi-update-launcher.test.ts +1 -1
- package/tests/primary-session-prompt.test.ts +9 -7
- package/tests/profile-fast-tier.test.ts +79 -4
- package/tests/progress-rule-contract.test.ts +54 -0
- package/tests/rdd-delivery-warning.test.ts +42 -4
- package/tests/review-actor-tool-deny.test.ts +1 -2
- package/tests/review-continuation-registry.test.ts +17 -17
- package/tests/review-controller-native-recovery.test.ts +100 -0
- package/tests/review-controller-native-routing.test.ts +129 -24
- package/tests/review-coordinator.test.ts +14 -0
- package/tests/review-host-relay-restart-parity.test.ts +2 -52
- package/tests/review-host-relay-routing.test.ts +57 -297
- package/tests/review-host-relay.test.ts +0 -46
- package/tests/review-integration-v2-forward.test.ts +39 -2
- package/tests/review-json-arguments.test.ts +30 -9
- package/tests/review-one-call-findings.test.ts +1 -0
- package/tests/review-untracked-inventory-replay.test.ts +181 -0
- package/tests/runtime-harness.mjs +27 -1
- package/tests/sensitive-path-tools.test.ts +155 -4
- package/tests/session-profile-extension.test.ts +90 -11
- package/tests/session-profile-freeze.test.ts +49 -2
- package/tests/session-profile-v1-compat.test.ts +11 -3
- package/tests/session-worktree-registry.test.ts +23 -0
- package/tests/shell-changes-idle-start.test.ts +510 -0
- package/tests/shell-changes-untracked-bound.test.ts +230 -0
- package/tests/shell-changes-view.test.ts +8 -2
- package/tests/shell-changes.test.ts +134 -0
- package/tests/shell-git-runner-stall.test.ts +74 -0
- package/tests/shell-git-worker-fallback.test.ts +140 -0
- package/tests/shell-git-worker-lifetime.test.ts +91 -0
- package/tests/shell-render-cache-runtime.test.ts +256 -3
- package/tests/shell-untracked-cache.test.ts +213 -0
- package/tests/short-check-routing-contract.test.ts +11 -7
- package/tests/skill-registry.test.ts +3 -3
- package/tests/support/chat-ui.ts +39 -0
- package/tests/t7-recovery-preservation.test.ts +68 -0
- package/tests/tps-policy.test.ts +96 -0
- package/tests/turn-end-rule-contract.test.ts +155 -0
- package/tests/turn-end-scope.test.ts +39 -0
- package/tests/verification-scoped-stop-contract.test.ts +1 -1
- package/tests/verification-tiers-contract.test.ts +4 -3
- package/tests/verify-first-launch-contract.test.ts +19 -7
- package/tests/vim-editor-adapter.test.ts +4 -4
- package/tests/voice-install.test.ts +97 -11
- package/tests/windows-hidden-processes.test.ts +11 -44
- package/tests/work-continuity-contract.test.ts +48 -55
- package/tests/yolo-session-policy.test.ts +2 -0
- package/contracts/review-provider-contract-mirror/v1.6.0/bundle/vectors/lens.json +0 -1
- package/extensions/codegraph-tools.ts +0 -437
- package/tests/child-codegraph-bootstrap.test.ts +0 -74
- package/tests/codegraph-tools.test.ts +0 -554
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// CANONICAL COPY, carried byte-identical as `./snapshot.js` by every gentle-* mod that shows
|
|
5
5
|
// snapshot data, gentle-chat included (gpui-shell refuses imports outside a mod's folder).
|
|
6
|
-
// `
|
|
6
|
+
// `targetSession` names the one session every region shows.
|
|
7
7
|
//
|
|
8
8
|
// Gentle Shell runs bundled (agent dir ~/.gentle-shell/agent), as the npm / Pi extension
|
|
9
9
|
// (~/.pi/agent) or with its own home (GENTLE_PI_AGENT_HOME / PI_CODING_AGENT_DIR). Snapshots are
|
|
@@ -91,24 +91,38 @@ export async function readFeeds(roots) {
|
|
|
91
91
|
const positive = (n) => Number.isInteger(n) && n > 0;
|
|
92
92
|
|
|
93
93
|
// Whether each publisher still runs: one `ps` for the pids not checked in the last ALIVE_MS (a
|
|
94
|
-
// crashed session leaves its snapshot behind until the next session start sweeps it).
|
|
95
|
-
//
|
|
94
|
+
// crashed session leaves its snapshot behind until the next session start sweeps it). Where `ps`
|
|
95
|
+
// cannot start (native Windows) or does not answer, one `tasklist` lists the running pids instead.
|
|
96
|
+
// A listing that did not answer decides nothing: when neither answers, every snapshot counts as live.
|
|
96
97
|
const ALIVE_MS = 5000;
|
|
97
98
|
const alive = new Map(); // pid -> { ok, at }
|
|
99
|
+
|
|
100
|
+
// `tasklist /NH /FO CSV` rows: "Image Name","PID","Session Name","Session#","Mem Usage".
|
|
101
|
+
export const parseTasklistPids = (stdout) =>
|
|
102
|
+
new Set([...String(stdout).matchAll(/^"[^"]*","(\d+)"/gm)].map((m) => Number(m[1])));
|
|
103
|
+
|
|
98
104
|
export async function liveFeeds(feeds) {
|
|
99
105
|
const now = Date.now();
|
|
100
106
|
const want = [...new Set(feeds.map((f) => f.identity?.pid).filter(positive))].filter((pid) => !(now - (alive.get(pid)?.at ?? 0) < ALIVE_MS));
|
|
101
107
|
if (want.length) {
|
|
108
|
+
let running = null;
|
|
102
109
|
try {
|
|
103
|
-
// `ps -p` lists the pids that run; it exits 1 when one of them does not.
|
|
110
|
+
// `ps -p` lists the pids that run; it exits 1 when one of them does not. A `ps` that rejects
|
|
111
|
+
// its own flags (MSYS/Git `ps` on Windows) also exits 1, but writes why on stderr: no answer.
|
|
104
112
|
const r = await exec("ps", ["-o", "pid=", "-p", want.join(",")], { timeout: 3000 });
|
|
105
|
-
if (r.code === 0 || r.code === 1)
|
|
106
|
-
const running = new Set(String(r.stdout).split(/\s+/).map(Number).filter(positive));
|
|
107
|
-
for (const pid of want) alive.set(pid, { ok: running.has(pid), at: now });
|
|
108
|
-
}
|
|
113
|
+
if (r.code === 0 || (r.code === 1 && !r.stderr)) running = new Set(String(r.stdout).split(/\s+/).map(Number).filter(positive));
|
|
109
114
|
} catch {
|
|
110
|
-
//
|
|
115
|
+
// `ps` cannot start
|
|
111
116
|
}
|
|
117
|
+
if (!running) {
|
|
118
|
+
try {
|
|
119
|
+
const r = await exec("tasklist", ["/NH", "/FO", "CSV"], { timeout: 3000 });
|
|
120
|
+
if (r.code === 0) running = parseTasklistPids(r.stdout);
|
|
121
|
+
} catch {
|
|
122
|
+
// neither: the publisher's own sweep is the only cleanup
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (running) for (const pid of want) alive.set(pid, { ok: running.has(pid), at: now });
|
|
112
126
|
if (alive.size > 256) for (const [pid, v] of alive) if (now - v.at > 60000) alive.delete(pid);
|
|
113
127
|
}
|
|
114
128
|
return feeds.filter((f) => alive.get(f.identity?.pid)?.ok !== false);
|
|
@@ -305,8 +319,10 @@ export function pickedKey() {
|
|
|
305
319
|
}
|
|
306
320
|
|
|
307
321
|
// The session the window is about: the picked one (see selectSession), else the focused Gentle
|
|
308
|
-
// Shell terminal's, else one in the shown tab
|
|
309
|
-
//
|
|
322
|
+
// Shell terminal's, else one in the shown tab. A shown Herdr tab with no Gentle Shell session shows
|
|
323
|
+
// none: a Herdr tab or space was chosen, so the window follows it instead of keeping another
|
|
324
|
+
// session. Only with no focused tab: the last one shown (`last`, a session key), else a Herdr one,
|
|
325
|
+
// else the newest snapshot.
|
|
310
326
|
export function targetSession(feeds, last) {
|
|
311
327
|
const all = allSessions(feeds);
|
|
312
328
|
const picked = pickedKey();
|
|
@@ -315,18 +331,9 @@ export function targetSession(feeds, last) {
|
|
|
315
331
|
const f = focused();
|
|
316
332
|
const byAddr = (a) => (a ? all.find((s) => s.terminal?.address === a) : undefined);
|
|
317
333
|
const inTab = agents().filter((a) => isGentle(a.app) && a.tab === f?.tab);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
// The Gentle Shell terminal the window is about: the focused one, else one in the shown tab,
|
|
323
|
-
// else the last one shown (`last`), else the first. Mirrors GentleChat.target().
|
|
324
|
-
export function targetTerminal(last) {
|
|
325
|
-
const all = gentleTerminals();
|
|
326
|
-
const f = focused();
|
|
327
|
-
const byAddr = (a) => (a ? all.find((t) => t.address === a) : undefined);
|
|
328
|
-
const inTab = agents().filter((a) => isGentle(a.app) && a.tab === f?.tab);
|
|
329
|
-
return byAddr(f?.agent) ?? byAddr(f?.terminal) ?? byAddr(inTab[0]?.address) ?? byAddr(last) ?? all[0] ?? null;
|
|
334
|
+
const here = byAddr(f?.agent) ?? byAddr(f?.terminal) ?? byAddr(inTab[0]?.address);
|
|
335
|
+
if (here || f?.tab) return here ?? null;
|
|
336
|
+
return (last ? all.find((s) => s.key === last) : undefined) ?? all.find((s) => s.terminal) ?? all[0] ?? null;
|
|
330
337
|
}
|
|
331
338
|
|
|
332
339
|
// The live snapshots as the leader published them ({ digest, at, feeds }), and their digest alone:
|
package/lib/agent-profiles.ts
CHANGED
|
@@ -38,6 +38,11 @@ export const DEFAULT_ORCHESTRATOR_MODE: OrchestratorMode = "organic";
|
|
|
38
38
|
|
|
39
39
|
export interface ProfileWorkflow {
|
|
40
40
|
orchestratorMode: OrchestratorMode;
|
|
41
|
+
/**
|
|
42
|
+
* Controlled Engineering (controlled-engineering S1): authoring rules against
|
|
43
|
+
* unrequested machinery. Off by default and never written while off.
|
|
44
|
+
*/
|
|
45
|
+
controlledEngineering?: boolean;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
export interface AgentProfilesFile {
|
|
@@ -229,13 +234,15 @@ function normalizeWorkflowMap(
|
|
|
229
234
|
dropped.push({ profile: name, mode: described });
|
|
230
235
|
continue;
|
|
231
236
|
}
|
|
232
|
-
|
|
237
|
+
// Only exactly `true` turns Controlled Engineering on; any other value reads as off.
|
|
238
|
+
const controlledEngineering = isRecord(rawEntry) && rawEntry.controlledEngineering === true;
|
|
239
|
+
workflow[name] = persistedWorkflow({ orchestratorMode: rawMode, controlledEngineering });
|
|
233
240
|
}
|
|
234
241
|
if (dropped.length > 0) drops.droppedWorkflow = dropped;
|
|
235
|
-
// An all-
|
|
242
|
+
// An all-default map carries no information: keep the file identical to the
|
|
236
243
|
// pre-change shape so an opted-out file never grows a `workflow` key.
|
|
237
244
|
const meaningful = Object.fromEntries(
|
|
238
|
-
Object.entries(workflow).filter(([, entry]) => entry
|
|
245
|
+
Object.entries(workflow).filter(([, entry]) => isMeaningfulWorkflow(entry)),
|
|
239
246
|
);
|
|
240
247
|
return Object.keys(meaningful).length === 0 ? undefined : meaningful;
|
|
241
248
|
}
|
|
@@ -281,7 +288,7 @@ export function serializeProfilesFile(file: AgentProfilesFile): string {
|
|
|
281
288
|
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
282
289
|
}
|
|
283
290
|
|
|
284
|
-
/** The subset of a workflow map worth persisting: declared profiles
|
|
291
|
+
/** The subset of a workflow map worth persisting: declared profiles with a non-default setting. */
|
|
285
292
|
function meaningfulWorkflowMap(
|
|
286
293
|
workflow: Record<string, ProfileWorkflow> | undefined,
|
|
287
294
|
profiles: Record<string, AgentModelConfig>,
|
|
@@ -289,12 +296,24 @@ function meaningfulWorkflowMap(
|
|
|
289
296
|
if (workflow === undefined) return undefined;
|
|
290
297
|
const kept = Object.fromEntries(
|
|
291
298
|
Object.entries(workflow)
|
|
292
|
-
.filter(([name, entry]) => hasOwn(profiles, name) && entry
|
|
293
|
-
.map(([name, entry]) => [name,
|
|
299
|
+
.filter(([name, entry]) => hasOwn(profiles, name) && isMeaningfulWorkflow(entry))
|
|
300
|
+
.map(([name, entry]) => [name, persistedWorkflow(entry)]),
|
|
294
301
|
);
|
|
295
302
|
return Object.keys(kept).length === 0 ? undefined : kept;
|
|
296
303
|
}
|
|
297
304
|
|
|
305
|
+
/** Whether an entry differs from the defaults (organic, Controlled Engineering off). */
|
|
306
|
+
function isMeaningfulWorkflow(entry: ProfileWorkflow): boolean {
|
|
307
|
+
return entry.orchestratorMode !== DEFAULT_ORCHESTRATOR_MODE || entry.controlledEngineering === true;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** The stored shape of an entry: the mode always, the option only while on. */
|
|
311
|
+
function persistedWorkflow(entry: ProfileWorkflow): ProfileWorkflow {
|
|
312
|
+
return entry.controlledEngineering === true
|
|
313
|
+
? { orchestratorMode: entry.orchestratorMode, controlledEngineering: true }
|
|
314
|
+
: { orchestratorMode: entry.orchestratorMode };
|
|
315
|
+
}
|
|
316
|
+
|
|
298
317
|
// ---- Store mutations (each returns a new file and never mutates the input) ----
|
|
299
318
|
|
|
300
319
|
export function createProfile(
|
|
@@ -335,7 +354,7 @@ export function duplicateProfile(
|
|
|
335
354
|
throw new AgentProfileError("duplicate_name", `Profile already exists: ${to}.`);
|
|
336
355
|
}
|
|
337
356
|
const created = createProfile(file, to, file.profiles[from]);
|
|
338
|
-
return
|
|
357
|
+
return withProfileWorkflow(created, to, readProfileWorkflow(file, from));
|
|
339
358
|
}
|
|
340
359
|
|
|
341
360
|
export function renameProfile(
|
|
@@ -408,7 +427,10 @@ export function setActiveProfile(file: AgentProfilesFile, name: string): AgentPr
|
|
|
408
427
|
*/
|
|
409
428
|
export function readProfileWorkflow(file: AgentProfilesFile, name: string): ProfileWorkflow {
|
|
410
429
|
const entry = file.workflow !== undefined && hasOwn(file.workflow, name) ? file.workflow[name] : undefined;
|
|
411
|
-
return {
|
|
430
|
+
return {
|
|
431
|
+
orchestratorMode: entry?.orchestratorMode ?? DEFAULT_ORCHESTRATOR_MODE,
|
|
432
|
+
controlledEngineering: entry?.controlledEngineering === true,
|
|
433
|
+
};
|
|
412
434
|
}
|
|
413
435
|
|
|
414
436
|
/**
|
|
@@ -419,13 +441,31 @@ export function setProfileOrchestratorMode(
|
|
|
419
441
|
file: AgentProfilesFile,
|
|
420
442
|
name: string,
|
|
421
443
|
mode: OrchestratorMode,
|
|
444
|
+
): AgentProfilesFile {
|
|
445
|
+
return withProfileWorkflow(file, name, { ...readProfileWorkflow(file, name), orchestratorMode: mode });
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Turns Controlled Engineering on or off for one profile, keeping its mode. */
|
|
449
|
+
export function setProfileControlledEngineering(
|
|
450
|
+
file: AgentProfilesFile,
|
|
451
|
+
name: string,
|
|
452
|
+
enabled: boolean,
|
|
453
|
+
): AgentProfilesFile {
|
|
454
|
+
return withProfileWorkflow(file, name, { ...readProfileWorkflow(file, name), controlledEngineering: enabled });
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** Stores one profile's workflow, removing the entry when it holds only defaults. */
|
|
458
|
+
function withProfileWorkflow(
|
|
459
|
+
file: AgentProfilesFile,
|
|
460
|
+
name: string,
|
|
461
|
+
workflow: ProfileWorkflow,
|
|
422
462
|
): AgentProfilesFile {
|
|
423
463
|
requireValidName(name);
|
|
424
464
|
if (!hasOwn(file.profiles, name)) {
|
|
425
465
|
throw new AgentProfileError("missing_profile", `Profile does not exist: ${name}.`);
|
|
426
466
|
}
|
|
427
|
-
if (
|
|
428
|
-
return { ...file, workflow: { ...file.workflow, [name]:
|
|
467
|
+
if (!isMeaningfulWorkflow(workflow)) return { ...file, workflow: workflowWithout(file.workflow, name) };
|
|
468
|
+
return { ...file, workflow: { ...file.workflow, [name]: persistedWorkflow(workflow) } };
|
|
429
469
|
}
|
|
430
470
|
|
|
431
471
|
/** The mode the focused profile would get from one key press (panel `d`). */
|
package/lib/agents-config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { basename, join } from "node:path";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
4
5
|
import { applyToolOverlay, loadToolOverlays } from "./agent-tool-overlay.ts";
|
|
5
6
|
import type { AgentProfilesFile } from "./agent-profiles.ts";
|
|
@@ -235,11 +236,58 @@ export function agentDirectories(roots: DiscoveryRoots): Array<{ dir: string; sc
|
|
|
235
236
|
];
|
|
236
237
|
}
|
|
237
238
|
|
|
238
|
-
|
|
239
|
+
/** Where a discovered definition came from, in `/gentle:profiles` terms. */
|
|
240
|
+
export type AgentSource = "builtin" | "user" | "project";
|
|
241
|
+
|
|
242
|
+
export interface AgentDirectory {
|
|
243
|
+
dir: string;
|
|
244
|
+
scope: AgentScope;
|
|
245
|
+
source: AgentSource;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const PACKAGE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
249
|
+
|
|
250
|
+
/** The agent directories of the bundled pi-subagents package, in lookup order. */
|
|
251
|
+
export function builtinAgentDirectories(cwd: string, home: string, packageRoot = PACKAGE_ROOT): string[] {
|
|
252
|
+
return [
|
|
253
|
+
join(packageRoot, "..", "pi-subagents-j0k3r", "agents"),
|
|
254
|
+
join(cwd, ".pi", "npm", "node_modules", "pi-subagents-j0k3r", "agents"),
|
|
255
|
+
join(home, ".local", "lib", "node_modules", "pi-subagents-j0k3r", "agents"),
|
|
256
|
+
join(packageRoot, "..", "pi-subagents", "agents"),
|
|
257
|
+
join(cwd, ".pi", "npm", "node_modules", "pi-subagents", "agents"),
|
|
258
|
+
join(home, ".local", "lib", "node_modules", "pi-subagents", "agents"),
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Every root `/gentle:profiles` lists, lowest precedence first: the built-in package
|
|
264
|
+
* agents, the agent home, `~/.agents`, `<cwd>/.agents`, then `<cwd>/.pi`.
|
|
265
|
+
*/
|
|
266
|
+
export function profileAgentDirectories(roots: DiscoveryRoots, builtinDirs: readonly string[] = builtinAgentDirectories(roots.cwd, roots.home)): AgentDirectory[] {
|
|
267
|
+
const agentHome = profileRoot(roots);
|
|
268
|
+
return [
|
|
269
|
+
...builtinDirs.map((dir) => ({ dir, scope: AGENT_SCOPE.GLOBAL, source: "builtin" as const })),
|
|
270
|
+
{ dir: join(agentHome, "agents"), scope: AGENT_SCOPE.GLOBAL, source: "user" },
|
|
271
|
+
{ dir: join(agentHome, "subagents"), scope: AGENT_SCOPE.GLOBAL, source: "user" },
|
|
272
|
+
{ dir: join(roots.home, ".agents"), scope: AGENT_SCOPE.GLOBAL, source: "user" },
|
|
273
|
+
{ dir: join(roots.cwd, ".agents"), scope: AGENT_SCOPE.PROJECT, source: "project" },
|
|
274
|
+
{ dir: join(roots.cwd, ".pi", "agents"), scope: AGENT_SCOPE.PROJECT, source: "project" },
|
|
275
|
+
{ dir: join(roots.cwd, ".pi", "subagents"), scope: AGENT_SCOPE.PROJECT, source: "project" },
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface SourcedDiscoveryResult extends DiscoveryResult {
|
|
280
|
+
/** The source of each returned agent, by name. */
|
|
281
|
+
sources: Map<string, AgentSource>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Discovery over explicit directories; a later directory overrides an earlier one by name. */
|
|
285
|
+
export function discoverAgentsIn(roots: DiscoveryRoots, directories: readonly AgentDirectory[]): SourcedDiscoveryResult {
|
|
239
286
|
const overlays = loadToolOverlays(roots.configHome ?? gentlePiConfigHome(), roots.cwd);
|
|
240
287
|
const agents = new Map<string, AgentDefinition>();
|
|
288
|
+
const sources = new Map<string, AgentSource>();
|
|
241
289
|
const errors: string[] = [];
|
|
242
|
-
for (const { dir, scope } of
|
|
290
|
+
for (const { dir, scope, source } of directories) {
|
|
243
291
|
if (!existsSync(dir)) continue;
|
|
244
292
|
for (const file of readdirSync(dir).filter((entry) => entry.toLowerCase().endsWith(".md")).sort()) {
|
|
245
293
|
const filePath = join(dir, file);
|
|
@@ -250,13 +298,20 @@ export function discoverAgents(roots: DiscoveryRoots): DiscoveryResult {
|
|
|
250
298
|
for (const key of unknownFrontmatterKeys(text)) overlays.notices.push(`${filePath}: unknown frontmatter key "${key}" is ignored`);
|
|
251
299
|
const tools = applyToolOverlay(parsed.tools, overlays.entries[parsed.name]);
|
|
252
300
|
agents.set(parsed.name, { ...parsed, tools });
|
|
301
|
+
sources.set(parsed.name, source);
|
|
253
302
|
}
|
|
254
303
|
}
|
|
255
304
|
}
|
|
256
305
|
for (const name of Object.keys(overlays.entries).filter((name) => !agents.has(name))) {
|
|
257
306
|
overlays.notices.push(`overlay names unknown agent "${name}"`);
|
|
258
307
|
}
|
|
259
|
-
return { agents: [...agents.values()].sort((a, b) => a.name.localeCompare(b.name)), errors, notices: overlays.notices };
|
|
308
|
+
return { agents: [...agents.values()].sort((a, b) => a.name.localeCompare(b.name)), errors, notices: overlays.notices, sources };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function discoverAgents(roots: DiscoveryRoots): DiscoveryResult {
|
|
312
|
+
const directories = agentDirectories(roots).map(({ dir, scope }) => ({ dir, scope, source: scope === AGENT_SCOPE.PROJECT ? "project" as const : "user" as const }));
|
|
313
|
+
const { agents, errors, notices } = discoverAgentsIn(roots, directories);
|
|
314
|
+
return { agents, errors, notices };
|
|
260
315
|
}
|
|
261
316
|
|
|
262
317
|
type RawConfig = Record<string, unknown> | undefined;
|
package/lib/agents-runner.ts
CHANGED
|
@@ -147,6 +147,8 @@ export interface TaskRequest {
|
|
|
147
147
|
sessionDir: string;
|
|
148
148
|
resumeSessionPath: string | undefined;
|
|
149
149
|
env: NodeJS.ProcessEnv;
|
|
150
|
+
// Active parent MCP tools for dynamic runtime capability expansion (#1686).
|
|
151
|
+
mcpTools?: readonly string[] | string[];
|
|
150
152
|
// Host-provided only: the launcher's package injection signal (#1690) or
|
|
151
153
|
// the curated fallback. Never derived from tool input or agent definitions.
|
|
152
154
|
extensionPaths?: string[];
|
|
@@ -331,9 +333,40 @@ export function formatChildExit(code: number | null | undefined, signal?: string
|
|
|
331
333
|
|
|
332
334
|
const hostProcess: ProcessControl = { platform: process.platform, kill: (pid, signal) => process.kill(pid, signal) };
|
|
333
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Expands declared agent tools for Pi 1.0 native MCP execution (#1686).
|
|
338
|
+
* When `mcp` is declared, it is treated as a runtime capability sentinel:
|
|
339
|
+
* 1. Omit the retired literal `mcp` token.
|
|
340
|
+
* 2. Add `codemode` and `tool_search` to enable Pi 1.0 native MCP execution and discovery.
|
|
341
|
+
* 3. Add all active parent MCP tools (`mcp__*`).
|
|
342
|
+
* When a scoped prefix like `mcp__<server>` is declared, it expands to `codemode`,
|
|
343
|
+
* `tool_search`, and matching `mcp__<server>__*` tools only when matching active tools exist.
|
|
344
|
+
* If no matching tools exist for that server prefix, discovery tools are omitted.
|
|
345
|
+
* Agents without `mcp` retain strict isolation with no MCP tools added.
|
|
346
|
+
*/
|
|
347
|
+
export function expandChildTools(tools: readonly string[], activeMcpTools: readonly string[] = []): string[] {
|
|
348
|
+
if (tools.length === 0) return [];
|
|
349
|
+
const expanded: string[] = [];
|
|
350
|
+
for (const tool of tools) {
|
|
351
|
+
if (tool === "mcp") {
|
|
352
|
+
expanded.push("codemode", "tool_search", ...activeMcpTools);
|
|
353
|
+
} else if (/^mcp__[a-zA-Z0-9_-]+$/.test(tool)) {
|
|
354
|
+
const prefix = `${tool}__`;
|
|
355
|
+
const matched = activeMcpTools.filter((t) => t.startsWith(prefix));
|
|
356
|
+
if (matched.length > 0) {
|
|
357
|
+
expanded.push("codemode", "tool_search", ...matched);
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
expanded.push(tool);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return [...new Set([...expanded, PARENT_NOTIFICATION_TOOL])];
|
|
364
|
+
}
|
|
365
|
+
|
|
334
366
|
// The --tools value, or undefined when Pi keeps its default tools.
|
|
335
367
|
function requestedTools(request: TaskRequest): string | undefined {
|
|
336
|
-
const
|
|
368
|
+
const rawTools = request.agent.tools;
|
|
369
|
+
const tools = rawTools.length > 0 ? expandChildTools(rawTools, request.mcpTools) : DEFAULT_TOOLS;
|
|
337
370
|
return tools.length > 0 ? tools.join(",") : undefined;
|
|
338
371
|
}
|
|
339
372
|
|
|
@@ -2,6 +2,7 @@ import { lstatSync, realpathSync } from "node:fs";
|
|
|
2
2
|
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
3
|
import type { ExtensionAPI, ExtensionContext, InputEvent, ToolCallEvent, ToolCallEventResult, ToolResultEvent } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
5
|
+
import { canonicalizeTarget } from "./path-consent-fence.ts";
|
|
5
6
|
import { AutoPermissionMemory } from "./auto-permission-memory.ts";
|
|
6
7
|
import { projectToolContext } from "./auto-permission-tool-context.ts";
|
|
7
8
|
import { subscribeHumanAnswers, type HumanAnswerReceipt } from "./auto-permission-answers.ts";
|
|
@@ -372,7 +373,7 @@ export class AutoPermissionRuntime {
|
|
|
372
373
|
const projectHome=resolve(ctx.cwd,".pi","gentle-ai");
|
|
373
374
|
if ((event.toolName==="write" || event.toolName==="edit") && typeof args.path==="string") {
|
|
374
375
|
try {
|
|
375
|
-
const target=
|
|
376
|
+
const target=canonicalizeTarget(args.path,ctx.cwd,event.toolName),home=canonical(this.configHome);
|
|
376
377
|
// Keep policy aliases and containing directories protected, including project restrictions.
|
|
377
378
|
if([resolve(this.configHome,"permission-mode.json"),resolve(this.configHome,"runtime-guardrails.json"),
|
|
378
379
|
resolve(projectHome,"runtime-guardrails.json")].some(path=>within(canonical(path),target)))return true;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { keyHint, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { BASH_BACKGROUND_TOOL, MAX_RUNNING_JOBS, MONITOR_TOOL, type JobRecord, type JobRegistry } from "./background-jobs.ts";
|
|
8
8
|
import { MONITOR_BATCH_MS, MONITOR_FLOOD_LINES, MONITOR_FLOOD_WINDOW_MS, MONITOR_LINES_PER_NOTICE, MONITOR_MAX_TIMEOUT_SECONDS, type MonitorBatch, type MonitorController, type MonitorStopReason } from "./background-monitor.ts";
|
|
9
|
-
import { CARD_TONE,
|
|
9
|
+
import { CARD_TONE, cachedCard, renderCard } from "./shell-card.ts";
|
|
10
10
|
import { sanitizeTerminalText } from "./terminal-theme.ts";
|
|
11
11
|
|
|
12
12
|
export const JOB_NOTICE_TYPE = "gentle-jobs.notice";
|
|
@@ -23,6 +23,7 @@ export function formatJobDuration(ms: number): string {
|
|
|
23
23
|
const quoted = (job: JobRecord) => `${job.id} ("${job.label}")`;
|
|
24
24
|
const noun = (job: JobRecord) => (job.kind === "monitor" ? "Monitor" : "Background job");
|
|
25
25
|
const plural = (count: number, word: string) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
26
|
+
const JOB_WAIT_TEXT = "Continue independent in-scope work now; end the turn to wait only when none remains.";
|
|
26
27
|
|
|
27
28
|
/** What changed on the registry, so a listener can ignore a no-op stop. */
|
|
28
29
|
export type BackgroundJobsChange =
|
|
@@ -47,6 +48,13 @@ export function jobNoticeText(job: JobRecord): string {
|
|
|
47
48
|
if (job.tail.length > 0) lines.push("Last output:", ...job.tail);
|
|
48
49
|
else lines.push("No output.");
|
|
49
50
|
lines.push(`Full output: ${job.outputPath} (read it with the read tool if you need more).`);
|
|
51
|
+
const failed = job.status === "failed" || (job.status === "exited" && job.exitCode !== 0);
|
|
52
|
+
// A human stop is an explicit limit on this job, never an obstacle to work around.
|
|
53
|
+
lines.push(job.status === "stopped"
|
|
54
|
+
? "The user stopped this job: that is an explicit limit on it. Do not restart it; continue only independent authorized work."
|
|
55
|
+
: failed
|
|
56
|
+
? "This failure is an obstacle, not the end of the task: read the result, diagnose the cause, and continue the authorized work that depended on this job."
|
|
57
|
+
: "This result does not end the task: read it and continue the authorized work that depended on this job.");
|
|
50
58
|
return lines.join("\n");
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -63,7 +71,7 @@ export function monitorStoppedText(job: JobRecord, reason: MonitorStopReason): s
|
|
|
63
71
|
const output = `Full output: ${job.outputPath}`;
|
|
64
72
|
if (reason === "timeout") {
|
|
65
73
|
const limit = job.timeoutSeconds === undefined ? "its timeout" : `its ${job.timeoutSeconds}s timeout`;
|
|
66
|
-
return `Monitor ${quoted(job)} reached ${limit} after ${events} and
|
|
74
|
+
return `Monitor ${quoted(job)} reached ${limit} after ${events} and ended. This is the limit you set with timeout_seconds, not a failure or a user stop. Start a new monitor only if watching is still needed for authorized work and other limits allow it.\n${output}`;
|
|
67
75
|
}
|
|
68
76
|
return `Monitor ${quoted(job)} was stopped: it printed more than ${MONITOR_FLOOD_LINES} lines within ${MONITOR_FLOOD_WINDOW_MS / 1000}s (${events}). Narrow the command's filter before watching it again.\n${output}`;
|
|
69
77
|
}
|
|
@@ -100,10 +108,10 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
100
108
|
name: BASH_BACKGROUND_TOOL,
|
|
101
109
|
label: "Bash (background)",
|
|
102
110
|
description: [
|
|
103
|
-
"Run a shell command in
|
|
104
|
-
"Use synchronous bash for local, finite, deterministic checks
|
|
105
|
-
"Put the wait condition
|
|
106
|
-
`
|
|
111
|
+
"Run a shell command in background; return a job id at once. One automatic exit notice gives the exit code, tail and log path. Do not poll, sleep, or delegate a subagent to wait.",
|
|
112
|
+
"Use synchronous bash for local, finite, deterministic checks likely to finish within 30s (explicit timeout <= 30s, inclusive). Use bash_background for longer or unknown duration, external waits, CI, builds, servers, deploys, and long tests. Report synchronous timeouts as failures. Read output and diagnose the cause. Rerun with a fix within explicit limits, never the same timed-out invocation. If duration is the cause, say so; the same command may run in background. Preserve RED/GREEN and public-check exit codes, stdout, and stderr; do not defer or batch Engram bugfix saves and session summaries or bypass RDD. Guidance, not a performance guarantee.",
|
|
113
|
+
"Put the wait condition in the command so exit notifies, e.g. `gh run watch <run-id> --exit-status` or `until curl -sf localhost:3000/health; do sleep 1; done`.",
|
|
114
|
+
`Read the log with read. Stop with job_stop; list with job_list. Max ${MAX_RUNNING_JOBS} running jobs.`,
|
|
107
115
|
].join(" "),
|
|
108
116
|
parameters: {
|
|
109
117
|
type: "object",
|
|
@@ -120,7 +128,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
120
128
|
const job = registry.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined });
|
|
121
129
|
options.onChange?.({ kind: "start", job });
|
|
122
130
|
return text(
|
|
123
|
-
`Started background job ${quoted(job)}.\nOutput: ${job.outputPath}\nYou will be notified once when it exits
|
|
131
|
+
`Started background job ${quoted(job)}.\nOutput: ${job.outputPath}\nYou will be notified once when it exits. ${JOB_WAIT_TEXT} Resume dependent work on the exit notice. Stop it with job_stop.`,
|
|
124
132
|
jobDetails(job),
|
|
125
133
|
);
|
|
126
134
|
},
|
|
@@ -153,7 +161,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
153
161
|
const job = monitors.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined, timeoutSeconds });
|
|
154
162
|
options.onChange?.({ kind: "start", job });
|
|
155
163
|
return text(
|
|
156
|
-
`Started monitor ${quoted(job)} for up to ${timeoutSeconds}s.\nOutput: ${job.outputPath}\nEach new output line reaches you as an event
|
|
164
|
+
`Started monitor ${quoted(job)} for up to ${timeoutSeconds}s.\nOutput: ${job.outputPath}\nEach new output line reaches you as an event. ${JOB_WAIT_TEXT} Resume work on relevant events or the exit notice. Stop it with job_stop.`,
|
|
157
165
|
jobDetails(job),
|
|
158
166
|
);
|
|
159
167
|
},
|
|
@@ -195,13 +203,13 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
195
203
|
const lines = sanitizeTerminalText(content).split("\n");
|
|
196
204
|
const tone = details?.event === "events" ? CARD_TONE.INFO
|
|
197
205
|
: details?.status === "exited" && details.exitCode === 0 ? CARD_TONE.SUCCESS : CARD_TONE.ERROR;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
};
|
|
206
|
+
const expanded = renderOptions.expanded;
|
|
207
|
+
const card = { title: details?.kind === "monitor" ? "Monitor" : "Background job", subtitle: details?.label, body: lines, tone, glyph: JOB_GLYPH };
|
|
208
|
+
return cachedCard((width) => {
|
|
209
|
+
const action = expanded ? "collapse" : "expand";
|
|
210
|
+
let hint: string;
|
|
211
|
+
try { hint = keyHint("app.tools.expand", action); } catch { hint = action; }
|
|
212
|
+
return renderCard(card, theme, width, { expanded, previewRows: 3, hint });
|
|
213
|
+
});
|
|
206
214
|
});
|
|
207
215
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// A read-only projection of `claude-bridge.json`, the config file of the
|
|
2
|
+
// third-party `pi-claude-bridge` Pi package, for users who already have it.
|
|
3
|
+
// Gentle Shell does not install, recommend, or write this package or its file.
|
|
4
|
+
//
|
|
5
|
+
// The file lives in the Pi agent dir and holds the selected plan under
|
|
6
|
+
// `provider.plan` (the shape gentle-shell-gpui reads and writes). Only that
|
|
7
|
+
// plan crosses, and only when it is a short plain token; every other key, and
|
|
8
|
+
// any value that is not such a token, stays here.
|
|
9
|
+
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
|
|
13
|
+
export type ClaudeBridgeRead =
|
|
14
|
+
| { status: "missing" }
|
|
15
|
+
| { status: "invalid" }
|
|
16
|
+
| { status: "valid"; plan: string | null };
|
|
17
|
+
|
|
18
|
+
const PLAN_TOKEN = /^[A-Za-z0-9._-]{1,32}$/;
|
|
19
|
+
|
|
20
|
+
export function claudeBridgeConfigPath(agentHome: string): string {
|
|
21
|
+
return join(agentHome, "claude-bridge.json");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `missing` when the file is absent, `invalid` when it is not a JSON object. */
|
|
29
|
+
export function readClaudeBridgeConfig(agentHome: string): ClaudeBridgeRead {
|
|
30
|
+
const path = claudeBridgeConfigPath(agentHome);
|
|
31
|
+
if (!existsSync(path)) return { status: "missing" };
|
|
32
|
+
let parsed: unknown;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(readFileSync(path, "utf8").replace(/^\uFEFF/, ""));
|
|
35
|
+
} catch {
|
|
36
|
+
return { status: "invalid" };
|
|
37
|
+
}
|
|
38
|
+
if (!isRecord(parsed)) return { status: "invalid" };
|
|
39
|
+
const plan = isRecord(parsed.provider) ? parsed.provider.plan : undefined;
|
|
40
|
+
return { status: "valid", plan: typeof plan === "string" && PLAN_TOKEN.test(plan) ? plan : null };
|
|
41
|
+
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// from the existing owners and projects their result with
|
|
3
3
|
// `lib/desktop-rpc-agent-definitions.ts`.
|
|
4
4
|
//
|
|
5
|
-
// The roots are the
|
|
6
|
-
//
|
|
7
|
-
// `resolveAgentHomeDirectory`,
|
|
5
|
+
// The roots are the ones `/gentle:profiles` lists (`profileAgentDirectories`):
|
|
6
|
+
// the built-in package agents, the agent home resolved by
|
|
7
|
+
// `resolveAgentHomeDirectory`, `~/.agents`, `<cwd>/.agents`, and `<cwd>/.pi`,
|
|
8
|
+
// plus the Gentle config home for tool overlays.
|
|
8
9
|
// The default orchestrator is read from Pi's `settings.json` in that agent
|
|
9
10
|
// home. Every read is fresh: definitions are plain files re-read on each call,
|
|
10
11
|
// and nothing is written or cached.
|
|
@@ -15,7 +16,7 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
15
16
|
import type { DesktopRpcOutcome } from "./desktop-rpc.ts";
|
|
16
17
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
17
18
|
import { resolveAgentHomeDirectory } from "./agent-model-resolution.ts";
|
|
18
|
-
import {
|
|
19
|
+
import { discoverAgentsIn, loadAgentsConfig, profileAgentDirectories, type DiscoveryRoots } from "./agents-config.ts";
|
|
19
20
|
import { readOrchestratorSettings } from "./profiles-orchestrator.ts";
|
|
20
21
|
import {
|
|
21
22
|
AGENT_DEFINITIONS_UNAVAILABLE,
|
|
@@ -27,6 +28,8 @@ import {
|
|
|
27
28
|
export interface AgentDefinitionsLocation {
|
|
28
29
|
roots: DiscoveryRoots;
|
|
29
30
|
orchestratorSettingsPath: string;
|
|
31
|
+
/** The built-in package agent directories; defaults to the installed pi-subagents locations. */
|
|
32
|
+
builtinDirs?: readonly string[];
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export type AgentDefinitionsLocationFactory = (context: ExtensionContext) => AgentDefinitionsLocation;
|
|
@@ -70,13 +73,14 @@ export class DesktopAgentDefinitionsBridge {
|
|
|
70
73
|
const host = this.host;
|
|
71
74
|
if (!host) return { ok: false, error: AGENT_DEFINITIONS_UNAVAILABLE };
|
|
72
75
|
try {
|
|
73
|
-
const { roots, orchestratorSettingsPath } = this.location(host);
|
|
74
|
-
const discovery =
|
|
76
|
+
const { roots, orchestratorSettingsPath, builtinDirs } = this.location(host);
|
|
77
|
+
const discovery = discoverAgentsIn(roots, profileAgentDirectories(roots, builtinDirs));
|
|
75
78
|
const config = loadAgentsConfig(roots);
|
|
76
79
|
const data = projectAgentDefinitions({
|
|
77
80
|
agents: discovery.agents,
|
|
78
81
|
errors: discovery.errors,
|
|
79
82
|
notices: discovery.notices,
|
|
83
|
+
sources: discovery.sources,
|
|
80
84
|
defaults: { model: config.defaultModel, thinking: config.defaultThinking, mode: config.defaultMode },
|
|
81
85
|
orchestrator: readOrchestratorSettings(orchestratorSettingsPath),
|
|
82
86
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gentle Shell's own extension commands that work from an RPC client.
|
|
3
|
+
*
|
|
4
|
+
* Pi's command registry (`pi.getCommands()`) carries only name, description,
|
|
5
|
+
* source and sourceInfo (agent-session.js `getCommands`), so a flag passed to
|
|
6
|
+
* `registerCommand` never reaches the Desktop feed; this list is the
|
|
7
|
+
* declaration instead, keyed by exact invocation name. Pi renames duplicated
|
|
8
|
+
* names (`name:1`, `name:2`), so a renamed duplicate never matches an entry.
|
|
9
|
+
*
|
|
10
|
+
* A command is listed only when its handler, read in full, answers through
|
|
11
|
+
* what Pi's RPC mode forwards to the client (modes/rpc/rpc-mode.js
|
|
12
|
+
* `createExtensionUIContext`: select, confirm, input, editor and notify become
|
|
13
|
+
* `extension_ui_request` lines; `custom()` resolves undefined and raw terminal
|
|
14
|
+
* input is ignored), through plain messages, or through side effects, on
|
|
15
|
+
* every path the bare command or its documented arguments reach. In RPC mode
|
|
16
|
+
* `ctx.hasUI` is true (runner.js `hasUI`: the UI context is not the no-op
|
|
17
|
+
* one) and `ctx.mode` is "rpc". A handler that uses `ui.custom`, an overlay
|
|
18
|
+
* or a TUI component, refuses when `ctx.mode !== "tui"`, or reads the TUI
|
|
19
|
+
* editor draft is left out, and so is everything this list does not name:
|
|
20
|
+
* undeclared means `rpc: false`.
|
|
21
|
+
*
|
|
22
|
+
* `terminal` is a different property (Herdr types commands into the TUI and
|
|
23
|
+
* shows the Terminal afterwards); this list never changes it.
|
|
24
|
+
*/
|
|
25
|
+
const RPC_CAPABLE_EXTENSION_COMMANDS: ReadonlySet<string> = new Set([
|
|
26
|
+
// extensions/gentle-ai.ts `gentle:install-${owner}`: installs assets, then notify.
|
|
27
|
+
"gentle:install-delegation",
|
|
28
|
+
"gentle:install-review",
|
|
29
|
+
// extensions/gentle-ai.ts "gentle:persona" -> handlePersonaCommand: ui.select, then notify.
|
|
30
|
+
"gentle:persona",
|
|
31
|
+
// extensions/gentle-ai.ts "gentle:dev-binary": status | <path> | off, notify only.
|
|
32
|
+
"gentle:dev-binary",
|
|
33
|
+
// extensions/gentle-ai.ts "gentle:status-timing" -> lib/status-timing-diagnostics.ts `command`: notify only.
|
|
34
|
+
"gentle:status-timing",
|
|
35
|
+
// extensions/gentle-ai.ts "gentle:rdd" -> openRddSelector: bindRddOwner accepts mode "tui" or "rpc"; ui.select, then notify.
|
|
36
|
+
"gentle:rdd",
|
|
37
|
+
// extensions/gentle-ai.ts "gentle:review-mode": status | enable | disable, notify only.
|
|
38
|
+
"gentle:review-mode",
|
|
39
|
+
// extensions/gentle-ai.ts "gentle:telemetry": runs the gentle-ai telemetry trigger, notify only.
|
|
40
|
+
"gentle:telemetry",
|
|
41
|
+
// extensions/gentle-ai.ts "gentle:background-subagents": ui.select when hasUI (true in RPC), then notify.
|
|
42
|
+
"gentle:background-subagents",
|
|
43
|
+
// extensions/gentle-ai.ts "gentle:status": notify only.
|
|
44
|
+
"gentle:status",
|
|
45
|
+
// extensions/gentle-design.ts DESIGN_COMMAND_NAME ("gentle:design"): opens the browser canvas,
|
|
46
|
+
// sends the design skill as a user message, or notifies; no TUI component.
|
|
47
|
+
"gentle:design",
|
|
48
|
+
// extensions/gentle-shell.ts "gentle:vim": ui.select when hasUI, writes the policy, notify.
|
|
49
|
+
"gentle:vim",
|
|
50
|
+
// extensions/gentle-shell.ts "gentle:animations": ui.select when hasUI, writes the policy, notify.
|
|
51
|
+
"gentle:animations",
|
|
52
|
+
// extensions/gentle-shell.ts DOUBLE_ESC_CANCEL_COMMAND_NAME ("gentle:double-esc-cancel"): notify only.
|
|
53
|
+
"gentle:double-esc-cancel",
|
|
54
|
+
// extensions/gentle-tower.ts "gentle:tower": starts the tower, opens the browser, notify.
|
|
55
|
+
"gentle:tower",
|
|
56
|
+
// extensions/session-scratch.ts "gentle:scratch": list | clean; clean asks ui.confirm when hasUI, then notify.
|
|
57
|
+
"gentle:scratch",
|
|
58
|
+
// extensions/skill-registry.ts "skill-registry:refresh": regenerates the registry, notify only.
|
|
59
|
+
"skill-registry:refresh",
|
|
60
|
+
// extensions/startup-banner.ts registerBannerCommand / registerToggleCommand / registerColorCommand:
|
|
61
|
+
// ui.select (or a direct toggle), writes the banner config, notify.
|
|
62
|
+
"gentle:banner",
|
|
63
|
+
"gentle:toggle-rose",
|
|
64
|
+
"gentle:toggle-text-logo",
|
|
65
|
+
"gentle:banner-color",
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
/** Whether a registry extension command is declared to work from an RPC client (undeclared: false). */
|
|
69
|
+
export function extensionCommandWorksOverRpc(name: string): boolean {
|
|
70
|
+
return RPC_CAPABLE_EXTENSION_COMMANDS.has(name);
|
|
71
|
+
}
|