@pugi/cli 0.1.0-beta.5 → 0.1.0-beta.50

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.
Files changed (263) hide show
  1. package/THIRD_PARTY_NOTICES.md +40 -0
  2. package/assets/pugi-mascot.ansi +15 -25
  3. package/assets/pugi-prozr2-mascot.ansi +9 -0
  4. package/bin/run.js +33 -1
  5. package/dist/commands/jobs-watch.js +201 -0
  6. package/dist/commands/jobs.js +15 -0
  7. package/dist/commands/smoke.js +133 -0
  8. package/dist/core/agent-progress/cleanup.js +134 -0
  9. package/dist/core/agent-progress/schema.js +144 -0
  10. package/dist/core/agent-progress/writer.js +101 -0
  11. package/dist/core/artifact-chain/dispatcher.js +148 -0
  12. package/dist/core/artifact-chain/exporter.js +164 -0
  13. package/dist/core/artifact-chain/state.js +243 -0
  14. package/dist/core/artifact-chain/steps.js +169 -0
  15. package/dist/core/auth/ensure-authenticated.js +129 -0
  16. package/dist/core/auth/env-provider.js +238 -0
  17. package/dist/core/auto-update/channels.js +122 -0
  18. package/dist/core/auto-update/checker.js +241 -0
  19. package/dist/core/auto-update/state.js +235 -0
  20. package/dist/core/bare-mode/index.js +107 -0
  21. package/dist/core/bash-classifier.js +400 -4
  22. package/dist/core/checkpoint/resumer.js +149 -0
  23. package/dist/core/checkpoint/rewinder.js +291 -0
  24. package/dist/core/codegraph/decision-store.js +248 -0
  25. package/dist/core/codegraph/detect-repo.js +459 -0
  26. package/dist/core/codegraph/install.js +134 -0
  27. package/dist/core/codegraph/offer-hook.js +220 -0
  28. package/dist/core/compact/auto-trigger.js +96 -0
  29. package/dist/core/compact/buffer-rewriter.js +115 -0
  30. package/dist/core/compact/summarizer.js +208 -0
  31. package/dist/core/compact/token-counter.js +108 -0
  32. package/dist/core/consensus/diff-capture.js +112 -3
  33. package/dist/core/context/index.js +7 -0
  34. package/dist/core/context/markdown-traverse.js +255 -0
  35. package/dist/core/cost/rate-card.js +129 -0
  36. package/dist/core/cost/tracker.js +221 -0
  37. package/dist/core/denial-tracking/index.js +8 -0
  38. package/dist/core/denial-tracking/state.js +264 -0
  39. package/dist/core/diagnostics/probe-runner.js +93 -0
  40. package/dist/core/diagnostics/probes/api.js +46 -0
  41. package/dist/core/diagnostics/probes/auth.js +86 -0
  42. package/dist/core/diagnostics/probes/bare-mode.js +42 -0
  43. package/dist/core/diagnostics/probes/cli-version.js +127 -0
  44. package/dist/core/diagnostics/probes/config.js +72 -0
  45. package/dist/core/diagnostics/probes/denial-tracking.js +57 -0
  46. package/dist/core/diagnostics/probes/disk.js +81 -0
  47. package/dist/core/diagnostics/probes/git.js +65 -0
  48. package/dist/core/diagnostics/probes/hooks.js +118 -0
  49. package/dist/core/diagnostics/probes/mcp.js +75 -0
  50. package/dist/core/diagnostics/probes/node.js +59 -0
  51. package/dist/core/diagnostics/probes/pnpm.js +36 -0
  52. package/dist/core/diagnostics/probes/pugi-md.js +89 -0
  53. package/dist/core/diagnostics/probes/sandbox.js +40 -0
  54. package/dist/core/diagnostics/probes/session.js +74 -0
  55. package/dist/core/diagnostics/probes/status-snapshot.js +488 -0
  56. package/dist/core/diagnostics/probes/workspace.js +63 -0
  57. package/dist/core/diagnostics/types.js +70 -0
  58. package/dist/core/dispatch/cache-cleanup.js +197 -0
  59. package/dist/core/dispatch/cache-handoff.js +295 -0
  60. package/dist/core/edits/dispatch.js +218 -2
  61. package/dist/core/edits/journal.js +199 -0
  62. package/dist/core/edits/layer-d-ast.js +557 -14
  63. package/dist/core/edits/verify-hook.js +273 -0
  64. package/dist/core/edits/worktree.js +322 -0
  65. package/dist/core/engine/anvil-client.js +115 -5
  66. package/dist/core/engine/budgets.js +98 -0
  67. package/dist/core/engine/context-prefix.js +155 -0
  68. package/dist/core/engine/intent.js +260 -0
  69. package/dist/core/engine/native-pugi.js +860 -211
  70. package/dist/core/engine/prompts.js +88 -2
  71. package/dist/core/engine/strip-internal-fields.js +124 -0
  72. package/dist/core/engine/tool-bridge.js +1045 -36
  73. package/dist/core/feedback/queue.js +177 -0
  74. package/dist/core/feedback/submitter.js +145 -0
  75. package/dist/core/file-cache.js +113 -1
  76. package/dist/core/hooks/events.js +44 -0
  77. package/dist/core/hooks/index.js +15 -0
  78. package/dist/core/hooks/registry.js +213 -0
  79. package/dist/core/hooks/runner.js +236 -0
  80. package/dist/core/hooks/v2/event-emitter.js +115 -0
  81. package/dist/core/hooks/v2/executor.js +282 -0
  82. package/dist/core/hooks/v2/index.js +25 -0
  83. package/dist/core/hooks/v2/lifecycle.js +104 -0
  84. package/dist/core/hooks/v2/loader.js +216 -0
  85. package/dist/core/hooks/v2/matcher.js +125 -0
  86. package/dist/core/hooks/v2/trust.js +143 -0
  87. package/dist/core/hooks/v2/types.js +86 -0
  88. package/dist/core/lsp/cache.js +105 -0
  89. package/dist/core/lsp/client.js +776 -0
  90. package/dist/core/lsp/language-detect.js +66 -0
  91. package/dist/core/lsp/post-edit-diagnostics.js +171 -0
  92. package/dist/core/mcp/client.js +75 -6
  93. package/dist/core/mcp/http-server.js +553 -0
  94. package/dist/core/mcp/orchestrator-tools.js +662 -0
  95. package/dist/core/mcp/permission.js +190 -0
  96. package/dist/core/mcp/registry.js +24 -2
  97. package/dist/core/mcp/server-tools.js +219 -0
  98. package/dist/core/mcp/server.js +397 -0
  99. package/dist/core/memory/dual-write.js +416 -0
  100. package/dist/core/memory/phase1-kinds.js +20 -0
  101. package/dist/core/memory-sync/queue.js +158 -0
  102. package/dist/core/onboarding/ensure-initialized.js +133 -0
  103. package/dist/core/onboarding/marker.js +111 -0
  104. package/dist/core/onboarding/telemetry-state.js +108 -0
  105. package/dist/core/output-style/presets.js +176 -0
  106. package/dist/core/output-style/state.js +185 -0
  107. package/dist/core/path-security.js +284 -2
  108. package/dist/core/permissions/auto-classifier.js +124 -0
  109. package/dist/core/permissions/circuit-breaker.js +83 -0
  110. package/dist/core/permissions/gate.js +278 -0
  111. package/dist/core/permissions/index.js +20 -0
  112. package/dist/core/permissions/mode.js +174 -0
  113. package/dist/core/permissions/state.js +241 -0
  114. package/dist/core/permissions/tool-class.js +93 -0
  115. package/dist/core/prd-check/parser.js +215 -0
  116. package/dist/core/prd-check/reporter.js +127 -0
  117. package/dist/core/prd-check/session-review.js +557 -0
  118. package/dist/core/prd-check/verifiers.js +223 -0
  119. package/dist/core/pugi-md/context-injector.js +76 -0
  120. package/dist/core/pugi-md/walk-up.js +207 -0
  121. package/dist/core/release-notes/parser.js +241 -0
  122. package/dist/core/release-notes/state.js +116 -0
  123. package/dist/core/repl/history.js +11 -1
  124. package/dist/core/repl/model-pricing.js +135 -0
  125. package/dist/core/repl/session.js +1897 -37
  126. package/dist/core/repl/slash-commands.js +430 -15
  127. package/dist/core/repl/store/session-store.js +31 -2
  128. package/dist/core/repl/workspace-context.js +22 -0
  129. package/dist/core/repo-map/build.js +125 -0
  130. package/dist/core/repo-map/cache.js +185 -0
  131. package/dist/core/repo-map/extractor.js +254 -0
  132. package/dist/core/repo-map/formatter.js +145 -0
  133. package/dist/core/repo-map/scanner.js +211 -0
  134. package/dist/core/retry-budget/budget.js +284 -0
  135. package/dist/core/retry-budget/index.js +5 -0
  136. package/dist/core/session.js +92 -0
  137. package/dist/core/settings.js +80 -0
  138. package/dist/core/share/formatter.js +271 -0
  139. package/dist/core/share/redactor.js +221 -0
  140. package/dist/core/share/uploader.js +267 -0
  141. package/dist/core/skills/defaults.js +457 -0
  142. package/dist/core/smoke/headless-driver.js +174 -0
  143. package/dist/core/smoke/orchestrator.js +194 -0
  144. package/dist/core/smoke/runner.js +238 -0
  145. package/dist/core/smoke/scenario-parser.js +316 -0
  146. package/dist/core/subagents/dispatcher-real.js +600 -0
  147. package/dist/core/subagents/dispatcher.js +113 -24
  148. package/dist/core/subagents/index.js +18 -5
  149. package/dist/core/subagents/isolation-matrix.js +213 -0
  150. package/dist/core/subagents/spawn.js +19 -4
  151. package/dist/core/telemetry/emitter.js +229 -0
  152. package/dist/core/telemetry/queue.js +251 -0
  153. package/dist/core/theme/context.js +91 -0
  154. package/dist/core/theme/presets.js +228 -0
  155. package/dist/core/theme/state.js +181 -0
  156. package/dist/core/todos/invariant.js +10 -0
  157. package/dist/core/todos/state.js +177 -0
  158. package/dist/core/transport/version-interceptor.js +166 -0
  159. package/dist/core/vim/keymap.js +288 -0
  160. package/dist/core/vim/state.js +92 -0
  161. package/dist/core/worktree-manager/cleanup.js +123 -0
  162. package/dist/core/worktree-manager/manager.js +303 -0
  163. package/dist/index.js +28 -0
  164. package/dist/runtime/bootstrap.js +190 -0
  165. package/dist/runtime/cli.js +3241 -343
  166. package/dist/runtime/commands/cancel.js +231 -0
  167. package/dist/runtime/commands/chain.js +489 -0
  168. package/dist/runtime/commands/codegraph-status.js +227 -0
  169. package/dist/runtime/commands/compact.js +297 -0
  170. package/dist/runtime/commands/cost.js +199 -0
  171. package/dist/runtime/commands/delegate.js +242 -11
  172. package/dist/runtime/commands/dispatch.js +126 -0
  173. package/dist/runtime/commands/doctor.js +412 -0
  174. package/dist/runtime/commands/feedback.js +184 -0
  175. package/dist/runtime/commands/hooks.js +184 -0
  176. package/dist/runtime/commands/lsp.js +368 -0
  177. package/dist/runtime/commands/mcp.js +879 -0
  178. package/dist/runtime/commands/memory.js +508 -0
  179. package/dist/runtime/commands/model.js +237 -0
  180. package/dist/runtime/commands/onboarding.js +275 -0
  181. package/dist/runtime/commands/patch.js +128 -0
  182. package/dist/runtime/commands/permissions.js +112 -0
  183. package/dist/runtime/commands/plan.js +143 -0
  184. package/dist/runtime/commands/prd-check.js +285 -0
  185. package/dist/runtime/commands/redo-blob-store.js +92 -0
  186. package/dist/runtime/commands/redo.js +361 -0
  187. package/dist/runtime/commands/release-notes.js +229 -0
  188. package/dist/runtime/commands/repo-map.js +95 -0
  189. package/dist/runtime/commands/report.js +299 -0
  190. package/dist/runtime/commands/resume.js +118 -0
  191. package/dist/runtime/commands/review-consensus.js +17 -2
  192. package/dist/runtime/commands/rewind.js +333 -0
  193. package/dist/runtime/commands/sessions.js +163 -0
  194. package/dist/runtime/commands/share.js +316 -0
  195. package/dist/runtime/commands/status.js +186 -0
  196. package/dist/runtime/commands/stickers.js +82 -0
  197. package/dist/runtime/commands/style.js +194 -0
  198. package/dist/runtime/commands/theme.js +196 -0
  199. package/dist/runtime/commands/undo.js +32 -0
  200. package/dist/runtime/commands/update.js +289 -0
  201. package/dist/runtime/commands/vim.js +140 -0
  202. package/dist/runtime/commands/worktree.js +177 -0
  203. package/dist/runtime/commands/worktrees.js +155 -0
  204. package/dist/runtime/headless-repl.js +195 -0
  205. package/dist/runtime/headless.js +543 -0
  206. package/dist/runtime/load-hooks-or-exit.js +71 -0
  207. package/dist/runtime/plan-decompose.js +531 -0
  208. package/dist/runtime/version.js +65 -0
  209. package/dist/tools/agent-tool.js +229 -0
  210. package/dist/tools/apply-patch.js +556 -0
  211. package/dist/tools/ask-user-question.js +213 -0
  212. package/dist/tools/ask-user.js +115 -0
  213. package/dist/tools/bash.js +203 -4
  214. package/dist/tools/file-tools.js +85 -14
  215. package/dist/tools/lsp-tools.js +189 -0
  216. package/dist/tools/mcp-tool.js +260 -0
  217. package/dist/tools/multi-edit.js +361 -0
  218. package/dist/tools/powershell.js +268 -0
  219. package/dist/tools/registry.js +51 -0
  220. package/dist/tools/skill-tool.js +96 -0
  221. package/dist/tools/tasks.js +208 -0
  222. package/dist/tools/todo-write.js +184 -0
  223. package/dist/tools/web-fetch.js +147 -2
  224. package/dist/tools/web-search.js +458 -0
  225. package/dist/tui/agent-progress-card.js +111 -0
  226. package/dist/tui/agent-tree.js +10 -0
  227. package/dist/tui/ask-modal.js +2 -2
  228. package/dist/tui/ask-user-question-prompt.js +192 -0
  229. package/dist/tui/compact-banner.js +81 -0
  230. package/dist/tui/conversation-pane.js +82 -8
  231. package/dist/tui/cost-table.js +111 -0
  232. package/dist/tui/doctor-table.js +46 -0
  233. package/dist/tui/feedback-prompt.js +156 -0
  234. package/dist/tui/input-box.js +218 -3
  235. package/dist/tui/markdown-render.js +4 -4
  236. package/dist/tui/onboarding-wizard.js +240 -0
  237. package/dist/tui/permissions-picker.js +86 -0
  238. package/dist/tui/render.js +35 -0
  239. package/dist/tui/repl-render.js +313 -35
  240. package/dist/tui/repl-splash-art.js +1 -1
  241. package/dist/tui/repl-splash-mascot.js +32 -8
  242. package/dist/tui/repl-splash.js +2 -2
  243. package/dist/tui/repl.js +85 -5
  244. package/dist/tui/splash.js +1 -1
  245. package/dist/tui/status-bar.js +94 -16
  246. package/dist/tui/status-table.js +7 -0
  247. package/dist/tui/stickers-art.js +136 -0
  248. package/dist/tui/style-table.js +28 -0
  249. package/dist/tui/theme-table.js +29 -0
  250. package/dist/tui/thinking-spinner.js +123 -0
  251. package/dist/tui/tool-stream-pane.js +52 -3
  252. package/dist/tui/update-banner.js +27 -2
  253. package/dist/tui/vim-input.js +267 -0
  254. package/dist/tui/welcome-banner.js +107 -0
  255. package/dist/tui/welcome-data.js +293 -0
  256. package/docs/examples/codegraph.mcp.json +10 -0
  257. package/package.json +12 -6
  258. package/test/scenarios/codegen-create-file.scenario.txt +13 -0
  259. package/test/scenarios/compact-force.scenario.txt +11 -0
  260. package/test/scenarios/identity.scenario.txt +11 -0
  261. package/test/scenarios/persona-handoff.scenario.txt +11 -0
  262. package/test/scenarios/walkback.scenario.txt +12 -0
  263. 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
+ * Leak L25 (2026-05-27) — 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
+ // Wave 7: number shortcuts mirror the canonical 6-mode order.
53
+ // Operators coming from Claude Code 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
+ // Wave 7: 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
@@ -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
  /**
@@ -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