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
|
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import test from "node:test";
|
|
5
|
-
import type
|
|
5
|
+
import { loadSkillsFromDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
7
7
|
import { readDelegationDetail } from "./support/orchestrator-modules.ts";
|
|
8
8
|
|
|
@@ -15,12 +15,8 @@ import { readDelegationDetail } from "./support/orchestrator-modules.ts";
|
|
|
15
15
|
// rendered `Receipt-driven development:` line, stated normatively exactly
|
|
16
16
|
// once in trigger 5 (Verification rule) and referenced -- not restated --
|
|
17
17
|
// everywhere else in this asset:
|
|
18
|
-
// -
|
|
19
|
-
//
|
|
20
|
-
// `{"operation":"assess"}` over the writer's diff and
|
|
21
|
-
// follows the returned plan by native risk tier
|
|
22
|
-
// (passive/medium/high/unassessable), instead of a
|
|
23
|
-
// blanket non-trivial judgment.
|
|
18
|
+
// - validated `off` -> no mandatory assess; named-risk verification remains.
|
|
19
|
+
// - `on`/`unknown` -> assess the writer's diff and follow the risk plan.
|
|
24
20
|
// - `on` -> the native review is an additional outside view; it
|
|
25
21
|
// never replaces or skips the tier's verification.
|
|
26
22
|
// These tests assert the exact distinctive sentences (not bare words like
|
|
@@ -45,7 +41,7 @@ const delegation = readDelegationDetail();
|
|
|
45
41
|
const worker = read("assets/agents/gentle-ai-worker.md");
|
|
46
42
|
|
|
47
43
|
const ROUTING_SENTENCE =
|
|
48
|
-
'After the writer returns,
|
|
44
|
+
'After the writer returns, when RDD is validated off, do not require `assess`: the writer\'s self-verification stands and a named Task Size high-risk item still requires an independent verifier. When RDD is on or unknown, call `gentle_review` with `{"operation":"assess"}` over the writer\'s diff and follow the returned plan.';
|
|
49
45
|
const RDD_ON_SENTENCE =
|
|
50
46
|
"When the line reads `on`, the native review is an additional outside view of the change; it never replaces or skips the tier's verification, and the tier's verifier runs before review.";
|
|
51
47
|
// Verification by named risk changed the tier table and replaced the
|
|
@@ -59,11 +55,20 @@ const HIGH_TIER_ROW = "| high | only through `escalate` naming a Task Size high-
|
|
|
59
55
|
const UNASSESSABLE_TIER_ROW = "| native high, unknown, or assess failed | informs only: writer self-verification stands; escalate when a named high-risk item applies |";
|
|
60
56
|
// odd/tasks/verifier-admission.md S6: the sentence names the runtime admission of the verifier launch.
|
|
61
57
|
const NAMED_RISK_SENTENCE =
|
|
62
|
-
"The independent verifier runs only when the change touches a named Task Size high-risk item
|
|
58
|
+
"The independent verifier runs only when the change touches a named Task Size high-risk item (runtime admits its launch on a `Risk: item N` line or sentence, a feature-document task line, or past the context backstop); never for size, a native tier alone, a failed assessment, or the model or effort that wrote the change. An unknown `Receipt-driven development:` line does not waive named-risk verification.";
|
|
63
59
|
const SPOT_CHECK_SENTENCE =
|
|
64
60
|
"The parent spot check (re-running one reported command before delivery) stays required in every tier.";
|
|
65
|
-
test("trigger 5
|
|
61
|
+
test("trigger 5 skips mandatory assess only for validated off and preserves named-risk verification", () => {
|
|
66
62
|
assert.ok(delegation.includes(ROUTING_SENTENCE), "trigger 5 is missing the exact routing sentence");
|
|
63
|
+
assert.doesNotMatch(delegation, /whatever the `Receipt-driven development:` line reads \(`on`, `off`, or `unknown`\)/);
|
|
64
|
+
assert.doesNotMatch(registeredReviewToolContract(), /it is the only way to get an independent verifier/);
|
|
65
|
+
for (const path of ["assets/orchestrator.md", "skills/gentle-ai/SKILL.md"]) {
|
|
66
|
+
assert.match(read(path), /assess `escalate` when RDD is on or unknown/, `${path} must not mandate assess while off`);
|
|
67
|
+
}
|
|
68
|
+
const { skills, diagnostics } = loadSkillsFromDir({ dir: join(ROOT, "skills/gentle-ai"), source: "fixture" });
|
|
69
|
+
assert.deepEqual(diagnostics, []);
|
|
70
|
+
assert.equal(skills.length, 1);
|
|
71
|
+
assert.equal(skills[0].name, "gentle-ai");
|
|
67
72
|
});
|
|
68
73
|
|
|
69
74
|
test("trigger 5 states that with RDD on the native review adds an outside view and never replaces verification", () => {
|
|
@@ -79,7 +84,7 @@ test("trigger 5 states the native risk tier table exactly once, with all four ro
|
|
|
79
84
|
}
|
|
80
85
|
});
|
|
81
86
|
|
|
82
|
-
test("trigger 5 states the named-risk verifier rule
|
|
87
|
+
test("trigger 5 states the named-risk verifier rule for unknown mode", () => {
|
|
83
88
|
assert.ok(delegation.includes(NAMED_RISK_SENTENCE), "trigger 5 is missing the named-risk verifier sentence");
|
|
84
89
|
assert.ok(!delegation.includes("small-model bias"), "the retired small-model bias must not survive in any orchestrator module");
|
|
85
90
|
});
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test, { type TestContext } from "node:test";
|
|
6
|
+
import { createEventBus, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { visibleWidth, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
8
|
+
import { createGentleAiExtension, __testing } from "../extensions/gentle-ai.ts";
|
|
9
|
+
import gentleShell from "../extensions/gentle-shell.ts";
|
|
10
|
+
import type { NativeReviewCli, NativeReviewModeRequest, NativeReviewModeResult } from "../lib/native-review-cli.ts";
|
|
11
|
+
|
|
12
|
+
const OPTIONS = ["Enable RDD for this repository", "Disable RDD for this repository", "Enable RDD machine-wide", "Disable RDD machine-wide"];
|
|
13
|
+
type View = { focus(label: string): boolean; render(width: number): string[]; handleInput(data: string): void; handleMouse(event: TuiMouseEvent): unknown; invalidate(): void };
|
|
14
|
+
type Mode = "" | "on" | "off";
|
|
15
|
+
|
|
16
|
+
function deferred<T>() {
|
|
17
|
+
let resolve!: (value: T) => void;
|
|
18
|
+
const promise = new Promise<T>(done => { resolve = done; });
|
|
19
|
+
return { promise, resolve };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function fixture(t: TestContext, options: { owner?: boolean; child?: boolean; provider?: boolean; global?: Mode; badBridge?: boolean; throwingBridge?: boolean; invalidStatusBridge?: boolean } = {}) {
|
|
23
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), "rdd-customize-")));
|
|
24
|
+
const cwd = join(root, "workspace"), home = join(root, "home"), config = join(root, "config");
|
|
25
|
+
mkdirSync(cwd); mkdirSync(home); mkdirSync(config);
|
|
26
|
+
const env = { HOME: root, USERPROFILE: root, XDG_CONFIG_HOME: join(root, "xdg"), PI_CODING_AGENT_DIR: home,
|
|
27
|
+
GENTLE_PI_AGENT_HOME: home, GENTLE_PI_CONFIG_HOME: config, GENTLE_AI_TELEMETRY: "0",
|
|
28
|
+
GENTLE_PI_AGENTS_CHILD: options.child ? "1" : "0", GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" };
|
|
29
|
+
const previous = Object.fromEntries(Object.keys(env).map(key => [key, process.env[key]]));
|
|
30
|
+
Object.assign(process.env, env);
|
|
31
|
+
__testing.clearRddStatusMemoForTesting();
|
|
32
|
+
t.after(() => {
|
|
33
|
+
__testing.clearRddStatusMemoForTesting();
|
|
34
|
+
for (const [key, value] of Object.entries(previous)) {
|
|
35
|
+
if (value === undefined) delete process.env[key]; else process.env[key] = value;
|
|
36
|
+
}
|
|
37
|
+
rmSync(root, { recursive: true, force: true });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let global: Mode = options.global ?? "", clone: Mode = "";
|
|
41
|
+
const calls: Array<{ operation: string; cwd: string; scope?: string }> = [];
|
|
42
|
+
const writes: Array<{ operation: string; cwd: string; scope?: string }> = [];
|
|
43
|
+
let statusFailure = false;
|
|
44
|
+
let heldStatus: { started: ReturnType<typeof deferred<void>>; release: ReturnType<typeof deferred<void>> } | undefined;
|
|
45
|
+
const native = {
|
|
46
|
+
async reviewMode(request: NativeReviewModeRequest) {
|
|
47
|
+
const call = { operation: request.operation, cwd: request.cwd, ...(request.scope ? { scope: request.scope } : {}) };
|
|
48
|
+
calls.push(call);
|
|
49
|
+
if (request.operation === "status" && heldStatus) {
|
|
50
|
+
const held = heldStatus; heldStatus = undefined; held.started.resolve(); await held.release.promise;
|
|
51
|
+
}
|
|
52
|
+
if (request.operation === "status" && statusFailure) throw new Error("fixture unavailable");
|
|
53
|
+
if (request.operation !== "status") {
|
|
54
|
+
if (request.scope === "global") global = request.operation === "enable" ? "on" : "off";
|
|
55
|
+
else clone = request.operation === "disable" ? "off" : "";
|
|
56
|
+
writes.push(call);
|
|
57
|
+
}
|
|
58
|
+
const source = clone === "off" ? "clone_local" : global ? "global" : "default";
|
|
59
|
+
const status = { global, cloneLocal: clone, effective: clone === "off" ? "off" : global || "on", source };
|
|
60
|
+
return { operation: request.operation, scope: request.scope ?? "clone", status } as NativeReviewModeResult;
|
|
61
|
+
},
|
|
62
|
+
} as unknown as NativeReviewCli;
|
|
63
|
+
const events = createEventBus();
|
|
64
|
+
const ownerHandlers = new Map<string, Array<(event: unknown, ctx: ExtensionContext) => unknown>>();
|
|
65
|
+
const shellHandlers = new Map<string, Array<(event: unknown, ctx: ExtensionContext) => unknown>>();
|
|
66
|
+
const commands = new Map<string, { handler(args: string, ctx: ExtensionContext): Promise<void> }>();
|
|
67
|
+
const notices: Array<{ message: string; type?: string }> = [];
|
|
68
|
+
const prompts: Array<{ title: string; options: string[] }> = [];
|
|
69
|
+
const themeChanges: string[] = [];
|
|
70
|
+
const theme = { name: "dark", fg: (_role: string, value: string) => value, bg: (_role: string, value: string) => value };
|
|
71
|
+
let sessionId = "fixture-session", managerCwd = cwd, view: View | undefined, finish: (() => void) | undefined;
|
|
72
|
+
let select: (title: string, options: string[]) => Promise<string | undefined> = async () => undefined;
|
|
73
|
+
let opened = deferred<void>(), renders = 0, discovery = 0, cardClosed = true;
|
|
74
|
+
const manager = { getSessionId: () => sessionId, getCwd: () => managerCwd, getEntries: () => [], getBranch: () => [] };
|
|
75
|
+
const ui = new Proxy({
|
|
76
|
+
theme,
|
|
77
|
+
getAllThemes: () => [{ name: "dark" }, { name: "light" }],
|
|
78
|
+
getTheme: (name: string) => ({ ...theme, name }),
|
|
79
|
+
setTheme: (name: string) => { themeChanges.push(name); return { success: true }; },
|
|
80
|
+
notify: (message: string, type?: string) => notices.push({ message, type }),
|
|
81
|
+
select: async (title: string, choices: string[]) => {
|
|
82
|
+
assert.equal(cardClosed, true, "owner selector must not be hidden by the Customize overlay");
|
|
83
|
+
prompts.push({ title, options: choices });
|
|
84
|
+
return select(title, choices);
|
|
85
|
+
},
|
|
86
|
+
custom: (factory: (tui: unknown, theme: unknown, keys: unknown, done: () => void) => View) => new Promise<void>(resolve => {
|
|
87
|
+
cardClosed = false;
|
|
88
|
+
finish = () => { cardClosed = true; resolve(); };
|
|
89
|
+
view = factory({ requestRender: () => { renders++; }, terminal: { rows: 30 } }, theme, {}, finish);
|
|
90
|
+
opened.resolve();
|
|
91
|
+
}),
|
|
92
|
+
}, { get(target, key) { return key in target ? Reflect.get(target, key) : () => undefined; } });
|
|
93
|
+
const ctx = { cwd, mode: "tui", hasUI: true, sessionManager: manager, ui } as unknown as ExtensionContext;
|
|
94
|
+
const makePi = (handlers: typeof ownerHandlers) => ({
|
|
95
|
+
events, on(name: string, handler: (event: unknown, ctx: ExtensionContext) => unknown) { handlers.set(name, [...handlers.get(name) ?? [], handler]); },
|
|
96
|
+
registerCommand(name: string, command: { handler(args: string, ctx: ExtensionContext): Promise<void> }) { commands.set(name, command); },
|
|
97
|
+
registerTool() {}, registerShortcut() {}, registerMessageRenderer() {}, appendEntry() {},
|
|
98
|
+
getActiveTools: () => [], getThinkingLevel: () => "off", getCommands: () => [],
|
|
99
|
+
sendUserMessage() { assert.fail("Customize must not synthesize a command"); },
|
|
100
|
+
}) as unknown as ExtensionAPI;
|
|
101
|
+
events.on("gentle:rdd:host-ui", () => { discovery++; });
|
|
102
|
+
if (options.badBridge) events.on("gentle:rdd:host-ui", payload => (payload as { respond(value: unknown): void }).respond({ read: "invalid" }));
|
|
103
|
+
if (options.throwingBridge) events.on("gentle:rdd:host-ui", payload => (payload as { respond(value: unknown): void }).respond({
|
|
104
|
+
read() { throw new Error("bridge unavailable"); }, open() { assert.fail("a failed bridge cannot open"); },
|
|
105
|
+
}));
|
|
106
|
+
if (options.invalidStatusBridge) events.on("gentle:rdd:host-ui", payload => (payload as { respond(value: unknown): void }).respond({
|
|
107
|
+
async read() { return { effective: "on", source: "invalid" }; }, open() { assert.fail("an invalid status cannot open"); },
|
|
108
|
+
}));
|
|
109
|
+
if (options.owner !== false) createGentleAiExtension({ nativeReviewCli: options.provider === false ? null : native, candidateViews: null,
|
|
110
|
+
processEnv: env, resolveTelemetryTriggerBinary: () => { throw new Error("disabled"); } })(makePi(ownerHandlers));
|
|
111
|
+
gentleShell(makePi(shellHandlers), env, { fetch: async () => { throw new Error("network disabled"); }, activeProfile: () => undefined, devBinary: () => undefined });
|
|
112
|
+
const emit = async (handlers: typeof ownerHandlers, name: string) => { for (const fn of handlers.get(name) ?? []) await fn({ type: name, reason: "startup" }, ctx); };
|
|
113
|
+
const text = () => { assert.ok(view); return view.render(140).join("\n"); };
|
|
114
|
+
return {
|
|
115
|
+
ctx, calls, writes, notices, prompts, themeChanges, text,
|
|
116
|
+
state: () => ({ global, clone }), renders: () => renders, discovery: () => discovery,
|
|
117
|
+
hasCommand: (name: string) => commands.has(name),
|
|
118
|
+
setId: (id: string) => { sessionId = id; }, setManagerCwd: (value: string) => { managerCwd = value; },
|
|
119
|
+
setSelect: (fn: typeof select) => { select = fn; }, failStatus: () => { statusFailure = true; },
|
|
120
|
+
holdStatus() { heldStatus = { started: deferred<void>(), release: deferred<void>() }; return heldStatus; },
|
|
121
|
+
async start() { await emit(ownerHandlers, "session_start"); notices.length = 0; calls.length = 0; },
|
|
122
|
+
async shutdown() { await emit(ownerHandlers, "session_shutdown"); await emit(shellHandlers, "session_shutdown"); },
|
|
123
|
+
async command(name: string, args = "") { const command = commands.get(name); assert.ok(command, `/${name} is registered`); await command.handler(args, ctx); },
|
|
124
|
+
async open() {
|
|
125
|
+
opened = deferred<void>();
|
|
126
|
+
const command = commands.get("gentle:customize"); assert.ok(command, "/gentle:customize is registered");
|
|
127
|
+
const result = command.handler("", ctx);
|
|
128
|
+
await Promise.race([opened.promise, result.then(() => { throw new Error("Customize did not open"); })]);
|
|
129
|
+
assert.ok(view);
|
|
130
|
+
return { view, result, close: () => { view?.handleInput("\x1b"); finish?.(); } };
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function until(check: () => boolean) {
|
|
136
|
+
for (let i = 0; i < 100; i++) { if (check()) return; await new Promise(resolve => setTimeout(resolve, 10)); }
|
|
137
|
+
assert.ok(check(), "expected visible result within one second");
|
|
138
|
+
}
|
|
139
|
+
async function focusRdd(h: ReturnType<typeof fixture>, view: View, expected: RegExp) {
|
|
140
|
+
await until(() => { view.focus("RDD:"); return expected.test(h.text()); });
|
|
141
|
+
assert.ok(view.focus("RDD:"));
|
|
142
|
+
view.render(140);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
test("opening, highlighting, navigation, rendering and Escape show truthful status without opening or changing RDD", async t => {
|
|
146
|
+
const h = fixture(t); await h.start();
|
|
147
|
+
const card = await h.open();
|
|
148
|
+
await focusRdd(h, card.view, /RDD: on \(decided by default\)/);
|
|
149
|
+
const before = h.state();
|
|
150
|
+
for (const width of [20, 60, 80, 140]) assert.ok(card.view.render(width).every(line => visibleWidth(line) <= width));
|
|
151
|
+
card.view.render(140); card.view.handleInput("\x1b[B"); card.view.handleInput("\x1b[A");
|
|
152
|
+
card.view.invalidate(); h.text();
|
|
153
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
154
|
+
card.close(); await card.result;
|
|
155
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("explicit application hands off to the owner selector and reopening refreshes effective mode and source", async t => {
|
|
159
|
+
const h = fixture(t); await h.start();
|
|
160
|
+
const card = await h.open(); await focusRdd(h, card.view, /RDD: on \(decided by default\)/);
|
|
161
|
+
h.setSelect(async () => OPTIONS[1]);
|
|
162
|
+
card.view.handleInput("\r"); await card.result;
|
|
163
|
+
assert.deepEqual(h.prompts, [{ title: "Receipt-driven development: on (decided by default)", options: OPTIONS }]);
|
|
164
|
+
assert.deepEqual(h.writes, [{ cwd: h.ctx.cwd, operation: "disable" }]);
|
|
165
|
+
assert.deepEqual(h.notices.at(-1), { message: "receipt-driven development: off (decided by clone_local)", type: "info" });
|
|
166
|
+
const again = await h.open(); await focusRdd(h, again.view, /RDD: off \(decided by clone_local\)/);
|
|
167
|
+
again.close(); await again.result;
|
|
168
|
+
assert.equal(h.prompts.length, 1); assert.equal(h.writes.length, 1);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("pointer hover and press are inert; a click hands off the explicitly named machine-wide choice", async t => {
|
|
172
|
+
const h = fixture(t); await h.start(); const card = await h.open();
|
|
173
|
+
await focusRdd(h, card.view, /RDD: on \(decided by default\)/);
|
|
174
|
+
const frame = card.view.render(140), y = frame.findIndex(line => line.includes("RDD:"));
|
|
175
|
+
assert.ok(y >= 0); const x = visibleWidth(frame[y]!.slice(0, frame[y]!.indexOf("RDD:")));
|
|
176
|
+
const event = { x, y, screenX: x, screenY: y, width: 140, height: frame.length, shift: false, alt: false, ctrl: false };
|
|
177
|
+
card.view.handleMouse({ ...event, type: "move", button: "none" });
|
|
178
|
+
card.view.handleMouse({ ...event, type: "press", button: "left" });
|
|
179
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []);
|
|
180
|
+
h.setSelect(async () => OPTIONS[3]);
|
|
181
|
+
card.view.handleMouse({ ...event, type: "click", button: "left" }); await card.result;
|
|
182
|
+
assert.deepEqual(h.prompts, [{ title: "Receipt-driven development: on (decided by default)", options: OPTIONS }]);
|
|
183
|
+
assert.deepEqual(h.writes, [{ cwd: h.ctx.cwd, operation: "disable", scope: "global" }]);
|
|
184
|
+
assert.deepEqual(h.notices.at(-1), { message: "receipt-driven development: off (decided by global)", type: "info" });
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("owner cancellation after explicit application leaves mode and write count unchanged", async t => {
|
|
188
|
+
const h = fixture(t, { global: "off" }); await h.start();
|
|
189
|
+
const card = await h.open(); await focusRdd(h, card.view, /RDD: off \(decided by global\)/);
|
|
190
|
+
const before = h.state(); card.view.handleInput(" "); await card.result;
|
|
191
|
+
assert.deepEqual(h.prompts, [{ title: "Receipt-driven development: off (decided by global)", options: OPTIONS }]);
|
|
192
|
+
assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before); assert.deepEqual(h.notices, []);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("missing bridge, unavailable provider and failed reads show unavailable and cannot invoke the selector", async t => {
|
|
196
|
+
for (const options of [{ owner: false }, { owner: false, badBridge: true }, { owner: false, throwingBridge: true }, { owner: false, invalidStatusBridge: true }, { provider: false }, { fail: true }]) await t.test(JSON.stringify(options), async st => {
|
|
197
|
+
const h = fixture(st, options); await h.start(); if (options.fail) h.failStatus();
|
|
198
|
+
const before = h.state(); const card = await h.open();
|
|
199
|
+
await focusRdd(h, card.view, /RDD: unavailable/i);
|
|
200
|
+
card.view.handleInput("\r");
|
|
201
|
+
await until(() => h.notices.some(({ message }) => /RDD.*unavailable/i.test(message)));
|
|
202
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
203
|
+
card.close(); await card.result;
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("headless and child contexts cannot acquire RDD authority", async t => {
|
|
208
|
+
await t.test("headless", async st => {
|
|
209
|
+
const h = fixture(st); await h.start(); Object.assign(h.ctx, { mode: "print", hasUI: false });
|
|
210
|
+
const before = h.state(); await h.command("gentle:customize");
|
|
211
|
+
assert.equal(h.discovery(), 0); assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
212
|
+
});
|
|
213
|
+
await t.test("rpc", async st => {
|
|
214
|
+
const h = fixture(st); await h.start(); Object.assign(h.ctx, { mode: "rpc" });
|
|
215
|
+
const before = h.state(); await h.command("gentle:customize");
|
|
216
|
+
assert.equal(h.discovery(), 0); assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
217
|
+
assert.deepEqual(h.notices, [{ message: "Customization requires an interactive terminal.", type: "warning" }]);
|
|
218
|
+
});
|
|
219
|
+
await t.test("child", async st => {
|
|
220
|
+
const h = fixture(st, { child: true }); await h.start(); const before = h.state();
|
|
221
|
+
assert.equal(h.hasCommand("gentle:customize"), false, "the shell is not registered in a child");
|
|
222
|
+
assert.equal(h.discovery(), 0); assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("stale card session or workspace cannot dispatch the owner selector", async t => {
|
|
227
|
+
for (const cause of ["session", "workspace", "manager-cwd"] as const) await t.test(cause, async st => {
|
|
228
|
+
const h = fixture(st); await h.start(); const card = await h.open(); await focusRdd(h, card.view, /RDD: on/);
|
|
229
|
+
const before = h.state(), calls = h.calls.length;
|
|
230
|
+
if (cause === "session") h.setId("replacement");
|
|
231
|
+
if (cause === "workspace") Object.assign(h.ctx, { cwd: `${h.ctx.cwd}-other` });
|
|
232
|
+
if (cause === "manager-cwd") h.setManagerCwd(`${h.ctx.cwd}-other`);
|
|
233
|
+
card.view.handleInput("\r"); await new Promise(resolve => setTimeout(resolve, 20));
|
|
234
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before); assert.equal(h.calls.length, calls);
|
|
235
|
+
card.close(); await card.result;
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test("session, workspace and shutdown changes reject a stale owner selection", async t => {
|
|
240
|
+
for (const cause of ["session", "workspace", "manager-cwd", "shutdown"] as const) await t.test(cause, async st => {
|
|
241
|
+
const h = fixture(st); await h.start(); const card = await h.open(); await focusRdd(h, card.view, /RDD: on/);
|
|
242
|
+
const answer = deferred<string | undefined>(), selecting = deferred<void>();
|
|
243
|
+
h.setSelect(async () => { selecting.resolve(); return answer.promise; });
|
|
244
|
+
const before = h.state(); card.view.handleInput("\r"); await selecting.promise;
|
|
245
|
+
if (cause === "session") h.setId("replacement");
|
|
246
|
+
if (cause === "workspace") Object.assign(h.ctx, { cwd: `${h.ctx.cwd}-other` });
|
|
247
|
+
if (cause === "manager-cwd") h.setManagerCwd(`${h.ctx.cwd}-other`);
|
|
248
|
+
if (cause === "shutdown") await h.shutdown();
|
|
249
|
+
answer.resolve(OPTIONS[3]); await card.result;
|
|
250
|
+
assert.equal(h.prompts.length, 1); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before); assert.deepEqual(h.notices, []);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test("a replacement Customize card cancels an obsolete queued selector handoff", async t => {
|
|
255
|
+
const h = fixture(t); await h.start(); const first = await h.open(); await focusRdd(h, first.view, /RDD: on/);
|
|
256
|
+
const before = h.state(); h.setSelect(async () => OPTIONS[3]);
|
|
257
|
+
first.view.handleInput("\r");
|
|
258
|
+
const replacing = h.open();
|
|
259
|
+
await first.result;
|
|
260
|
+
const second = await replacing; await focusRdd(h, second.view, /RDD: on/);
|
|
261
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before);
|
|
262
|
+
second.close(); await second.result;
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("closing a card during a pending status read cannot revive the selector or repaint", async t => {
|
|
266
|
+
const h = fixture(t); await h.start(); const held = h.holdStatus();
|
|
267
|
+
const card = await h.open(); await held.started.promise;
|
|
268
|
+
await focusRdd(h, card.view, /RDD: checking/);
|
|
269
|
+
card.close(); await card.result;
|
|
270
|
+
const count = h.renders(), before = h.state();
|
|
271
|
+
held.release.resolve(); card.view.handleInput("\r"); card.view.invalidate();
|
|
272
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
273
|
+
assert.deepEqual(h.prompts, []); assert.deepEqual(h.writes, []); assert.deepEqual(h.state(), before); assert.equal(h.renders(), count);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
test("existing Customize theme and live animation controls retain their application behavior", async t => {
|
|
277
|
+
const h = fixture(t); await h.start(); const card = await h.open();
|
|
278
|
+
assert.ok(card.view.focus("Theme: light")); card.view.render(140);
|
|
279
|
+
assert.deepEqual(h.themeChanges, []); card.view.handleInput("\r");
|
|
280
|
+
await until(() => h.themeChanges.length === 1);
|
|
281
|
+
assert.deepEqual(h.themeChanges, ["light"]);
|
|
282
|
+
await until(() => card.view.focus("Animations: quality")); card.view.render(140);
|
|
283
|
+
card.view.handleInput("\x1b[C");
|
|
284
|
+
await until(() => h.notices.some(({ message }) => message === "Animation saved. Prompt applies now; startup banner applies at next startup."));
|
|
285
|
+
assert.deepEqual(h.writes, []); assert.deepEqual(h.prompts, []);
|
|
286
|
+
card.close(); await card.result;
|
|
287
|
+
});
|