arc402-cli 0.8.0 → 0.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.
Files changed (65) hide show
  1. package/INK6-UX-SPEC.md +446 -0
  2. package/dist/tui/App.d.ts.map +1 -1
  3. package/dist/tui/App.js +43 -3
  4. package/dist/tui/App.js.map +1 -1
  5. package/dist/tui/Header.d.ts +1 -1
  6. package/dist/tui/Header.d.ts.map +1 -1
  7. package/dist/tui/Header.js +6 -5
  8. package/dist/tui/Header.js.map +1 -1
  9. package/dist/tui/InputLine.d.ts +1 -2
  10. package/dist/tui/InputLine.d.ts.map +1 -1
  11. package/dist/tui/InputLine.js +76 -24
  12. package/dist/tui/InputLine.js.map +1 -1
  13. package/dist/tui/components/Button.d.ts +7 -0
  14. package/dist/tui/components/Button.d.ts.map +1 -0
  15. package/dist/tui/components/Button.js +18 -0
  16. package/dist/tui/components/Button.js.map +1 -0
  17. package/dist/tui/components/CeremonyView.d.ts +13 -0
  18. package/dist/tui/components/CeremonyView.d.ts.map +1 -0
  19. package/dist/tui/components/CeremonyView.js +7 -0
  20. package/dist/tui/components/CeremonyView.js.map +1 -0
  21. package/dist/tui/components/CompletionDropdown.d.ts +7 -0
  22. package/dist/tui/components/CompletionDropdown.d.ts.map +1 -0
  23. package/dist/tui/components/CompletionDropdown.js +20 -0
  24. package/dist/tui/components/CompletionDropdown.js.map +1 -0
  25. package/dist/tui/components/ConfirmPrompt.d.ts +9 -0
  26. package/dist/tui/components/ConfirmPrompt.d.ts.map +1 -0
  27. package/dist/tui/components/ConfirmPrompt.js +7 -0
  28. package/dist/tui/components/ConfirmPrompt.js.map +1 -0
  29. package/dist/tui/components/InteractiveTable.d.ts +14 -0
  30. package/dist/tui/components/InteractiveTable.d.ts.map +1 -0
  31. package/dist/tui/components/InteractiveTable.js +58 -0
  32. package/dist/tui/components/InteractiveTable.js.map +1 -0
  33. package/dist/tui/components/StepSpinner.d.ts +11 -0
  34. package/dist/tui/components/StepSpinner.d.ts.map +1 -0
  35. package/dist/tui/components/StepSpinner.js +29 -0
  36. package/dist/tui/components/StepSpinner.js.map +1 -0
  37. package/dist/tui/components/Toast.d.ts +18 -0
  38. package/dist/tui/components/Toast.d.ts.map +1 -0
  39. package/dist/tui/components/Toast.js +25 -0
  40. package/dist/tui/components/Toast.js.map +1 -0
  41. package/dist/tui/index.d.ts.map +1 -1
  42. package/dist/tui/index.js +15 -1
  43. package/dist/tui/index.js.map +1 -1
  44. package/dist/tui/useNotifications.d.ts +9 -0
  45. package/dist/tui/useNotifications.d.ts.map +1 -0
  46. package/dist/tui/useNotifications.js +14 -0
  47. package/dist/tui/useNotifications.js.map +1 -0
  48. package/dist/ui/banner.d.ts +12 -0
  49. package/dist/ui/banner.d.ts.map +1 -1
  50. package/dist/ui/banner.js +23 -0
  51. package/dist/ui/banner.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/tui/App.tsx +53 -9
  54. package/src/tui/Header.tsx +25 -4
  55. package/src/tui/InputLine.tsx +107 -32
  56. package/src/tui/components/Button.tsx +38 -0
  57. package/src/tui/components/CeremonyView.tsx +39 -0
  58. package/src/tui/components/CompletionDropdown.tsx +59 -0
  59. package/src/tui/components/ConfirmPrompt.tsx +36 -0
  60. package/src/tui/components/InteractiveTable.tsx +112 -0
  61. package/src/tui/components/StepSpinner.tsx +84 -0
  62. package/src/tui/components/Toast.tsx +59 -0
  63. package/src/tui/index.tsx +20 -1
  64. package/src/tui/useNotifications.ts +28 -0
  65. package/src/ui/banner.ts +27 -0
