@pugi/cli 0.1.0-beta.9 → 0.1.0-beta.90
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/CHANGELOG.md +132 -0
- package/LICENSE +1 -1
- package/assets/pugi-prozr2-mascot.ansi +9 -0
- package/bin/run.js +33 -1
- package/dist/commands/deploy.js +40 -40
- package/dist/commands/flatten.js +191 -0
- package/dist/commands/jobs-watch.js +201 -0
- package/dist/commands/jobs.js +42 -27
- package/dist/commands/smoke.js +133 -0
- package/dist/core/agent-progress/cleanup.js +134 -0
- package/dist/core/agent-progress/schema.js +144 -0
- package/dist/core/agent-progress/writer.js +101 -0
- package/dist/core/agents/adaptive-router.js +330 -0
- package/dist/core/agents/query-decomposer.js +297 -0
- package/dist/core/agents/registry.js +3 -3
- package/dist/core/approvals/shortcut-resolver.js +98 -0
- package/dist/core/artifact-chain/dispatcher.js +148 -0
- package/dist/core/artifact-chain/exporter.js +164 -0
- package/dist/core/artifact-chain/state.js +243 -0
- package/dist/core/artifact-chain/steps.js +169 -0
- package/dist/core/ask-user/question.js +92 -0
- package/dist/core/audit/audit-trail.js +275 -0
- package/dist/core/auth/ensure-authenticated.js +129 -0
- package/dist/core/auth/env-provider.js +238 -0
- package/dist/core/auto-open-browser.js +4 -4
- package/dist/core/auto-update/channels.js +122 -0
- package/dist/core/auto-update/checker.js +241 -0
- package/dist/core/auto-update/state.js +235 -0
- package/dist/core/bare-mode/index.js +107 -0
- package/dist/core/bash/redirect.js +281 -0
- package/dist/core/bash-classifier.js +436 -40
- package/dist/core/checkpoint/resumer.js +149 -0
- package/dist/core/checkpoint/rewinder.js +291 -0
- package/dist/core/checkpoints/shadow-git.js +670 -0
- package/dist/core/citations/parser.js +109 -0
- package/dist/core/classifier/yolo-classifier.js +88 -0
- package/dist/core/codegraph/decision-store.js +248 -0
- package/dist/core/codegraph/detect-repo.js +459 -0
- package/dist/core/codegraph/install.js +134 -0
- package/dist/core/codegraph/offer-hook.js +220 -0
- package/dist/core/compact/auto-trigger.js +96 -0
- package/dist/core/compact/buffer-rewriter.js +115 -0
- package/dist/core/compact/summarizer.js +208 -0
- package/dist/core/compact/token-counter.js +108 -0
- package/dist/core/consensus/anvil-fanout.js +25 -25
- package/dist/core/consensus/diff-capture.js +121 -12
- package/dist/core/consensus/rubric.js +21 -21
- package/dist/core/context/builder.js +6 -6
- package/dist/core/context/compaction-events.js +8 -8
- package/dist/core/context/compaction.js +31 -31
- package/dist/core/context/index.js +15 -8
- package/dist/core/context/invariants.js +51 -51
- package/dist/core/context/markdown-loader.js +28 -10
- package/dist/core/context/markdown-traverse.js +255 -0
- package/dist/core/context/pugiignore.js +41 -41
- package/dist/core/context/repo-skeleton.js +37 -37
- package/dist/core/context/tool-eviction.js +55 -0
- package/dist/core/context/watcher.js +32 -32
- package/dist/core/context/working-set.js +23 -23
- package/dist/core/coordinator/agent-tools.js +77 -0
- package/dist/core/coordinator/agent-toolset.js +65 -0
- package/dist/core/coordinator/fsm.js +73 -0
- package/dist/core/coordinator/mode-fsm.js +70 -0
- package/dist/core/cost/rate-card.js +129 -0
- package/dist/core/cost/tracker.js +221 -0
- package/dist/core/credentials.js +13 -13
- package/dist/core/cron/scheduler.js +138 -0
- package/dist/core/denial-tracking/index.js +8 -0
- package/dist/core/denial-tracking/state.js +264 -0
- package/dist/core/diagnostics/probe-runner.js +93 -0
- package/dist/core/diagnostics/probes/api.js +46 -0
- package/dist/core/diagnostics/probes/auth.js +93 -0
- package/dist/core/diagnostics/probes/bare-mode.js +42 -0
- package/dist/core/diagnostics/probes/cli-version.js +127 -0
- package/dist/core/diagnostics/probes/config.js +72 -0
- package/dist/core/diagnostics/probes/denial-tracking.js +57 -0
- package/dist/core/diagnostics/probes/disk.js +81 -0
- package/dist/core/diagnostics/probes/engine-live.js +46 -0
- package/dist/core/diagnostics/probes/git.js +65 -0
- package/dist/core/diagnostics/probes/hooks.js +118 -0
- package/dist/core/diagnostics/probes/mcp.js +75 -0
- package/dist/core/diagnostics/probes/node.js +59 -0
- package/dist/core/diagnostics/probes/pnpm.js +36 -0
- package/dist/core/diagnostics/probes/pugi-md.js +89 -0
- package/dist/core/diagnostics/probes/sandbox.js +40 -0
- package/dist/core/diagnostics/probes/session.js +74 -0
- package/dist/core/diagnostics/probes/status-snapshot.js +488 -0
- package/dist/core/diagnostics/probes/workspace.js +63 -0
- package/dist/core/diagnostics/types.js +70 -0
- package/dist/core/dispatch/cache-cleanup.js +197 -0
- package/dist/core/dispatch/cache-handoff.js +295 -0
- package/dist/core/edits/apply-patch-layer-e.js +189 -0
- package/dist/core/edits/dispatch.js +333 -7
- package/dist/core/edits/format-detector.js +260 -0
- package/dist/core/edits/format-matrix.js +26 -0
- package/dist/core/edits/fuzzy-ladder.js +650 -0
- package/dist/core/edits/index.js +5 -1
- package/dist/core/edits/journal.js +199 -0
- package/dist/core/edits/layer-a-apply.js +15 -15
- package/dist/core/edits/layer-a-fuzzy-apply.js +198 -0
- package/dist/core/edits/layer-b-apply.js +9 -9
- package/dist/core/edits/layer-c-apply.js +6 -6
- package/dist/core/edits/layer-d-ast.js +557 -14
- package/dist/core/edits/marker-parser.js +12 -12
- package/dist/core/edits/security-gate.js +27 -27
- package/dist/core/edits/verify-hook.js +273 -0
- package/dist/core/edits/worktree.js +29 -29
- package/dist/core/engine/anvil-client.js +214 -26
- package/dist/core/engine/auto-compact.js +179 -0
- package/dist/core/engine/budgets.js +186 -0
- package/dist/core/engine/context-prefix.js +155 -0
- package/dist/core/engine/index.js +1 -1
- package/dist/core/engine/intensity.js +158 -0
- package/dist/core/engine/intent.js +260 -0
- package/dist/core/engine/native-pugi.js +1295 -227
- package/dist/core/engine/prompts.js +129 -19
- package/dist/core/engine/strip-internal-fields.js +124 -0
- package/dist/core/engine/tool-bridge.js +1731 -59
- package/dist/core/evaluation/golden-dataset.js +293 -0
- package/dist/core/feedback/queue.js +177 -0
- package/dist/core/feedback/submitter.js +145 -0
- package/dist/core/file-cache.js +113 -1
- package/dist/core/flatten/flatten-repo.js +439 -0
- package/dist/core/format/osc8-link.js +28 -0
- package/dist/core/hook-chains.js +392 -0
- package/dist/core/hooks/citation-verify-hook.js +138 -0
- package/dist/core/hooks/citation-verify.js +112 -0
- package/dist/core/hooks/events.js +46 -0
- package/dist/core/hooks/index.js +15 -0
- package/dist/core/hooks/registry.js +216 -0
- package/dist/core/hooks/runner.js +236 -0
- package/dist/core/hooks/v2/event-emitter.js +115 -0
- package/dist/core/hooks/v2/executor.js +282 -0
- package/dist/core/hooks/v2/index.js +25 -0
- package/dist/core/hooks/v2/lifecycle.js +104 -0
- package/dist/core/hooks/v2/loader.js +216 -0
- package/dist/core/hooks/v2/matcher.js +125 -0
- package/dist/core/hooks/v2/trust.js +143 -0
- package/dist/core/hooks/v2/types.js +86 -0
- package/dist/core/hooks/worktree-events.js +158 -0
- package/dist/core/image/renderer.js +71 -0
- package/dist/core/init/detector.js +582 -0
- package/dist/core/init/template-renderer.js +242 -0
- package/dist/core/jobs/registry.js +18 -18
- package/dist/core/ledger/results-tsv.js +142 -0
- package/dist/core/log-discipline/stdout-redirect.js +51 -0
- package/dist/core/lsp/cache.js +105 -0
- package/dist/core/lsp/client.js +551 -41
- package/dist/core/lsp/language-detect.js +66 -0
- package/dist/core/lsp/post-edit-diagnostics.js +171 -0
- package/dist/core/lsp/server-detect.js +173 -0
- package/dist/core/lsp/symbol-cache.js +162 -0
- package/dist/core/lsp/symbol-tools.js +664 -0
- package/dist/core/mcp/client.js +97 -28
- package/dist/core/mcp/http-server.js +553 -0
- package/dist/core/mcp/orchestrator-tools.js +662 -0
- package/dist/core/mcp/permission.js +190 -0
- package/dist/core/mcp/registry.js +39 -17
- package/dist/core/mcp/server-tools.js +219 -0
- package/dist/core/mcp/server.js +397 -0
- package/dist/core/mcp/trust.js +10 -10
- package/dist/core/memory/dual-write.js +416 -0
- package/dist/core/memory/passive-extract.js +130 -0
- package/dist/core/memory/phase1-kinds.js +20 -0
- package/dist/core/memory/secret-scanner.js +304 -0
- package/dist/core/memory-sync/queue.js +170 -0
- package/dist/core/metrics/extract.js +113 -0
- package/dist/core/modes/roo-modes.js +68 -0
- package/dist/core/onboarding/ensure-initialized.js +133 -0
- package/dist/core/onboarding/marker.js +111 -0
- package/dist/core/onboarding/telemetry-state.js +108 -0
- package/dist/core/output-style/presets.js +176 -0
- package/dist/core/output-style/state.js +185 -0
- package/dist/core/path-security.js +287 -5
- package/dist/core/permission.js +82 -22
- package/dist/core/permissions/auto-classifier.js +124 -0
- package/dist/core/permissions/bash-parser.js +371 -0
- package/dist/core/permissions/circuit-breaker.js +83 -0
- package/dist/core/permissions/constrained-edit.js +91 -0
- package/dist/core/permissions/gate.js +278 -0
- package/dist/core/permissions/index.js +20 -0
- package/dist/core/permissions/mode.js +174 -0
- package/dist/core/permissions/network-egress.js +137 -0
- package/dist/core/permissions/state.js +241 -0
- package/dist/core/permissions/tool-class.js +93 -0
- package/dist/core/plan-mode/ui-state.js +51 -0
- package/dist/core/plans/plan-artifact.js +721 -0
- package/dist/core/policy-limits/etag-store.js +122 -0
- package/dist/core/prd-check/parser.js +215 -0
- package/dist/core/prd-check/reporter.js +127 -0
- package/dist/core/prd-check/session-review.js +557 -0
- package/dist/core/prd-check/verifiers.js +223 -0
- package/dist/core/prompt-cache/client-cache.js +99 -0
- package/dist/core/prompts/assembly.js +29 -0
- package/dist/core/prompts/registry.js +364 -0
- package/dist/core/pugi-md/cc-compat-rules.js +735 -0
- package/dist/core/pugi-md/context-injector.js +76 -0
- package/dist/core/pugi-md/walk-up.js +207 -0
- package/dist/core/python/uv-installer.js +270 -0
- package/dist/core/python/uv-resolver.js +83 -0
- package/dist/core/rate-limit/narrator.js +146 -0
- package/dist/core/recipes/cli-types.js +20 -0
- package/dist/core/recipes/loader.js +103 -0
- package/dist/core/recipes/runner.js +345 -0
- package/dist/core/recipes/schema.js +587 -0
- package/dist/core/release-notes/parser.js +241 -0
- package/dist/core/release-notes/state.js +116 -0
- package/dist/core/repl/ask.js +37 -37
- package/dist/core/repl/cancellation.js +26 -26
- package/dist/core/repl/cap-warning.js +4 -4
- package/dist/core/repl/clipboard-read.js +11 -11
- package/dist/core/repl/dispatch-fsm.js +12 -12
- package/dist/core/repl/history-search.js +15 -15
- package/dist/core/repl/history.js +28 -18
- package/dist/core/repl/kill-ring.js +5 -5
- package/dist/core/repl/model-pricing.js +135 -0
- package/dist/core/repl/privacy-banner.js +22 -22
- package/dist/core/repl/session.js +2148 -217
- package/dist/core/repl/slash-commands.js +501 -41
- package/dist/core/repl/store/index.js +1 -1
- package/dist/core/repl/store/jsonl-log.js +22 -22
- package/dist/core/repl/store/lockfile.js +10 -10
- package/dist/core/repl/store/session-store.js +136 -107
- package/dist/core/repl/store/types.js +15 -15
- package/dist/core/repl/store/uuid-v7.js +12 -12
- package/dist/core/repl/workspace-context.js +43 -21
- package/dist/core/repo-map/build.js +125 -0
- package/dist/core/repo-map/cache.js +185 -0
- package/dist/core/repo-map/extractor.js +254 -0
- package/dist/core/repo-map/formatter.js +145 -0
- package/dist/core/repo-map/page-rank.js +105 -0
- package/dist/core/repo-map/scanner.js +211 -0
- package/dist/core/retry-budget/budget.js +284 -0
- package/dist/core/retry-budget/index.js +5 -0
- package/dist/core/retry-budget/retry-cap.js +74 -0
- package/dist/core/routing/lead-worker.js +43 -0
- package/dist/core/routing/pre-flight-estimator.js +108 -0
- package/dist/core/runs/run-tree.js +103 -0
- package/dist/core/security/injection-scanner.js +367 -0
- package/dist/core/security/output-filter.js +418 -0
- package/dist/core/session/env-file.js +105 -0
- package/dist/core/session/section-budgets.js +140 -0
- package/dist/core/session.js +92 -0
- package/dist/core/settings.js +324 -5
- package/dist/core/share/formatter.js +271 -0
- package/dist/core/share/redactor.js +221 -0
- package/dist/core/share/uploader.js +267 -0
- package/dist/core/skills/defaults.js +30 -30
- package/dist/core/skills/loader.js +22 -22
- package/dist/core/skills/sources.js +27 -27
- package/dist/core/smoke/headless-driver.js +174 -0
- package/dist/core/smoke/orchestrator.js +194 -0
- package/dist/core/smoke/runner.js +238 -0
- package/dist/core/smoke/scenario-parser.js +316 -0
- package/dist/core/statusline.js +99 -0
- package/dist/core/subagents/dispatcher-real.js +600 -0
- package/dist/core/subagents/dispatcher.js +132 -43
- package/dist/core/subagents/index.js +19 -6
- package/dist/core/subagents/isolation-matrix.js +213 -0
- package/dist/core/subagents/spawn.js +19 -4
- package/dist/core/telemetry/emitter.js +229 -0
- package/dist/core/telemetry/queue.js +251 -0
- package/dist/core/theme/context.js +91 -0
- package/dist/core/theme/presets.js +228 -0
- package/dist/core/theme/state.js +181 -0
- package/dist/core/todos/invariant.js +10 -0
- package/dist/core/todos/state.js +177 -0
- package/dist/core/tool-schema/compressor.js +89 -0
- package/dist/core/transport/version-interceptor.js +166 -0
- package/dist/core/trust.js +2 -2
- package/dist/core/tui/thinking-block.js +64 -0
- package/dist/core/vim/keymap.js +288 -0
- package/dist/core/vim/state.js +92 -0
- package/dist/core/watch-markers/marker-watcher.js +133 -0
- package/dist/core/worktree/include-parser.js +249 -0
- package/dist/core/worktree-manager/cleanup.js +123 -0
- package/dist/core/worktree-manager/manager.js +303 -0
- package/dist/index.js +36 -0
- package/dist/runtime/bootstrap.js +190 -0
- package/dist/runtime/cli.js +4185 -549
- package/dist/runtime/commands/agents.js +31 -31
- package/dist/runtime/commands/budget.js +5 -5
- package/dist/runtime/commands/cancel.js +231 -0
- package/dist/runtime/commands/chain.js +489 -0
- package/dist/runtime/commands/codegraph-status.js +227 -0
- package/dist/runtime/commands/compact.js +297 -0
- package/dist/runtime/commands/config.js +73 -39
- package/dist/runtime/commands/cost.js +199 -0
- package/dist/runtime/commands/delegate.js +27 -4
- package/dist/runtime/commands/dispatch.js +126 -0
- package/dist/runtime/commands/doctor.js +579 -0
- package/dist/runtime/commands/feedback.js +184 -0
- package/dist/runtime/commands/hooks.js +187 -0
- package/dist/runtime/commands/init.js +254 -0
- package/dist/runtime/commands/lsp.js +200 -38
- package/dist/runtime/commands/mcp.js +879 -0
- package/dist/runtime/commands/memory.js +582 -0
- package/dist/runtime/commands/model.js +237 -0
- package/dist/runtime/commands/onboarding.js +275 -0
- package/dist/runtime/commands/patch.js +12 -12
- package/dist/runtime/commands/permissions.js +112 -0
- package/dist/runtime/commands/plan.js +143 -0
- package/dist/runtime/commands/prd-check.js +285 -0
- package/dist/runtime/commands/privacy.js +17 -17
- package/dist/runtime/commands/recipe.js +325 -0
- package/dist/runtime/commands/redo-blob-store.js +92 -0
- package/dist/runtime/commands/redo.js +361 -0
- package/dist/runtime/commands/release-notes.js +229 -0
- package/dist/runtime/commands/repo-map.js +95 -0
- package/dist/runtime/commands/report.js +299 -0
- package/dist/runtime/commands/resume.js +118 -0
- package/dist/runtime/commands/review-consensus.js +68 -53
- package/dist/runtime/commands/rewind.js +333 -0
- package/dist/runtime/commands/roster.js +14 -14
- package/dist/runtime/commands/sessions.js +163 -0
- package/dist/runtime/commands/share.js +316 -0
- package/dist/runtime/commands/skills.js +31 -31
- package/dist/runtime/commands/status.js +186 -0
- package/dist/runtime/commands/stickers.js +82 -0
- package/dist/runtime/commands/style.js +194 -0
- package/dist/runtime/commands/theme.js +196 -0
- package/dist/runtime/commands/undo.js +54 -22
- package/dist/runtime/commands/update.js +289 -0
- package/dist/runtime/commands/vim.js +140 -0
- package/dist/runtime/commands/worktree.js +8 -8
- package/dist/runtime/commands/worktrees.js +155 -0
- package/dist/runtime/headless-repl.js +195 -0
- package/dist/runtime/headless.js +543 -0
- package/dist/runtime/load-hooks-or-exit.js +71 -0
- package/dist/runtime/plan-decompose.js +22 -22
- package/dist/runtime/sigint-guard.js +272 -0
- package/dist/runtime/update-check.js +28 -28
- package/dist/runtime/version.js +65 -0
- package/dist/runtime/worktree-bootstrap.js +579 -0
- package/dist/skills/bundled/batch.js +617 -0
- package/dist/skills/bundled/index.js +45 -0
- package/dist/skills/bundled/loop.js +358 -0
- package/dist/skills/bundled/remember.js +383 -0
- package/dist/skills/bundled/simplify.js +289 -0
- package/dist/skills/bundled/skillify.js +373 -0
- package/dist/skills/bundled/stuck.js +558 -0
- package/dist/skills/bundled/verify.js +439 -0
- package/dist/testing/vcr.js +486 -0
- package/dist/tools/agent-tool.js +229 -0
- package/dist/tools/apply-patch.js +89 -28
- package/dist/tools/ask-user-question.js +337 -0
- package/dist/tools/ask-user.js +115 -0
- package/dist/tools/bash.js +624 -46
- package/dist/tools/brief.js +224 -0
- package/dist/tools/enter-worktree.js +250 -0
- package/dist/tools/exit-worktree.js +147 -0
- package/dist/tools/file-tools.js +161 -44
- package/dist/tools/lsp-tools.js +377 -1
- package/dist/tools/mcp-tool.js +260 -0
- package/dist/tools/multi-edit.js +361 -0
- package/dist/tools/powershell.js +268 -0
- package/dist/tools/registry.js +86 -4
- package/dist/tools/skill-tool.js +96 -0
- package/dist/tools/sleep.js +99 -0
- package/dist/tools/synthetic-output.js +133 -0
- package/dist/tools/tasks.js +208 -0
- package/dist/tools/todo-write.js +184 -0
- package/dist/tools/verify-plan-execution.js +295 -0
- package/dist/tools/web-fetch-injection-scanner.js +207 -0
- package/dist/tools/web-fetch.js +195 -10
- package/dist/tools/web-search.js +458 -0
- package/dist/tui/agent-progress-card.js +111 -0
- package/dist/tui/agent-tree.js +11 -1
- package/dist/tui/ask-modal.js +14 -14
- package/dist/tui/ask-user-question-chips.js +315 -0
- package/dist/tui/ask-user-question-prompt.js +203 -0
- package/dist/tui/compact-banner.js +81 -0
- package/dist/tui/conversation-pane.js +85 -11
- package/dist/tui/cost-table.js +111 -0
- package/dist/tui/device-flow.js +2 -2
- package/dist/tui/doctor-table.js +46 -0
- package/dist/tui/feedback-prompt.js +156 -0
- package/dist/tui/input-box.js +247 -32
- package/dist/tui/login-picker.js +3 -3
- package/dist/tui/markdown-render.js +6 -6
- package/dist/tui/onboarding-wizard.js +240 -0
- package/dist/tui/permissions-picker.js +86 -0
- package/dist/tui/render.js +36 -1
- package/dist/tui/repl-render.js +176 -25
- package/dist/tui/repl-splash-art.js +16 -16
- package/dist/tui/repl-splash-mascot.js +48 -24
- package/dist/tui/repl-splash.js +22 -22
- package/dist/tui/repl.js +125 -45
- package/dist/tui/slash-palette.js +6 -6
- package/dist/tui/splash.js +2 -2
- package/dist/tui/status-bar.js +109 -31
- package/dist/tui/status-table.js +7 -0
- package/dist/tui/stickers-art.js +136 -0
- package/dist/tui/style-table.js +28 -0
- package/dist/tui/theme-table.js +29 -0
- package/dist/tui/thinking-spinner.js +123 -0
- package/dist/tui/tool-stream-pane.js +53 -4
- package/dist/tui/update-banner.js +27 -2
- package/dist/tui/vim-input.js +267 -0
- package/dist/tui/welcome-banner.js +107 -0
- package/dist/tui/welcome-data.js +293 -0
- package/dist/tui/workspace-context.js +2 -2
- package/package.json +31 -16
- package/test/scenarios/codegen-create-file.scenario.txt +13 -0
- package/test/scenarios/compact-force.scenario.txt +12 -0
- package/test/scenarios/identity.scenario.txt +12 -0
- package/test/scenarios/persona-handoff.scenario.txt +12 -0
- package/test/scenarios/walkback.scenario.txt +12 -0
- package/dist/core/engine/compaction-hook.js +0 -154
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* — Onboarding Ink wizard.
|
|
4
|
+
*
|
|
5
|
+
* Six-screen interactive walk:
|
|
6
|
+
*
|
|
7
|
+
* 1. Welcome + auth status (single Enter to continue)
|
|
8
|
+
* 2. Default permission mode (4-row picker)
|
|
9
|
+
* 3. Output style preset (5-row picker)
|
|
10
|
+
* 4. MCP server pointer (informational, Enter to continue)
|
|
11
|
+
* 5. Telemetry consent (3-row picker)
|
|
12
|
+
* 6. Recap card (Enter to commit + exit)
|
|
13
|
+
*
|
|
14
|
+
* Driven entirely by Ink's `useInput`. The component does NOT perform
|
|
15
|
+
* any fs writes — it resolves the verdict back to the caller
|
|
16
|
+
* (`runOnboardingCommand`), which translates verdicts into L6 / L18 /
|
|
17
|
+
* telemetry-state mutations. Single source of truth: the runner.
|
|
18
|
+
*
|
|
19
|
+
* Each picker step pre-selects the CURRENT persisted value (from the
|
|
20
|
+
* snapshot passed in props) so pressing Enter on Step 2/3/5 keeps the
|
|
21
|
+
* current value — that is the idempotency contract.
|
|
22
|
+
*
|
|
23
|
+
* Cancellation:
|
|
24
|
+
* - Esc / Ctrl-C at any step → verdict.cancelled = true, the runner
|
|
25
|
+
* skips ALL writes (including the marker touch) so the next bare
|
|
26
|
+
* `pugi` invocation still surfaces the first-run hint.
|
|
27
|
+
*
|
|
28
|
+
* Keystrokes:
|
|
29
|
+
* - ↑/↓ or j/k — move selection in pickers.
|
|
30
|
+
* - Enter — confirm step (keep current = pass through; new pick
|
|
31
|
+
* = update verdict for that tier).
|
|
32
|
+
* - 's' — skip current step explicitly (verdict slot stays null).
|
|
33
|
+
* - Esc / 'q' — cancel the wizard.
|
|
34
|
+
*/
|
|
35
|
+
import { useState } from 'react';
|
|
36
|
+
import { Box, Text, render, useApp, useInput } from 'ink';
|
|
37
|
+
import { PERMISSION_MODES, PERMISSION_MODE_GLOSS, } from '../core/permissions/index.js';
|
|
38
|
+
import { OUTPUT_STYLES, OUTPUT_STYLE_SLUGS, } from '../core/output-style/presets.js';
|
|
39
|
+
import { TELEMETRY_CHOICES, } from '../core/onboarding/telemetry-state.js';
|
|
40
|
+
const EMPTY_DRAFT = {
|
|
41
|
+
permissionMode: null,
|
|
42
|
+
outputStyle: null,
|
|
43
|
+
telemetry: null,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Lookup the snapshot value's index within the picker rows so the
|
|
47
|
+
* initial cursor sits on the current value. Returns 0 (safe default)
|
|
48
|
+
* when the snapshot value is outside the closed list — should never
|
|
49
|
+
* happen given the type guards in the state modules, but the index
|
|
50
|
+
* fallback keeps Ink from crashing on a malformed config.
|
|
51
|
+
*/
|
|
52
|
+
function indexOf(rows, value) {
|
|
53
|
+
const idx = rows.indexOf(value);
|
|
54
|
+
return idx === -1 ? 0 : idx;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The wizard component. Pure: no fs, no env, no network. Verdicts
|
|
58
|
+
* flow up via `onComplete`; the caller owns the writes.
|
|
59
|
+
*/
|
|
60
|
+
export function OnboardingWizard(props) {
|
|
61
|
+
const { snapshot, onComplete } = props;
|
|
62
|
+
const [step, setStep] = useState(1);
|
|
63
|
+
const [permissionIdx, setPermissionIdx] = useState(indexOf(PERMISSION_MODES, snapshot.permissionMode));
|
|
64
|
+
const [styleIdx, setStyleIdx] = useState(indexOf(OUTPUT_STYLE_SLUGS, snapshot.outputStyle));
|
|
65
|
+
const [telemetryIdx, setTelemetryIdx] = useState(indexOf(TELEMETRY_CHOICES, snapshot.telemetry));
|
|
66
|
+
const [draft, setDraft] = useState(EMPTY_DRAFT);
|
|
67
|
+
const finish = (final, cancelled) => {
|
|
68
|
+
onComplete({
|
|
69
|
+
permissionMode: final.permissionMode,
|
|
70
|
+
outputStyle: final.outputStyle,
|
|
71
|
+
telemetry: final.telemetry,
|
|
72
|
+
cancelled,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
useInput((input, key) => {
|
|
76
|
+
// Universal cancel.
|
|
77
|
+
if (key.escape || (key.ctrl && input === 'c')) {
|
|
78
|
+
finish(EMPTY_DRAFT, true);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Universal skip — Enter on a picker means "keep current"; explicit
|
|
82
|
+
// 's' makes the skip intent obvious in the recap.
|
|
83
|
+
const isAdvance = key.return;
|
|
84
|
+
const moveUp = key.upArrow || input === 'k';
|
|
85
|
+
const moveDown = key.downArrow || input === 'j';
|
|
86
|
+
const explicitSkip = input === 's';
|
|
87
|
+
switch (step) {
|
|
88
|
+
case 1: {
|
|
89
|
+
if (isAdvance)
|
|
90
|
+
setStep(2);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
case 2: {
|
|
94
|
+
if (moveUp) {
|
|
95
|
+
setPermissionIdx((i) => (i === 0 ? PERMISSION_MODES.length - 1 : i - 1));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (moveDown) {
|
|
99
|
+
setPermissionIdx((i) => (i === PERMISSION_MODES.length - 1 ? 0 : i + 1));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (isAdvance || explicitSkip) {
|
|
103
|
+
const picked = PERMISSION_MODES[permissionIdx];
|
|
104
|
+
const verdict = explicitSkip || picked === snapshot.permissionMode ? null : picked ?? null;
|
|
105
|
+
setDraft((d) => ({ ...d, permissionMode: verdict }));
|
|
106
|
+
setStep(3);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
case 3: {
|
|
112
|
+
if (moveUp) {
|
|
113
|
+
setStyleIdx((i) => (i === 0 ? OUTPUT_STYLE_SLUGS.length - 1 : i - 1));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (moveDown) {
|
|
117
|
+
setStyleIdx((i) => (i === OUTPUT_STYLE_SLUGS.length - 1 ? 0 : i + 1));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (isAdvance || explicitSkip) {
|
|
121
|
+
const picked = OUTPUT_STYLE_SLUGS[styleIdx];
|
|
122
|
+
const verdict = explicitSkip || picked === snapshot.outputStyle ? null : picked ?? null;
|
|
123
|
+
setDraft((d) => ({ ...d, outputStyle: verdict }));
|
|
124
|
+
setStep(4);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
case 4: {
|
|
130
|
+
if (isAdvance)
|
|
131
|
+
setStep(5);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
case 5: {
|
|
135
|
+
if (moveUp) {
|
|
136
|
+
setTelemetryIdx((i) => (i === 0 ? TELEMETRY_CHOICES.length - 1 : i - 1));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (moveDown) {
|
|
140
|
+
setTelemetryIdx((i) => (i === TELEMETRY_CHOICES.length - 1 ? 0 : i + 1));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (isAdvance || explicitSkip) {
|
|
144
|
+
const picked = TELEMETRY_CHOICES[telemetryIdx];
|
|
145
|
+
const verdict = explicitSkip || picked === snapshot.telemetry ? null : picked ?? null;
|
|
146
|
+
setDraft((d) => ({ ...d, telemetry: verdict }));
|
|
147
|
+
setStep(6);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
case 6: {
|
|
153
|
+
if (isAdvance)
|
|
154
|
+
finish(draft, false);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [_jsx(StepHeader, { step: step }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [step === 1 && _jsx(WelcomeStep, { snapshot: snapshot }), step === 2 && (_jsx(ModeStep, { current: snapshot.permissionMode, selectedIdx: permissionIdx })), step === 3 && (_jsx(StyleStep, { current: snapshot.outputStyle, currentSource: snapshot.outputStyleSource, selectedIdx: styleIdx })), step === 4 && _jsx(McpStep, {}), step === 5 && (_jsx(TelemetryStep, { current: snapshot.telemetry, selectedIdx: telemetryIdx })), step === 6 && _jsx(RecapStep, { snapshot: snapshot, draft: draft })] }), _jsx(FooterHints, { step: step })] }));
|
|
160
|
+
}
|
|
161
|
+
function StepHeader({ step }) {
|
|
162
|
+
const titles = {
|
|
163
|
+
1: 'Welcome to Pugi',
|
|
164
|
+
2: 'Step 2 / 5 — Default permission mode',
|
|
165
|
+
3: 'Step 3 / 5 — Output style',
|
|
166
|
+
4: 'Step 4 / 5 — MCP servers',
|
|
167
|
+
5: 'Step 5 / 5 — Telemetry consent',
|
|
168
|
+
6: 'Setup complete',
|
|
169
|
+
};
|
|
170
|
+
return (_jsx(Text, { bold: true, color: "cyan", children: titles[step] }));
|
|
171
|
+
}
|
|
172
|
+
function WelcomeStep({ snapshot }) {
|
|
173
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "Brief it. It ships." }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: snapshot.authPresent
|
|
174
|
+
? 'You are signed in. The wizard configures local defaults; values persist to ~/.pugi/config.json.'
|
|
175
|
+
: 'You are NOT signed in. The wizard still configures local defaults, but you should run `pugi login` after.' }) })] }));
|
|
176
|
+
}
|
|
177
|
+
function ModeStep({ current, selectedIdx, }) {
|
|
178
|
+
return (_jsx(Box, { flexDirection: "column", children: PERMISSION_MODES.map((mode, idx) => (_jsx(PickerRow, { isSelected: idx === selectedIdx, isCurrent: mode === current, title: mode, gloss: PERMISSION_MODE_GLOSS[mode] }, mode))) }));
|
|
179
|
+
}
|
|
180
|
+
function StyleStep({ current, currentSource, selectedIdx, }) {
|
|
181
|
+
return (_jsxs(Box, { flexDirection: "column", children: [OUTPUT_STYLE_SLUGS.map((slug, idx) => (_jsx(PickerRow, { isSelected: idx === selectedIdx, isCurrent: slug === current, title: slug, gloss: OUTPUT_STYLES[slug].gloss }, slug))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: currentSource === 'workspace'
|
|
182
|
+
? 'Active style is currently a workspace override. The wizard writes the user-tier default.'
|
|
183
|
+
: `Active source: ${currentSource}.` }) })] }));
|
|
184
|
+
}
|
|
185
|
+
function McpStep() {
|
|
186
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: "MCP servers extend Pugi with extra tools (filesystem, browser, custom APIs)." }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Add one with:" }) }), _jsx(Text, { children: ' pugi mcp add <name> <command>' }), _jsx(Text, { children: ' pugi mcp list' }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "You can skip for now and add servers later." }) })] }));
|
|
187
|
+
}
|
|
188
|
+
function TelemetryStep({ current, selectedIdx, }) {
|
|
189
|
+
const gloss = {
|
|
190
|
+
off: 'No telemetry of any kind.',
|
|
191
|
+
anonymous: 'Counts + error categories only; no payloads.',
|
|
192
|
+
community: 'Anonymous + opt-in usage panels.',
|
|
193
|
+
};
|
|
194
|
+
return (_jsx(Box, { flexDirection: "column", children: TELEMETRY_CHOICES.map((choice, idx) => (_jsx(PickerRow, { isSelected: idx === selectedIdx, isCurrent: choice === current, title: choice, gloss: gloss[choice] }, choice))) }));
|
|
195
|
+
}
|
|
196
|
+
function RecapStep({ snapshot, draft, }) {
|
|
197
|
+
const finalMode = draft.permissionMode ?? snapshot.permissionMode;
|
|
198
|
+
const finalStyle = draft.outputStyle ?? snapshot.outputStyle;
|
|
199
|
+
const finalTelemetry = draft.telemetry ?? snapshot.telemetry;
|
|
200
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: ` Permission mode: ${finalMode}${draft.permissionMode === null ? ' (unchanged)' : ''}` }), _jsx(Text, { children: ` Output style: ${finalStyle}${draft.outputStyle === null ? ' (unchanged)' : ''}` }), _jsx(Text, { children: ` Telemetry: ${finalTelemetry}${draft.telemetry === null ? ' (unchanged)' : ''}` }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Press Enter to write defaults + exit. Esc to cancel without saving." }) })] }));
|
|
201
|
+
}
|
|
202
|
+
function PickerRow({ isSelected, isCurrent, title, gloss, }) {
|
|
203
|
+
const indicator = isSelected ? '▸ ' : ' ';
|
|
204
|
+
const currentTag = isCurrent ? ' [current]' : '';
|
|
205
|
+
return (_jsxs(Text, { children: [_jsxs(Text, { color: isSelected ? 'cyan' : undefined, bold: isSelected, children: [indicator, title.padEnd(18, ' ')] }), _jsx(Text, { dimColor: true, children: `${gloss}${currentTag}` })] }));
|
|
206
|
+
}
|
|
207
|
+
function FooterHints({ step }) {
|
|
208
|
+
const hint = step === 1 || step === 4
|
|
209
|
+
? 'Enter continue Esc cancel'
|
|
210
|
+
: step === 6
|
|
211
|
+
? 'Enter commit + exit Esc cancel'
|
|
212
|
+
: '↑/↓ select Enter confirm s skip Esc cancel';
|
|
213
|
+
return (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: hint }) }));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Mount the wizard, await the operator's verdict, unmount Ink, return
|
|
217
|
+
* the verdict to the runner. Wrapped in a `useApp` consumer so we can
|
|
218
|
+
* call `exit()` and let `waitUntilExit()` resolve cleanly.
|
|
219
|
+
*/
|
|
220
|
+
export async function renderOnboardingWizard(opts) {
|
|
221
|
+
return new Promise((resolvePromise) => {
|
|
222
|
+
let resolved = false;
|
|
223
|
+
const handleComplete = (verdict) => {
|
|
224
|
+
if (resolved)
|
|
225
|
+
return;
|
|
226
|
+
resolved = true;
|
|
227
|
+
app.unmount();
|
|
228
|
+
resolvePromise(verdict);
|
|
229
|
+
};
|
|
230
|
+
const Wrapper = () => {
|
|
231
|
+
const { exit } = useApp();
|
|
232
|
+
return (_jsx(OnboardingWizard, { snapshot: opts.snapshot, onComplete: (verdict) => {
|
|
233
|
+
handleComplete(verdict);
|
|
234
|
+
exit();
|
|
235
|
+
} }));
|
|
236
|
+
};
|
|
237
|
+
const app = render(_jsx(Wrapper, {}));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=onboarding-wizard.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
import { PERMISSION_MODES, PERMISSION_MODE_GLOSS, } from '../core/permissions/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build the rendered rows from the canonical mode list. We map the
|
|
7
|
+
* 1-line gloss → row hint so `/permissions` and the picker stay in
|
|
8
|
+
* sync — a change to `PERMISSION_MODE_GLOSS` shows up here too.
|
|
9
|
+
*/
|
|
10
|
+
const ITEMS = PERMISSION_MODES.map((mode) => ({
|
|
11
|
+
mode,
|
|
12
|
+
title: titleCase(mode),
|
|
13
|
+
hint: PERMISSION_MODE_GLOSS[mode],
|
|
14
|
+
}));
|
|
15
|
+
function titleCase(mode) {
|
|
16
|
+
return mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the initial cursor — prefer the explicit `initialIndex`
|
|
20
|
+
* (spec / test) when provided, otherwise highlight the row matching
|
|
21
|
+
* the active mode so the operator opens the picker with their
|
|
22
|
+
* current selection focused.
|
|
23
|
+
*/
|
|
24
|
+
function resolveInitialIndex(currentMode, override) {
|
|
25
|
+
if (typeof override === 'number') {
|
|
26
|
+
return Math.min(Math.max(override, 0), ITEMS.length - 1);
|
|
27
|
+
}
|
|
28
|
+
const idx = ITEMS.findIndex((item) => item.mode === currentMode);
|
|
29
|
+
return idx >= 0 ? idx : 0;
|
|
30
|
+
}
|
|
31
|
+
export function PermissionsPicker(props) {
|
|
32
|
+
const [index, setIndex] = useState(resolveInitialIndex(props.currentMode, props.initialIndex));
|
|
33
|
+
useInput((input, key) => {
|
|
34
|
+
if (key.upArrow || input === 'k') {
|
|
35
|
+
setIndex((current) => (current === 0 ? ITEMS.length - 1 : current - 1));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (key.downArrow || input === 'j') {
|
|
39
|
+
setIndex((current) => (current === ITEMS.length - 1 ? 0 : current + 1));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (key.return) {
|
|
43
|
+
const selected = ITEMS[index];
|
|
44
|
+
if (selected)
|
|
45
|
+
props.onSelect(selected.mode);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (key.escape || input === 'q') {
|
|
49
|
+
props.onCancel();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// : number shortcuts mirror the canonical 6-mode order.
|
|
53
|
+
// Operators coming from the upstream tool reach the same mode with the
|
|
54
|
+
// same digit (1=default, 2=acceptEdits, …, 6=bypassPermissions).
|
|
55
|
+
if (input === '1')
|
|
56
|
+
props.onSelect('default');
|
|
57
|
+
if (input === '2')
|
|
58
|
+
props.onSelect('acceptEdits');
|
|
59
|
+
if (input === '3')
|
|
60
|
+
props.onSelect('plan');
|
|
61
|
+
if (input === '4')
|
|
62
|
+
props.onSelect('auto');
|
|
63
|
+
if (input === '5')
|
|
64
|
+
props.onSelect('dontAsk');
|
|
65
|
+
if (input === '6')
|
|
66
|
+
props.onSelect('bypassPermissions');
|
|
67
|
+
});
|
|
68
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Permission mode" }), _jsx(Text, { dimColor: true, children: ` (current: ${props.currentMode} — ${props.sourceLabel})` })] }), props.firstRun ? (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "First time? Mode = Ask \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E. Use /permissions \u043A change later." }) })) : null, _jsx(Box, { marginTop: 1, flexDirection: "column", children: ITEMS.map((item, itemIndex) => {
|
|
69
|
+
const isSelected = itemIndex === index;
|
|
70
|
+
const isCurrent = item.mode === props.currentMode;
|
|
71
|
+
return (_jsx(PickerRow, { isSelected: isSelected, isCurrent: isCurrent, title: item.title, hint: item.hint }, item.mode));
|
|
72
|
+
}) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: '↑/↓ select Enter confirm Esc cancel' }) })] }));
|
|
73
|
+
}
|
|
74
|
+
function PickerRow({ isSelected, isCurrent, title, hint, }) {
|
|
75
|
+
// Arrow glyph + padded title so highlighted and dim rows share
|
|
76
|
+
// column alignment. A trailing ` ●` marks the currently-effective
|
|
77
|
+
// mode (separate from cursor focus) so an operator instantly sees
|
|
78
|
+
// which row is "what I have now" vs "what I'm hovering".
|
|
79
|
+
const indicator = isSelected ? '▸ ' : ' ';
|
|
80
|
+
// : longest title is `BypassPermissions` (17 chars). Bump the
|
|
81
|
+
// pad column так the gloss column stays aligned across all 6 rows.
|
|
82
|
+
const padded = title.padEnd(18, ' ');
|
|
83
|
+
const currentMarker = isCurrent ? ' ●' : ' ';
|
|
84
|
+
return (_jsxs(Text, { children: [_jsxs(Text, { color: isSelected ? 'cyan' : undefined, bold: isSelected, children: [indicator, padded] }), _jsx(Text, { color: isCurrent ? 'green' : undefined, children: currentMarker }), _jsx(Text, { dimColor: true, children: ` ${hint}` })] }));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=permissions-picker.js.map
|
package/dist/tui/render.js
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { render } from 'ink';
|
|
3
3
|
import { DeviceFlow } from './device-flow.js';
|
|
4
4
|
import { LoginPicker } from './login-picker.js';
|
|
5
|
+
import { PermissionsPicker } from './permissions-picker.js';
|
|
5
6
|
import { Splash } from './splash.js';
|
|
6
7
|
import { collectSplashData } from './splash-data.js';
|
|
7
8
|
/**
|
|
@@ -25,7 +26,7 @@ export async function renderSplash(cliVersion) {
|
|
|
25
26
|
* Sentinel thrown when the user dismisses the login picker via Esc
|
|
26
27
|
* or `q`. The CLI dispatcher catches it, prints a one-line abort
|
|
27
28
|
* message, and exits 130 (the standard exit code for SIGINT-style
|
|
28
|
-
* user cancellations — matches gh CLI
|
|
29
|
+
* user cancellations — matches gh CLI and peer CLIs).
|
|
29
30
|
*/
|
|
30
31
|
export class LoginCancelledError extends Error {
|
|
31
32
|
constructor() {
|
|
@@ -66,6 +67,40 @@ export function renderLoginPicker(apiUrl) {
|
|
|
66
67
|
}));
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Sentinel thrown when the operator dismisses the permissions picker
|
|
72
|
+
* via Esc / q. Mirrors `LoginCancelledError` — the host catches and
|
|
73
|
+
* prints a one-line abort message; no mode flip lands.
|
|
74
|
+
*/
|
|
75
|
+
export class PermissionsPickerCancelledError extends Error {
|
|
76
|
+
constructor() {
|
|
77
|
+
super('Permissions picker cancelled');
|
|
78
|
+
this.name = 'PermissionsPickerCancelledError';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function renderPermissionsPicker(options) {
|
|
82
|
+
return new Promise((resolveMode, rejectMode) => {
|
|
83
|
+
let settled = false;
|
|
84
|
+
const finish = (cb) => {
|
|
85
|
+
if (settled)
|
|
86
|
+
return;
|
|
87
|
+
settled = true;
|
|
88
|
+
instance.unmount();
|
|
89
|
+
setImmediate(cb);
|
|
90
|
+
};
|
|
91
|
+
const instance = render(React.createElement(PermissionsPicker, {
|
|
92
|
+
currentMode: options.currentMode,
|
|
93
|
+
sourceLabel: options.sourceLabel,
|
|
94
|
+
firstRun: options.firstRun ?? false,
|
|
95
|
+
onSelect: (mode) => {
|
|
96
|
+
finish(() => resolveMode(mode));
|
|
97
|
+
},
|
|
98
|
+
onCancel: () => {
|
|
99
|
+
finish(() => rejectMode(new PermissionsPickerCancelledError()));
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
69
104
|
/**
|
|
70
105
|
* Mount `<DeviceFlow />` on a TTY and return a handle the host uses to
|
|
71
106
|
* drive the frame. Mirrors `renderLoginPicker`'s lifecycle: we
|