gentle-pi 4.7.0 → 4.8.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 +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import { fileURLToPath } from "node:url";
|
|
2
4
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
5
|
import { Type } from "typebox";
|
|
4
6
|
import { appendSystemPromptOnce } from "../lib/append-system-prompt.ts";
|
|
7
|
+
import { codemodeReaches, DESIGN_TOOLS_ROUTE, hideBehindCodemode } from "../lib/hidden-tools.ts";
|
|
5
8
|
import type { DesignSessionContent } from "../lib/design-canvas-server.ts";
|
|
6
9
|
import { DESIGN_COMMENTS_TOOL_NAME, DESIGN_HELP, DESIGN_PROMPT_HINT, DESIGN_SKILL_NAME, DESIGN_SYNC_REQUEST, DESIGN_TOOL_NAME, createDesignCanvas, designRunMessage, designUsage, hasSystemBoard, listDesigns, parseDesignArgs, planDesignImplement, runDesignCommentsTool, runDesignTool, sendDesignImplement, type DesignCanvasDeps, type DesignCommentsToolParams, type DesignToolParams } from "../lib/gentle-design.ts";
|
|
10
|
+
import { DESKTOP_DESIGN_SERVICE_CHANNEL, DESKTOP_DESIGN_SERVICE_SCHEMA, type DesktopDesignService } from "../lib/desktop-rpc-design.ts";
|
|
7
11
|
|
|
8
12
|
// Gentle Design: /gentle:design <brief> runs the bundled gentle-design skill,
|
|
9
13
|
// which writes self-contained HTML artboards under design/<slug>/ with
|
|
@@ -29,6 +33,7 @@ const DesignCommentsParams = Type.Object({
|
|
|
29
33
|
slug: Type.Optional(Type.String({ description: "Design slug (directory under design/); required for resolve" })),
|
|
30
34
|
file: Type.Optional(Type.String({ description: "Artboard file within the design, such as 01-calm.html (list only)" })),
|
|
31
35
|
ids: Type.Optional(Type.Array(Type.String(), { maxItems: 500, description: "Comment ids to resolve" })),
|
|
36
|
+
note: Type.Optional(Type.String({ maxLength: 500, description: "resolve only: one line on what you changed, at most 500 characters; shown next to the comment in the canvas" })),
|
|
32
37
|
});
|
|
33
38
|
|
|
34
39
|
const DesignParams = Type.Object({
|
|
@@ -38,6 +43,7 @@ const DesignParams = Type.Object({
|
|
|
38
43
|
status: Type.Optional(Type.Union([Type.Literal("in_progress"), Type.Literal("implemented")], { description: "handoff only: in_progress when you start implementing, implemented when it is done" })),
|
|
39
44
|
note: Type.Optional(Type.String({ maxLength: 1000, description: "handoff only: a short note shown on the canvas" })),
|
|
40
45
|
previewUrl: Type.Optional(Type.String({ maxLength: 2048, description: "handoff only: the running app's loopback URL (http or https on localhost, 127.0.0.1 or [::1], any port), so the canvas can compare it with the artboard" })),
|
|
46
|
+
part: Type.Optional(Type.String({ maxLength: 32, description: "handoff only: the part id from an \"Implement only one part\" message; reports on that part alone, without choosing the artboard" })),
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
export interface GentleDesignDeps extends DesignCanvasDeps {
|
|
@@ -56,7 +62,17 @@ function isIdle(ctx: ExtensionContext | undefined): boolean {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
function isDirectory(path: string): boolean {
|
|
66
|
+
try {
|
|
67
|
+
return statSync(path).isDirectory();
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
export default function gentleDesign(pi: ExtensionAPI, deps: GentleDesignDeps = {}): void {
|
|
74
|
+
// Primary runs only; unknown (no run yet, or a child) keeps the tools declared.
|
|
75
|
+
let withoutDesigns = false;
|
|
60
76
|
const skillPath = deps.skillPath ?? fileURLToPath(new URL("../skills/design/SKILL.md", import.meta.url));
|
|
61
77
|
// Canvas comments arrive between commands; the last command's context answers whether the agent is busy.
|
|
62
78
|
let latest: ExtensionContext | undefined;
|
|
@@ -69,6 +85,50 @@ export default function gentleDesign(pi: ExtensionAPI, deps: GentleDesignDeps =
|
|
|
69
85
|
};
|
|
70
86
|
const canvas = createDesignCanvas(deliver, deps);
|
|
71
87
|
|
|
88
|
+
// Desktop's design slice reaches the canvas only through this versioned,
|
|
89
|
+
// adapter-shaped seam — the design analogue of the YOLO host-ui adapter. It
|
|
90
|
+
// wraps the same single DesignCanvas and listDesigns owner; there is no
|
|
91
|
+
// second server, port, or canvas store. The tokenized URL stays a capability
|
|
92
|
+
// here: it is returned only to an explicitly subscribing observer, and the
|
|
93
|
+
// Desktop bridge re-checks the interactive-host trust before it reaches the
|
|
94
|
+
// wire. Agent-driven canvas work (the gentle_design tool and /gentle:design)
|
|
95
|
+
// emits through the same observers, so a connected Desktop app sees it too.
|
|
96
|
+
pi.events?.on(DESKTOP_DESIGN_SERVICE_CHANNEL, (payload: unknown) => {
|
|
97
|
+
if (!payload || typeof payload !== "object") return;
|
|
98
|
+
const request = payload as Partial<{ context: ExtensionContext; respond(service: DesktopDesignService): void }>;
|
|
99
|
+
if (typeof request.respond !== "function" || !request.context) return;
|
|
100
|
+
const ctx = request.context;
|
|
101
|
+
try {
|
|
102
|
+
let disposed = false;
|
|
103
|
+
const subscriptions = new Set<() => void>();
|
|
104
|
+
request.respond({
|
|
105
|
+
schema: DESKTOP_DESIGN_SERVICE_SCHEMA,
|
|
106
|
+
read: () => (disposed ? Promise.resolve({ running: false, slug: null, connectedClients: 0 }) : canvas.state()),
|
|
107
|
+
url: () => (disposed ? undefined : canvas.url()),
|
|
108
|
+
listDesigns: () => (disposed || typeof ctx.cwd !== "string" ? [] : listDesigns(ctx.cwd)),
|
|
109
|
+
observe: (options, onTransition) => {
|
|
110
|
+
if (disposed) return () => {};
|
|
111
|
+
const unsubscribe = canvas.observe((transition) => {
|
|
112
|
+
const url = options.includeUrl ? canvas.url() : undefined;
|
|
113
|
+
onTransition({ ...transition, ...(url === undefined ? {} : { url }) });
|
|
114
|
+
});
|
|
115
|
+
subscriptions.add(unsubscribe);
|
|
116
|
+
return () => {
|
|
117
|
+
subscriptions.delete(unsubscribe);
|
|
118
|
+
unsubscribe();
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
dispose: () => {
|
|
122
|
+
disposed = true;
|
|
123
|
+
for (const unsubscribe of [...subscriptions]) unsubscribe();
|
|
124
|
+
subscriptions.clear();
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
} catch {
|
|
128
|
+
/* obsolete trusted context: discovery expires closed */
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
72
132
|
const open = async (ctx: ExtensionContext, slug?: string) => {
|
|
73
133
|
const notice = await canvas.open(ctx.cwd, slug);
|
|
74
134
|
ctx.ui.notify(notice.message, notice.level);
|
|
@@ -120,9 +180,10 @@ export default function gentleDesign(pi: ExtensionAPI, deps: GentleDesignDeps =
|
|
|
120
180
|
pi.registerTool({
|
|
121
181
|
name: DESIGN_COMMENTS_TOOL_NAME,
|
|
122
182
|
label: "Design comments",
|
|
123
|
-
description: "List the open canvas comments stored in design/<slug>/comments.json, or mark comments resolved once you have applied them.",
|
|
183
|
+
description: "List the open canvas comments stored in design/<slug>/comments.json, or mark comments resolved once you have applied them, with a one-line note on what you changed (shown on the canvas next to the comment).",
|
|
124
184
|
promptSnippet: "List open gentle-design canvas comments and resolve them after applying them.",
|
|
125
185
|
parameters: DesignCommentsParams,
|
|
186
|
+
prepareLoadout: hideBehindCodemode(DESIGN_COMMENTS_TOOL_NAME, () => withoutDesigns),
|
|
126
187
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
127
188
|
const result = await runDesignCommentsTool(ctx.cwd, params as DesignCommentsToolParams);
|
|
128
189
|
return { content: [{ type: "text" as const, text: result.text }], details: result.details };
|
|
@@ -131,9 +192,10 @@ export default function gentleDesign(pi: ExtensionAPI, deps: GentleDesignDeps =
|
|
|
131
192
|
pi.registerTool({
|
|
132
193
|
name: DESIGN_TOOL_NAME,
|
|
133
194
|
label: "Gentle Design",
|
|
134
|
-
description: "Drive the gentle-design canvas. Call list before designing: it reports the project's design sources and whether design/system.md is missing or older than them (sync first, or offer to sync again). list also gives the designs under design/ (artboards, system board, whether the canvas runs and its URL); open a design on the local canvas (optional slug, default the most recent) or refresh it after writing or changing artboards, returning the URL; stop the canvas; implement one artboard (target <slug>/<artboard>), which returns the handoff instructions to follow and records it as the design's chosen artboard; handoff reports your progress on that artboard (status in_progress when you start, implemented when done, with previewUrl of the running app on localhost, 127.0.0.1 or [::1] when there is one), which the canvas shows live. Write briefs and run the design-system sync by following the gentle-design skill, not this tool.",
|
|
195
|
+
description: "Drive the gentle-design canvas. Call list before designing: it reports the project's design sources and whether design/system.md is missing or older than them (sync first, or offer to sync again). list also gives the designs under design/ (artboards, system board, whether the canvas runs and its URL); open a design on the local canvas (optional slug, default the most recent) or refresh it after writing or changing artboards, returning the URL; stop the canvas; implement one artboard (target <slug>/<artboard>), which returns the handoff instructions to follow and records it as the design's chosen artboard; handoff reports your progress on that artboard (status in_progress when you start, implemented when done, with previewUrl of the running app on localhost, 127.0.0.1 or [::1] when there is one), which the canvas shows live; with part (the id an \"Implement only one part\" message names) it reports on that part alone and chooses nothing. Write briefs and run the design-system sync by following the gentle-design skill, not this tool.",
|
|
135
196
|
promptSnippet: "List gentle-design designs, open or stop their canvas, get an artboard's implementation handoff, and report its progress.",
|
|
136
197
|
parameters: DesignParams,
|
|
198
|
+
prepareLoadout: hideBehindCodemode(DESIGN_TOOL_NAME, () => withoutDesigns),
|
|
137
199
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
138
200
|
// Comments from a canvas the tool opened are queued while this run is busy.
|
|
139
201
|
latest = ctx;
|
|
@@ -144,11 +206,15 @@ export default function gentleDesign(pi: ExtensionAPI, deps: GentleDesignDeps =
|
|
|
144
206
|
// gentle-shell#1485: appendSystemPrompt reaches every provider. Delegated
|
|
145
207
|
// children only run their task, so they never get the default design flow.
|
|
146
208
|
const env = deps.env ?? process.env;
|
|
147
|
-
pi.on("before_agent_start", (event) => {
|
|
209
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
148
210
|
if (env.GENTLE_PI_AGENTS_CHILD === "1") return undefined;
|
|
149
211
|
const options = event.systemPromptOptions;
|
|
150
212
|
const available = options?.skills?.some((skill) => skill.name === DESIGN_SKILL_NAME) || skillLoaded();
|
|
151
213
|
if (available) appendSystemPromptOnce(options, DESIGN_PROMPT_HINT);
|
|
214
|
+
// Set before Pi prepares this run's loadout: without design/ the design
|
|
215
|
+
// tools stay reachable from codemode only, and the prompt says how.
|
|
216
|
+
withoutDesigns = typeof ctx?.cwd === "string" && !isDirectory(join(ctx.cwd, "design"));
|
|
217
|
+
if (withoutDesigns && codemodeReaches(options?.selectedTools) && options?.selectedTools?.includes(DESIGN_TOOL_NAME)) appendSystemPromptOnce(options, DESIGN_TOOLS_ROUTE);
|
|
152
218
|
return undefined;
|
|
153
219
|
});
|
|
154
220
|
pi.on("session_shutdown", async () => {
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
DESKTOP_RPC_COMMAND,
|
|
4
|
+
DESKTOP_RPC_WIDGET,
|
|
5
|
+
DesktopRpcRouter,
|
|
6
|
+
type DesktopRpcDomain,
|
|
7
|
+
type DesktopRpcPublish,
|
|
8
|
+
} from "../lib/desktop-rpc.ts";
|
|
9
|
+
import {
|
|
10
|
+
DESKTOP_CONFIG_EVENTS,
|
|
11
|
+
DESKTOP_CONFIG_METHODS,
|
|
12
|
+
DesktopConfigBridge,
|
|
13
|
+
} from "../lib/desktop-rpc-config.ts";
|
|
14
|
+
import {
|
|
15
|
+
DESKTOP_PERMISSION_EVENT,
|
|
16
|
+
DESKTOP_PERMISSION_METHODS,
|
|
17
|
+
DesktopPermissionBridge,
|
|
18
|
+
} from "../lib/desktop-rpc-permissions.ts";
|
|
19
|
+
import { DESKTOP_USAGE_EVENTS, DESKTOP_USAGE_METHODS } from "../lib/desktop-rpc-usage.ts";
|
|
20
|
+
import { DesktopUsageBridge } from "../lib/desktop-usage-service.ts";
|
|
21
|
+
import { DESKTOP_DESIGN_EVENTS, DESKTOP_DESIGN_METHODS } from "../lib/desktop-rpc-design.ts";
|
|
22
|
+
import { DesktopDesignBridge } from "../lib/desktop-design-service.ts";
|
|
23
|
+
import { DESKTOP_JOBS_EVENTS, DESKTOP_JOBS_METHODS } from "../lib/desktop-rpc-jobs.ts";
|
|
24
|
+
import { DesktopJobsBridge } from "../lib/desktop-jobs-service.ts";
|
|
25
|
+
import { DESKTOP_AGENTS_EVENTS, DESKTOP_AGENTS_METHODS } from "../lib/desktop-rpc-agents.ts";
|
|
26
|
+
import { DesktopAgentsBridge } from "../lib/desktop-agents-service.ts";
|
|
27
|
+
import { DESKTOP_PROFILES_EVENTS, DESKTOP_PROFILES_METHODS, DesktopProfilesBridge } from "../lib/desktop-rpc-profiles.ts";
|
|
28
|
+
import { isInteractiveRpcHost } from "../lib/rpc-host.ts";
|
|
29
|
+
|
|
30
|
+
function publisher(ctx: ExtensionContext): DesktopRpcPublish {
|
|
31
|
+
return (line) => {
|
|
32
|
+
try {
|
|
33
|
+
ctx.ui.setWidget(DESKTOP_RPC_WIDGET, [line]);
|
|
34
|
+
} catch {
|
|
35
|
+
throw new Error("Desktop RPC transport unavailable");
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function desktopRpc(pi: ExtensionAPI) {
|
|
41
|
+
// Permission control always delegates to the existing Gentle AI session owner;
|
|
42
|
+
// config reads and writes delegate to the existing store owners; subscription
|
|
43
|
+
// usage delegates to the existing usage owner; design canvas reads delegate
|
|
44
|
+
// to the existing design owner; background jobs list/cancel delegate to the
|
|
45
|
+
// existing parent-session job registry and monitor controller; subagents
|
|
46
|
+
// list/cancel delegate to the existing parent-session TaskStore and
|
|
47
|
+
// AgentRunner; profile applies delegate to the existing `/gentle:profiles`
|
|
48
|
+
// owner and its own apply actions. None has a store of its own.
|
|
49
|
+
const permissions = new DesktopPermissionBridge(pi);
|
|
50
|
+
const config = new DesktopConfigBridge();
|
|
51
|
+
const usage = new DesktopUsageBridge(pi);
|
|
52
|
+
const design = new DesktopDesignBridge(pi);
|
|
53
|
+
const jobs = new DesktopJobsBridge(pi);
|
|
54
|
+
const agents = new DesktopAgentsBridge(pi);
|
|
55
|
+
const profiles = new DesktopProfilesBridge(pi);
|
|
56
|
+
const domain: DesktopRpcDomain = (method, params) => {
|
|
57
|
+
// Config is the only synchronous bridge; permission, usage, design, jobs,
|
|
58
|
+
// profiles, and agents answers are awaited in fall-through order, so an unknown
|
|
59
|
+
// method still resolves to the router's `unsupported_method` instead of an
|
|
60
|
+
// early `undefined`.
|
|
61
|
+
const configOutcome = config.handle(method, params);
|
|
62
|
+
if (configOutcome !== undefined) return configOutcome;
|
|
63
|
+
return (async () => {
|
|
64
|
+
const permissionOutcome = await permissions.handle(method, params);
|
|
65
|
+
if (permissionOutcome !== undefined) return permissionOutcome;
|
|
66
|
+
const usageOutcome = await usage.handle(method, params);
|
|
67
|
+
if (usageOutcome !== undefined) return usageOutcome;
|
|
68
|
+
const designOutcome = await design.handle(method, params);
|
|
69
|
+
if (designOutcome !== undefined) return designOutcome;
|
|
70
|
+
const jobsOutcome = await jobs.handle(method, params);
|
|
71
|
+
if (jobsOutcome !== undefined) return jobsOutcome;
|
|
72
|
+
const profilesOutcome = await profiles.handle(method, params);
|
|
73
|
+
if (profilesOutcome !== undefined) return profilesOutcome;
|
|
74
|
+
return agents.handle(method, params);
|
|
75
|
+
})();
|
|
76
|
+
};
|
|
77
|
+
const router = new DesktopRpcRouter(
|
|
78
|
+
["capabilities", "get_snapshot", ...DESKTOP_CONFIG_METHODS, ...DESKTOP_PERMISSION_METHODS, ...DESKTOP_USAGE_METHODS, ...DESKTOP_DESIGN_METHODS, ...DESKTOP_JOBS_METHODS, ...DESKTOP_PROFILES_METHODS, ...DESKTOP_AGENTS_METHODS],
|
|
79
|
+
[...DESKTOP_CONFIG_EVENTS, DESKTOP_PERMISSION_EVENT, ...DESKTOP_USAGE_EVENTS, ...DESKTOP_DESIGN_EVENTS, ...DESKTOP_JOBS_EVENTS, ...DESKTOP_PROFILES_EVENTS, ...DESKTOP_AGENTS_EVENTS],
|
|
80
|
+
() => config.snapshotState(),
|
|
81
|
+
domain,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
pi.on("session_start", (_event, ctx) => {
|
|
85
|
+
permissions.reset();
|
|
86
|
+
config.reset();
|
|
87
|
+
usage.reset();
|
|
88
|
+
design.reset();
|
|
89
|
+
jobs.reset();
|
|
90
|
+
profiles.reset();
|
|
91
|
+
agents.reset();
|
|
92
|
+
router.stop();
|
|
93
|
+
if (!isInteractiveRpcHost(ctx.mode)) return;
|
|
94
|
+
design.attach(ctx);
|
|
95
|
+
jobs.attach(ctx);
|
|
96
|
+
agents.attach(ctx);
|
|
97
|
+
router.start(publisher(ctx));
|
|
98
|
+
// Header-driven usage snapshots (Claude's 5h/7d windows, Codex SSE
|
|
99
|
+
// headers) become ordered `rate_limit` events through the router.
|
|
100
|
+
usage.wire((event, data) => router.emit(event, data));
|
|
101
|
+
// Agent-driven canvas transitions become ordered `design_canvas` events;
|
|
102
|
+
// subscribe eagerly so canvas work that happens before any Desktop
|
|
103
|
+
// request still reaches the app.
|
|
104
|
+
design.wire((event, data) => router.emit(event, data));
|
|
105
|
+
void design.start();
|
|
106
|
+
// Agent-driven background-job registry changes become ordered `jobs_update`
|
|
107
|
+
// events; subscribe eagerly so a job started or stopped before any Desktop
|
|
108
|
+
// request still reaches the app.
|
|
109
|
+
jobs.wire((event, data) => router.emit(event, data));
|
|
110
|
+
void jobs.start();
|
|
111
|
+
// Agent-driven TaskStore transitions become ordered `agents_update` events;
|
|
112
|
+
// subscribe eagerly so a subagent started or settled before any Desktop
|
|
113
|
+
// request still reaches the app.
|
|
114
|
+
agents.wire((event, data) => router.emit(event, data));
|
|
115
|
+
void agents.start();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
pi.on("session_shutdown", () => {
|
|
119
|
+
permissions.reset();
|
|
120
|
+
config.reset();
|
|
121
|
+
usage.reset();
|
|
122
|
+
design.reset();
|
|
123
|
+
jobs.reset();
|
|
124
|
+
profiles.reset();
|
|
125
|
+
agents.reset();
|
|
126
|
+
router.stop();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
pi.registerCommand(DESKTOP_RPC_COMMAND, {
|
|
130
|
+
description: "Handle a versioned Gentle Desktop RPC request",
|
|
131
|
+
async handler(args, ctx) {
|
|
132
|
+
if (!isInteractiveRpcHost(ctx.mode)) return;
|
|
133
|
+
permissions.attach(ctx);
|
|
134
|
+
config.attach(ctx);
|
|
135
|
+
usage.attach(ctx);
|
|
136
|
+
design.attach(ctx);
|
|
137
|
+
jobs.attach(ctx);
|
|
138
|
+
profiles.attach(ctx);
|
|
139
|
+
agents.attach(ctx);
|
|
140
|
+
await router.handle(args);
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
|
|
|
2
2
|
import type { TUI } from "@earendil-works/pi-tui";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { appendSystemPromptOnce } from "../lib/append-system-prompt.ts";
|
|
5
|
+
import { codemodeReaches, GUIDE_TOOL_ROUTE, hideBehindCodemode } from "../lib/hidden-tools.ts";
|
|
5
6
|
import { guidePlacement, GuidePopover, guideStepText, guideSteps, GuideTour, type GuideMode, type GuideResult } from "../lib/gentle-guide.ts";
|
|
6
7
|
import { sidebarState } from "../lib/shell-sidebar.ts";
|
|
7
8
|
|
|
@@ -135,6 +136,7 @@ export default function gentleGuide(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
135
136
|
description: "Drive the /gentle:guide tour of Gentle Shell: start shows the first step as a popover beside the part of the screen it describes and returns its text to explain; next, previous and show (with a step id) move; end closes the popover. Show one step per turn and let the user ask questions between steps.",
|
|
136
137
|
promptSnippet: "Show the Gentle Shell guided tour one step at a time and explain each step.",
|
|
137
138
|
parameters: GuideParams,
|
|
139
|
+
prepareLoadout: hideBehindCodemode(GUIDE_TOOL_NAME),
|
|
138
140
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
139
141
|
const { action, step } = params as GuideParamsValue;
|
|
140
142
|
const text = (value: string) => ({ content: [{ type: "text" as const, text: value }], details: {} });
|
|
@@ -165,6 +167,7 @@ export default function gentleGuide(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
165
167
|
|
|
166
168
|
pi.on("before_agent_start", (event) => {
|
|
167
169
|
appendSystemPromptOnce(event.systemPromptOptions, GUIDE_PROMPT_HINT);
|
|
170
|
+
if (codemodeReaches(event.systemPromptOptions?.selectedTools) && event.systemPromptOptions?.selectedTools?.includes(GUIDE_TOOL_NAME)) appendSystemPromptOnce(event.systemPromptOptions, GUIDE_TOOL_ROUTE);
|
|
168
171
|
return undefined;
|
|
169
172
|
});
|
|
170
173
|
pi.on("session_shutdown", () => {
|
|
@@ -39,14 +39,13 @@ import { applyVisualPreset, CHROME_SURFACE, DEFAULT_VISUAL_SETTINGS, DENSITY, HE
|
|
|
39
39
|
import { BANNER_COLORS, DEFAULT_BANNER_CONFIG, readBannerConfig, readBannerConfigForEdit, writeBannerConfig } from "./startup-banner.ts";
|
|
40
40
|
import { commandKeymapId, commandKeymapIds, effectiveKey, keymapCommand, keymapLabel, keymapSavedNotice, loadKeymaps, prepareKeymapChange, writeKeymaps, type KeymapBindings, type PiKeybindings } from "../lib/keymaps.ts";
|
|
41
41
|
import { GentleAiDevBinaryOverrideError, resolveGentleAiDevBinaryOverride } from "../lib/gentle-ai-binary.ts";
|
|
42
|
-
import { DOUBLE_ESC_CANCEL_HINT, floatPromptRow, framePromptLines, panelPromptRow, resolvePromptLayout, IDLE_ESC_CLEAR_HINT, PANEL_BUTTON, PROMPT_HINT, PROMPT_STATE, SHELL_PULSE_WATCHDOG_MS, withPromptHint, type PromptState } from "../lib/shell-prompt.ts";
|
|
42
|
+
import { DOUBLE_ESC_CANCEL_HINT, floatPromptRow, framePromptLines, panelPromptRow, resolvePromptLayout, IDLE_ESC_CLEAR_HINT, PANEL_BUTTON, PROMPT_HINT, PROMPT_STATE, SHELL_PULSE_MS, SHELL_PULSE_WATCHDOG_MS, withPromptHint, workingTick, type PromptState } from "../lib/shell-prompt.ts";
|
|
43
43
|
import { stripAnsi } from "../lib/terminal-theme.ts";
|
|
44
44
|
import { oddPhaseRegistry } from "../lib/odd-phase.ts";
|
|
45
45
|
import { CLAUDE_BRIDGE_PROVIDER, priceBridgeMessage } from "../lib/bridge-cost.ts";
|
|
46
46
|
import { inferOddPhase } from "../lib/odd-phase-inference.ts";
|
|
47
47
|
import { isInteractiveMode } from "../lib/rpc-host.ts";
|
|
48
48
|
import { gentlePiConfigHome } from "../lib/agent-home.ts";
|
|
49
|
-
import { isNanAdaptiveReasoningModel } from "../lib/nan-provider.ts";
|
|
50
49
|
import { resolveAnimationPolicy, writeAnimationPolicy, type AnimationPolicy } from "../lib/animation-policy.ts";
|
|
51
50
|
import { resolveVimPolicy, writeVimPolicy, type VimPolicy } from "../lib/vim-policy.ts";
|
|
52
51
|
import { resolveHistoryCapture, writeHistoryCapturePolicy } from "../lib/history-capture-policy.ts";
|
|
@@ -130,6 +129,15 @@ import {
|
|
|
130
129
|
type DoubleEscCancelResolution,
|
|
131
130
|
} from "../lib/double-esc-cancel-policy.ts";
|
|
132
131
|
import { accountIdFromToken, CODEX_PROVIDER, CODEX_USAGE_URL, NAN_PROVIDER, NAN_QUOTA_URL, parseCodexUsage, parseNanQuota, parseProviderUsage, parseUsageHeaders, parseUsageSource, usageScopeProviders, UsageSourceRegistry, UsageStore, USAGE_SOURCE_EVENT, type ProviderUsage, type UsageSource } from "../lib/shell-usage.ts";
|
|
132
|
+
import {
|
|
133
|
+
DESKTOP_USAGE_SERVICE_CHANNEL,
|
|
134
|
+
DESKTOP_USAGE_SERVICE_SCHEMA,
|
|
135
|
+
isRefreshableUsageProvider,
|
|
136
|
+
isSupportedUsageProvider,
|
|
137
|
+
type DesktopUsageOwnerRead,
|
|
138
|
+
type DesktopUsageRecordedSnapshot,
|
|
139
|
+
type DesktopUsageService,
|
|
140
|
+
} from "../lib/desktop-rpc-usage.ts";
|
|
133
141
|
import { UsageView } from "../lib/shell-usage-view.ts";
|
|
134
142
|
import { releaseSidebarHover, setSidebarHover, sidebarHeader, sidebarPart, sidebarState, sidebarStatusBar, VISUAL_SETTINGS_CHANGED, type SidebarRail } from "../lib/shell-sidebar.ts";
|
|
135
143
|
import { installSidebar, invalidateSidebar, narrowStatusOwner, SIDEBAR_BREAKPOINT, STATUS_OWNER } from "../lib/shell-sidebar-layout.ts";
|
|
@@ -355,7 +363,6 @@ export function buildShellBarModel(
|
|
|
355
363
|
const home = options.home ?? os.homedir();
|
|
356
364
|
const { usage, costTotal } = sessionStats(ctx);
|
|
357
365
|
const model = ctx.model;
|
|
358
|
-
const adaptiveReasoning = isNanAdaptiveReasoningModel(model);
|
|
359
366
|
const entries = Array.from(footerData.getExtensionStatuses().entries())
|
|
360
367
|
.filter(([key]) => key !== "gentle-fast" && (options.jobs === undefined || key !== JOBS_STATUS_KEY))
|
|
361
368
|
.sort(([a], [b]) => a.localeCompare(b));
|
|
@@ -374,7 +381,7 @@ export function buildShellBarModel(
|
|
|
374
381
|
dirty: options.dirty,
|
|
375
382
|
sessionName: ctx.sessionManager.getSessionName(),
|
|
376
383
|
modelId: model?.id ?? "no-model",
|
|
377
|
-
effort: model?.reasoning ?
|
|
384
|
+
effort: model?.reasoning ? pi.getThinkingLevel() : undefined,
|
|
378
385
|
contextPercent: usage?.percent ?? null,
|
|
379
386
|
contextWindow: usage?.contextWindow ?? model?.contextWindow ?? 0,
|
|
380
387
|
costTotal,
|
|
@@ -425,7 +432,7 @@ export function createFooterStatusMemo(deps: FooterStatusMemoDeps): { key(): str
|
|
|
425
432
|
statsKey ? [statsKey[0], statsKey[1], statsKey[2]] : sessionStats(ctx),
|
|
426
433
|
model?.id ?? null,
|
|
427
434
|
model?.contextWindow ?? null,
|
|
428
|
-
model?.reasoning ?
|
|
435
|
+
model?.reasoning ? pi.getThinkingLevel() : undefined,
|
|
429
436
|
model ? ctx.modelRegistry.isUsingOAuth(model) : false,
|
|
430
437
|
footerData.getGitBranch(),
|
|
431
438
|
deps.profile(),
|
|
@@ -518,7 +525,7 @@ interface PromptEditorDeps {
|
|
|
518
525
|
/** Pasted images become atomic `[Image#N]` chips; absent, Pi's paste handler runs unchanged. */
|
|
519
526
|
attachments?: ImageAttachments;
|
|
520
527
|
readClipboardImage?: () => Promise<ClipboardImage | null>;
|
|
521
|
-
/** Injectable
|
|
528
|
+
/** Injectable coarse-animation window; production and tests default to SHELL_PULSE_WATCHDOG_MS. */
|
|
522
529
|
watchdogMs?: number;
|
|
523
530
|
/** Read on every render: true while the wide IDE chrome shows, so the editor draws its panel frame. */
|
|
524
531
|
panelChrome?: () => boolean;
|
|
@@ -568,7 +575,6 @@ export function extractQueuedText(combined: string, draft: string): string | und
|
|
|
568
575
|
|
|
569
576
|
export class GentlePromptEditor extends CustomEditor {
|
|
570
577
|
private promptState: PromptState = PROMPT_STATE.IDLE;
|
|
571
|
-
private tick = 0;
|
|
572
578
|
private animationPolicy: AnimationPolicy = "quality";
|
|
573
579
|
private vimPolicy: VimPolicy = "off";
|
|
574
580
|
private vimRejected = false;
|
|
@@ -585,9 +591,6 @@ export class GentlePromptEditor extends CustomEditor {
|
|
|
585
591
|
private visualObjectPending: "i" | "a" | undefined;
|
|
586
592
|
private visualAnchor: { line: number; col: number } | undefined;
|
|
587
593
|
private watchdog: NodeJS.Timeout | undefined;
|
|
588
|
-
// Last time a frame painted (or the watchdog forced one) while working; the
|
|
589
|
-
// quality watchdog repaints only when now() drifts past its window.
|
|
590
|
-
private lastRenderAt = 0;
|
|
591
594
|
private readonly deps: PromptEditorDeps;
|
|
592
595
|
private readonly pointerTui: TUI;
|
|
593
596
|
private floatMouseLayout?: ReturnType<typeof resolvePromptLayout>;
|
|
@@ -815,20 +818,22 @@ export class GentlePromptEditor extends CustomEditor {
|
|
|
815
818
|
this.deps.requestRender();
|
|
816
819
|
}
|
|
817
820
|
|
|
821
|
+
/** Current animation phase: elapsed working time at the policy cadence. */
|
|
822
|
+
private workingPhase(): number {
|
|
823
|
+
// potato never animates (no timer, static petal); quality steps per
|
|
824
|
+
// SHELL_PULSE_MS window; performance keeps the coarse watchdog cadence.
|
|
825
|
+
if (this.animationPolicy === "potato") return 0;
|
|
826
|
+
return workingTick(this.deps.now(), this.animationPolicy === "quality" ? SHELL_PULSE_MS : (this.deps.watchdogMs ?? SHELL_PULSE_WATCHDOG_MS));
|
|
827
|
+
}
|
|
828
|
+
|
|
818
829
|
private startWatchdog(): void {
|
|
830
|
+
// Time-based animation: the phase comes from workingPhase(), so this
|
|
831
|
+
// timer only keeps repaints flowing while working — quality pulses at
|
|
832
|
+
// SHELL_PULSE_MS so silent tool runs stay on cadence; potato gets no
|
|
833
|
+
// timer at all (its coarse frames paint only when a repaint happens).
|
|
819
834
|
if (this.animationPolicy === "potato") return;
|
|
820
|
-
const windowMs = this.deps.watchdogMs ?? SHELL_PULSE_WATCHDOG_MS;
|
|
821
|
-
this.
|
|
822
|
-
this.watchdog = setInterval(() => {
|
|
823
|
-
// Render-driven petal (gentle-shell#994): streaming frames already
|
|
824
|
-
// advance the animation in render(), so under quality the watchdog
|
|
825
|
-
// stays silent unless no frame painted within its window. performance
|
|
826
|
-
// keeps its coarse cadence regardless of render traffic.
|
|
827
|
-
if (this.animationPolicy === "quality" && this.deps.now() - this.lastRenderAt < windowMs) return;
|
|
828
|
-
this.tick += 1;
|
|
829
|
-
this.lastRenderAt = this.deps.now();
|
|
830
|
-
this.deps.requestRender();
|
|
831
|
-
}, windowMs);
|
|
835
|
+
const windowMs = this.animationPolicy === "quality" ? SHELL_PULSE_MS : (this.deps.watchdogMs ?? SHELL_PULSE_WATCHDOG_MS);
|
|
836
|
+
this.watchdog = setInterval(() => this.deps.requestRender(), windowMs);
|
|
832
837
|
this.watchdog.unref();
|
|
833
838
|
}
|
|
834
839
|
|
|
@@ -1384,13 +1389,9 @@ export class GentlePromptEditor extends CustomEditor {
|
|
|
1384
1389
|
}
|
|
1385
1390
|
|
|
1386
1391
|
render(width: number): string[] {
|
|
1387
|
-
//
|
|
1388
|
-
//
|
|
1389
|
-
//
|
|
1390
|
-
if (this.promptState === PROMPT_STATE.WORKING && this.animationPolicy === "quality") {
|
|
1391
|
-
this.tick += 1;
|
|
1392
|
-
this.lastRenderAt = this.deps.now();
|
|
1393
|
-
}
|
|
1392
|
+
// Time-based animation: the phase is read from the clock per frame, so a
|
|
1393
|
+
// streaming render burst cannot strobe the wave and silent tool runs
|
|
1394
|
+
// advance it via the working pulse timer.
|
|
1394
1395
|
const layout = resolvePromptLayout(width, cardStyle(), this.deps.bg, this.deps.panelChrome?.() ?? false);
|
|
1395
1396
|
this.floatMouseLayout = layout.background || layout.panel ? layout : undefined;
|
|
1396
1397
|
const inner = layout.nativeWidth;
|
|
@@ -1417,7 +1418,7 @@ export class GentlePromptEditor extends CustomEditor {
|
|
|
1417
1418
|
? visibleCount! + 2 : editorLines.length;
|
|
1418
1419
|
const framed = framePromptLines(editorLines.slice(0, borderEnd), width, {
|
|
1419
1420
|
state,
|
|
1420
|
-
tick: this.
|
|
1421
|
+
tick: this.workingPhase(),
|
|
1421
1422
|
borderColor: (text) => layout.background || layout.panel ? this.borderColor(text) : this.deps.fg(PROMPT_FRAME_ROLE, text),
|
|
1422
1423
|
fg: this.deps.fg,
|
|
1423
1424
|
bold: this.deps.bold,
|
|
@@ -1497,7 +1498,6 @@ export class GentlePromptEditor extends CustomEditor {
|
|
|
1497
1498
|
private stopWatchdog(): void {
|
|
1498
1499
|
if (this.watchdog) clearInterval(this.watchdog);
|
|
1499
1500
|
this.watchdog = undefined;
|
|
1500
|
-
this.tick = 0;
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
1503
|
|
|
@@ -2083,17 +2083,6 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
2083
2083
|
// overlapping refreshes of the SAME source (or of builtins) can otherwise
|
|
2084
2084
|
// let an older failure settle after a newer success and poison it.
|
|
2085
2085
|
const usageGenerations = new Map<string, number>();
|
|
2086
|
-
// NaN accepts a thinking level for DeepSeek V4 Flash, Qwen 3.8 Flash, and MiMo
|
|
2087
|
-
// but manages their depth itself, so the header reports `auto` and the shell says
|
|
2088
|
-
// why once per model instead of repeating it on every level change.
|
|
2089
|
-
const adaptiveReasoningNotices = new Set<string>();
|
|
2090
|
-
const announceAdaptiveReasoning = (ctx: ExtensionContext, model: { provider: string; id: string; name?: string } | undefined) => {
|
|
2091
|
-
if (!ctx.hasUI || !isNanAdaptiveReasoningModel(model)) return;
|
|
2092
|
-
const key = `${model.provider}/${model.id}`;
|
|
2093
|
-
if (adaptiveReasoningNotices.has(key)) return;
|
|
2094
|
-
adaptiveReasoningNotices.add(key);
|
|
2095
|
-
ctx.ui.notify(`${model.name || model.id} chooses its reasoning depth automatically; the selected thinking level is accepted but does not change it.`, "info");
|
|
2096
|
-
};
|
|
2097
2086
|
// One spelling of the config home, so the pin resolver, the global profiles
|
|
2098
2087
|
// store and the profile reader cannot drift onto two different stores.
|
|
2099
2088
|
const usageConfigHome = gentlePiConfigHome(env);
|
|
@@ -2220,6 +2209,75 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
2220
2209
|
.map((provider) => refreshProvider(ctx, provider, usageSources.get(provider), force, now)),
|
|
2221
2210
|
);
|
|
2222
2211
|
};
|
|
2212
|
+
// Desktop's usage slice reaches the owner only through this versioned,
|
|
2213
|
+
// adapter-shaped seam — the usage analogue of the YOLO host-ui adapter. It
|
|
2214
|
+
// wraps the existing UsageStore / UsageSourceRegistry / refreshUsage /
|
|
2215
|
+
// after_provider_response closures; there is no second store, fetcher, or
|
|
2216
|
+
// auth resolver. Header-driven snapshots are broadcast to every subscribed
|
|
2217
|
+
// Desktop consumer through the shared observer set below, already parsed.
|
|
2218
|
+
const desktopUsageObservers = new Set<(recorded: DesktopUsageRecordedSnapshot) => void>();
|
|
2219
|
+
pi.events.on(DESKTOP_USAGE_SERVICE_CHANNEL, (payload: unknown) => {
|
|
2220
|
+
if (!payload || typeof payload !== "object") return;
|
|
2221
|
+
const request = payload as Partial<{ context: ExtensionContext; respond(service: DesktopUsageService): void }>;
|
|
2222
|
+
if (typeof request.respond !== "function" || !request.context) return;
|
|
2223
|
+
const ctx = request.context;
|
|
2224
|
+
try {
|
|
2225
|
+
let disposed = false;
|
|
2226
|
+
const subscriptions = new Set<(recorded: DesktopUsageRecordedSnapshot) => void>();
|
|
2227
|
+
const read = (provider?: string, outOfScope = false): DesktopUsageOwnerRead => {
|
|
2228
|
+
if (disposed) return { providers: [] };
|
|
2229
|
+
const scope = provider === undefined ? resolveUsageScope(ctx) : [provider];
|
|
2230
|
+
return {
|
|
2231
|
+
providers: scope.map((name) => ({
|
|
2232
|
+
provider: name,
|
|
2233
|
+
supported: isSupportedUsageProvider(name, usageSources.has(name)),
|
|
2234
|
+
refreshable: isRefreshableUsageProvider(name, usageSources.has(name)),
|
|
2235
|
+
failed: usageFailures.has(name),
|
|
2236
|
+
...(outOfScope ? { outOfScope: true } : {}),
|
|
2237
|
+
snapshot: usage.get(name),
|
|
2238
|
+
})),
|
|
2239
|
+
};
|
|
2240
|
+
};
|
|
2241
|
+
const refresh = async (provider?: string): Promise<DesktopUsageOwnerRead> => {
|
|
2242
|
+
if (disposed) return { providers: [] };
|
|
2243
|
+
// Resolve the scope BEFORE delegation: a filtered refresh for a provider
|
|
2244
|
+
// outside the current session scope would never fetch anything (refreshUsage
|
|
2245
|
+
// filters by scope), so it answers a truthful out_of_scope no-op instead of
|
|
2246
|
+
// an ambiguous pending, and never attempts the fetch.
|
|
2247
|
+
const scope = resolveUsageScope(ctx);
|
|
2248
|
+
if (provider !== undefined && !scope.includes(provider)) {
|
|
2249
|
+
return read(provider, true);
|
|
2250
|
+
}
|
|
2251
|
+
// The same API-key/auth logic the panel uses: refreshUsage resolves
|
|
2252
|
+
// the scope, the credentials, and the fetch window itself. Anthropic
|
|
2253
|
+
// is skipped there because it has no usage endpoint, so a refresh
|
|
2254
|
+
// for it is a truthful no-op rather than a fabricated snapshot.
|
|
2255
|
+
await refreshUsage(ctx, true, provider);
|
|
2256
|
+
return read(provider);
|
|
2257
|
+
};
|
|
2258
|
+
request.respond({
|
|
2259
|
+
schema: DESKTOP_USAGE_SERVICE_SCHEMA,
|
|
2260
|
+
read,
|
|
2261
|
+
refresh,
|
|
2262
|
+
observe: (onSnapshot) => {
|
|
2263
|
+
if (disposed) return () => {};
|
|
2264
|
+
subscriptions.add(onSnapshot);
|
|
2265
|
+
desktopUsageObservers.add(onSnapshot);
|
|
2266
|
+
return () => {
|
|
2267
|
+
subscriptions.delete(onSnapshot);
|
|
2268
|
+
desktopUsageObservers.delete(onSnapshot);
|
|
2269
|
+
};
|
|
2270
|
+
},
|
|
2271
|
+
dispose: () => {
|
|
2272
|
+
disposed = true;
|
|
2273
|
+
for (const onSnapshot of subscriptions) desktopUsageObservers.delete(onSnapshot);
|
|
2274
|
+
subscriptions.clear();
|
|
2275
|
+
},
|
|
2276
|
+
});
|
|
2277
|
+
} catch {
|
|
2278
|
+
/* obsolete trusted context: discovery expires closed */
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2223
2281
|
// Subscribed once, for the life of the extension: a registration can
|
|
2224
2282
|
// arrive before the first session_start (the owning extension's factory
|
|
2225
2283
|
// runs first) or after it (its own session_start fires later, or it
|
|
@@ -2248,6 +2306,11 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
2248
2306
|
// A snapshot that arrived with a response is evidence the provider is
|
|
2249
2307
|
// answering: a failure some earlier refresh recorded no longer stands.
|
|
2250
2308
|
usageFailures.delete(parsed.provider);
|
|
2309
|
+
// Desktop consumers subscribed through the owner service get the already-
|
|
2310
|
+
// parsed snapshot (Claude's 5h/7d windows included), never header text.
|
|
2311
|
+
for (const onSnapshot of [...desktopUsageObservers]) {
|
|
2312
|
+
try { onSnapshot({ provider: parsed.provider, usage: parsed }); } catch { /* a listener never breaks usage */ }
|
|
2313
|
+
}
|
|
2251
2314
|
renderHost?.invalidateSidebar?.();
|
|
2252
2315
|
renderHost?.requestRender();
|
|
2253
2316
|
});
|
|
@@ -2542,10 +2605,6 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
2542
2605
|
}
|
|
2543
2606
|
closeCustomize?.();
|
|
2544
2607
|
runningJobs = undefined;
|
|
2545
|
-
adaptiveReasoningNotices.clear();
|
|
2546
|
-
// A restored or default session never emits model_select, so the startup model
|
|
2547
|
-
// announces itself here when it manages its own depth.
|
|
2548
|
-
announceAdaptiveReasoning(ctx, ctx.model);
|
|
2549
2608
|
if (review) {
|
|
2550
2609
|
review = undefined;
|
|
2551
2610
|
redrawReview();
|
|
@@ -3733,10 +3792,4 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
|
|
|
3733
3792
|
trackChangeRefresh(refreshChanges(ctx));
|
|
3734
3793
|
void refreshUsage(ctx, false);
|
|
3735
3794
|
});
|
|
3736
|
-
pi.on("model_select", (event, ctx) => {
|
|
3737
|
-
announceAdaptiveReasoning(ctx, event.model);
|
|
3738
|
-
});
|
|
3739
|
-
pi.on("thinking_level_select", (_event, ctx) => {
|
|
3740
|
-
announceAdaptiveReasoning(ctx, ctx.model);
|
|
3741
|
-
});
|
|
3742
3795
|
}
|