gentle-pi 4.8.0 → 4.9.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 +60 -0
- package/assets/agents/gentle-ai-explore.md +1 -1
- package/assets/agents/gentle-ai-verify.md +1 -1
- package/assets/agents/gentle-ai-worker.md +10 -9
- package/assets/design-canvas/canvas-boards.js +22 -2
- package/assets/design-canvas/canvas-boot.js +3 -1
- package/assets/design-canvas/canvas-i18n-es.js +5 -0
- package/assets/design-canvas/canvas-menu.js +13 -7
- package/assets/design-canvas/canvas-messages.js +1 -1
- package/assets/design-canvas/canvas-rail.js +5 -2
- package/assets/design-canvas/canvas-store.js +3 -0
- package/assets/design-canvas/canvas-theme.js +69 -0
- package/assets/design-canvas/canvas.css +27 -2
- package/assets/design-canvas/index.html +3 -0
- package/assets/design-canvas/inspector.js +28 -5
- package/assets/design-canvas/theme-early.js +10 -0
- package/assets/migrations/agent-body-history.json +6 -0
- package/assets/orchestrator-delegation.md +1 -5
- package/assets/orchestrator-full-delegation-card.md +9 -13
- package/assets/orchestrator-full-delegation.md +2 -2
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +3 -31
- package/assets/orchestrator-tracking.md +6 -6
- package/assets/orchestrator-verification.md +4 -4
- package/assets/orchestrator-writer.md +12 -12
- package/assets/orchestrator.md +2 -2
- package/bin/gentle-shell.mjs +77 -1
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +7 -7
- package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/orchestration/pi.md +1 -1
- package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/routing/pi.md +10 -10
- package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/features/gentle-tower.png +0 -0
- package/docs/auto-permission-answers.md +1 -1
- package/docs/bundled-install.md +1 -1
- package/docs/delegated-verification.md +6 -4
- package/docs/desktop-feed.md +303 -0
- package/docs/desktop-rpc.md +703 -25
- package/docs/fast-mode.md +2 -2
- package/docs/gentle-shell-desktop.md +465 -0
- package/docs/gentle-shell.md +65 -3
- package/docs/images/desktop/chat.png +0 -0
- package/docs/images/desktop/palette.png +0 -0
- package/docs/images/desktop/todo.png +0 -0
- package/docs/install-wizard.md +1 -1
- package/docs/odd-preparation-continuity.md +1 -1
- package/docs/readme-reference.md +44 -15
- package/docs/work-continuity.md +10 -7
- package/extensions/ask-user-choice.ts +36 -18
- package/extensions/ask-user-question.ts +47 -8
- package/extensions/gentle-agents.ts +206 -37
- package/extensions/gentle-ai.ts +234 -24
- package/extensions/gentle-desktop-feed.ts +778 -0
- package/extensions/gentle-desktop-rpc.ts +145 -12
- package/extensions/gentle-herdr-desktop-status.ts +275 -0
- package/extensions/gentle-shell.ts +69 -7
- package/extensions/gentle-stats.ts +30 -1
- package/extensions/gentle-tower.ts +305 -0
- package/extensions/skill-registry.ts +13 -3
- package/herdr/RECIPE.md +157 -0
- package/herdr/keys.json +14 -0
- package/herdr/layouts/gentle-shell.json +202 -0
- package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-agents/main.js +190 -0
- package/herdr/mods/gentle-agents/mod.json +1 -0
- package/herdr/mods/gentle-agents/snapshot.js +469 -0
- package/herdr/mods/gentle-agents/tokens.js +273 -0
- package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
- package/herdr/mods/gentle-chat/actions.js +180 -0
- package/herdr/mods/gentle-chat/feed.js +321 -0
- package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
- package/herdr/mods/gentle-chat/icons/check.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
- package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
- package/herdr/mods/gentle-chat/icons/down.svg +1 -0
- package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
- package/herdr/mods/gentle-chat/icons/send.svg +1 -0
- package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
- package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
- package/herdr/mods/gentle-chat/icons/term.svg +1 -0
- package/herdr/mods/gentle-chat/icons/user.svg +1 -0
- package/herdr/mods/gentle-chat/icons/x.svg +1 -0
- package/herdr/mods/gentle-chat/main.js +968 -0
- package/herdr/mods/gentle-chat/mod.json +1 -0
- package/herdr/mods/gentle-chat/session.js +212 -0
- package/herdr/mods/gentle-chat/snapshot.js +469 -0
- package/herdr/mods/gentle-chat/tokens.js +137 -0
- package/herdr/mods/gentle-chat/ui.js +883 -0
- package/herdr/mods/gentle-confirm/main.js +60 -0
- package/herdr/mods/gentle-confirm/mod.json +1 -0
- package/herdr/mods/gentle-inspector/actions.js +180 -0
- package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
- package/herdr/mods/gentle-inspector/main.js +500 -0
- package/herdr/mods/gentle-inspector/mod.json +1 -0
- package/herdr/mods/gentle-inspector/snapshot.js +469 -0
- package/herdr/mods/gentle-inspector/tokens.js +273 -0
- package/herdr/mods/gentle-palette/actions.js +180 -0
- package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
- package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
- package/herdr/mods/gentle-palette/icons/check.svg +1 -0
- package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
- package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
- package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
- package/herdr/mods/gentle-palette/icons/review.svg +1 -0
- package/herdr/mods/gentle-palette/icons/search.svg +1 -0
- package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
- package/herdr/mods/gentle-palette/icons/term.svg +1 -0
- package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
- package/herdr/mods/gentle-palette/main.js +333 -0
- package/herdr/mods/gentle-palette/mod.json +1 -0
- package/herdr/mods/gentle-palette/snapshot.js +469 -0
- package/herdr/mods/gentle-palette/tokens.js +273 -0
- package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
- package/herdr/mods/gentle-pane/icons/close.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
- package/herdr/mods/gentle-pane/icons/term.svg +1 -0
- package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
- package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
- package/herdr/mods/gentle-pane/main.js +91 -0
- package/herdr/mods/gentle-pane/mod.json +1 -0
- package/herdr/mods/gentle-pane/snapshot.js +469 -0
- package/herdr/mods/gentle-pane/tokens.js +273 -0
- package/herdr/mods/gentle-sidebar/actions.js +180 -0
- package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
- package/herdr/mods/gentle-sidebar/main.js +171 -0
- package/herdr/mods/gentle-sidebar/mod.json +1 -0
- package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
- package/herdr/mods/gentle-sidebar/tokens.js +273 -0
- package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
- package/herdr/mods/gentle-spaces/machines.js +31 -0
- package/herdr/mods/gentle-spaces/main.js +299 -0
- package/herdr/mods/gentle-spaces/mod.json +1 -0
- package/herdr/mods/gentle-spaces/snapshot.js +469 -0
- package/herdr/mods/gentle-spaces/tokens.js +273 -0
- package/herdr/mods/gentle-status/actions.js +180 -0
- package/herdr/mods/gentle-status/main.js +192 -0
- package/herdr/mods/gentle-status/mod.json +1 -0
- package/herdr/mods/gentle-status/snapshot.js +469 -0
- package/herdr/mods/gentle-status/tokens.js +273 -0
- package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
- package/herdr/mods/gentle-tabs/main.js +171 -0
- package/herdr/mods/gentle-tabs/mod.json +1 -0
- package/herdr/mods/gentle-tabs/snapshot.js +469 -0
- package/herdr/mods/gentle-tabs/tokens.js +273 -0
- package/herdr/mods/gentle-tokens/main.js +20 -0
- package/herdr/mods/gentle-tokens/mod.json +1 -0
- package/herdr/mods/gentle-tokens/snapshot.js +469 -0
- package/herdr/mods/gentle-tokens/tokens.js +273 -0
- package/herdr/preview.png +0 -0
- package/herdr/themes/gentle-shell-dark.json +33 -0
- package/herdr/themes/gentle-shell-light.json +34 -0
- package/lib/agents-protocol.ts +2 -0
- package/lib/agents-rpc-publisher.ts +39 -12
- package/lib/agents-runner.ts +1 -0
- package/lib/auto-permission-answers.ts +2 -1
- package/lib/background-jobs.ts +22 -2
- package/lib/bounded-writer-admission.ts +1 -1
- package/lib/change-diff.ts +104 -0
- package/lib/commit-slice-signal.ts +1 -1
- package/lib/design-canvas-assets.ts +2 -0
- package/lib/desktop-agents-service.ts +31 -10
- package/lib/desktop-changes-service.ts +171 -0
- package/lib/desktop-feed-actions.ts +804 -0
- package/lib/desktop-feed-answers.ts +129 -0
- package/lib/desktop-feed-sources.ts +184 -0
- package/lib/desktop-feed-stats.ts +98 -0
- package/lib/desktop-feed-store.ts +124 -0
- package/lib/desktop-feed.ts +788 -0
- package/lib/desktop-jobs-service.ts +34 -7
- package/lib/desktop-review-service.ts +187 -0
- package/lib/desktop-rpc-agents.ts +112 -3
- package/lib/desktop-rpc-changes.ts +223 -0
- package/lib/desktop-rpc-config-watch.ts +285 -0
- package/lib/desktop-rpc-config.ts +162 -8
- package/lib/desktop-rpc-jobs.ts +118 -9
- package/lib/desktop-rpc-permissions.ts +154 -3
- package/lib/desktop-rpc-review.ts +180 -0
- package/lib/desktop-rpc-session.ts +203 -0
- package/lib/desktop-rpc-sessions.ts +250 -0
- package/lib/desktop-rpc-stats.ts +187 -0
- package/lib/desktop-rpc-updates.ts +143 -0
- package/lib/desktop-rpc.ts +116 -5
- package/lib/desktop-session-service.ts +223 -0
- package/lib/desktop-sessions-service.ts +249 -0
- package/lib/desktop-stats-service.ts +142 -0
- package/lib/desktop-updates-service.ts +268 -0
- package/lib/gentle-shell-desktop.ts +1370 -0
- package/lib/gentle-shell-launcher.ts +45 -3
- package/lib/herdr-desktop-events.ts +40 -0
- package/lib/herdr-desktop-status.ts +229 -0
- package/lib/jobs-sidebar-state.ts +5 -0
- package/lib/native-review-cli.ts +7 -0
- package/lib/openai-fast-tier.ts +1 -0
- package/lib/session-profile-freeze.ts +13 -5
- package/lib/stats-collector.ts +56 -27
- package/lib/tower-actions.ts +100 -0
- package/lib/tower-hub.ts +73 -0
- package/lib/tower-launch.ts +111 -0
- package/lib/tower-open.ts +99 -0
- package/lib/tower-presence.ts +70 -0
- package/lib/tower-server.ts +234 -0
- package/lib/tower-snapshot.ts +298 -0
- package/lib/update-status.ts +238 -0
- package/lib/verifier-settle-reminder.ts +1 -1
- package/package.json +13 -4
- package/runtime/design-canvas-assets.mjs +2 -0
- package/runtime/gentle-shell-desktop.mjs +1371 -0
- package/runtime/gentle-shell-launcher.mjs +44 -2
- package/runtime/native-review-cli.mjs +7 -0
- package/runtime/tower-actions.mjs +101 -0
- package/runtime/tower-hub.mjs +74 -0
- package/runtime/tower-launch.mjs +112 -0
- package/runtime/tower-open.mjs +100 -0
- package/runtime/tower-presence.mjs +71 -0
- package/runtime/tower-server.mjs +234 -0
- package/runtime/tower-snapshot.mjs +299 -0
- package/scripts/build-full-delegation-card.mjs +1 -21
- package/scripts/build-runtime-modules.mjs +9 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/verify-package-files.mjs +35 -15
- package/skills/provider-defect-report/SKILL.md +61 -0
- package/skills/rdd-defect-workflow/SKILL.md +3 -3
- package/tests/agent-prompt-diet-contract.test.ts +2 -2
- package/tests/append-system-prompt-route.test.ts +16 -5
- package/tests/ask-user-choice.test.ts +78 -21
- package/tests/ask-user-question.test.ts +59 -5
- package/tests/auto-permission-answers.test.ts +12 -1
- package/tests/background-jobs.test.ts +12 -0
- package/tests/bounded-stop-contract.test.ts +139 -26
- package/tests/change-diff.test.ts +75 -0
- package/tests/commit-slice-signal.test.ts +3 -2
- package/tests/decision-routing-contract.test.ts +390 -0
- package/tests/delegated-key-learnings-contract.test.ts +21 -28
- package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
- package/tests/design-canvas-i18n.test.ts +24 -22
- package/tests/design-canvas-inspector.test.ts +67 -0
- package/tests/design-canvas-modules.test.ts +3 -2
- package/tests/design-canvas-rail.test.ts +10 -10
- package/tests/design-canvas-store.test.ts +9 -0
- package/tests/design-canvas-theme.test.ts +198 -0
- package/tests/design-canvas-tokens.test.ts +1 -1
- package/tests/desktop-feed-actions-guards.test.ts +595 -0
- package/tests/desktop-feed-actions.test.ts +761 -0
- package/tests/desktop-feed-live-work.test.ts +209 -0
- package/tests/desktop-feed-performance.test.ts +369 -0
- package/tests/desktop-feed-plan-profiles.test.ts +509 -0
- package/tests/desktop-feed-send-prompt.test.ts +303 -0
- package/tests/desktop-feed-tool-summaries.test.ts +69 -0
- package/tests/desktop-feed.test.ts +615 -0
- package/tests/desktop-rpc-agents.test.ts +428 -2
- package/tests/desktop-rpc-changes.test.ts +608 -0
- package/tests/desktop-rpc-config-watch.test.ts +1159 -0
- package/tests/desktop-rpc-config.test.ts +11 -1
- package/tests/desktop-rpc-design.test.ts +11 -1
- package/tests/desktop-rpc-jobs.test.ts +402 -5
- package/tests/desktop-rpc-permissions.test.ts +11 -1
- package/tests/desktop-rpc-review.test.ts +678 -0
- package/tests/desktop-rpc-session.test.ts +642 -0
- package/tests/desktop-rpc-sessions.test.ts +647 -0
- package/tests/desktop-rpc-stats.test.ts +431 -0
- package/tests/desktop-rpc-updates.test.ts +525 -0
- package/tests/desktop-rpc-usage.test.ts +11 -1
- package/tests/desktop-rpc.test.ts +43 -2
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +11 -13
- package/tests/fixtures/session-profile-v1/replay.ts +4 -1
- package/tests/full-delegation-closure.test.ts +20 -1
- package/tests/gentle-agents.test.ts +519 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-installer.test.ts +52 -52
- package/tests/gentle-ai.test.ts +75 -16
- package/tests/gentle-fast.test.ts +15 -0
- package/tests/gentle-herdr-desktop-status.test.ts +595 -0
- package/tests/gentle-shell-desktop-bin.test.ts +125 -0
- package/tests/gentle-shell-desktop.test.ts +927 -0
- package/tests/gentle-shell-launcher-tower.test.ts +104 -0
- package/tests/gentle-shell.test.ts +3 -0
- package/tests/gentle-tower.test.ts +578 -0
- package/tests/herdr-desktop-status.test.ts +285 -0
- package/tests/independent-recovery-delivery.test.ts +16 -4
- package/tests/installer-server.test.ts +2 -2
- package/tests/lazy-module-contradictions-contract.test.ts +27 -4
- package/tests/maintainer/desktop-rpc.maintest.ts +279 -4
- package/tests/native-review-capability-contract.test.ts +9 -1
- package/tests/no-self-pause-contract.test.ts +23 -13
- package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
- package/tests/odd-routing-contract.test.ts +19 -3
- package/tests/orchestrator-budget.test.ts +3 -1
- package/tests/orchestrator-prompt-budget.test.ts +2 -1
- package/tests/orchestrator-prompt-diet-contract.test.ts +31 -3
- package/tests/package-manifest.test.ts +10 -10
- package/tests/pi-routing-measured-values.test.ts +24 -0
- package/tests/primary-session-prompt.test.ts +25 -0
- package/tests/profile-fast-tier.test.ts +66 -1
- package/tests/provider-defect-handoff.test.ts +118 -100
- package/tests/review-contract-prompt.test.ts +2 -1
- package/tests/review-due-public-boundary.test.ts +2 -1
- package/tests/sensitive-path-tools.test.ts +138 -4
- package/tests/session-profile-extension.test.ts +310 -16
- package/tests/session-profile-freeze.test.ts +26 -0
- package/tests/session-profile-v1-compat.test.ts +20 -0
- package/tests/skill-collision-prefixes.test.ts +1 -0
- package/tests/skill-contradictions-contract.test.ts +5 -3
- package/tests/skill-registry.test.ts +54 -0
- package/tests/stats-collector.test.ts +109 -2
- package/tests/support/design-canvas-dom.ts +17 -0
- package/tests/task-size-routing-contract.test.ts +7 -3
- package/tests/tower-actions.test.ts +247 -0
- package/tests/tower-artifacts.test.ts +114 -0
- package/tests/tower-open.test.ts +97 -0
- package/tests/tower-presence.test.ts +175 -0
- package/tests/tower-server.test.ts +122 -0
- package/tests/tower-snapshot.test.ts +236 -0
- package/tests/tower-web-echo.test.ts +125 -0
- package/tests/tower-web-hover.test.ts +251 -0
- package/tests/verification-scoped-stop-contract.test.ts +32 -0
- package/tests/verification-tiers-contract.test.ts +5 -5
- package/tests/verifier-settle-reminder.test.ts +2 -2
- package/tests/verify-first-launch-contract.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +83 -17
- package/tests/writer-rejection-next-step.test.ts +55 -0
- package/tests/writer-surface-authority-contract.test.ts +158 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import { VERSION, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import desktopRpc from "../extensions/gentle-desktop-rpc.ts";
|
|
8
|
+
import { DESKTOP_RPC_SCHEMA } from "../lib/desktop-rpc.ts";
|
|
9
|
+
import {
|
|
10
|
+
DESKTOP_UPDATES_EVENTS,
|
|
11
|
+
DESKTOP_UPDATES_METHODS,
|
|
12
|
+
INVALID_UPDATES_PARAMS,
|
|
13
|
+
packageDisplayName,
|
|
14
|
+
parseUpdateStatusParams,
|
|
15
|
+
UPDATES_UNAVAILABLE,
|
|
16
|
+
type ShellChannel,
|
|
17
|
+
} from "../lib/desktop-rpc-updates.ts";
|
|
18
|
+
import { DesktopUpdatesBridge, resetUpdateStatusCacheForTesting, type UpdateSourcesFactory } from "../lib/desktop-updates-service.ts";
|
|
19
|
+
import { INTERACTIVE_HOST_ENV } from "../lib/rpc-host.ts";
|
|
20
|
+
import { defaultUpdateSources, packageKey, type ConfiguredPackageFacts, type UpdateSources } from "../lib/update-status.ts";
|
|
21
|
+
|
|
22
|
+
// get_update_status: a read over Gentle Shell's own channel/version resolution
|
|
23
|
+
// and Pi's own package update check. The transport tests inject fake sources
|
|
24
|
+
// (counting every lookup that would reach the network); the last tests run the
|
|
25
|
+
// real sources against a temporary agent dir, config files, and a fake fetch.
|
|
26
|
+
|
|
27
|
+
const NOW = Date.parse("2026-11-17T12:00:00.000Z");
|
|
28
|
+
const CACHED_AT = Date.parse("2026-11-16T08:00:00.000Z");
|
|
29
|
+
const SHA = "0123456789abcdef0123456789abcdef01234567";
|
|
30
|
+
|
|
31
|
+
function pkg(name: string, overrides: Partial<ConfiguredPackageFacts> = {}): ConfiguredPackageFacts {
|
|
32
|
+
return { key: packageKey("user", `npm:${name}`), name, kind: "npm", scope: "user", current: "1.0.0", pinned: false, checkable: true, ...overrides };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface FakeOptions {
|
|
36
|
+
offline?: boolean;
|
|
37
|
+
channel?: ShellChannel;
|
|
38
|
+
shellVersion?: string;
|
|
39
|
+
releaseCache?: { checkedAt: number; latest: string };
|
|
40
|
+
latestShell?: () => Promise<string>;
|
|
41
|
+
latestPi?: (() => Promise<string>) | undefined;
|
|
42
|
+
piVersion?: string;
|
|
43
|
+
packages?: ConfiguredPackageFacts[] | undefined;
|
|
44
|
+
checkPackages?: () => Promise<Set<string>>;
|
|
45
|
+
throwOnChannel?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function fakeSources(options: FakeOptions = {}) {
|
|
49
|
+
const calls = { network: 0, latestShell: 0, latestPi: 0, checkPackages: 0, factory: 0 };
|
|
50
|
+
const sources: UpdateSources = {
|
|
51
|
+
offline: options.offline ?? false,
|
|
52
|
+
now: () => NOW,
|
|
53
|
+
shellVersion: () => options.shellVersion ?? "4.8.0",
|
|
54
|
+
async shellChannel() {
|
|
55
|
+
if (options.throwOnChannel) throw new Error("C:\\Users\\secret\\channel.json is broken");
|
|
56
|
+
return options.channel ?? "release";
|
|
57
|
+
},
|
|
58
|
+
shellReleaseCache: () => ("releaseCache" in options ? options.releaseCache : undefined),
|
|
59
|
+
latestShell() {
|
|
60
|
+
calls.network += 1;
|
|
61
|
+
calls.latestShell += 1;
|
|
62
|
+
return options.latestShell ? options.latestShell() : Promise.resolve("4.9.0");
|
|
63
|
+
},
|
|
64
|
+
piVersion: () => options.piVersion ?? "1.5.2",
|
|
65
|
+
latestPi: "latestPi" in options && options.latestPi === undefined ? undefined : () => {
|
|
66
|
+
calls.network += 1;
|
|
67
|
+
calls.latestPi += 1;
|
|
68
|
+
return options.latestPi ? options.latestPi() : Promise.resolve("1.6.0");
|
|
69
|
+
},
|
|
70
|
+
packages: () => ("packages" in options ? options.packages : [pkg("alpha"), pkg("beta")]),
|
|
71
|
+
checkPackages() {
|
|
72
|
+
calls.network += 1;
|
|
73
|
+
calls.checkPackages += 1;
|
|
74
|
+
return options.checkPackages ? options.checkPackages() : Promise.resolve(new Set([packageKey("user", "npm:alpha")]));
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const factory: UpdateSourcesFactory = () => {
|
|
78
|
+
calls.factory += 1;
|
|
79
|
+
return sources;
|
|
80
|
+
};
|
|
81
|
+
return { factory, calls };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function interactiveHost(t: test.TestContext): void {
|
|
85
|
+
const previous = process.env[INTERACTIVE_HOST_ENV];
|
|
86
|
+
process.env[INTERACTIVE_HOST_ENV] = "1";
|
|
87
|
+
t.after(() => {
|
|
88
|
+
if (previous === undefined) delete process.env[INTERACTIVE_HOST_ENV];
|
|
89
|
+
else process.env[INTERACTIVE_HOST_ENV] = previous;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The real Desktop transport on one fake pi, with injected update sources. */
|
|
94
|
+
function harness(t: test.TestContext, factory?: UpdateSourcesFactory, timeoutMs?: number) {
|
|
95
|
+
interactiveHost(t);
|
|
96
|
+
resetUpdateStatusCacheForTesting();
|
|
97
|
+
t.after(resetUpdateStatusCacheForTesting);
|
|
98
|
+
const commands = new Map<string, { handler: (args: string, ctx: any) => Promise<void> }>();
|
|
99
|
+
const handlers = new Map<string, Array<(event: unknown, ctx: any) => unknown>>();
|
|
100
|
+
const pi = {
|
|
101
|
+
registerCommand(name: string, command: any) { commands.set(name, command); },
|
|
102
|
+
registerShortcut() {},
|
|
103
|
+
on(name: string, handler: any) { handlers.set(name, [...(handlers.get(name) ?? []), handler]); },
|
|
104
|
+
events: { on() { return () => {}; }, emit() {} },
|
|
105
|
+
} as unknown as ExtensionAPI;
|
|
106
|
+
desktopRpc(pi, { ...(factory ? { updateSources: factory } : {}), ...(timeoutMs === undefined ? {} : { updateTimeoutMs: timeoutMs }) });
|
|
107
|
+
const widgets: string[] = [];
|
|
108
|
+
const ctx = {
|
|
109
|
+
mode: "rpc",
|
|
110
|
+
cwd: "/home/devel/secret/project",
|
|
111
|
+
sessionManager: { getCwd: () => "/home/devel/secret/project", getSessionId: () => "session-a", getEntries: () => [] },
|
|
112
|
+
ui: { setWidget(_key: string, lines: string[]) { widgets.push(...lines); } },
|
|
113
|
+
};
|
|
114
|
+
for (const handler of handlers.get("session_start") ?? []) handler({}, ctx);
|
|
115
|
+
return {
|
|
116
|
+
widgets,
|
|
117
|
+
async fire(event: string) { for (const handler of handlers.get(event) ?? []) await handler({}, ctx); },
|
|
118
|
+
invoke(requestId: string, params: Record<string, unknown>, method = "get_update_status") {
|
|
119
|
+
return commands.get("gentle:desktop")!.handler(JSON.stringify({ schema: DESKTOP_RPC_SCHEMA, requestId, method, params }), ctx);
|
|
120
|
+
},
|
|
121
|
+
responses() { return widgets.map((line) => JSON.parse(line)); },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ---- Capabilities ----
|
|
126
|
+
|
|
127
|
+
test("the Desktop transport advertises get_update_status once and no new event", (t) => {
|
|
128
|
+
assert.deepEqual([...DESKTOP_UPDATES_METHODS], ["get_update_status"]);
|
|
129
|
+
assert.deepEqual([...DESKTOP_UPDATES_EVENTS], []);
|
|
130
|
+
const app = harness(t, fakeSources().factory);
|
|
131
|
+
void app.invoke("cap-1", {}, "capabilities");
|
|
132
|
+
const response = app.responses()[0];
|
|
133
|
+
assert.ok(response.data.methods.includes("get_update_status"));
|
|
134
|
+
assert.equal(response.data.methods.filter((method: string) => method === "get_update_status").length, 1);
|
|
135
|
+
assert.ok(response.data.methods.includes("get_usage_stats"), "the previous methods stay advertised");
|
|
136
|
+
assert.deepEqual(response.data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed"]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ---- Without refresh: cache only, no network ----
|
|
140
|
+
|
|
141
|
+
test("without refresh it answers from the launcher's recorded release lookup with no network work", async (t) => {
|
|
142
|
+
const fake = fakeSources({ releaseCache: { checkedAt: CACHED_AT, latest: "4.9.0" } });
|
|
143
|
+
const app = harness(t, fake.factory);
|
|
144
|
+
await app.invoke("upd-1", {});
|
|
145
|
+
const responses = app.responses();
|
|
146
|
+
assert.equal(responses.length, 1, "a read publishes its response and no event");
|
|
147
|
+
assert.equal(responses[0].kind, "response");
|
|
148
|
+
assert.equal(responses[0].requestId, "upd-1");
|
|
149
|
+
assert.equal(responses[0].ok, true);
|
|
150
|
+
assert.equal(fake.calls.network, 0);
|
|
151
|
+
assert.deepEqual(responses[0].data, {
|
|
152
|
+
refreshed: false,
|
|
153
|
+
offline: false,
|
|
154
|
+
gentleShell: { current: "4.8.0", latest: "4.9.0", channel: "release", state: "update_available", command: "gentle-shell upgrade", checkedAt: "2026-11-16T08:00:00.000Z" },
|
|
155
|
+
pi: { current: "1.5.2", latest: null, state: "unknown", command: "gentle-shell update", checkedAt: null },
|
|
156
|
+
packages: {
|
|
157
|
+
available: true,
|
|
158
|
+
items: [
|
|
159
|
+
{ name: "alpha", kind: "npm", scope: "user", current: "1.0.0", latest: null, pinned: false, state: "unknown" },
|
|
160
|
+
{ name: "beta", kind: "npm", scope: "user", current: "1.0.0", latest: null, pinned: false, state: "unknown" },
|
|
161
|
+
],
|
|
162
|
+
truncated: false,
|
|
163
|
+
command: "gentle-shell update --extensions",
|
|
164
|
+
checkedAt: null,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("an omitted or false refresh never looks anything up, and with no cache every latest is unknown", async (t) => {
|
|
170
|
+
const fake = fakeSources({ releaseCache: undefined });
|
|
171
|
+
const app = harness(t, fake.factory);
|
|
172
|
+
await app.invoke("upd-1", {});
|
|
173
|
+
await app.invoke("upd-2", { refresh: false });
|
|
174
|
+
const [first, second] = app.responses();
|
|
175
|
+
assert.equal(fake.calls.network, 0);
|
|
176
|
+
for (const response of [first, second]) {
|
|
177
|
+
assert.equal(response.data.gentleShell.latest, null);
|
|
178
|
+
assert.equal(response.data.gentleShell.state, "unknown");
|
|
179
|
+
assert.equal(response.data.gentleShell.checkedAt, null);
|
|
180
|
+
assert.equal(response.data.pi.state, "unknown");
|
|
181
|
+
assert.equal(response.data.refreshed, false);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// ---- refresh: true ----
|
|
186
|
+
|
|
187
|
+
test("refresh runs each lookup once, reports the check time, and later plain reads answer from that result", async (t) => {
|
|
188
|
+
const fake = fakeSources({ releaseCache: { checkedAt: CACHED_AT, latest: "4.7.0" } });
|
|
189
|
+
const app = harness(t, fake.factory);
|
|
190
|
+
await app.invoke("upd-refresh", { refresh: true });
|
|
191
|
+
await app.invoke("upd-cached", {});
|
|
192
|
+
const [refreshed, cached] = app.responses();
|
|
193
|
+
assert.equal(app.responses().length, 2, "no event");
|
|
194
|
+
assert.deepEqual({ latestShell: fake.calls.latestShell, latestPi: fake.calls.latestPi, checkPackages: fake.calls.checkPackages }, { latestShell: 1, latestPi: 1, checkPackages: 1 });
|
|
195
|
+
assert.equal(refreshed.data.refreshed, true);
|
|
196
|
+
assert.deepEqual(refreshed.data.gentleShell, { current: "4.8.0", latest: "4.9.0", channel: "release", state: "update_available", command: "gentle-shell upgrade", checkedAt: "2026-11-17T12:00:00.000Z" });
|
|
197
|
+
assert.deepEqual(refreshed.data.pi, { current: "1.5.2", latest: "1.6.0", state: "update_available", command: "gentle-shell update", checkedAt: "2026-11-17T12:00:00.000Z" });
|
|
198
|
+
assert.deepEqual(refreshed.data.packages.items.map((item: any) => [item.name, item.state]), [["alpha", "update_available"], ["beta", "no_update_reported"]]);
|
|
199
|
+
assert.equal(refreshed.data.packages.checkedAt, "2026-11-17T12:00:00.000Z");
|
|
200
|
+
// The plain read reuses the refresh in memory, over the older launcher record.
|
|
201
|
+
assert.equal(cached.data.refreshed, false);
|
|
202
|
+
assert.deepEqual(cached.data.gentleShell, refreshed.data.gentleShell);
|
|
203
|
+
assert.deepEqual(cached.data.pi, refreshed.data.pi);
|
|
204
|
+
assert.deepEqual(cached.data.packages, refreshed.data.packages);
|
|
205
|
+
assert.equal(fake.calls.network, 3, "the plain read did no network work");
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("an exact match is up_to_date only after a successful lookup", async (t) => {
|
|
209
|
+
const fake = fakeSources({ latestShell: async () => "4.8.0", latestPi: async () => "1.5.2", checkPackages: async () => new Set() });
|
|
210
|
+
const app = harness(t, fake.factory);
|
|
211
|
+
await app.invoke("upd-1", { refresh: true });
|
|
212
|
+
const data = app.responses()[0].data;
|
|
213
|
+
assert.equal(data.gentleShell.state, "up_to_date");
|
|
214
|
+
assert.equal(data.pi.state, "up_to_date");
|
|
215
|
+
// Pi's package check cannot tell a failed lookup from no update, so a
|
|
216
|
+
// package it did not list is never called up to date.
|
|
217
|
+
assert.deepEqual(data.packages.items.map((item: any) => item.state), ["no_update_reported", "no_update_reported"]);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("a newer local build or an incomparable version is unknown, never up to date", async (t) => {
|
|
221
|
+
const fake = fakeSources({ shellVersion: "4.10.0", latestShell: async () => "4.9.0", piVersion: "1.5.2-dev", latestPi: async () => "1.5.2" });
|
|
222
|
+
const app = harness(t, fake.factory);
|
|
223
|
+
await app.invoke("upd-1", { refresh: true });
|
|
224
|
+
const data = app.responses()[0].data;
|
|
225
|
+
assert.equal(data.gentleShell.state, "unknown");
|
|
226
|
+
assert.equal(data.pi.state, "unknown");
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("failed lookups report unknown with no latest, never up to date, and keep the last good result for plain reads", async (t) => {
|
|
230
|
+
let fail = false;
|
|
231
|
+
const fake = fakeSources({
|
|
232
|
+
latestShell: async () => { if (fail) throw new Error("ENOTFOUND registry.npmjs.org token=npm_secret"); return "4.8.0"; },
|
|
233
|
+
latestPi: async () => { if (fail) throw new Error("pnpm view failed"); return "1.5.2"; },
|
|
234
|
+
checkPackages: async () => { if (fail) throw new Error("npm view failed"); return new Set(); },
|
|
235
|
+
});
|
|
236
|
+
const app = harness(t, fake.factory);
|
|
237
|
+
await app.invoke("good", { refresh: true });
|
|
238
|
+
fail = true;
|
|
239
|
+
await app.invoke("bad", { refresh: true });
|
|
240
|
+
await app.invoke("plain", {});
|
|
241
|
+
const [good, bad, plain] = app.responses();
|
|
242
|
+
assert.equal(good.data.gentleShell.state, "up_to_date");
|
|
243
|
+
assert.equal(bad.ok, true);
|
|
244
|
+
assert.deepEqual(
|
|
245
|
+
{ shell: [bad.data.gentleShell.state, bad.data.gentleShell.latest, bad.data.gentleShell.checkedAt], pi: [bad.data.pi.state, bad.data.pi.latest, bad.data.pi.checkedAt] },
|
|
246
|
+
{ shell: ["unknown", null, null], pi: ["unknown", null, null] },
|
|
247
|
+
);
|
|
248
|
+
assert.deepEqual(bad.data.packages.items.map((item: any) => item.state), ["unknown", "unknown"]);
|
|
249
|
+
assert.equal(bad.data.packages.checkedAt, null);
|
|
250
|
+
assert.doesNotMatch(JSON.stringify(bad), /secret|ENOTFOUND|registry|pnpm view|npm view/);
|
|
251
|
+
// A plain read shows the last successful check with its own time.
|
|
252
|
+
assert.equal(plain.data.gentleShell.state, "up_to_date");
|
|
253
|
+
assert.equal(plain.data.gentleShell.checkedAt, "2026-11-17T12:00:00.000Z");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("a refresh is bounded by its deadline even when a lookup never settles", async (t) => {
|
|
257
|
+
const never = () => new Promise<never>(() => {});
|
|
258
|
+
const fake = fakeSources({ latestShell: never, latestPi: never, checkPackages: never });
|
|
259
|
+
const app = harness(t, fake.factory, 30);
|
|
260
|
+
const started = Date.now();
|
|
261
|
+
await app.invoke("upd-slow", { refresh: true });
|
|
262
|
+
assert.ok(Date.now() - started < 5_000, "the answer came back at the deadline");
|
|
263
|
+
const data = app.responses()[0].data;
|
|
264
|
+
assert.equal(data.refreshed, true);
|
|
265
|
+
assert.equal(data.gentleShell.state, "unknown");
|
|
266
|
+
assert.equal(data.pi.state, "unknown");
|
|
267
|
+
assert.deepEqual(data.packages.items.map((item: any) => item.state), ["unknown", "unknown"]);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("concurrent refreshes share one run of the lookups", async (t) => {
|
|
271
|
+
let release!: (value: string) => void;
|
|
272
|
+
const fake = fakeSources({ latestShell: () => new Promise<string>((resolve) => { release = resolve; }) });
|
|
273
|
+
const app = harness(t, fake.factory);
|
|
274
|
+
const first = app.invoke("upd-a", { refresh: true });
|
|
275
|
+
const second = app.invoke("upd-b", { refresh: true });
|
|
276
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
277
|
+
release("4.9.0");
|
|
278
|
+
await Promise.all([first, second]);
|
|
279
|
+
assert.equal(fake.calls.latestShell, 1);
|
|
280
|
+
assert.equal(fake.calls.checkPackages, 1);
|
|
281
|
+
const [a, b] = app.responses();
|
|
282
|
+
assert.deepEqual(a.data, b.data);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// ---- PI_OFFLINE ----
|
|
286
|
+
|
|
287
|
+
test("PI_OFFLINE: refresh does no network work and reports nothing as up to date", async (t) => {
|
|
288
|
+
const fake = fakeSources({ offline: true, releaseCache: { checkedAt: CACHED_AT, latest: "4.8.0" } });
|
|
289
|
+
const app = harness(t, fake.factory);
|
|
290
|
+
await app.invoke("offline-refresh", { refresh: true });
|
|
291
|
+
await app.invoke("offline-plain", {});
|
|
292
|
+
const [refresh, plain] = app.responses();
|
|
293
|
+
assert.equal(fake.calls.network, 0);
|
|
294
|
+
assert.equal(refresh.data.offline, true);
|
|
295
|
+
assert.equal(refresh.data.refreshed, false);
|
|
296
|
+
assert.deepEqual([refresh.data.gentleShell.state, refresh.data.gentleShell.latest], ["unknown", null]);
|
|
297
|
+
assert.equal(refresh.data.pi.state, "unknown");
|
|
298
|
+
assert.deepEqual(refresh.data.packages.items.map((item: any) => item.state), ["unknown", "unknown"]);
|
|
299
|
+
// A plain read still answers from the recorded lookup, dated, and flagged offline.
|
|
300
|
+
assert.equal(plain.data.offline, true);
|
|
301
|
+
assert.deepEqual([plain.data.gentleShell.state, plain.data.gentleShell.checkedAt], ["up_to_date", "2026-11-16T08:00:00.000Z"]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// ---- Channels and fixed commands ----
|
|
305
|
+
|
|
306
|
+
test("the main channel compares the latest main commit with the commit in the running version", async (t) => {
|
|
307
|
+
const current = fakeSources({ channel: "main", shellVersion: `4.8.0-main.${SHA.slice(0, 12)}`, latestShell: async () => SHA, releaseCache: { checkedAt: CACHED_AT, latest: "9.9.9" } });
|
|
308
|
+
const app = harness(t, current.factory);
|
|
309
|
+
await app.invoke("main-plain", {});
|
|
310
|
+
await app.invoke("main-current", { refresh: true });
|
|
311
|
+
const [plain, fresh] = app.responses();
|
|
312
|
+
assert.deepEqual([plain.data.gentleShell.latest, plain.data.gentleShell.state], [null, "unknown"], "the release record never answers for main");
|
|
313
|
+
assert.deepEqual(fresh.data.gentleShell, { current: `4.8.0-main.${SHA.slice(0, 12)}`, latest: SHA.slice(0, 12), channel: "main", state: "up_to_date", command: "gentle-shell upgrade --channel main", checkedAt: "2026-11-17T12:00:00.000Z" });
|
|
314
|
+
|
|
315
|
+
const behind = fakeSources({ channel: "main", shellVersion: "4.8.0-main.ffffffffffff", latestShell: async () => SHA });
|
|
316
|
+
const other = harness(t, behind.factory);
|
|
317
|
+
await other.invoke("main-behind", { refresh: true });
|
|
318
|
+
assert.equal(other.responses()[0].data.gentleShell.state, "update_available");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("each install channel carries its fixed command, and an unknown channel looks nothing up", async (t) => {
|
|
322
|
+
const expected: Record<ShellChannel, string | null> = {
|
|
323
|
+
release: "gentle-shell upgrade",
|
|
324
|
+
main: "gentle-shell upgrade --channel main",
|
|
325
|
+
bundled: "gentle-shell upgrade",
|
|
326
|
+
"gentle-ai-managed": "gentle-shell update --extensions",
|
|
327
|
+
unknown: null,
|
|
328
|
+
};
|
|
329
|
+
for (const [channel, command] of Object.entries(expected) as Array<[ShellChannel, string | null]>) {
|
|
330
|
+
const fake = fakeSources({ channel });
|
|
331
|
+
const app = harness(t, fake.factory);
|
|
332
|
+
await app.invoke(`ch-${channel}`, { refresh: true });
|
|
333
|
+
const shell = app.responses()[0].data.gentleShell;
|
|
334
|
+
assert.equal(shell.channel, channel);
|
|
335
|
+
assert.equal(shell.command, command);
|
|
336
|
+
if (channel === "unknown") {
|
|
337
|
+
assert.equal(fake.calls.latestShell, 0);
|
|
338
|
+
assert.deepEqual([shell.state, shell.latest], ["unknown", null]);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("a Pi with no reachable latest-version source stays unknown and is never looked up", async (t) => {
|
|
344
|
+
const fake = fakeSources({ latestPi: undefined });
|
|
345
|
+
const app = harness(t, fake.factory);
|
|
346
|
+
await app.invoke("pi-1", { refresh: true });
|
|
347
|
+
const pi = app.responses()[0].data.pi;
|
|
348
|
+
assert.deepEqual(pi, { current: "1.5.2", latest: null, state: "unknown", command: "gentle-shell update", checkedAt: null });
|
|
349
|
+
assert.equal(fake.calls.latestPi, 0);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ---- Packages ----
|
|
353
|
+
|
|
354
|
+
test("packages: Pi's skipped kinds, project scope, unknown sources, and the wire carries no source text", async (t) => {
|
|
355
|
+
const packages = [
|
|
356
|
+
pkg("alpha"),
|
|
357
|
+
pkg("pinned", { key: packageKey("user", "npm:pinned@1.2.3"), pinned: true, checkable: false, current: "1.2.3" }),
|
|
358
|
+
pkg("github.com/user/repo", { key: packageKey("project", "git:https://ghp_secret@github.com/user/repo"), kind: "git", scope: "project", current: null, checkable: true }),
|
|
359
|
+
pkg("my-ext", { key: packageKey("user", "C:\\Users\\secret\\my-ext"), kind: "local", current: null, pinned: null, checkable: false }),
|
|
360
|
+
pkg("missing", { key: packageKey("user", "npm:missing"), current: null, checkable: false }),
|
|
361
|
+
pkg("unknown", { key: packageKey("user", "weird"), kind: "unknown", current: null, pinned: null, checkable: false }),
|
|
362
|
+
];
|
|
363
|
+
const fake = fakeSources({ packages, checkPackages: async () => new Set([packageKey("project", "git:https://ghp_secret@github.com/user/repo")]) });
|
|
364
|
+
const app = harness(t, fake.factory);
|
|
365
|
+
await app.invoke("pkg-1", { refresh: true });
|
|
366
|
+
const data = app.responses()[0].data;
|
|
367
|
+
assert.deepEqual(data.packages.items, [
|
|
368
|
+
{ name: "alpha", kind: "npm", scope: "user", current: "1.0.0", latest: null, pinned: false, state: "no_update_reported" },
|
|
369
|
+
{ name: "pinned", kind: "npm", scope: "user", current: "1.2.3", latest: null, pinned: true, state: "skipped" },
|
|
370
|
+
{ name: "github.com/user/repo", kind: "git", scope: "project", current: null, latest: null, pinned: false, state: "update_available" },
|
|
371
|
+
{ name: "my-ext", kind: "local", scope: "user", current: null, latest: null, pinned: null, state: "skipped" },
|
|
372
|
+
{ name: "missing", kind: "npm", scope: "user", current: null, latest: null, pinned: false, state: "skipped" },
|
|
373
|
+
{ name: "unknown", kind: "unknown", scope: "user", current: null, latest: null, pinned: null, state: "unknown" },
|
|
374
|
+
]);
|
|
375
|
+
assert.doesNotMatch(JSON.stringify(data), /ghp_secret|https:|C:\\\\|secret|npm:|key/);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
test("packages are bounded to 100 rows with truncated, and an unreadable listing is available: false", async (t) => {
|
|
379
|
+
const many = Array.from({ length: 105 }, (_, index) => pkg(`p${String(index).padStart(3, "0")}`, { key: packageKey("user", `npm:p${index}`) }));
|
|
380
|
+
const app = harness(t, fakeSources({ packages: many }).factory);
|
|
381
|
+
await app.invoke("many", {});
|
|
382
|
+
const data = app.responses()[0].data;
|
|
383
|
+
assert.equal(data.packages.items.length, 100);
|
|
384
|
+
assert.equal(data.packages.items[99].name, "p099");
|
|
385
|
+
assert.equal(data.packages.truncated, true);
|
|
386
|
+
|
|
387
|
+
const broken = harness(t, fakeSources({ packages: undefined }).factory);
|
|
388
|
+
await broken.invoke("broken", {});
|
|
389
|
+
assert.deepEqual(broken.responses()[0].data.packages, { available: false, items: [], truncated: false, command: "gentle-shell update --extensions", checkedAt: null });
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("package names are display names only: no path, URL, or credential", () => {
|
|
393
|
+
assert.equal(packageDisplayName("npm", "@scope/pkg"), "@scope/pkg");
|
|
394
|
+
assert.equal(packageDisplayName("git", "github.com/user/repo"), "github.com/user/repo");
|
|
395
|
+
assert.equal(packageDisplayName("git", "token@github.com/user/repo"), "unknown");
|
|
396
|
+
assert.equal(packageDisplayName("local", "/home/devel/secret/my-ext"), "my-ext");
|
|
397
|
+
assert.equal(packageDisplayName("local", "C:\\Users\\secret\\my-ext\\"), "my-ext");
|
|
398
|
+
assert.equal(packageDisplayName("npm", "https://registry.example/x"), "unknown");
|
|
399
|
+
assert.equal(packageDisplayName("npm", undefined), "unknown");
|
|
400
|
+
assert.equal(packageDisplayName("npm", "x".repeat(200)).length, 128);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// ---- Params, absence, and failures ----
|
|
404
|
+
|
|
405
|
+
test("params: only an optional boolean refresh; anything else is invalid_request before any source work", async (t) => {
|
|
406
|
+
assert.deepEqual(parseUpdateStatusParams({}), { refresh: false });
|
|
407
|
+
assert.deepEqual(parseUpdateStatusParams({ refresh: true }), { refresh: true });
|
|
408
|
+
const fake = fakeSources();
|
|
409
|
+
const app = harness(t, fake.factory);
|
|
410
|
+
const bad = [{ refresh: "yes" }, { refresh: null }, { refresh: 1 }, { force: true }, { refresh: true, extra: 1 }];
|
|
411
|
+
for (const [index, params] of bad.entries()) await app.invoke(`bad-${index}`, params);
|
|
412
|
+
for (const response of app.responses()) {
|
|
413
|
+
assert.equal(response.ok, false);
|
|
414
|
+
assert.deepEqual(response.error, INVALID_UPDATES_PARAMS);
|
|
415
|
+
}
|
|
416
|
+
assert.equal(fake.calls.factory, 0, "no source was even created");
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test("updates_unavailable without a bound session, on a source failure, and for a read a reset superseded", async (t) => {
|
|
420
|
+
resetUpdateStatusCacheForTesting();
|
|
421
|
+
t.after(resetUpdateStatusCacheForTesting);
|
|
422
|
+
const unbound = new DesktopUpdatesBridge({ sources: fakeSources().factory });
|
|
423
|
+
assert.deepEqual(await unbound.handle("get_update_status", {}), { ok: false, error: UPDATES_UNAVAILABLE });
|
|
424
|
+
assert.equal(await unbound.handle("get_usage_stats", {}), undefined, "other methods fall through");
|
|
425
|
+
|
|
426
|
+
const app = harness(t, fakeSources({ throwOnChannel: true }).factory);
|
|
427
|
+
await app.invoke("throws", {});
|
|
428
|
+
const response = app.responses()[0];
|
|
429
|
+
assert.deepEqual([response.ok, response.error], [false, UPDATES_UNAVAILABLE]);
|
|
430
|
+
assert.doesNotMatch(JSON.stringify(response), /secret|channel\.json/);
|
|
431
|
+
|
|
432
|
+
let release!: (value: string) => void;
|
|
433
|
+
const slow = fakeSources({ latestShell: () => new Promise<string>((resolve) => { release = resolve; }) });
|
|
434
|
+
const bridge = new DesktopUpdatesBridge({ sources: slow.factory });
|
|
435
|
+
bridge.attach({ cwd: "/x" } as unknown as ExtensionContext);
|
|
436
|
+
const pending = bridge.handle("get_update_status", { refresh: true });
|
|
437
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
438
|
+
bridge.reset();
|
|
439
|
+
release("4.9.0");
|
|
440
|
+
assert.deepEqual(await pending, { ok: false, error: UPDATES_UNAVAILABLE });
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
test("a session shutdown leaves the transport answering nothing", async (t) => {
|
|
444
|
+
const app = harness(t, fakeSources().factory);
|
|
445
|
+
await app.fire("session_shutdown");
|
|
446
|
+
await app.invoke("after-shutdown", {});
|
|
447
|
+
assert.equal(app.responses().length, 0);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// ---- The real sources ----
|
|
451
|
+
|
|
452
|
+
function realFixture(t: test.TestContext) {
|
|
453
|
+
const root = mkdtempSync(join(tmpdir(), "desktop-rpc-updates-"));
|
|
454
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
455
|
+
const agentDir = join(root, "agent");
|
|
456
|
+
const installed = (name: string, version: string) => {
|
|
457
|
+
const dir = join(agentDir, "npm", "node_modules", name);
|
|
458
|
+
mkdirSync(dir, { recursive: true });
|
|
459
|
+
writeFileSync(join(dir, "package.json"), JSON.stringify({ name, version }));
|
|
460
|
+
};
|
|
461
|
+
installed("alpha", "1.4.0");
|
|
462
|
+
installed("pinned", "2.0.0");
|
|
463
|
+
mkdirSync(join(root, "local-ext"), { recursive: true });
|
|
464
|
+
writeFileSync(join(agentDir, "settings.json"), JSON.stringify({ packages: ["npm:alpha", "npm:pinned@2.0.0", join(root, "local-ext")] }));
|
|
465
|
+
const configHome = join(root, "config");
|
|
466
|
+
mkdirSync(configHome, { recursive: true });
|
|
467
|
+
const launcherConfig = join(root, "launcher.json");
|
|
468
|
+
writeFileSync(launcherConfig, JSON.stringify({ startupReleaseCheck: { checkedAt: "2026-11-16T08:00:00.000Z", latest: "4.9.0" } }));
|
|
469
|
+
const previous = process.env.PI_CODING_AGENT_DIR;
|
|
470
|
+
process.env.PI_CODING_AGENT_DIR = agentDir;
|
|
471
|
+
t.after(() => {
|
|
472
|
+
if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR;
|
|
473
|
+
else process.env.PI_CODING_AGENT_DIR = previous;
|
|
474
|
+
});
|
|
475
|
+
return { root, configHome, launcherConfig, project: join(root, "project") };
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
test("real sources: Pi's listing, the launcher's release record, the channel record, and Pi's VERSION", async (t) => {
|
|
479
|
+
const fixture = realFixture(t);
|
|
480
|
+
const requests: string[] = [];
|
|
481
|
+
const fetch = (async (url: string) => {
|
|
482
|
+
requests.push(url);
|
|
483
|
+
return new Response(JSON.stringify({ version: "4.9.1" }), { status: 200 });
|
|
484
|
+
}) as typeof globalThis.fetch;
|
|
485
|
+
const env = { GENTLE_PI_CONFIG_HOME: fixture.configHome, GENTLE_SHELL_CONFIG: fixture.launcherConfig };
|
|
486
|
+
const sources = defaultUpdateSources({ cwd: fixture.project, env, home: fixture.root, fetch });
|
|
487
|
+
|
|
488
|
+
assert.equal(sources.offline, false);
|
|
489
|
+
assert.equal(sources.piVersion(), VERSION);
|
|
490
|
+
assert.match(sources.shellVersion() ?? "", /^\d+\.\d+\.\d+/);
|
|
491
|
+
assert.equal(sources.latestPi, undefined, "outside a bundled install no existing source names the latest Pi");
|
|
492
|
+
assert.equal(await sources.shellChannel(), "release", "no channel record means release");
|
|
493
|
+
assert.deepEqual(sources.shellReleaseCache(), { checkedAt: Date.parse("2026-11-16T08:00:00.000Z"), latest: "4.9.0" });
|
|
494
|
+
const facts = sources.packages()!;
|
|
495
|
+
assert.deepEqual(facts.map(({ key: _key, ...fact }) => fact), [
|
|
496
|
+
{ name: "alpha", kind: "npm", scope: "user", current: "1.4.0", pinned: false, checkable: true },
|
|
497
|
+
{ name: "pinned", kind: "npm", scope: "user", current: "2.0.0", pinned: true, checkable: false },
|
|
498
|
+
{ name: "local-ext", kind: "local", scope: "user", current: null, pinned: null, checkable: false },
|
|
499
|
+
]);
|
|
500
|
+
assert.equal(requests.length, 0, "every read above was local");
|
|
501
|
+
assert.equal(await sources.latestShell("release", new AbortController().signal), "4.9.1");
|
|
502
|
+
assert.deepEqual(requests, ["https://registry.npmjs.org/gentle-pi/latest"]);
|
|
503
|
+
|
|
504
|
+
writeFileSync(join(fixture.configHome, "channel.json"), JSON.stringify({ schema: "gentle-shell.channel/v1", channel: "main", shellCommit: SHA, gentleAiCommit: SHA }));
|
|
505
|
+
assert.equal(await sources.shellChannel(), "main");
|
|
506
|
+
writeFileSync(join(fixture.configHome, "channel.json"), "not json");
|
|
507
|
+
assert.equal(await sources.shellChannel(), "unknown", "a malformed channel record is never guessed");
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test("real sources: PI_OFFLINE makes Pi's own package check report nothing, so the answer stays unknown", async (t) => {
|
|
511
|
+
const fixture = realFixture(t);
|
|
512
|
+
const sources = defaultUpdateSources({ cwd: fixture.project, env: { PI_OFFLINE: "1", GENTLE_SHELL_CONFIG: fixture.launcherConfig, GENTLE_PI_CONFIG_HOME: fixture.configHome }, home: fixture.root, fetch: (() => { throw new Error("no network"); }) as typeof globalThis.fetch });
|
|
513
|
+
assert.equal(sources.offline, true);
|
|
514
|
+
const bridge = new DesktopUpdatesBridge({ sources: () => sources });
|
|
515
|
+
resetUpdateStatusCacheForTesting();
|
|
516
|
+
t.after(resetUpdateStatusCacheForTesting);
|
|
517
|
+
bridge.attach({ cwd: fixture.project } as unknown as ExtensionContext);
|
|
518
|
+
const outcome = await bridge.handle("get_update_status", { refresh: true });
|
|
519
|
+
assert.equal(outcome?.ok, true);
|
|
520
|
+
const data = (outcome as { data: any }).data;
|
|
521
|
+
assert.equal(data.offline, true);
|
|
522
|
+
assert.equal(data.refreshed, false);
|
|
523
|
+
assert.deepEqual(data.packages.items.map((item: any) => [item.name, item.state]), [["alpha", "unknown"], ["pinned", "skipped"], ["local-ext", "skipped"]]);
|
|
524
|
+
assert.doesNotMatch(JSON.stringify(data), new RegExp(fixture.root.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/\\\\/g, "[\\\\/]+")));
|
|
525
|
+
});
|
|
@@ -663,11 +663,21 @@ test("the Desktop transport advertises the usage methods and rate_limit event",
|
|
|
663
663
|
"get_design_canvas",
|
|
664
664
|
"list_jobs",
|
|
665
665
|
"cancel_job",
|
|
666
|
+
"get_job_output",
|
|
666
667
|
"apply_profile",
|
|
667
668
|
"list_subagents",
|
|
668
669
|
"cancel_subagent",
|
|
670
|
+
"get_subagent_thread",
|
|
671
|
+
"list_sessions",
|
|
672
|
+
"switch_session",
|
|
673
|
+
"get_changes",
|
|
674
|
+
"get_change_diff",
|
|
675
|
+
"get_review_mode",
|
|
676
|
+
"set_review_mode",
|
|
677
|
+
"get_usage_stats",
|
|
678
|
+
"get_update_status",
|
|
669
679
|
]);
|
|
670
|
-
assert.deepEqual(response.data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update"]);
|
|
680
|
+
assert.deepEqual(response.data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed"]);
|
|
671
681
|
});
|
|
672
682
|
|
|
673
683
|
test("get_subscription_usage answers usage_unavailable through the transport without an owner extension", async (t) => {
|
|
@@ -66,8 +66,8 @@ test("capabilities and snapshots use correlated structured responses", async (t)
|
|
|
66
66
|
schema: DESKTOP_RPC_SCHEMA,
|
|
67
67
|
command: "gentle:desktop",
|
|
68
68
|
widget: DESKTOP_RPC_WIDGET,
|
|
69
|
-
methods: ["capabilities", "get_snapshot", "get_config", "set_config", "get_permission_mode", "set_permission_mode", "get_subscription_usage", "refresh_subscription_usage", "get_design_canvas", "list_jobs", "cancel_job", "apply_profile", "list_subagents", "cancel_subagent"],
|
|
70
|
-
events: ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update"],
|
|
69
|
+
methods: ["capabilities", "get_snapshot", "get_config", "set_config", "get_permission_mode", "set_permission_mode", "get_subscription_usage", "refresh_subscription_usage", "get_design_canvas", "list_jobs", "cancel_job", "get_job_output", "apply_profile", "list_subagents", "cancel_subagent", "get_subagent_thread", "list_sessions", "switch_session", "get_changes", "get_change_diff", "get_review_mode", "set_review_mode", "get_usage_stats", "get_update_status"],
|
|
70
|
+
events: ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed"],
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
73
|
|
|
@@ -250,3 +250,44 @@ test("TUI and headless RPC sessions do not activate the Desktop channel", async
|
|
|
250
250
|
await app.invoke(request("capabilities"));
|
|
251
251
|
assert.equal(app.widgets.length, 0);
|
|
252
252
|
});
|
|
253
|
+
|
|
254
|
+
test("a router gate refuses a request synchronously before any domain work", async () => {
|
|
255
|
+
const lines: string[] = [];
|
|
256
|
+
const calls: string[] = [];
|
|
257
|
+
const domain: DesktopRpcDomain = (method) => { calls.push(method); return { ok: true, data: {} }; };
|
|
258
|
+
const router = new DesktopRpcRouter(["capabilities", "get_snapshot", "set_permission_mode"], [], undefined, domain);
|
|
259
|
+
router.start((line) => lines.push(line));
|
|
260
|
+
router.setGate(() => ({ code: "session_switching", message: "busy" }));
|
|
261
|
+
router.handle(JSON.stringify(request("set_permission_mode", { mode: "auto" })));
|
|
262
|
+
router.handle(JSON.stringify(request("capabilities")));
|
|
263
|
+
router.handle(JSON.stringify({ ...request("capabilities"), method: "unknown" }));
|
|
264
|
+
assert.deepEqual(calls, [], "no domain call while gated");
|
|
265
|
+
assert.deepEqual(lines.map((line) => JSON.parse(line).error.code), ["session_switching", "session_switching", "unsupported_method"]);
|
|
266
|
+
|
|
267
|
+
router.setGate(undefined);
|
|
268
|
+
await router.handle(JSON.stringify(request("set_permission_mode", { mode: "auto" })));
|
|
269
|
+
assert.deepEqual(calls, ["set_permission_mode"], "an open gate dispatches as before");
|
|
270
|
+
assert.equal(JSON.parse(lines.at(-1)!).ok, true);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test("abandonPending answers each pending request once, keeps the named one, and drops their late outcomes", async () => {
|
|
274
|
+
const lines: string[] = [];
|
|
275
|
+
const resolvers = new Map<string, (outcome: DesktopRpcOutcome) => void>();
|
|
276
|
+
const domain: DesktopRpcDomain = (_method, params) => new Promise((resolve) => resolvers.set(String(params.tag), resolve));
|
|
277
|
+
const router = new DesktopRpcRouter(["capabilities", "get_snapshot", "slow"], [], undefined, domain);
|
|
278
|
+
router.start((line) => lines.push(line));
|
|
279
|
+
const first = router.handle(JSON.stringify({ ...request("slow", { tag: "a" }), requestId: "req-a" }));
|
|
280
|
+
const kept = router.handle(JSON.stringify({ ...request("slow", { tag: "b" }), requestId: "req-b" }));
|
|
281
|
+
router.abandonPending({ code: "session_switching", message: "busy" }, (requestId) => requestId === "req-b");
|
|
282
|
+
assert.deepEqual(lines.map((line) => [JSON.parse(line).requestId, JSON.parse(line).error.code]), [["req-a", "session_switching"]]);
|
|
283
|
+
|
|
284
|
+
resolvers.get("a")!({ ok: true, data: { late: true } });
|
|
285
|
+
resolvers.get("b")!({ ok: true, data: { kept: true } });
|
|
286
|
+
await Promise.all([first, kept]);
|
|
287
|
+
assert.deepEqual(lines.map((line) => JSON.parse(line).requestId), ["req-a", "req-b"], "the abandoned request never answers twice");
|
|
288
|
+
assert.deepEqual(JSON.parse(lines[1]!).data, { kept: true });
|
|
289
|
+
|
|
290
|
+
router.stop();
|
|
291
|
+
router.abandonPending({ code: "session_switching", message: "busy" });
|
|
292
|
+
assert.equal(lines.length, 2, "a stopped router answers nothing");
|
|
293
|
+
});
|