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
|
@@ -16,11 +16,12 @@ export const SUPER_YOLO_STATUS_TEXT = "💥 SUPER YOLO ON — no permission prom
|
|
|
16
16
|
export const SUPER_YOLO_DIRECTIVE = `<gentle-super-yolo-session>
|
|
17
17
|
SUPER YOLO session standing permission is ON, authorized by the human for this live primary session and canonical workspace. No permission questions are asked in this mode: proceed through ordinary and destructive shell work (including rm, resets, force operations and configured-guard confirmations) without confirmation dialogs, and make implementation and delivery choices directly.
|
|
18
18
|
The ONLY hard line is private material: never read, print, copy, transmit or commit secrets or private credentials — .env files, .ssh, keychains, *.pem/*.key/*.p12/*.pfx, secrets/ directories, cloud credential files. If a task seems to need them, stop and ask the human.
|
|
19
|
-
This does NOT override explicit human restrictions in the live conversation, and never auto-answers ask_user tools, provider consent, maintenance/recovery authorization or opaque-token decisions. Children remain bounded by their delegated task; they receive no independent delivery grant or Super Yolo inheritance.
|
|
19
|
+
This does NOT override explicit human restrictions in the live conversation, and never auto-answers permission-mode selections, ask_user tools, provider consent, maintenance/recovery authorization or opaque-token decisions. Children remain bounded by their delegated task; they receive no independent delivery grant or Super Yolo inheritance.
|
|
20
20
|
</gentle-super-yolo-session>`;
|
|
21
21
|
export const YOLO_DIRECTIVE = `<gentle-yolo-session>
|
|
22
22
|
YOLO session standing permission is ON, authorized by the human for this live primary session and canonical workspace (directly or through a trusted global default).
|
|
23
23
|
Qualify the default commit, push and PR confirmation clauses: for ordinary already-scoped implementation, checks, commits, non-force pushes and PR creation, this activation supplies standing permission instead of repeated permission questions. Make ordinary reversible implementation choices without needless interviews.
|
|
24
|
+
Quoted, cited, logged or analyzed destructive text is not an execution: the mandatory destructive confirmations apply only to commands this session actually runs, never to destructive commands appearing inside issue bodies, file contents, documentation, transcripts or command output. Reading and listing non-sensitive material outside the workspace — including Gentle AI's own skills, docs and configuration — is covered by this standing permission; do not ask permission for those reads. Sensitive-path and private-credential blocks still win.
|
|
24
25
|
This does NOT override explicit human restrictions, repository policy, project trust, configured confirmations or blocks, or the authorized task scope. Ask before scope expansion, privacy-sensitive disclosure, genuinely unresolved consequential product choices, or ambiguous destinations or credentials. Never invent destinations or credentials.
|
|
25
26
|
Destructive/data-loss confirmations remain mandatory and independent. Never auto-answer ask_user tools, provider consent, maintenance/recovery authorization or opaque-token decisions. Review standing permission and RDD are unchanged. Children remain bounded by their delegated task; they receive no independent delivery grant or YOLO inheritance.
|
|
26
27
|
</gentle-yolo-session>`;
|
|
@@ -57,6 +58,12 @@ export function updateYoloPrompt(options: AppendableSystemPromptOptions | null |
|
|
|
57
58
|
if (superActive) appendSystemPromptOnce(options, SUPER_YOLO_DIRECTIVE);
|
|
58
59
|
else if (active) appendSystemPromptOnce(options, YOLO_DIRECTIVE);
|
|
59
60
|
}
|
|
61
|
+
const MODE_CHOICES: ReadonlyArray<{ mode: PermissionMode; label: string }> = [
|
|
62
|
+
{ mode: "normal", label: "normal — standard permission prompts" },
|
|
63
|
+
{ mode: "auto", label: "auto — independent checks; extra model calls" },
|
|
64
|
+
{ mode: "yolo", label: "yolo — scoped work; destructive actions ask" },
|
|
65
|
+
{ mode: "super-yolo", label: "super-yolo — no permission prompts; private paths blocked; consent remains" },
|
|
66
|
+
];
|
|
60
67
|
const HUMAN_ACTION = { on: "on", off: "off", toggle: "" } as const;
|
|
61
68
|
type HumanAction = (typeof HUMAN_ACTION)[keyof typeof HUMAN_ACTION];
|
|
62
69
|
export const YOLO_DISPLAY = { on: "ON", off: "OFF", unavailable: "UNAVAILABLE" } as const;
|
|
@@ -131,6 +138,8 @@ interface ModeIdentity {
|
|
|
131
138
|
id: string;
|
|
132
139
|
workspace: string;
|
|
133
140
|
}
|
|
141
|
+
const sameModeIdentity = (left: ModeIdentity, right: ModeIdentity): boolean =>
|
|
142
|
+
left.manager === right.manager && left.id === right.id && left.workspace === right.workspace;
|
|
134
143
|
/** UI/slash authoring only. Defaults are read from the dedicated trusted user store. */
|
|
135
144
|
export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessEnv,
|
|
136
145
|
options: { onChange?: () => void; resolveIdentity?: typeof resolveCanonicalGitRepositoryIdentity } = {}): YoloSessionController {
|
|
@@ -219,6 +228,9 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
219
228
|
finally { pendingCaptures.delete(scope); }
|
|
220
229
|
};
|
|
221
230
|
const defaultMode = (): PermissionMode => resolvePermissionModePolicy(store).mode;
|
|
231
|
+
// Preview and initialization share the same fresh-session default rule.
|
|
232
|
+
const initialMode = (identity: ModeIdentity): PermissionMode =>
|
|
233
|
+
seen.get(identity.manager)?.has(identity.id) ? "normal" : defaultMode();
|
|
222
234
|
const mode = async (ctx: ExtensionContext, admission?: { toolCallId: string }): Promise<PermissionMode> => {
|
|
223
235
|
const scope = session(ctx);
|
|
224
236
|
const admissionId = admission?.toolCallId;
|
|
@@ -237,8 +249,9 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
237
249
|
}
|
|
238
250
|
if (!binding && identity) {
|
|
239
251
|
const fresh = !seen.get(identity.manager)?.has(identity.id);
|
|
252
|
+
const initial = fresh ? initialMode(identity) : "normal";
|
|
240
253
|
remember(identity); binding = identity;
|
|
241
|
-
if (fresh) { liveMode =
|
|
254
|
+
if (fresh) { liveMode = initial; interactiveGrant = false; changed(ctx); }
|
|
242
255
|
}
|
|
243
256
|
// Record after the binding pass: internal changed() bumps above must not strand
|
|
244
257
|
// a cache entry stamped with a superseded generation. Only admission-keyed
|
|
@@ -258,7 +271,7 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
258
271
|
binding = undefined; liveMode = "normal"; interactiveGrant = false;
|
|
259
272
|
changed(ctx); observers.clear();
|
|
260
273
|
};
|
|
261
|
-
const setMode = async (requested: PermissionMode, ctx: ExtensionContext, lifetime = () => true): Promise<boolean> => {
|
|
274
|
+
const setMode = async (requested: PermissionMode, ctx: ExtensionContext, lifetime = () => true, expectedIdentity?: ModeIdentity): Promise<boolean> => {
|
|
262
275
|
if (!isPermissionMode(requested) || !interactive(ctx) || !lifetime()) return false;
|
|
263
276
|
const current = bindCurrent(ctx, () => !lifetime());
|
|
264
277
|
// Revoke immediately, including off versus a pending activation race.
|
|
@@ -266,7 +279,7 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
266
279
|
binding = undefined; liveMode = "normal"; interactiveGrant = false; changed(ctx);
|
|
267
280
|
const epoch = generation;
|
|
268
281
|
const identity = await capture(ctx);
|
|
269
|
-
if (!current() || epoch !== generation || !identity) return false;
|
|
282
|
+
if (!current() || epoch !== generation || !identity || (expectedIdentity && !sameModeIdentity(expectedIdentity, identity))) return false;
|
|
270
283
|
binding = identity; remember(identity); liveMode = requested; interactiveGrant = true; changed(ctx);
|
|
271
284
|
if (requested === "auto") notify(ctx, AUTO_MODE_NOTICE);
|
|
272
285
|
return true;
|
|
@@ -357,23 +370,35 @@ export function registerYoloSessionPolicy(pi: ExtensionAPI, env: NodeJS.ProcessE
|
|
|
357
370
|
},
|
|
358
371
|
});
|
|
359
372
|
pi.registerCommand("gentle:yolo", {
|
|
360
|
-
description: "
|
|
373
|
+
description: "Choose a session permission mode; enable|disable|status remain available as explicit shortcuts.",
|
|
361
374
|
handler: async (args, ctx) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
|
|
375
|
+
const action = args.trim() || "status";
|
|
376
|
+
if (!args.trim() && interactive(ctx) && typeof ctx.ui.select === "function") {
|
|
377
|
+
const current = bindCurrent(ctx), epoch = generation;
|
|
378
|
+
const stale = () => notify(ctx, "YOLO unchanged — the session changed while the menu was open.", true);
|
|
379
|
+
const identity = await capture(ctx);
|
|
380
|
+
if (!current() || epoch !== generation || !identity) { stale(); return; }
|
|
381
|
+
// Preview the effective default without initializing authority merely by opening a dialog.
|
|
382
|
+
const state = binding && sameModeIdentity(binding, identity) ? liveMode : initialMode(identity);
|
|
383
|
+
const selected = await ctx.ui.select(`Permissions for this session (current: ${state.toUpperCase()})`, MODE_CHOICES.map(choice => choice.label));
|
|
368
384
|
if (selected === undefined) return;
|
|
369
|
-
|
|
385
|
+
if (!current() || epoch !== generation) { stale(); return; }
|
|
386
|
+
const choice = MODE_CHOICES.find(item => item.label === selected);
|
|
387
|
+
if (!choice) { notify(ctx, "YOLO unchanged — invalid menu selection.", true); return; }
|
|
388
|
+
const fresh = await capture(ctx);
|
|
389
|
+
if (!current() || epoch !== generation || !fresh || !sameModeIdentity(identity, fresh)) { stale(); return; }
|
|
390
|
+
if (await setMode(choice.mode, ctx, current, identity)) notify(ctx, `Permissions: ${choice.mode.toUpperCase()}`);
|
|
391
|
+
else stale();
|
|
392
|
+
return;
|
|
370
393
|
}
|
|
371
394
|
if (action !== "enable" && action !== "disable" && action !== "status") {
|
|
372
395
|
notify(ctx, "Use /gentle:yolo enable|disable|status. State unchanged.", true); return;
|
|
373
396
|
}
|
|
374
|
-
if (action === "status") {
|
|
375
|
-
|
|
376
|
-
|
|
397
|
+
if (action === "status") {
|
|
398
|
+
const state = await mode(ctx);
|
|
399
|
+
notify(ctx, state === "super-yolo" ? SUPER_YOLO_STATUS_TEXT : state === "yolo" ? YOLO_STATUS_TEXT : "YOLO OFF"); return;
|
|
400
|
+
}
|
|
401
|
+
await humanAction(action === "enable" ? HUMAN_ACTION.on : HUMAN_ACTION.off, ctx);
|
|
377
402
|
},
|
|
378
403
|
});
|
|
379
404
|
return { active, superActive, mode, setMode, defaultMode, saveDefault, epoch: () => generation, humanAction, reset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gentle-pi",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Turn Pi into el Gentleman: an ODD development harness with focused subagents, configured TDD evidence, native review, and skill discovery.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"build:runtime-modules": "node scripts/build-runtime-modules.mjs --write",
|
|
52
52
|
"check:runtime-modules": "node scripts/build-runtime-modules.mjs --check",
|
|
53
53
|
"test:packed-package": "node scripts/test-packed-runner.mjs",
|
|
54
|
+
"perf:render-cache": "node scripts/render-cache-performance.mjs",
|
|
54
55
|
"prepack": "pnpm test && pnpm run check:runtime-modules && node scripts/verify-package-files.mjs",
|
|
55
56
|
"prepublishOnly": "pnpm test && pnpm run check:runtime-modules && node scripts/verify-package-files.mjs && pnpm run test:packed-package",
|
|
56
57
|
"typecheck": "node scripts/check-types.mjs"
|
|
@@ -383,7 +383,7 @@ function binaryIdentity(path ) {
|
|
|
383
383
|
return [details.dev, details.ino, details.size, details.mtimeNs, details.ctimeNs].join(":");
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
function binaryDigest(path , readBinary
|
|
386
|
+
export function binaryDigest(path , readBinary = readFileSync) {
|
|
387
387
|
let entries = binaryDigestCache.get(readBinary);
|
|
388
388
|
if (entries === undefined) binaryDigestCache.set(readBinary, entries = new Map());
|
|
389
389
|
const identity = binaryIdentity(path);
|
|
@@ -267,8 +267,8 @@ export function bundledPi(install , input
|
|
|
267
267
|
// given explicitly, and its npm through the home's npmCommand setting), plus
|
|
268
268
|
// only no Pi override, subagents on the same node and Pi (the subagent runner
|
|
269
269
|
// splits GENTLE_PI_AGENTS_PI on whitespace, so a spaced path is left to its
|
|
270
|
-
// default, the running node and cli.js), and no Pi update check, since
|
|
271
|
-
//
|
|
270
|
+
// default, the running node and cli.js), and no separate Pi update check, since
|
|
271
|
+
// Shell handles Pi updates. S9: the prefix (GENTLE_SHELL_PREFIX, from
|
|
272
272
|
// which gentle-pi derives its config folder and gives its own gentle-ai runs
|
|
273
273
|
// Gentle AI's variables, never set here because the agent's shell would pass
|
|
274
274
|
// them to a gentle-ai the user runs), and the published Engram as
|
|
@@ -276,7 +276,7 @@ export function bundledPi(install , input
|
|
|
276
276
|
// (S2, S6): the startup policy, and ENGRAM_BIN is the Shell-owned guard, so no
|
|
277
277
|
// provider, whatever loaded it, runs an Engram binary against a store; allowed
|
|
278
278
|
// memory reaches the shared server through ENGRAM_URL only.
|
|
279
|
-
export const ENGRAM_COMPANION_SOURCE = "npm:gentle-engram
|
|
279
|
+
export const ENGRAM_COMPANION_SOURCE = "npm:gentle-engram";
|
|
280
280
|
export const ENGRAM_RECOVERY_NOTICE = "Engram memory disabled: Shell could not verify safe server reuse. Matching versions or updating alone do not prove compatibility. Reuse requires a server on 127.0.0.1:7437 with verified /compatibility evidence; Shell never stops or replaces a server already listening there. Back up existing Engram data before manual changes; do not delete it or bypass the safety check. Shell rechecks on every launch and remains usable without memory.";
|
|
281
281
|
export const ENGRAM_START_FAILED_NOTICE = "Engram memory disabled for this launch: Shell could not start the shared Engram server, or it did not report ready in time. Restart Shell to retry; if another program holds 127.0.0.1:7437, stop it first. Shell remains usable without memory.";
|
|
282
282
|
export const ENGRAM_NEWER_SCHEMA_NOTICE = "Engram memory disabled: ~/.engram was migrated by a newer Engram than Shell's bundled core, so Shell will not start a server on it. Start that newer Engram's server yourself (engram serve); Shell reuses a running server with verified /compatibility evidence. Back up the store; do not delete or downgrade it. Shell remains usable without memory.";
|
|
@@ -614,29 +614,16 @@ export function bundledUpdatePlan(passthrough ) {
|
|
|
614
614
|
return { self: true, ...marked };
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
-
// nothing left for Pi it exits with that code; otherwise Pi still runs, so
|
|
620
|
-
// `update --all` updates the extensions even when that step could not complete.
|
|
617
|
+
// Forward extension updates even when the latest Pi update failed; the caller
|
|
618
|
+
// retains that failure code while Pi handles the remaining arguments.
|
|
621
619
|
export function bundledUpdateNext(plan , upgradeCode ) {
|
|
622
620
|
if (plan.piArgs === undefined) return { exitCode: upgradeCode ?? 0 };
|
|
623
621
|
if (plan.self && upgradeCode !== undefined && upgradeCode !== 0) {
|
|
624
|
-
|
|
625
|
-
return { piArgs: plan.piArgs, note: `gentle-shell: the ${step} did not complete; updating the extensions anyway.` };
|
|
622
|
+
return { piArgs: plan.piArgs, note: "gentle-shell: the latest Pi update did not complete; updating the extensions anyway." };
|
|
626
623
|
}
|
|
627
624
|
return { piArgs: plan.piArgs };
|
|
628
625
|
}
|
|
629
626
|
|
|
630
|
-
export function bundledUpdateNotice(input ) {
|
|
631
|
-
return [
|
|
632
|
-
`Pi ships pinned with Gentle Shell (Pi ${input.piVersion}): a newer Pi arrives with a Gentle Shell release.`,
|
|
633
|
-
input.interactive
|
|
634
|
-
? "Running 'gentle-shell upgrade'..."
|
|
635
|
-
: "Run 'gentle-shell upgrade' to install the latest Gentle Shell release and its Pi.",
|
|
636
|
-
"Run 'gentle-shell update --latest' to install the newest published Pi now, without the release's verified lockfile.",
|
|
637
|
-
];
|
|
638
|
-
}
|
|
639
|
-
|
|
640
627
|
|
|
641
628
|
|
|
642
629
|
export const BUNDLED_UPGRADE_USAGE = "usage: gentle-shell upgrade [--channel release] | gentle-shell upgrade --rollback";
|
|
@@ -223,6 +223,32 @@ export function userPiHome(env , homedir
|
|
|
223
223
|
return env[USER_PI_HOME_ENV] || linkDir(env, homedir);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
// Nobody can see or type into an editor git opens from Pi's bash tool, so
|
|
227
|
+
// `git rebase --continue` or a bare `git commit` would wait on it forever.
|
|
228
|
+
// `true` makes git keep the prepared message (or abort an empty one) instead.
|
|
229
|
+
// A value the user already set is kept; on Windows env names ignore case, so a
|
|
230
|
+
// user's `git_editor` counts too.
|
|
231
|
+
export const NON_INTERACTIVE_GIT_ENV = { GIT_EDITOR: "true", GIT_SEQUENCE_EDITOR: "true" } ;
|
|
232
|
+
|
|
233
|
+
export function nonInteractiveGitEnv(env , platform = process.platform) {
|
|
234
|
+
const isSet = (key ) => platform === "win32"
|
|
235
|
+
? Object.entries(env).some(([name, value]) => value !== undefined && name.toUpperCase() === key)
|
|
236
|
+
: env[key] !== undefined;
|
|
237
|
+
return Object.fromEntries(Object.entries(NON_INTERACTIVE_GIT_ENV).filter(([key]) => !isSet(key)));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// On Windows, Node keeps only the first of a set of case variants (in sorted
|
|
241
|
+
// order) and then skips it if it is undefined, so `{ GIT_EDITOR: undefined,
|
|
242
|
+
// git_editor: "vim" }` would reach the child with neither. Drop the undefined
|
|
243
|
+
// variants so the defined one is what gets spawned.
|
|
244
|
+
export function dropUndefinedCaseVariants(env , platform = process.platform) {
|
|
245
|
+
if (platform !== "win32") return;
|
|
246
|
+
const defined = new Set(Object.entries(env).filter(([, value]) => value !== undefined).map(([name]) => name.toUpperCase()));
|
|
247
|
+
for (const [name, value] of Object.entries(env)) {
|
|
248
|
+
if (value === undefined && defined.has(name.toUpperCase())) delete env[name];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
226
252
|
export function isolatedDir(env , homedir ) {
|
|
227
253
|
return env.GENTLE_SHELL_HOME || join(homedir, ".gentle-shell", "agent");
|
|
228
254
|
}
|
|
@@ -463,13 +489,18 @@ export function recordProvisioned(config , homeDir , pi
|
|
|
463
489
|
|
|
464
490
|
|
|
465
491
|
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
466
497
|
|
|
467
498
|
export function resolvePiRuntime(deps ) {
|
|
468
499
|
const envOverride = deps.env.GENTLE_SHELL_PI;
|
|
469
500
|
if (envOverride !== undefined && envOverride.length > 0) return { kind: "env", command: envOverride, args: [] };
|
|
470
501
|
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
502
|
+
const bundledCli = deps.resolveBundledCli();
|
|
503
|
+
if (bundledCli !== undefined) return { kind: "bundled", command: deps.nodeExecPath, args: [bundledCli.path], version: bundledCli.version };
|
|
473
504
|
|
|
474
505
|
const onPath = deps.findOnPath("pi");
|
|
475
506
|
if (onPath !== undefined) return { kind: "path", command: onPath, args: [] };
|
|
@@ -1004,6 +1035,8 @@ export function discoverLooseExtensionEntries(dir , fs )
|
|
|
1004
1035
|
|
|
1005
1036
|
|
|
1006
1037
|
|
|
1038
|
+
|
|
1039
|
+
|
|
1007
1040
|
|
|
1008
1041
|
|
|
1009
1042
|
|
|
@@ -1086,6 +1119,7 @@ export function buildPiInvocation(input ) {
|
|
|
1086
1119
|
|
|
1087
1120
|
const env = {
|
|
1088
1121
|
...input.baseEnv,
|
|
1122
|
+
...nonInteractiveGitEnv(input.baseEnv, input.platform),
|
|
1089
1123
|
PI_CODING_AGENT_DIR: input.home.dir,
|
|
1090
1124
|
PI_PROGRAM_STATUS_APP: "gentle-shell",
|
|
1091
1125
|
GENTLE_PI_AGENT_HOME: input.home.dir,
|
|
@@ -1099,6 +1133,7 @@ export function buildPiInvocation(input ) {
|
|
|
1099
1133
|
else env[GENTLE_SHELL_CONFIG_HOME_ENV] = configHome;
|
|
1100
1134
|
if (childInjection === undefined) delete env[CHILD_PACKAGE_INJECTION_ENV];
|
|
1101
1135
|
else env[CHILD_PACKAGE_INJECTION_ENV] = encodeChildPackageInjection(childInjection);
|
|
1136
|
+
dropUndefinedCaseVariants(env, input.platform);
|
|
1102
1137
|
|
|
1103
1138
|
return { command: input.runtime.command, args, env };
|
|
1104
1139
|
}
|
|
@@ -1353,11 +1388,11 @@ export function helpText() {
|
|
|
1353
1388
|
" gentle-shell install npm:<pkg> Run pi's own 'install' against the resolved home.",
|
|
1354
1389
|
" gentle-shell remove <source> Run pi's own 'remove' against the resolved home.",
|
|
1355
1390
|
" gentle-shell list Run pi's own 'list' against the resolved home.",
|
|
1356
|
-
" gentle-shell update [target]
|
|
1357
|
-
" In a bundled install
|
|
1358
|
-
"
|
|
1359
|
-
"
|
|
1360
|
-
"
|
|
1391
|
+
" gentle-shell update [target] Update Pi through its supported owner, or packages in the resolved home.",
|
|
1392
|
+
" In a bundled install 'update' installs the newest stable Pi",
|
|
1393
|
+
" without the release's verified lockfile; --latest is an alias.",
|
|
1394
|
+
" --all also updates extensions; explicit package pins remain pinned.",
|
|
1395
|
+
" --force is not supported for managed Pi self updates.",
|
|
1361
1396
|
" gentle-shell config Run pi's own 'config' against the resolved home.",
|
|
1362
1397
|
" gentle-shell auth <command> Run pi's own 'auth' against the resolved home.",
|
|
1363
1398
|
" gentle-shell mcp <command> Run pi's own 'mcp' (add, list, login, logout) against the",
|
|
@@ -4,12 +4,13 @@ import { chmod, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { dirname, isAbsolute, join, posix, win32 } from "node:path";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
|
-
import { gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.mjs";
|
|
7
|
+
import { binaryDigest, gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.mjs";
|
|
8
8
|
import { GENTLE_PI_REVIEW_RELAY_CONTRACT, GENTLE_PI_REVIEW_RELAY_CONTRACT_ENV } from "./review-relay-contract.mjs";
|
|
9
9
|
import { decodeReviewAssessmentV1, } from "./review-risk-assessment.mjs";
|
|
10
10
|
import {
|
|
11
11
|
REVIEW_INTEGRATION_CONTRACT,
|
|
12
12
|
decodeReviewAcknowledgedV1,
|
|
13
|
+
decodeReviewCapabilitiesV2,
|
|
13
14
|
decodeReviewConsentV2,
|
|
14
15
|
decodeReviewConsentV3,
|
|
15
16
|
decodeReviewFailureV2,
|
|
@@ -166,6 +167,9 @@ export const NATIVE_REVIEW_MODE_SCOPE = {
|
|
|
166
167
|
|
|
167
168
|
|
|
168
169
|
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
169
173
|
// Read-only risk assessment request (gentle-pi#662). `baseRef` requires
|
|
170
174
|
// explicit `committedOnly` acknowledgement, exactly like Native START's
|
|
171
175
|
// baseRef/committedOnly pairing, because both select a committed range
|
|
@@ -539,6 +543,19 @@ export const NATIVE_UNTRACKED_SCOPE = {
|
|
|
539
543
|
|
|
540
544
|
|
|
541
545
|
|
|
546
|
+
/** Explicit request file; native owns reading, freezing, sizing and identity. */
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
export const NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE = "provider does not support request context";
|
|
552
|
+
|
|
553
|
+
function nativeRequestContextArguments(request ) {
|
|
554
|
+
if (request.requestContextPath === undefined) return [];
|
|
555
|
+
if (!isCanonicalProcessString(request.requestContextPath)) throw new TypeError("Native requestContextPath must be a non-empty, trimmed, NUL-free string");
|
|
556
|
+
return ["--request-context", request.requestContextPath];
|
|
557
|
+
}
|
|
558
|
+
|
|
542
559
|
|
|
543
560
|
|
|
544
561
|
|
|
@@ -1099,6 +1116,13 @@ export const NATIVE_CLI_CONTRACTS = Object.freeze({
|
|
|
1099
1116
|
// The v4.3.0 tag has no release and is never pinned.
|
|
1100
1117
|
// No new negotiated capability identity is asserted.
|
|
1101
1118
|
"4.3.1": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1119
|
+
// v4.4.0 repeats 4.3.1: the published binary still advertises
|
|
1120
|
+
// capabilities/v2.6 under review-integration/v2 with the same capabilities
|
|
1121
|
+
// payload apart from build identity, and the provider contract stays at
|
|
1122
|
+
// 1.4.0, with published tarball SHA-256
|
|
1123
|
+
// 58450471280aeb357443d6a28c819132d8c8eb78dd25b12bac64296b2f8c27c2.
|
|
1124
|
+
// No new negotiated capability identity is asserted.
|
|
1125
|
+
"4.4.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1102
1126
|
});
|
|
1103
1127
|
|
|
1104
1128
|
|
|
@@ -1477,6 +1501,16 @@ function decodeNativeReviewStatus(value ) {
|
|
|
1477
1501
|
raw: body,
|
|
1478
1502
|
};
|
|
1479
1503
|
}
|
|
1504
|
+
function nativeReviewModeScopeArguments(operation , scope ) {
|
|
1505
|
+
if (scope !== undefined && scope !== NATIVE_REVIEW_MODE_SCOPE.CLONE && scope !== NATIVE_REVIEW_MODE_SCOPE.GLOBAL) {
|
|
1506
|
+
throw new TypeError("Native review mode scope must be clone or global");
|
|
1507
|
+
}
|
|
1508
|
+
if (scope !== undefined && operation !== NATIVE_REVIEW_MODE_OPERATION.ENABLE && operation !== NATIVE_REVIEW_MODE_OPERATION.DISABLE) {
|
|
1509
|
+
throw new TypeError("Native review mode scope is only valid for enable or disable");
|
|
1510
|
+
}
|
|
1511
|
+
return operation === NATIVE_REVIEW_MODE_OPERATION.STATUS ? [] : ["--scope", scope ?? NATIVE_REVIEW_MODE_SCOPE.CLONE];
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1480
1514
|
function isWindowsRepositoryPath(value ) { return /^[A-Za-z]:[\\/]/.test(value) || /^\\\\/.test(value); }
|
|
1481
1515
|
export function normalizeNativeReviewCwd(value , platform = process.platform) {
|
|
1482
1516
|
if (platform !== "win32") return value;
|
|
@@ -1668,22 +1702,21 @@ class NativeReviewPlainCli {
|
|
|
1668
1702
|
return status;
|
|
1669
1703
|
}
|
|
1670
1704
|
|
|
1671
|
-
//
|
|
1672
|
-
//
|
|
1673
|
-
// exact fixed argv per the design's data flow); `enable`/`disable` mutate
|
|
1674
|
-
// and always pass `--scope clone` so Pi's own kill-switch command surface
|
|
1675
|
-
// never mutates the operator's global gentle-ai state across other clones.
|
|
1705
|
+
// Status stays read-only; mutation defaults to clone unless the caller
|
|
1706
|
+
// explicitly supplies global. Validate scope before cwd or process access.
|
|
1676
1707
|
async reviewMode(request ) {
|
|
1708
|
+
const operation = request.operation;
|
|
1709
|
+
const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
|
|
1677
1710
|
const cwd = await canonicalNativeReviewCwd(request.cwd);
|
|
1678
|
-
const mutating =
|
|
1711
|
+
const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
|
|
1679
1712
|
const { body } = await this.execute(
|
|
1680
1713
|
NATIVE_REVIEW_OPERATION.MODE,
|
|
1681
1714
|
cwd,
|
|
1682
|
-
["review", "mode",
|
|
1715
|
+
["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
|
|
1683
1716
|
mutating,
|
|
1684
1717
|
request.signal,
|
|
1685
1718
|
);
|
|
1686
|
-
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body,
|
|
1719
|
+
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body, operation));
|
|
1687
1720
|
}
|
|
1688
1721
|
|
|
1689
1722
|
async reclaim(request ) {
|
|
@@ -1929,12 +1962,14 @@ export class NativeReviewIntegrationError extends Error {
|
|
|
1929
1962
|
// answer only through one of the exact invocations carried by the envelope.
|
|
1930
1963
|
export class NativeReviewConsentRequiredError extends Error {
|
|
1931
1964
|
consent ;
|
|
1965
|
+
requestContextPath ;
|
|
1932
1966
|
launchAttempted = true;
|
|
1933
1967
|
mutationOutcome = "none";
|
|
1934
|
-
constructor(consent ) {
|
|
1968
|
+
constructor(consent , requestContextPath ) {
|
|
1935
1969
|
super(consent.headline);
|
|
1936
1970
|
this.name = "NativeReviewConsentRequiredError";
|
|
1937
1971
|
this.consent = consent;
|
|
1972
|
+
this.requestContextPath = requestContextPath;
|
|
1938
1973
|
}
|
|
1939
1974
|
}
|
|
1940
1975
|
|
|
@@ -2065,6 +2100,10 @@ function consentInvocationArguments(request )
|
|
|
2065
2100
|
const words = splitNativeConsentInvocation(choice.invocation);
|
|
2066
2101
|
if (words[0] !== "gentle-ai" || words[1] !== "review" || words[2] !== "start") throw new NativeReviewConsentBindingError("consent-invocation-not-start", "Native consent invocation is not a provider review START");
|
|
2067
2102
|
const arguments_ = words.slice(1);
|
|
2103
|
+
if (request.requestContextPath !== undefined) {
|
|
2104
|
+
const values = arguments_.flatMap((token, index) => token === "--request-context" ? [arguments_[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
|
|
2105
|
+
if (values.length !== 1 || values[0] !== request.requestContextPath) throw new NativeReviewConsentBindingError("consent-invocation-request-context-changed", "Native consent invocation did not retain the requested context file");
|
|
2106
|
+
}
|
|
2068
2107
|
if (exactConsentOption(arguments_, "--contract") !== REVIEW_INTEGRATION_CONTRACT) throw new NativeReviewConsentBindingError("consent-invocation-contract-changed", "Native consent invocation contract changed");
|
|
2069
2108
|
const providerCwd = exactConsentOption(arguments_, "--cwd");
|
|
2070
2109
|
const requestedCwd = normalizeNativeReviewCwd(request.cwd);
|
|
@@ -2166,6 +2205,8 @@ function decodeNativeUnachievableLensCaptureArtifact(value )
|
|
|
2166
2205
|
}
|
|
2167
2206
|
|
|
2168
2207
|
export class NativeReviewCliV216 {
|
|
2208
|
+
// Only executable capabilities are reusable. STATUS and authority remain fresh.
|
|
2209
|
+
contextCapabilities ;
|
|
2169
2210
|
plain ;
|
|
2170
2211
|
adapter ;
|
|
2171
2212
|
executable ;
|
|
@@ -2268,6 +2309,7 @@ export class NativeReviewCliV216 {
|
|
|
2268
2309
|
const selection = nativeUntrackedSelection(request);
|
|
2269
2310
|
const statusRequest = {
|
|
2270
2311
|
cwd: request.cwd,
|
|
2312
|
+
...(request.requestContextPath === undefined ? {} : { requestContextPath: request.requestContextPath }),
|
|
2271
2313
|
projection,
|
|
2272
2314
|
...(request.baseRef === undefined ? {} : { baseRef: request.baseRef, committedOnly: true }),
|
|
2273
2315
|
...(request.lineageId === undefined ? {} : { lineageId: request.lineageId }),
|
|
@@ -2301,6 +2343,10 @@ export class NativeReviewCliV216 {
|
|
|
2301
2343
|
return argument.token;
|
|
2302
2344
|
});
|
|
2303
2345
|
const targetIdentity = status.targetIdentity;
|
|
2346
|
+
if (request.requestContextPath !== undefined) {
|
|
2347
|
+
const values = transitionTokens.flatMap((token, index) => token === "--request-context" ? [transitionTokens[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
|
|
2348
|
+
if (values.length !== 1 || values[0] !== request.requestContextPath) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, false, "native START transition did not retain the requested context file", undefined, false);
|
|
2349
|
+
}
|
|
2304
2350
|
const execution = await this.negotiated(NATIVE_REVIEW_OPERATION.START, request.cwd, ["review", "start", ...transitionTokens], true, request.signal);
|
|
2305
2351
|
// A negotiated v2 START may answer a consent question (action:
|
|
2306
2352
|
// "consent_required") instead of `start/v3` when the provider needs an
|
|
@@ -2318,7 +2364,10 @@ export class NativeReviewCliV216 {
|
|
|
2318
2364
|
return decoded;
|
|
2319
2365
|
});
|
|
2320
2366
|
if (consent.targetIdentity !== targetIdentity || consent.projection !== projection) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native consent target binding mismatch");
|
|
2321
|
-
|
|
2367
|
+
if (request.requestContextPath !== undefined) {
|
|
2368
|
+
for (const choice of consent.choices) consentInvocationArguments({ cwd: request.cwd, consent, answer: choice.answer, requestContextPath: request.requestContextPath });
|
|
2369
|
+
}
|
|
2370
|
+
throw new NativeReviewConsentRequiredError(consent, request.requestContextPath);
|
|
2322
2371
|
}
|
|
2323
2372
|
const result = decode(NATIVE_REVIEW_OPERATION.START, true, () => decodeReviewStartResponse(execution.body));
|
|
2324
2373
|
if (request.lineageId !== undefined && result.lineageId !== request.lineageId) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native start lineage mismatch");
|
|
@@ -2388,6 +2437,9 @@ export class NativeReviewCliV216 {
|
|
|
2388
2437
|
}
|
|
2389
2438
|
|
|
2390
2439
|
async observedTargetStatus(request ) {
|
|
2440
|
+
// Validate locally before discovery; never probe support by sending an
|
|
2441
|
+
// unknown flag or retrying the review without its requested intent.
|
|
2442
|
+
const requestContextArguments = nativeRequestContextArguments(request);
|
|
2391
2443
|
if (request.baseRef !== undefined && !isCanonicalProcessString(request.baseRef)) throw new TypeError("Native STATUS baseRef must be a non-empty, trimmed, NUL-free string");
|
|
2392
2444
|
if (request.baseRef !== undefined && request.committedOnly !== true) throw new TypeError("Native STATUS baseRef requires explicit committedOnly acknowledgement");
|
|
2393
2445
|
if (request.baseRef === undefined && request.committedOnly !== undefined) throw new TypeError("Native STATUS committedOnly requires an explicit baseRef");
|
|
@@ -2423,6 +2475,26 @@ export class NativeReviewCliV216 {
|
|
|
2423
2475
|
...(submittedHasCommittedOnly ? [] : ["--committed-only"]),
|
|
2424
2476
|
];
|
|
2425
2477
|
const forwardedLineage = request.lineageId === undefined || submittedLineageValue !== undefined ? [] : ["--lineage", request.lineageId];
|
|
2478
|
+
let contextExecutable ;
|
|
2479
|
+
if (requestContextArguments.length > 0) {
|
|
2480
|
+
contextExecutable = this.executablePath(NATIVE_REVIEW_OPERATION.STATUS, false);
|
|
2481
|
+
const digest = binaryDigest(contextExecutable);
|
|
2482
|
+
let capabilities = this.contextCapabilities?.executable === contextExecutable && this.contextCapabilities.digest === digest
|
|
2483
|
+
? this.contextCapabilities.value : undefined;
|
|
2484
|
+
if (capabilities === undefined) {
|
|
2485
|
+
this.contextCapabilities = undefined;
|
|
2486
|
+
const discovery = await this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd,
|
|
2487
|
+
["review", "capabilities", "--contract", REVIEW_INTEGRATION_CONTRACT], false, request.signal, contextExecutable);
|
|
2488
|
+
capabilities = decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewCapabilitiesV2(discovery.body, digest));
|
|
2489
|
+
if (binaryDigest(contextExecutable) !== digest) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH,
|
|
2490
|
+
NATIVE_REVIEW_OPERATION.STATUS, false, "native executable changed during capability discovery", undefined, false);
|
|
2491
|
+
this.contextCapabilities = { executable: contextExecutable, digest, value: capabilities };
|
|
2492
|
+
}
|
|
2493
|
+
if (!["start_request_context", "start_options_preflight"].every(feature => capabilities.optionalFeatures.has(feature))) {
|
|
2494
|
+
throw nativeError(NATIVE_REVIEW_ERROR_CODE.VERSION_INCOMPATIBLE, NATIVE_REVIEW_OPERATION.STATUS, false,
|
|
2495
|
+
NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE, undefined, false);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2426
2498
|
const statusArguments = submittedTokens === undefined ? [
|
|
2427
2499
|
"review", "status", "--contract", REVIEW_INTEGRATION_CONTRACT, "--cwd", request.cwd,
|
|
2428
2500
|
"--projection", request.projection ?? "workspace",
|
|
@@ -2431,9 +2503,12 @@ export class NativeReviewCliV216 {
|
|
|
2431
2503
|
...(request.lineageId === undefined ? [] : ["--lineage", request.lineageId]),
|
|
2432
2504
|
...(request.agent === undefined ? [] : ["--agent", request.agent]),
|
|
2433
2505
|
...nativeLensSelectionArguments(request),
|
|
2506
|
+
...requestContextArguments,
|
|
2434
2507
|
"--next-transition",
|
|
2435
|
-
] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request)];
|
|
2436
|
-
const execution =
|
|
2508
|
+
] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request), ...requestContextArguments];
|
|
2509
|
+
const execution = contextExecutable === undefined
|
|
2510
|
+
? await this.negotiated(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments, false, request.signal)
|
|
2511
|
+
: await this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments, false, request.signal, contextExecutable);
|
|
2437
2512
|
measureStatusSync("decode", () => assertSupportedNextTransitionOperation(execution.body));
|
|
2438
2513
|
return decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewStatusV3(execution.body));
|
|
2439
2514
|
}
|
|
@@ -2641,17 +2716,19 @@ export class NativeReviewCliV216 {
|
|
|
2641
2716
|
}
|
|
2642
2717
|
|
|
2643
2718
|
async reviewMode(request ) {
|
|
2719
|
+
const operation = request.operation;
|
|
2720
|
+
const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
|
|
2644
2721
|
const cwd = await canonicalNativeReviewCwd(request.cwd);
|
|
2645
|
-
const mutating =
|
|
2722
|
+
const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
|
|
2646
2723
|
const execution = await this.invoke(
|
|
2647
2724
|
NATIVE_REVIEW_OPERATION.MODE,
|
|
2648
2725
|
cwd,
|
|
2649
|
-
["review", "mode",
|
|
2726
|
+
["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
|
|
2650
2727
|
mutating,
|
|
2651
2728
|
request.signal,
|
|
2652
2729
|
this.executablePath(NATIVE_REVIEW_OPERATION.MODE, mutating),
|
|
2653
2730
|
);
|
|
2654
|
-
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body,
|
|
2731
|
+
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body, operation));
|
|
2655
2732
|
}
|
|
2656
2733
|
|
|
2657
2734
|
// Read-only risk assessment (gentle-ai#4295, gentle-pi#662). Never mutates;
|
|
@@ -218,6 +218,8 @@ const CAPABILITIES_SCHEMA_IDENTITIES
|
|
|
218
218
|
}),
|
|
219
219
|
});
|
|
220
220
|
const OPTIONAL_FEATURE_NAMES = Object.freeze([
|
|
221
|
+
"start_request_context",
|
|
222
|
+
"start_options_preflight",
|
|
221
223
|
"base_ref_workspace_overlay",
|
|
222
224
|
"bounded_process_waits",
|
|
223
225
|
"classified_authority_repair",
|
|
@@ -237,6 +239,8 @@ const OPTIONAL_FEATURE_NAMES = Object.freeze([
|
|
|
237
239
|
"validating_result_reopen",
|
|
238
240
|
] );
|
|
239
241
|
const FEATURE_NAMES = Object.freeze([
|
|
242
|
+
"start_request_context",
|
|
243
|
+
"start_options_preflight",
|
|
240
244
|
"base_ref_workspace_overlay",
|
|
241
245
|
"bounded_process_waits",
|
|
242
246
|
"classified_authority_repair",
|
|
@@ -1600,6 +1604,7 @@ function decodeCorrectionPlanRequestV1(value , label )
|
|
|
1600
1604
|
};
|
|
1601
1605
|
}
|
|
1602
1606
|
|
|
1607
|
+
/** Decode frozen validation evidence, preserving an explicit empty policy and rejecting absence. */
|
|
1603
1608
|
export function decodeReviewTargetedValidationRequestV1(value , label = "targeted_validation_request") {
|
|
1604
1609
|
const body = exactRecord(value, label, [
|
|
1605
1610
|
"schema", "request_hash", "lineage_id", "expected_revision", "target_identity", "fix_finding_ids", "policy_content", "fix_findings", "fix_classifications",
|
|
@@ -1642,7 +1647,8 @@ export function decodeReviewTargetedValidationRequestV1(value , label =
|
|
|
1642
1647
|
expectedRevision: sha256(body.expected_revision, `${label}.expected_revision`),
|
|
1643
1648
|
targetIdentity: sha256(body.target_identity, `${label}.target_identity`),
|
|
1644
1649
|
fixFindingIds,
|
|
1645
|
-
|
|
1650
|
+
// A frozen empty policy is valid; missing historical policy is not.
|
|
1651
|
+
policyContent: text(body.policy_content, `${label}.policy_content`),
|
|
1646
1652
|
fixFindings,
|
|
1647
1653
|
fixClassifications,
|
|
1648
1654
|
projection: enumeration(body.projection, REQUIRED_PROJECTIONS, `${label}.projection`),
|