gentle-pi 4.6.0 → 4.7.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 +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +1 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
|
-
import {
|
|
3
|
+
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { YoloSessionPolicy, YOLO_DIRECTIVE, YOLO_STATUS_TEXT, SUPER_YOLO_STATUS_TEXT, AUTO_MODE_NOTICE, updateYoloPrompt, registerYoloSessionPolicy, discoverYoloUiAdapter } from "../lib/yolo-session-policy.ts";
|
|
4
7
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
8
|
import type { ReviewSessionIdentity } from "../lib/review-session-standing-permission.ts";
|
|
9
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
6
10
|
|
|
7
11
|
function identity(): ReviewSessionIdentity {
|
|
8
12
|
return { sessionManager: { getSessionId: () => "live" }, sessionId: "live", repositoryIdentity: "clone-a", worktreeRoot: "/repo" };
|
|
@@ -54,6 +58,271 @@ test("active-only structured directive qualifies defaults and is removed from re
|
|
|
54
58
|
assert.match(YOLO_DIRECTIVE, /default.*commit.*push.*PR/i);
|
|
55
59
|
assert.match(YOLO_DIRECTIVE, /ask_user/);
|
|
56
60
|
assert.match(YOLO_DIRECTIVE, /credentials/);
|
|
61
|
+
// Quoted destructive text is prose, not an execution: confirmation applies
|
|
62
|
+
// only to commands the session actually runs (gentle-pi quoted-rm-rf report).
|
|
63
|
+
assert.match(YOLO_DIRECTIVE, /Quoted.*not an execution/is);
|
|
64
|
+
assert.match(YOLO_DIRECTIVE, /only to commands this session actually runs/i);
|
|
65
|
+
// Non-sensitive reads outside the workspace (own skills, docs, config) are
|
|
66
|
+
// standing-permitted: no permission questions for those reads.
|
|
67
|
+
assert.match(YOLO_DIRECTIVE, /non-sensitive.*outside the workspace/is);
|
|
68
|
+
assert.match(YOLO_DIRECTIVE, /skills/);
|
|
57
69
|
updateYoloPrompt(options, false);
|
|
58
70
|
assert.equal(options.appendSystemPrompt, "existing harness");
|
|
59
71
|
});
|
|
72
|
+
|
|
73
|
+
const MODE_CHOICES = [
|
|
74
|
+
"normal — standard permission prompts",
|
|
75
|
+
"auto — independent checks; extra model calls",
|
|
76
|
+
"yolo — scoped work; destructive actions ask",
|
|
77
|
+
"super-yolo — no permission prompts; private paths blocked; consent remains",
|
|
78
|
+
];
|
|
79
|
+
const STALE = "YOLO unchanged — the session changed while the menu was open.";
|
|
80
|
+
const INVALID_SELECTION = "YOLO unchanged — invalid menu selection.";
|
|
81
|
+
|
|
82
|
+
type Selector = (title: string, choices: string[]) => Promise<string | undefined>;
|
|
83
|
+
function selectorHost(t: test.TestContext, env: NodeJS.ProcessEnv = {}) {
|
|
84
|
+
const root = mkdtempSync(join(tmpdir(), "yolo-selector-"));
|
|
85
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
86
|
+
const home = join(root, "config"), workspace = join(root, "workspace"), other = join(root, "other");
|
|
87
|
+
for (const dir of [home, workspace, other]) mkdirSync(dir);
|
|
88
|
+
const commands = new Map<string, { handler(args: string, ctx: ExtensionContext): Promise<void> }>();
|
|
89
|
+
const notices: Array<[string, string | undefined]> = [], prompts: Array<{ title: string; choices: string[] }> = [];
|
|
90
|
+
const statuses = new Map<string, string | undefined>();
|
|
91
|
+
let sessionId = "session", workspaceIdentity = "clone-a", changes = 0, confirms = 0;
|
|
92
|
+
let select: Selector = async () => undefined;
|
|
93
|
+
const context = {
|
|
94
|
+
cwd: workspace, mode: "tui", hasUI: true,
|
|
95
|
+
sessionManager: { getSessionId: () => sessionId },
|
|
96
|
+
ui: {
|
|
97
|
+
notify: (message: string, type?: string) => notices.push([message, type]),
|
|
98
|
+
setStatus: (key: string, value?: string) => statuses.set(key, value), setWidget() {},
|
|
99
|
+
confirm: async () => { confirms++; return false; },
|
|
100
|
+
select: async (title: string, choices: string[]) => { prompts.push({ title, choices }); return select(title, choices); },
|
|
101
|
+
},
|
|
102
|
+
} as unknown as ExtensionContext;
|
|
103
|
+
const pi = {
|
|
104
|
+
registerCommand: (name: string, command: { handler(args: string, ctx: ExtensionContext): Promise<void> }) => commands.set(name, command),
|
|
105
|
+
events: { on() {}, emit() {} },
|
|
106
|
+
} as unknown as ExtensionAPI;
|
|
107
|
+
registerYoloSessionPolicy(pi, { ...env, GENTLE_PI_CONFIG_HOME: home }, {
|
|
108
|
+
onChange: () => { changes++; }, resolveIdentity: async () => workspaceIdentity,
|
|
109
|
+
});
|
|
110
|
+
const files = () => Object.fromEntries(readdirSync(home).sort().map(name => [name, readFileSync(join(home, name), "utf8")]));
|
|
111
|
+
return {
|
|
112
|
+
context, notices, prompts, statuses, files, other,
|
|
113
|
+
changes: () => changes, confirms: () => confirms,
|
|
114
|
+
setSelect: (fn: Selector) => { select = fn; },
|
|
115
|
+
setSession: () => { sessionId = "replacement"; },
|
|
116
|
+
setIdentity: () => { workspaceIdentity = "clone-b"; },
|
|
117
|
+
async run(name: "gentle:yolo" | "gentle:mode", args: string) {
|
|
118
|
+
const command = commands.get(name); assert.ok(command, `${name} is registered`);
|
|
119
|
+
assert.equal(await command.handler(args, context), undefined);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
test("YOLO selector offers the four existing modes and applies only the selected live mode", async t => {
|
|
125
|
+
const h = selectorHost(t);
|
|
126
|
+
await h.run("gentle:mode", "status");
|
|
127
|
+
await h.run("gentle:mode", "default auto");
|
|
128
|
+
assert.deepEqual(h.notices.splice(0), [
|
|
129
|
+
["Permissions: NORMAL — default: NORMAL", "info"],
|
|
130
|
+
[`Default AUTO saved for next primary sessions. ${AUTO_MODE_NOTICE}`, "info"],
|
|
131
|
+
]);
|
|
132
|
+
const saved = h.files();
|
|
133
|
+
let previous = "NORMAL";
|
|
134
|
+
for (const [index, mode] of ["normal", "auto", "yolo", "super-yolo"].entries()) {
|
|
135
|
+
const before = h.changes();
|
|
136
|
+
h.setSelect(async (title, choices) => {
|
|
137
|
+
assert.equal(title, `Permissions for this session (current: ${previous})`);
|
|
138
|
+
assert.deepEqual(choices, MODE_CHOICES);
|
|
139
|
+
assert.equal(h.changes(), before, "opening the selector grants nothing");
|
|
140
|
+
assert.deepEqual(h.files(), saved);
|
|
141
|
+
return choices[index];
|
|
142
|
+
});
|
|
143
|
+
await h.run("gentle:yolo", "");
|
|
144
|
+
assert.equal(h.changes(), before + 2, "the canonical live-mode transition publishes revocation and selection");
|
|
145
|
+
assert.deepEqual(h.notices.splice(0), mode === "auto"
|
|
146
|
+
? [[AUTO_MODE_NOTICE, "info"], ["Permissions: AUTO", "info"]]
|
|
147
|
+
: [[`Permissions: ${mode.toUpperCase()}`, "info"]]);
|
|
148
|
+
assert.deepEqual(h.files(), saved, "a session selection never saves the default");
|
|
149
|
+
await h.run("gentle:mode", "status");
|
|
150
|
+
assert.deepEqual(h.notices.splice(0), [[`Permissions: ${mode.toUpperCase()} — default: AUTO`, "info"]]);
|
|
151
|
+
previous = mode.toUpperCase();
|
|
152
|
+
}
|
|
153
|
+
assert.equal(h.prompts.length, 4);
|
|
154
|
+
assert.equal(h.confirms(), 0);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("YOLO selector opens and cancels without initializing authority, even with a saved default", async t => {
|
|
158
|
+
for (const savedMode of ["normal", "yolo"]) {
|
|
159
|
+
const h = selectorHost(t);
|
|
160
|
+
if (savedMode === "yolo") await h.run("gentle:mode", "default yolo");
|
|
161
|
+
h.setSession(); h.notices.length = 0;
|
|
162
|
+
const before = h.changes(), saved = h.files();
|
|
163
|
+
h.setSelect(async (title, choices) => {
|
|
164
|
+
assert.equal(title, `Permissions for this session (current: ${savedMode.toUpperCase()})`);
|
|
165
|
+
assert.deepEqual(choices, MODE_CHOICES);
|
|
166
|
+
assert.equal(h.changes(), before, "opening does not initialize or grant a mode");
|
|
167
|
+
return undefined;
|
|
168
|
+
});
|
|
169
|
+
await h.run("gentle:yolo", "");
|
|
170
|
+
assert.equal(h.changes(), before);
|
|
171
|
+
assert.deepEqual(h.files(), saved);
|
|
172
|
+
assert.deepEqual(h.notices, []);
|
|
173
|
+
await h.run("gentle:mode", "status");
|
|
174
|
+
assert.deepEqual(h.notices.splice(0), [[`Permissions: ${savedMode.toUpperCase()} — default: ${savedMode.toUpperCase()}`, "info"]]);
|
|
175
|
+
assert.equal(h.prompts.length, 1);
|
|
176
|
+
assert.equal(h.confirms(), 0);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("YOLO selector waits for the human even in super-yolo; cancel and rejected answers do not change authority", async t => {
|
|
181
|
+
const h = selectorHost(t);
|
|
182
|
+
await h.run("gentle:mode", "super-yolo"); h.notices.length = 0;
|
|
183
|
+
const before = h.changes(), saved = h.files();
|
|
184
|
+
for (const answer of [undefined, "enable", "not an option"]) {
|
|
185
|
+
h.setSelect(async (title, choices) => {
|
|
186
|
+
assert.equal(title, "Permissions for this session (current: SUPER-YOLO)");
|
|
187
|
+
assert.deepEqual(choices, MODE_CHOICES);
|
|
188
|
+
assert.equal(h.changes(), before);
|
|
189
|
+
return answer;
|
|
190
|
+
});
|
|
191
|
+
await h.run("gentle:yolo", "");
|
|
192
|
+
assert.deepEqual(h.notices.splice(0), answer === undefined ? [] : [[INVALID_SELECTION, "warning"]]);
|
|
193
|
+
assert.equal(h.changes(), before);
|
|
194
|
+
assert.deepEqual(h.files(), saved);
|
|
195
|
+
await h.run("gentle:yolo", "status");
|
|
196
|
+
assert.deepEqual(h.notices.splice(0), [[SUPER_YOLO_STATUS_TEXT, "info"]]);
|
|
197
|
+
}
|
|
198
|
+
assert.equal(h.prompts.length, 3);
|
|
199
|
+
assert.equal(h.confirms(), 0);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("YOLO selector rejects a stale session, cwd, clone identity, or superseded mode action", async t => {
|
|
203
|
+
for (const reason of ["session", "cwd", "identity", "superseded"]) {
|
|
204
|
+
const h = selectorHost(t);
|
|
205
|
+
await h.run("gentle:mode", "status"); h.notices.length = 0;
|
|
206
|
+
let choose!: (value: string) => void, opened!: () => void;
|
|
207
|
+
const ready = new Promise<void>(resolve => { opened = resolve; });
|
|
208
|
+
h.setSelect(async () => { opened(); return new Promise<string>(resolve => { choose = resolve; }); });
|
|
209
|
+
const pending = h.run("gentle:yolo", ""); await ready;
|
|
210
|
+
if (reason === "session") h.setSession();
|
|
211
|
+
if (reason === "cwd") h.context.cwd = h.other;
|
|
212
|
+
if (reason === "identity") h.setIdentity();
|
|
213
|
+
if (reason === "superseded") { await h.run("gentle:mode", "auto"); h.notices.length = 0; }
|
|
214
|
+
const before = h.changes(), saved = h.files();
|
|
215
|
+
choose(MODE_CHOICES[3]); await pending;
|
|
216
|
+
assert.equal(h.changes(), before, `${reason}: stale choice cannot publish a transition`);
|
|
217
|
+
assert.deepEqual(h.files(), saved, reason);
|
|
218
|
+
assert.deepEqual(h.notices.splice(0), [[STALE, "warning"]], reason);
|
|
219
|
+
await h.run("gentle:mode", "status");
|
|
220
|
+
assert.deepEqual(h.notices.splice(0), [[`Permissions: ${reason === "superseded" ? "AUTO" : "NORMAL"} — default: NORMAL`, "info"]]);
|
|
221
|
+
assert.equal(h.prompts.length, 1);
|
|
222
|
+
assert.equal(h.confirms(), 0);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("YOLO selector does not prompt or upgrade headless, RPC, or child sessions", async t => {
|
|
227
|
+
for (const variant of ["headless", "rpc", "child"]) {
|
|
228
|
+
const h = selectorHost(t, variant === "child" ? { GENTLE_PI_AGENTS_CHILD: "1" } : {});
|
|
229
|
+
if (variant === "headless") Object.assign(h.context, { hasUI: false, mode: "json" });
|
|
230
|
+
if (variant === "rpc") Object.assign(h.context, { mode: "rpc" });
|
|
231
|
+
await h.run("gentle:mode", "status"); h.notices.length = 0;
|
|
232
|
+
const before = h.changes(), saved = h.files();
|
|
233
|
+
h.setSelect(async () => MODE_CHOICES[3]);
|
|
234
|
+
await h.run("gentle:yolo", "");
|
|
235
|
+
assert.deepEqual(h.notices.splice(0), [["YOLO OFF", "info"]], variant);
|
|
236
|
+
assert.equal(h.prompts.length, 0, variant);
|
|
237
|
+
assert.equal(h.changes(), before, variant);
|
|
238
|
+
assert.deepEqual(h.files(), saved, variant);
|
|
239
|
+
assert.equal(h.confirms(), 0, variant);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
test("selector-selected super-yolo preserves the private-path gate and human question boundary", async t => {
|
|
244
|
+
const root = mkdtempSync(join(tmpdir(), "yolo-selector-guards-"));
|
|
245
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
246
|
+
const home = join(root, "config"), workspace = join(root, "workspace");
|
|
247
|
+
mkdirSync(home); mkdirSync(workspace);
|
|
248
|
+
const commands = new Map<string, { handler(args: string, ctx: ExtensionContext): Promise<void> }>();
|
|
249
|
+
const handlers = new Map<string, Array<(event: unknown, ctx: ExtensionContext) => unknown>>();
|
|
250
|
+
const notices: Array<[string, string | undefined]> = [];
|
|
251
|
+
let selects = 0, confirms = 0, nativeCalls = 0;
|
|
252
|
+
const native = new Proxy({}, { get: () => () => { nativeCalls++; throw new Error("native call forbidden in fixture"); } });
|
|
253
|
+
const pi = {
|
|
254
|
+
on(name: string, fn: (event: unknown, ctx: ExtensionContext) => unknown) { handlers.set(name, [...handlers.get(name) ?? [], fn]); },
|
|
255
|
+
registerCommand(name: string, command: { handler(args: string, ctx: ExtensionContext): Promise<void> }) { commands.set(name, command); },
|
|
256
|
+
registerTool() {}, registerMessageRenderer() {}, registerFlag() {}, getActiveTools: () => [], events: { on() {}, emit() {} },
|
|
257
|
+
} as unknown as ExtensionAPI;
|
|
258
|
+
const ctx = {
|
|
259
|
+
cwd: workspace, mode: "tui", hasUI: true, sessionManager: { getSessionId: () => "guard-fixture" },
|
|
260
|
+
ui: { notify: (message: string, type?: string) => notices.push([message, type]), setStatus() {}, setWidget() {},
|
|
261
|
+
select: async (_title: string, choices: string[]) => { selects++; return choices[3]; },
|
|
262
|
+
confirm: async () => { confirms++; return false; } },
|
|
263
|
+
} as unknown as ExtensionContext;
|
|
264
|
+
createGentleAiExtension({ nativeReviewCli: native as never, candidateViews: null, processEnv: { GENTLE_PI_CONFIG_HOME: home },
|
|
265
|
+
resolveTelemetryTriggerBinary: () => { throw new Error("disabled in fixture"); } })(pi);
|
|
266
|
+
const command = commands.get("gentle:yolo"); assert.ok(command);
|
|
267
|
+
assert.equal(await command.handler("", ctx), undefined);
|
|
268
|
+
assert.deepEqual(notices, [["Permissions: SUPER-YOLO", "info"]]);
|
|
269
|
+
const emit = async (event: unknown) => {
|
|
270
|
+
let result: unknown;
|
|
271
|
+
for (const fn of handlers.get("tool_call") ?? []) { const next = await fn(event, ctx); if (next !== undefined) result = next; }
|
|
272
|
+
return result;
|
|
273
|
+
};
|
|
274
|
+
const deniedPath = "private-fixture/.env"; // A lexical input only; no file is created or read.
|
|
275
|
+
assert.deepEqual(await emit({ toolName: "read", toolCallId: "read-1", input: { path: deniedPath } }), {
|
|
276
|
+
block: true, reason: `Gentle AI safety policy blocked access to sensitive path: ${deniedPath}. Ask the user for an explicit safer plan.`,
|
|
277
|
+
});
|
|
278
|
+
const question = { toolName: "ask_user_choice", toolCallId: "question-1", input: { question: "Approve?", options: ["Yes", "No"] } };
|
|
279
|
+
const original = structuredClone(question);
|
|
280
|
+
assert.equal(await emit(question), undefined);
|
|
281
|
+
assert.deepEqual(question, original);
|
|
282
|
+
assert.equal(selects, 1); assert.equal(confirms, 0); assert.equal(nativeCalls, 0);
|
|
283
|
+
assert.deepEqual(readdirSync(home), []);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("legacy YOLO enable, disable and status remain explicit; super-yolo status is truthful", async t => {
|
|
287
|
+
const h = selectorHost(t);
|
|
288
|
+
await h.run("gentle:yolo", "status");
|
|
289
|
+
await h.run("gentle:yolo", "enable");
|
|
290
|
+
await h.run("gentle:yolo", "status");
|
|
291
|
+
await h.run("gentle:yolo", "disable");
|
|
292
|
+
await h.run("gentle:yolo", "status");
|
|
293
|
+
assert.deepEqual(h.notices.splice(0), [
|
|
294
|
+
["YOLO OFF", "info"], [YOLO_STATUS_TEXT, "info"], [YOLO_STATUS_TEXT, "info"],
|
|
295
|
+
["YOLO OFF", "info"], ["YOLO OFF", "info"],
|
|
296
|
+
]);
|
|
297
|
+
await h.run("gentle:mode", "super-yolo"); h.notices.length = 0;
|
|
298
|
+
const before = h.changes(), saved = h.files();
|
|
299
|
+
await h.run("gentle:yolo", "status");
|
|
300
|
+
assert.deepEqual(h.notices.splice(0), [[SUPER_YOLO_STATUS_TEXT, "info"]]);
|
|
301
|
+
await h.run("gentle:yolo", "invalid");
|
|
302
|
+
assert.deepEqual(h.notices.splice(0), [["Use /gentle:yolo enable|disable|status. State unchanged.", "warning"]]);
|
|
303
|
+
assert.equal(h.changes(), before);
|
|
304
|
+
assert.deepEqual(h.files(), saved);
|
|
305
|
+
assert.equal(h.prompts.length, 0);
|
|
306
|
+
assert.equal(h.confirms(), 0);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test("legacy mode and default commands retain their independent session and saved behavior", async t => {
|
|
310
|
+
const h = selectorHost(t);
|
|
311
|
+
for (const mode of ["normal", "auto", "yolo", "super-yolo"]) {
|
|
312
|
+
await h.run("gentle:mode", mode);
|
|
313
|
+
assert.deepEqual(h.notices.splice(0), mode === "auto"
|
|
314
|
+
? [[AUTO_MODE_NOTICE, "info"], ["Permissions: AUTO", "info"]]
|
|
315
|
+
: [[`Permissions: ${mode.toUpperCase()}`, "info"]]);
|
|
316
|
+
}
|
|
317
|
+
await h.run("gentle:mode", "default yolo");
|
|
318
|
+
assert.deepEqual(h.notices.splice(0), [["Default YOLO saved for next primary sessions.", "info"]]);
|
|
319
|
+
const saved = h.files(), before = h.changes();
|
|
320
|
+
await h.run("gentle:mode", "status");
|
|
321
|
+
assert.deepEqual(h.notices.splice(0), [["Permissions: SUPER-YOLO — default: YOLO", "info"]]);
|
|
322
|
+
await h.run("gentle:mode", "bad-input");
|
|
323
|
+
assert.deepEqual(h.notices.splice(0), [["Use /gentle:mode normal|auto|yolo|super-yolo|status or /gentle:mode default normal|auto|yolo|super-yolo. State unchanged.", "warning"]]);
|
|
324
|
+
assert.deepEqual(h.files(), saved);
|
|
325
|
+
assert.equal(h.changes(), before);
|
|
326
|
+
assert.equal(h.prompts.length, 0);
|
|
327
|
+
assert.equal(h.confirms(), 0);
|
|
328
|
+
});
|