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
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// The tool rail on the left: Move and Comment (one pressed pair over Comment
|
|
2
|
+
// mode), Overview (Fit) and Settings (a menu with the design system board, the
|
|
3
|
+
// keyboard shortcuts, Technical details, which turns the token inspector on, and the language). Its single-key shortcuts, and the ? list where a person
|
|
4
|
+
// gives any of them another single key, saved in this browser for every design
|
|
5
|
+
// the canvas server shows (per address: a restarted server has a new port).
|
|
6
|
+
|
|
7
|
+
// Every string the rail shows, in English; canvas-i18n-es.js has the Spanish (S8 of odd/tasks/canvas-i18n.md).
|
|
8
|
+
const TEXT = Object.freeze({
|
|
9
|
+
settings: "Settings",
|
|
10
|
+
system: "Design system board",
|
|
11
|
+
keys: "Keyboard shortcuts",
|
|
12
|
+
technical: "Technical details",
|
|
13
|
+
navigateTitle: (key) => `Move around the canvas (${key})`,
|
|
14
|
+
commentTitle: (key) => `Comment on an element (${key})`,
|
|
15
|
+
fitTitle: (key) => `See all the directions (${key})`,
|
|
16
|
+
panelTitle: (key) => `Comments panel (${key})`,
|
|
17
|
+
actions: {
|
|
18
|
+
navigate: "Move around the canvas",
|
|
19
|
+
comment: "Comment on an element",
|
|
20
|
+
fit: "Overview (fit all directions)",
|
|
21
|
+
panel: "Show or hide the comments panel",
|
|
22
|
+
minimap: "Show or hide the minimap",
|
|
23
|
+
help: "Show keyboard shortcuts",
|
|
24
|
+
},
|
|
25
|
+
change: "Change",
|
|
26
|
+
changeAria: (action, key) => `Change the key for “${action}” (${key})`,
|
|
27
|
+
reset: "Reset",
|
|
28
|
+
resetAria: (action, key) => `Reset “${action}” to ${key}`,
|
|
29
|
+
waiting: "Press a key…",
|
|
30
|
+
waitingMessage: (action) => `Press the new key for “${action}”, or Esc to cancel.`,
|
|
31
|
+
assigned: (action, key) => `“${action}” is now ${key}.`,
|
|
32
|
+
kept: (action, key) => `“${action}” keeps ${key}.`,
|
|
33
|
+
taken: (key, action) => `${key} is already used by “${action}”. Nothing changed.`,
|
|
34
|
+
fixed: (key) => `${key} is a fixed key and can’t be assigned. Nothing changed.`,
|
|
35
|
+
invalid: "Use a single letter, digit or punctuation key, without Ctrl, Alt or Cmd. Nothing changed.",
|
|
36
|
+
unsaved: "This browser could not save the change, so it holds for this page only.",
|
|
37
|
+
resetDone: (action, key) => `“${action}” is back to ${key}.`,
|
|
38
|
+
restored: "All shortcuts are back to their defaults.",
|
|
39
|
+
spaceKey: "Space",
|
|
40
|
+
shiftEscKey: "Shift+Esc",
|
|
41
|
+
// The language choices (canvas-i18n.js) under their heading: each language by its own name.
|
|
42
|
+
language: "Language",
|
|
43
|
+
spanish: "Español",
|
|
44
|
+
english: "English",
|
|
45
|
+
auto: "Match the browser",
|
|
46
|
+
languageNote: "Messages to the agent stay in English.",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Settings' language radios, in order: the choice and its label.
|
|
50
|
+
const LANGUAGES = [["es", "spanish"], ["en", "english"], ["auto", "auto"]];
|
|
51
|
+
|
|
52
|
+
// The keys a person gave the single-key shortcuts in this browser, for every design at this canvas address: a JSON object, action id -> key.
|
|
53
|
+
const SHORTCUTS_KEY = "gentle-design:shortcuts";
|
|
54
|
+
// Never assignable: Esc, Shift+Esc, Enter, Tab, Space, the arrows and the zoom keys keep their meaning.
|
|
55
|
+
const FIXED_KEYS = ["Escape", "Enter", "Tab", " ", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "+", "=", "-", "0"];
|
|
56
|
+
const ARROW_KEYS = { ArrowLeft: "←", ArrowRight: "→", ArrowUp: "↑", ArrowDown: "↓" };
|
|
57
|
+
// Pressed alone while a Change waits, these keep it waiting: Shift (and AltGr) are how many keyboards type ? or ].
|
|
58
|
+
const MODIFIER_KEYS = ["Shift", "Control", "Alt", "AltGraph", "Meta", "OS", "CapsLock", "NumLock", "ScrollLock", "Fn", "FnLock", "Hyper", "Super", "Symbol", "SymbolLock"];
|
|
59
|
+
const TYPING_TAGS = ["input", "textarea", "select"];
|
|
60
|
+
|
|
61
|
+
/** One printable character (a letter, a digit or punctuation). */
|
|
62
|
+
const printable = (key) => typeof key === "string" && [...key].length === 1 && /^\S$/u.test(key);
|
|
63
|
+
/**
|
|
64
|
+
* The key a shortcut can take from `key`: one printable character, lower case, that is still one printable
|
|
65
|
+
* character once lower case (İ is not: it lowers to i plus a combining dot); otherwise "".
|
|
66
|
+
*/
|
|
67
|
+
const singleKey = (key) => (printable(key) && printable(key.toLowerCase()) ? key.toLowerCase() : "");
|
|
68
|
+
/**
|
|
69
|
+
* Ctrl, Alt or Cmd held for a browser chord. AltGr, which types a character, reports Ctrl and Alt
|
|
70
|
+
* on some systems and AltGraph in getModifierState: that press is a printable key, not a chord.
|
|
71
|
+
*/
|
|
72
|
+
const isChord = (event) => Boolean(event.metaKey || ((event.ctrlKey || event.altKey) && !(typeof event.getModifierState === "function" && event.getModifierState("AltGraph"))));
|
|
73
|
+
/** How a key is written: a letter upper case, as on the keyboard. */
|
|
74
|
+
const keyText = (key) => (key.toUpperCase().length === key.length ? key.toUpperCase() : key);
|
|
75
|
+
|
|
76
|
+
export function init(ctx) {
|
|
77
|
+
const { win, doc, els, store, actions } = ctx;
|
|
78
|
+
const { state } = store;
|
|
79
|
+
const T = ctx.i18n.text("rail", TEXT);
|
|
80
|
+
|
|
81
|
+
// The rail, panel and minimap actions, each with its default key; keys match without letter case, so they are kept lower case.
|
|
82
|
+
const SHORTCUTS = [
|
|
83
|
+
{ id: "navigate", key: "v", run: () => actions.setCommenting(false) },
|
|
84
|
+
{ id: "comment", key: "c", run: () => actions.setCommenting(true) },
|
|
85
|
+
{ id: "fit", key: "f", run: () => actions.fit() },
|
|
86
|
+
{ id: "panel", key: "]", run: () => actions.setPanel(els.panel.hidden) },
|
|
87
|
+
{ id: "minimap", key: "m", run: () => actions.toggleMinimap() },
|
|
88
|
+
{ id: "help", key: "?", run: () => openShortcuts() },
|
|
89
|
+
];
|
|
90
|
+
const shortcutById = (id) => SHORTCUTS.find((shortcut) => shortcut.id === id);
|
|
91
|
+
const labelOf = (shortcut) => T.actions[shortcut.id];
|
|
92
|
+
|
|
93
|
+
/** The custom keys saved in this browser; an entry that is no usable key, names no action or takes another action's key is left out. */
|
|
94
|
+
function storedShortcuts() {
|
|
95
|
+
let stored = null;
|
|
96
|
+
try {
|
|
97
|
+
stored = JSON.parse(win.localStorage.getItem(SHORTCUTS_KEY) ?? "null");
|
|
98
|
+
} catch {
|
|
99
|
+
stored = null;
|
|
100
|
+
}
|
|
101
|
+
const custom = {};
|
|
102
|
+
if (!stored || typeof stored !== "object" || Array.isArray(stored)) return custom;
|
|
103
|
+
for (const shortcut of SHORTCUTS) {
|
|
104
|
+
if (!Object.prototype.hasOwnProperty.call(stored, shortcut.id)) continue;
|
|
105
|
+
const key = singleKey(stored[shortcut.id]);
|
|
106
|
+
if (key && !FIXED_KEYS.includes(key) && key !== shortcut.key) custom[shortcut.id] = key;
|
|
107
|
+
}
|
|
108
|
+
// A key two actions would share is neither's custom key: those fall back to their defaults, until no two share one.
|
|
109
|
+
for (;;) {
|
|
110
|
+
const keyOf = (shortcut) => custom[shortcut.id] ?? shortcut.key;
|
|
111
|
+
const shared = SHORTCUTS.filter((shortcut) => shortcut.id in custom && SHORTCUTS.some((other) => other !== shortcut && keyOf(other) === custom[shortcut.id]));
|
|
112
|
+
if (shared.length === 0) return custom;
|
|
113
|
+
for (const shortcut of shared) delete custom[shortcut.id];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// This module's own state, like the pan drag in canvas-view.js: the custom keys, the
|
|
118
|
+
// shortcut whose Change waits for the next key (or null), and the list's rows.
|
|
119
|
+
let customKeys = storedShortcuts();
|
|
120
|
+
let keyWait = null;
|
|
121
|
+
const shortcutRows = new Map();
|
|
122
|
+
const shortcutKey = (shortcut) => customKeys[shortcut.id] ?? shortcut.key;
|
|
123
|
+
|
|
124
|
+
/** Saves the custom keys in this browser; false when storage refused them (they then hold for this page only). */
|
|
125
|
+
function saveShortcuts() {
|
|
126
|
+
try {
|
|
127
|
+
win.localStorage.setItem(SHORTCUTS_KEY, JSON.stringify(customKeys));
|
|
128
|
+
return true;
|
|
129
|
+
} catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The message after a change: `text`, plus a warning (read as an error) when it could not be saved. */
|
|
135
|
+
function showSavedMessage(text, saved) {
|
|
136
|
+
showKeysMessage(saved ? text : `${text} ${T.unsaved}`, !saved);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The line under the list that says what a Change did; a refusal reads as an error. No text clears it. */
|
|
140
|
+
function showKeysMessage(text, refused = false) {
|
|
141
|
+
els.keysMessage.textContent = text ?? "";
|
|
142
|
+
els.keysMessage.classList.toggle("gd-error", refused);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Move and Comment are one pressed pair. */
|
|
146
|
+
function renderTools() {
|
|
147
|
+
els.comment.setAttribute("aria-pressed", String(state.commenting));
|
|
148
|
+
els.toolNavigate.setAttribute("aria-pressed", String(!state.commenting));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Where the rail and the top bar name a key: in the tooltip, and in aria-keyshortcuts for screen readers.
|
|
152
|
+
const SHORTCUT_HINTS = [["navigate", els.toolNavigate, "navigateTitle"], ["comment", els.comment, "commentTitle"], ["fit", els.railFit, "fitTitle"], ["panel", els.panelToggle, "panelTitle"]];
|
|
153
|
+
|
|
154
|
+
/** Every place that shows a key shows the current one: the rail, the comments panel button, the minimap and the list. */
|
|
155
|
+
function renderShortcuts() {
|
|
156
|
+
for (const [id, element, title] of SHORTCUT_HINTS) {
|
|
157
|
+
const key = keyText(shortcutKey(shortcutById(id)));
|
|
158
|
+
element.setAttribute("aria-keyshortcuts", key);
|
|
159
|
+
element.title = T[title](key);
|
|
160
|
+
}
|
|
161
|
+
els.minimapKey.textContent = keyText(shortcutKey(shortcutById("minimap")));
|
|
162
|
+
for (const shortcut of SHORTCUTS) renderShortcutRow(shortcut);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A row of the list: the action, its key, Change and Reset. Built once and kept, so a change never takes the focus away. */
|
|
166
|
+
function renderShortcutRow(shortcut) {
|
|
167
|
+
let row = shortcutRows.get(shortcut.id);
|
|
168
|
+
if (!row) {
|
|
169
|
+
const root = doc.createElement("li");
|
|
170
|
+
root.className = "gd-key-row";
|
|
171
|
+
root.dataset.shortcut = shortcut.id;
|
|
172
|
+
const action = doc.createElement("span");
|
|
173
|
+
action.className = "gd-key-action";
|
|
174
|
+
const key = doc.createElement("kbd");
|
|
175
|
+
key.className = "gd-key-current";
|
|
176
|
+
const change = doc.createElement("button");
|
|
177
|
+
change.type = "button";
|
|
178
|
+
change.className = "gd-key-change gd-small";
|
|
179
|
+
const reset = doc.createElement("button");
|
|
180
|
+
reset.type = "button";
|
|
181
|
+
reset.className = "gd-key-reset gd-small";
|
|
182
|
+
change.addEventListener("click", () => {
|
|
183
|
+
if (keyWait !== shortcut) startKeyWait(shortcut);
|
|
184
|
+
else {
|
|
185
|
+
stopKeyWait();
|
|
186
|
+
showKeysMessage(T.kept(labelOf(shortcut), keyText(shortcutKey(shortcut))));
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
// Leaving the button (a click elsewhere, Restore defaults) ends its wait.
|
|
190
|
+
change.addEventListener("blur", () => {
|
|
191
|
+
if (keyWait !== shortcut) return;
|
|
192
|
+
stopKeyWait();
|
|
193
|
+
showKeysMessage(null);
|
|
194
|
+
});
|
|
195
|
+
reset.addEventListener("click", () => {
|
|
196
|
+
stopKeyWait();
|
|
197
|
+
assignKey(shortcut, shortcut.key, T.resetDone);
|
|
198
|
+
});
|
|
199
|
+
root.append(action, key, change, reset);
|
|
200
|
+
els.keysCustom.append(root);
|
|
201
|
+
row = { root, action, key, change, reset };
|
|
202
|
+
shortcutRows.set(shortcut.id, row);
|
|
203
|
+
}
|
|
204
|
+
const key = keyText(shortcutKey(shortcut));
|
|
205
|
+
const waiting = keyWait === shortcut;
|
|
206
|
+
row.root.classList.toggle("gd-key-waiting", waiting);
|
|
207
|
+
row.action.textContent = labelOf(shortcut);
|
|
208
|
+
row.key.textContent = key;
|
|
209
|
+
row.reset.textContent = T.reset;
|
|
210
|
+
row.change.textContent = waiting ? T.waiting : T.change;
|
|
211
|
+
// While it waits, its visible text is its name.
|
|
212
|
+
if (waiting) row.change.removeAttribute("aria-label");
|
|
213
|
+
else row.change.setAttribute("aria-label", T.changeAria(labelOf(shortcut), key));
|
|
214
|
+
row.reset.setAttribute("aria-label", T.resetAria(labelOf(shortcut), keyText(shortcut.key)));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function startKeyWait(shortcut) {
|
|
218
|
+
const previous = keyWait;
|
|
219
|
+
keyWait = shortcut;
|
|
220
|
+
if (previous) renderShortcutRow(previous);
|
|
221
|
+
renderShortcutRow(shortcut);
|
|
222
|
+
showKeysMessage(T.waitingMessage(labelOf(shortcut)));
|
|
223
|
+
shortcutRows.get(shortcut.id).change.focus();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function stopKeyWait() {
|
|
227
|
+
const shortcut = keyWait;
|
|
228
|
+
if (!shortcut) return;
|
|
229
|
+
keyWait = null;
|
|
230
|
+
renderShortcutRow(shortcut);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Gives `shortcut` the key, unless another action has it; `done` writes the message that says it was given. */
|
|
234
|
+
function assignKey(shortcut, key, done) {
|
|
235
|
+
const owner = SHORTCUTS.find((other) => other !== shortcut && shortcutKey(other) === key);
|
|
236
|
+
if (owner) {
|
|
237
|
+
showKeysMessage(T.taken(keyText(key), labelOf(owner)), true);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (key === shortcut.key) delete customKeys[shortcut.id];
|
|
241
|
+
else customKeys[shortcut.id] = key;
|
|
242
|
+
const saved = saveShortcuts();
|
|
243
|
+
renderShortcuts();
|
|
244
|
+
showSavedMessage(done(labelOf(shortcut), keyText(key)), saved);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function openShortcuts() {
|
|
248
|
+
showKeysMessage(null);
|
|
249
|
+
if (typeof els.shortcuts.showModal === "function") els.shortcuts.showModal();
|
|
250
|
+
else els.shortcuts.setAttribute("open", "");
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function closeShortcuts() {
|
|
254
|
+
stopKeyWait();
|
|
255
|
+
if (typeof els.shortcuts.close === "function") els.shortcuts.close();
|
|
256
|
+
else els.shortcuts.removeAttribute("open");
|
|
257
|
+
els.railSettings.focus();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** What Settings offers: the design system board (when there is one, and not over Compare), the keyboard shortcuts, Technical details and the language. */
|
|
261
|
+
function settingsActions() {
|
|
262
|
+
return [
|
|
263
|
+
// Checked again when chosen: a live reload may have removed the board while the menu was open.
|
|
264
|
+
{ label: T.system, icon: "i-palette", disabled: !state.systemBoard || Boolean(state.compare), run: () => {
|
|
265
|
+
if (state.systemBoard && !state.compare) actions.enterFocus(state.systemBoard);
|
|
266
|
+
} },
|
|
267
|
+
{ label: T.keys, icon: "i-keys", shortcut: keyText(shortcutKey(shortcutById("help"))), run: openShortcuts },
|
|
268
|
+
// A checkbox: the token inspector in Comment mode (canvas-tokens.js).
|
|
269
|
+
{ label: T.technical, icon: "i-code", checked: state.technical, run: () => actions.setTechnical(!state.technical) },
|
|
270
|
+
// The language: radios under their heading, applied at once (canvas-i18n.js), and what stays English.
|
|
271
|
+
{ separator: true },
|
|
272
|
+
{ group: T.language, actions: LANGUAGES.map(([choice, label]) => ({ label: T[label], radio: true, checked: state.languageChoice === choice, run: () => ctx.i18n.setLanguage(choice) })) },
|
|
273
|
+
{ note: T.languageNote },
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** The first render of the rail and the list, and the Settings menu; boot() runs it once every module is ready. */
|
|
278
|
+
function startRail() {
|
|
279
|
+
renderTools();
|
|
280
|
+
renderShortcuts();
|
|
281
|
+
actions.wireMenu(els.railSettings, (last) => actions.showMenu(els.railSettings, settingsActions(), T.settings, last, true));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
els.toolNavigate.addEventListener("click", () => actions.setCommenting(false));
|
|
285
|
+
els.railFit.addEventListener("click", () => actions.fit());
|
|
286
|
+
|
|
287
|
+
// The browser closes the modal list on Esc too (not while a Change waits: that Esc only cancels the wait).
|
|
288
|
+
els.shortcuts.addEventListener("close", stopKeyWait);
|
|
289
|
+
els.shortcutsClose.addEventListener("click", closeShortcuts);
|
|
290
|
+
els.keysRestore.addEventListener("click", () => {
|
|
291
|
+
stopKeyWait();
|
|
292
|
+
customKeys = {};
|
|
293
|
+
const saved = saveShortcuts();
|
|
294
|
+
renderShortcuts();
|
|
295
|
+
showSavedMessage(T.restored, saved);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// While a Change waits, the next key is the new one and nothing else gets it; Esc cancels the wait (in the capture
|
|
299
|
+
// phase, ahead of every other key handler, and without closing the list). Tab ends the wait as leaving the button
|
|
300
|
+
// does, and still moves focus.
|
|
301
|
+
doc.addEventListener("keydown", (event) => {
|
|
302
|
+
const shortcut = keyWait;
|
|
303
|
+
if (!shortcut || MODIFIER_KEYS.includes(event.key)) return;
|
|
304
|
+
if (event.key === "Tab") {
|
|
305
|
+
stopKeyWait();
|
|
306
|
+
showKeysMessage(null);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
stopKeyWait();
|
|
311
|
+
if (event.key === "Escape" && !event.shiftKey) {
|
|
312
|
+
showKeysMessage(T.kept(labelOf(shortcut), keyText(shortcutKey(shortcut))));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (FIXED_KEYS.includes(event.key)) {
|
|
316
|
+
const name = event.key === "Escape" ? T.shiftEscKey : event.key === " " ? T.spaceKey : ARROW_KEYS[event.key] ?? event.key;
|
|
317
|
+
showKeysMessage(T.fixed(name), true);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const key = isChord(event) ? "" : singleKey(event.key);
|
|
321
|
+
if (key) assignKey(shortcut, key, T.assigned);
|
|
322
|
+
else showKeysMessage(T.invalid, true);
|
|
323
|
+
}, true);
|
|
324
|
+
|
|
325
|
+
// The shortcuts never fire while typing, with a browser chord, while the comment box, a menu or the list (where the
|
|
326
|
+
// help key closes it) is open, in Compare, or in focus mode (the artboard owns the keyboard; Shift+Esc is handled apart).
|
|
327
|
+
// A held key runs its shortcut once: the browser's repeated keydowns would toggle the panel or the list again.
|
|
328
|
+
doc.addEventListener("keydown", (event) => {
|
|
329
|
+
if (event.defaultPrevented || event.repeat || isChord(event)) return;
|
|
330
|
+
const target = event.target;
|
|
331
|
+
if (target && (TYPING_TAGS.includes(target.localName) || target.isContentEditable)) return;
|
|
332
|
+
const key = singleKey(event.key);
|
|
333
|
+
const shortcut = key ? SHORTCUTS.find((entry) => shortcutKey(entry) === key) : null;
|
|
334
|
+
if (els.shortcuts.hasAttribute("open")) {
|
|
335
|
+
if (shortcut && shortcut.id === "help") {
|
|
336
|
+
event.preventDefault();
|
|
337
|
+
closeShortcuts();
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (!shortcut || !els.popover.hidden || state.focus || state.compare || state.menu) return;
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
shortcut.run();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// A new language: the tooltips and the list's rows (the line under the list keeps the language it was written in).
|
|
347
|
+
return { renderTools, renderShortcuts, startRail, relabel: renderShortcuts };
|
|
348
|
+
}
|