@@ -5,5 +5,17 @@ export interface BannerConfig {
5
5
  }
6
6
  /** Returns banner as an array of plain lines (no trailing newlines). */
7
7
  export declare function getBannerLines(config?: BannerConfig): string[];
8
+ export interface StatusItem {
9
+ label: string;
10
+ value: string;
11
+ }
12
+ /** Returns the ASCII art lines (no status info) and a subtitle line. */
13
+ export declare function getBannerArt(): {
14
+ artLines: string[];
15
+ subtitle: string;
16
+ separator: string;
17
+ };
18
+ /** Returns structured status items for flexWrap rendering. */
19
+ export declare function getStatusItems(config?: BannerConfig): StatusItem[];
8
20
  export declare function renderBanner(config?: BannerConfig): void;
9
21
  //# sourceMappingURL=banner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/ui/banner.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAsB9D;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAIxD"}
1
+ {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/ui/banner.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAsB9D;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,wBAAgB,YAAY,IAAI;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAU1F;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,EAAE,CAMlE;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAIxD"}
package/dist/ui/banner.js CHANGED
@@ -33,6 +33,29 @@ export function getBannerLines(config) {
33
33
  lines.push("");
34
34
  return lines;
35
35
  }
36
+ /** Returns the ASCII art lines (no status info) and a subtitle line. */
37
+ export function getBannerArt() {
38
+ const artLines = [];
39
+ for (const l of ART.split("\n").slice(1)) {
40
+ artLines.push(chalk.cyan(l));
41
+ }
42
+ return {
43
+ artLines,
44
+ subtitle: " " + chalk.dim(`agent-to-agent arcing · v${_pkg.version}`),
45
+ separator: " " + SEPARATOR,
46
+ };
47
+ }
48
+ /** Returns structured status items for flexWrap rendering. */
49
+ export function getStatusItems(config) {
50
+ const items = [];
51
+ if (config?.network)
52
+ items.push({ label: "Network", value: config.network });
53
+ if (config?.wallet)
54
+ items.push({ label: "Wallet", value: config.wallet });
55
+ if (config?.balance)
56
+ items.push({ label: "Balance", value: config.balance });
57
+ return items;
58
+ }
36
59
  export function renderBanner(config) {
37
60
  for (const line of getBannerLines(config)) {
38
61
  console.log(line);
@@ -1 +1 @@
1
- {"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/ui/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAwB,CAAC;AAEzF,MAAM,GAAG,GAAG;;;;;;wDAM4C,CAAC;AAEzD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAQ1E,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAqB;IAClD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,sCAAsC;IACtC,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAA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MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,MAAM,EAAE,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,IAAI,MAAM,EAAE,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,IAAI,MAAM,EAAE,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arc402-cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "ARC-402 CLI for discovery, negotiation payloads, hire/remediation/dispute workflows, and network reads",
5
5
  "bin": {
6
6
  "arc402": "./dist/index.js"
package/src/tui/App.tsx CHANGED
@@ -1,14 +1,16 @@
1
1
  import React, { useState, useCallback, useEffect } from "react";
2
2
  import { createRequire } from "node:module";
3
- import { Box, Text, useApp } from "ink";
4
- import { Header } from "./Header.js";
3
+ import { Box, Text, Static, useApp, useInput } from "ink";
5
4
  import { Viewport } from "./Viewport.js";
6
5
  import { Footer } from "./Footer.js";
7
6
  import { InputLine } from "./InputLine.js";
8
7
  import { useCommand } from "./useCommand.js";
9
8
  import { useChat } from "./useChat.js";
10
9
  import { useScroll } from "./useScroll.js";
10
+ import { useNotifications } from "./useNotifications.js";
11
+ import { ToastContainer } from "./components/Toast.js";
11
12
  import { createProgram } from "../program.js";
13
+ import { getBannerArt, getStatusItems } from "../ui/banner.js";
12
14
  import chalk from "chalk";
13
15
 
14
16
  const pkg = createRequire(import.meta.url)("../../package.json") as { version: string };
@@ -27,6 +29,32 @@ interface AppProps {
27
29
  */
28
30
  export function App({ version, network, wallet, balance }: AppProps) {
29
31
  const { exit } = useApp();
32
+
33
+ // Banner computed once — rendered via <Static> so it never re-renders
34
+ const [bannerData] = useState(() => {
35
+ const { artLines, subtitle, separator } = getBannerArt();
36
+ const statusItems = getStatusItems({ network, wallet, balance });
37
+ // Build static items: art lines + subtitle + separator + status + help hint
38
+ const items: { id: string; text: string }[] = [];
39
+ artLines.forEach((line, i) => items.push({ id: `art-${i}`, text: line }));
40
+ items.push({ id: "blank-1", text: "" });
41
+ items.push({ id: "subtitle", text: subtitle });
42
+ items.push({ id: "separator", text: separator });
43
+ if (statusItems.length > 0) {
44
+ items.push({ id: "blank-2", text: "" });
45
+ // Status items as a single formatted line for <Static>
46
+ // (FlexWrap rendering happens in the Header component for non-Static contexts)
47
+ const statusLine = statusItems
48
+ .map((s) => `\x1b[2m${s.label}\x1b[22m ${s.value}`)
49
+ .join(" ");
50
+ items.push({ id: "status", text: ` ${statusLine}` });
51
+ }
52
+ items.push({ id: "blank-3", text: "" });
53
+ items.push({ id: "hint", text: " \x1b[2mType 'help' to get started\x1b[22m" });
54
+ items.push({ id: "blank-4", text: "" });
55
+ return items;
56
+ });
57
+
30
58
  const [outputBuffer, setOutputBuffer] = useState<string[]>([
31
59
  chalk.dim(" Type 'help' to see available commands"),
32
60
  "",
@@ -45,6 +73,8 @@ export function App({ version, network, wallet, balance }: AppProps) {
45
73
  const { scrollOffset, isAutoScroll, scrollUp, scrollDown, snapToBottom } =
46
74
  useScroll(viewportHeight);
47
75
 
76
+ const { toasts, dismiss: dismissToast } = useNotifications();
77
+
48
78
  // Get top-level command names for dispatch detection
49
79
  const [topCmds] = useState<string[]>(() => {
50
80
  try {
@@ -55,6 +85,20 @@ export function App({ version, network, wallet, balance }: AppProps) {
55
85
  }
56
86
  });
57
87
 
88
+ // ── Enhanced keyboard shortcuts ────────────────────────────────────────
89
+ useInput((input, key) => {
90
+ // Ctrl+L — clear viewport
91
+ if (key.ctrl && input === "l") {
92
+ setOutputBuffer([]);
93
+ return;
94
+ }
95
+ // Escape — cancel / clear (snap to bottom if scrolled)
96
+ if (key.escape) {
97
+ snapToBottom();
98
+ return;
99
+ }
100
+ });
101
+
58
102
  const appendLine = useCallback((line: string) => {
59
103
  setOutputBuffer((prev) => [...prev, line]);
60
104
  }, []);
@@ -185,13 +229,10 @@ export function App({ version, network, wallet, balance }: AppProps) {
185
229
 
186
230
  return (
187
231
  <Box flexDirection="column" height="100%">
188
- {/* HEADERfixed, never scrolls */}
189
- <Header
190
- version={version}
191
- network={network}
192
- wallet={wallet}
193
- balance={balance}
194
- />
232
+ {/* BANNERrendered once via <Static>, never re-renders */}
233
+ <Static items={bannerData}>
234
+ {(item) => <Text key={item.id}>{item.text}</Text>}
235
+ </Static>
195
236
 
196
237
  {/* Separator */}
197
238
  <Box>
@@ -205,6 +246,9 @@ export function App({ version, network, wallet, balance }: AppProps) {
205
246
  isAutoScroll={isAutoScroll}
206
247
  />
207
248
 
249
+ {/* Notification toasts — above footer */}
250
+ <ToastContainer toasts={toasts} onDismiss={dismissToast} />
251
+
208
252
  {/* Bottom separator */}
209
253
  <Box>
210
254
  <Text dimColor>{"─".repeat(60)}</Text>
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { Box, Text } from "ink";
3
- import { getBannerLines } from "../ui/banner.js";
3
+ import { getBannerArt, getStatusItems } from "../ui/banner.js";
4
+ import type { BannerConfig } from "../ui/banner.js";
4
5
 
5
6
  interface HeaderProps {
6
7
  version: string;
@@ -11,20 +12,40 @@ interface HeaderProps {
11
12
 
12
13
  /**
13
14
  * Fixed header showing the ASCII art banner + status info.
14
- * Never re-renders unless config changes.
15
+ * Status items use flexWrap to adapt to narrow terminals.
15
16
  */
16
17
  export const Header = React.memo(function Header({
17
18
  network,
18
19
  wallet,
19
20
  balance,
20
21
  }: HeaderProps) {
21
- const bannerLines = getBannerLines({ network, wallet, balance });
22
+ const { artLines, subtitle, separator } = getBannerArt();
23
+ const statusItems = getStatusItems({ network, wallet, balance });
22
24
 
23
25
  return (
24
26
  <Box flexDirection="column">
25
- {bannerLines.map((line, i) => (
27
+ {artLines.map((line, i) => (
26
28
  <Text key={i}>{line}</Text>
27
29
  ))}
30
+ <Text>{""}</Text>
31
+ <Text>{subtitle}</Text>
32
+ <Text>{separator}</Text>
33
+ {statusItems.length > 0 && (
34
+ <>
35
+ <Text>{""}</Text>
36
+ <Box flexWrap="wrap" columnGap={2}>
37
+ {statusItems.map((item) => (
38
+ <Box key={item.label}>
39
+ <Text dimColor>{item.label}</Text>
40
+ <Text> {item.value}</Text>
41
+ </Box>
42
+ ))}
43
+ </Box>
44
+ </>
45
+ )}
46
+ <Text>{""}</Text>
47
+ <Text dimColor>{" Type 'help' to get started"}</Text>
48
+ <Text>{""}</Text>
28
49
  </Box>
29
50
  );
30
51
  });
@@ -1,7 +1,8 @@
1
- import React, { useState, useCallback } from "react";
1
+ import React, { useState, useCallback, useMemo } from "react";
2
2
  import { Box, Text, useInput } from "ink";
3
3
  import TextInput from "ink-text-input";
4
4
  import { createProgram } from "../program.js";
5
+ import { CompletionDropdown } from "./components/CompletionDropdown.js";
5
6
 
6
7
  const BUILTIN_CMDS = ["help", "exit", "quit", "clear", "status"];
7
8
 
@@ -11,8 +12,7 @@ interface InputLineProps {
11
12
  }
12
13
 
13
14
  /**
14
- * Input line with command history navigation and tab completion.
15
- * Uses ink-text-input for text input with cursor.
15
+ * Input line with command history navigation, tab completion, and dropdown.
16
16
  */
17
17
  export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
18
18
  const [value, setValue] = useState("");
@@ -20,6 +20,11 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
20
20
  const [historyIdx, setHistoryIdx] = useState(-1);
21
21
  const [historyTemp, setHistoryTemp] = useState("");
22
22
 
23
+ // Dropdown state
24
+ const [showDropdown, setShowDropdown] = useState(false);
25
+ const [dropdownIdx, setDropdownIdx] = useState(0);
26
+ const [dropdownCandidates, setDropdownCandidates] = useState<string[]>([]);
27
+
23
28
  // Lazily build command list for tab completion
24
29
  const [topCmds] = useState<string[]>(() => {
25
30
  try {
@@ -44,12 +49,30 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
44
49
  }
45
50
  });
46
51
 
52
+ const getCompletions = useCallback(
53
+ (input: string): string[] => {
54
+ const allTop = [...BUILTIN_CMDS, ...topCmds];
55
+ const trimmed = input.trimStart();
56
+ const spaceIdx = trimmed.indexOf(" ");
57
+
58
+ if (spaceIdx === -1) {
59
+ return allTop.filter((cmd) => cmd.startsWith(trimmed));
60
+ }
61
+ const parent = trimmed.slice(0, spaceIdx);
62
+ const rest = trimmed.slice(spaceIdx + 1);
63
+ const subs = subCmds.get(parent) ?? [];
64
+ return subs
65
+ .filter((s) => s.startsWith(rest))
66
+ .map((s) => `${parent} ${s}`);
67
+ },
68
+ [topCmds, subCmds]
69
+ );
70
+
47
71
  const handleSubmit = useCallback(
48
72
  (val: string) => {
49
73
  const trimmed = val.trim();
50
74
  if (!trimmed) return;
51
75
 
52
- // Add to history (avoid duplicate of last entry)
53
76
  setHistory((prev) => {
54
77
  if (prev[prev.length - 1] === trimmed) return prev;
55
78
  return [...prev, trimmed];
@@ -57,6 +80,7 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
57
80
  setHistoryIdx(-1);
58
81
  setHistoryTemp("");
59
82
  setValue("");
83
+ setShowDropdown(false);
60
84
 
61
85
  onSubmit(trimmed);
62
86
  },
@@ -67,7 +91,33 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
67
91
  (_input, key) => {
68
92
  if (isDisabled) return;
69
93
 
70
- // Up arrow history prev
94
+ // ── Dropdown navigation ───────────────────────────────────────────
95
+ if (showDropdown) {
96
+ if (key.upArrow) {
97
+ setDropdownIdx((i) => Math.max(0, i - 1));
98
+ return;
99
+ }
100
+ if (key.downArrow) {
101
+ setDropdownIdx((i) =>
102
+ Math.min(dropdownCandidates.length - 1, i + 1)
103
+ );
104
+ return;
105
+ }
106
+ if (key.return) {
107
+ // Select the highlighted candidate
108
+ if (dropdownCandidates[dropdownIdx]) {
109
+ setValue(dropdownCandidates[dropdownIdx] + " ");
110
+ }
111
+ setShowDropdown(false);
112
+ return;
113
+ }
114
+ if (key.escape) {
115
+ setShowDropdown(false);
116
+ return;
117
+ }
118
+ }
119
+
120
+ // ── History navigation ────────────────────────────────────────────
71
121
  if (key.upArrow) {
72
122
  setHistory((hist) => {
73
123
  setHistoryIdx((idx) => {
@@ -88,7 +138,6 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
88
138
  return;
89
139
  }
90
140
 
91
- // Down arrow — history next
92
141
  if (key.downArrow) {
93
142
  setHistory((hist) => {
94
143
  setHistoryIdx((idx) => {
@@ -109,32 +158,27 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
109
158
  return;
110
159
  }
111
160
 
112
- // Tab — completion
161
+ // ── Tab — completion / dropdown ───────────────────────────────────
113
162
  if (_input === "\t") {
114
- const allTop = [...BUILTIN_CMDS, ...topCmds];
115
- const trimmed = value.trimStart();
116
- const spaceIdx = trimmed.indexOf(" ");
163
+ const completions = getCompletions(value);
117
164
 
118
- let completions: string[];
119
- if (spaceIdx === -1) {
120
- completions = allTop.filter((cmd) => cmd.startsWith(trimmed));
121
- } else {
122
- const parent = trimmed.slice(0, spaceIdx);
123
- const rest = trimmed.slice(spaceIdx + 1);
124
- const subs = subCmds.get(parent) ?? [];
125
- completions = subs
126
- .filter((s) => s.startsWith(rest))
127
- .map((s) => `${parent} ${s}`);
165
+ if (completions.length === 0) {
166
+ setShowDropdown(false);
167
+ return;
128
168
  }
129
169
 
130
- if (completions.length === 0) return;
131
-
132
170
  if (completions.length === 1) {
133
171
  setValue(completions[0] + " ");
172
+ setShowDropdown(false);
134
173
  return;
135
174
  }
136
175
 
137
- // Find common prefix
176
+ // Show dropdown with multiple candidates
177
+ setDropdownCandidates(completions);
178
+ setDropdownIdx(0);
179
+ setShowDropdown(true);
180
+
181
+ // Also advance to common prefix
138
182
  const common = completions.reduce((a, b) => {
139
183
  let i = 0;
140
184
  while (i < a.length && i < b.length && a[i] === b[i]) i++;
@@ -144,21 +188,52 @@ export function InputLine({ onSubmit, isDisabled = false }: InputLineProps) {
144
188
  setValue(common);
145
189
  }
146
190
  }
191
+
192
+ // ── Escape — dismiss dropdown ─────────────────────────────────────
193
+ if (key.escape) {
194
+ setShowDropdown(false);
195
+ }
147
196
  },
148
197
  { isActive: !isDisabled }
149
198
  );
150
199
 
200
+ // Dismiss dropdown when value changes (user types more)
201
+ const handleChange = useCallback(
202
+ (newVal: string) => {
203
+ setValue(newVal);
204
+ // If dropdown is open, update candidates live
205
+ if (showDropdown) {
206
+ const completions = getCompletions(newVal);
207
+ if (completions.length <= 1) {
208
+ setShowDropdown(false);
209
+ } else {
210
+ setDropdownCandidates(completions);
211
+ setDropdownIdx(0);
212
+ }
213
+ }
214
+ },
215
+ [showDropdown, getCompletions]
216
+ );
217
+
151
218
  return (
152
- <Box>
153
- <Text color="cyan">◈</Text>
154
- <Text dimColor> arc402 </Text>
155
- <Text color="white">{">"} </Text>
156
- <TextInput
157
- value={value}
158
- onChange={setValue}
159
- onSubmit={handleSubmit}
160
- focus={!isDisabled}
219
+ <Box flexDirection="column">
220
+ {/* Completion dropdown renders above the input */}
221
+ <CompletionDropdown
222
+ candidates={dropdownCandidates}
223
+ selectedIndex={dropdownIdx}
224
+ visible={showDropdown}
161
225
  />
226
+ <Box>
227
+ <Text color="cyan">◈</Text>
228
+ <Text dimColor> arc402 </Text>
229
+ <Text color="white">{">"} </Text>
230
+ <TextInput
231
+ value={value}
232
+ onChange={handleChange}
233
+ onSubmit={handleSubmit}
234
+ focus={!isDisabled}
235
+ />
236
+ </Box>
162
237
  </Box>
163
238
  );
164
239
  }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import { Box, Text, useFocus, useInput } from "ink";
3
+
4
+ export interface ButtonProps {
5
+ label: string;
6
+ onPress: () => void;
7
+ variant?: "primary" | "danger" | "dim";
8
+ }
9
+
10
+ const VARIANT_COLORS: Record<string, string> = {
11
+ primary: "cyan",
12
+ danger: "red",
13
+ dim: "gray",
14
+ };
15
+
16
+ export function Button({ label, onPress, variant = "primary" }: ButtonProps) {
17
+ const { isFocused } = useFocus();
18
+
19
+ useInput(
20
+ (_input, key) => {
21
+ if (key.return) {
22
+ onPress();
23
+ }
24
+ },
25
+ { isActive: isFocused }
26
+ );
27
+
28
+ const color = isFocused ? VARIANT_COLORS[variant] ?? "cyan" : "white";
29
+
30
+ return (
31
+ <Box>
32
+ <Text color={color} bold={isFocused}>
33
+ {isFocused ? "▸ " : " "}
34
+ {label}
35
+ </Text>
36
+ </Box>
37
+ );
38
+ }
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import { Box, Text } from "ink";
3
+ import { StepSpinner } from "./StepSpinner.js";
4
+ import type { StepStatus } from "./StepSpinner.js";
5
+
6
+ export interface CeremonyStep {
7
+ label: string;
8
+ status: StepStatus;
9
+ detail?: string;
10
+ error?: string;
11
+ }
12
+
13
+ export interface CeremonyViewProps {
14
+ title: string;
15
+ steps: CeremonyStep[];
16
+ }
17
+
18
+ export function CeremonyView({ title, steps }: CeremonyViewProps) {
19
+ return (
20
+ <Box flexDirection="column">
21
+ <Box marginBottom={1}>
22
+ <Text bold color="cyan">
23
+ ◈ {title}
24
+ </Text>
25
+ </Box>
26
+ {steps.map((step, i) => (
27
+ <StepSpinner
28
+ key={i}
29
+ step={i + 1}
30
+ total={steps.length}
31
+ label={step.label}
32
+ status={step.status}
33
+ detail={step.detail}
34
+ error={step.error}
35
+ />
36
+ ))}
37
+ </Box>
38
+ );
39
+ }
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import { Box, Text } from "ink";
3
+
4
+ export interface CompletionDropdownProps {
5
+ candidates: string[];
6
+ selectedIndex: number;
7
+ visible: boolean;
8
+ }
9
+
10
+ const MAX_VISIBLE = 8;
11
+
12
+ export function CompletionDropdown({
13
+ candidates,
14
+ selectedIndex,
15
+ visible,
16
+ }: CompletionDropdownProps) {
17
+ if (!visible || candidates.length === 0) return null;
18
+
19
+ // Window the list if there are too many candidates
20
+ let startIdx = 0;
21
+ if (candidates.length > MAX_VISIBLE) {
22
+ startIdx = Math.max(0, selectedIndex - Math.floor(MAX_VISIBLE / 2));
23
+ startIdx = Math.min(startIdx, candidates.length - MAX_VISIBLE);
24
+ }
25
+ const visibleCandidates = candidates.slice(
26
+ startIdx,
27
+ startIdx + MAX_VISIBLE
28
+ );
29
+
30
+ return (
31
+ <Box flexDirection="column" marginLeft={4}>
32
+ <Box>
33
+ <Text dimColor>{"┌─ completions ─"}</Text>
34
+ </Box>
35
+ {visibleCandidates.map((candidate, i) => {
36
+ const actualIdx = startIdx + i;
37
+ const isSelected = actualIdx === selectedIndex;
38
+ return (
39
+ <Box key={candidate}>
40
+ <Text dimColor>{"│"}</Text>
41
+ <Text color={isSelected ? "cyan" : "white"} bold={isSelected}>
42
+ {isSelected ? " ▸ " : " "}
43
+ {candidate}
44
+ </Text>
45
+ </Box>
46
+ );
47
+ })}
48
+ <Box>
49
+ <Text dimColor>{"└─"}</Text>
50
+ {candidates.length > MAX_VISIBLE && (
51
+ <Text dimColor>
52
+ {" "}
53
+ ({candidates.length} total)
54
+ </Text>
55
+ )}
56
+ </Box>
57
+ </Box>
58
+ );
59
+ }
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { Box, Text } from "ink";
3
+ import { Button } from "./Button.js";
4
+
5
+ export interface ConfirmPromptProps {
6
+ message: string;
7
+ onConfirm: () => void;
8
+ onCancel: () => void;
9
+ confirmLabel?: string;
10
+ cancelLabel?: string;
11
+ }
12
+
13
+ export function ConfirmPrompt({
14
+ message,
15
+ onConfirm,
16
+ onCancel,
17
+ confirmLabel = "Confirm",
18
+ cancelLabel = "Cancel",
19
+ }: ConfirmPromptProps) {
20
+ return (
21
+ <Box flexDirection="column">
22
+ <Box marginBottom={1}>
23
+ <Text bold color="cyan">
24
+ ◈ {message}
25
+ </Text>
26
+ </Box>
27
+ <Box gap={2}>
28
+ <Button label={confirmLabel} onPress={onConfirm} variant="primary" />
29
+ <Button label={cancelLabel} onPress={onCancel} variant="dim" />
30
+ </Box>
31
+ <Box marginTop={1}>
32
+ <Text dimColor>Tab to switch · Enter to select</Text>
33
+ </Box>
34
+ </Box>
35
+ );
36
+ }