@orkestrel/terminal 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # @orkestrel/terminal
2
2
 
3
- An interactive terminal-prompt toolkit for the `@orkestrel` line — six
4
- prompt forms (`input`, `password`, `confirm`, `select`, `checkbox`,
5
- `editor`) modelled as pure, event-free state machines, driven across three
6
- symmetric surfaces: a headless `Prompt` broker that parks each call and
7
- resolves it when answered, an SSE `PromptClient` bridge that dispatches a
8
- remote prompt to a local terminal, and a raw-mode `Terminal` driver
9
- (`node:readline` fallback when piped) that answers each prompt at this
10
- machine's keyboard. Built to sit beside `@orkestrel/console` (the shared
11
- style engine), `@orkestrel/contract`, `@orkestrel/emitter`, and
12
- `@orkestrel/sse`, reusing all four as it takes shape.
3
+ The terminal side of a form, for the `@orkestrel` line. `@orkestrel/form` owns
4
+ the document — the schema, the twelve controls, the rules, the values, and the
5
+ settle-once `answer` promise. This package owns what form has no opinion about:
6
+ a key decoder, a theme, pure per-field reducers, and three surfaces one form
7
+ can be answered on. The server `Terminal` implements the one driving contract
8
+ against a real TTY (raw-mode stdin, live in-place re-render, a `node:readline`
9
+ fallback when piped). The headless `Prompt` broker PARKS a live form until
10
+ somebody elsewhere answers it. The `PromptClient` bridge carries a form parked
11
+ elsewhere to this machine's keyboard over SSE. Built beside
12
+ `@orkestrel/console` (the shared style engine), `@orkestrel/contract`,
13
+ `@orkestrel/emitter`, `@orkestrel/database`, and `@orkestrel/sse`.
13
14
 
14
15
  ## Install
15
16
 
@@ -17,60 +18,77 @@ style engine), `@orkestrel/contract`, `@orkestrel/emitter`, and
17
18
  npm install @orkestrel/terminal
18
19
  ```
19
20
 
21
+ `@orkestrel/form` is pinned to a committed tarball until it is published, so
22
+ this package is not publishable yet. The pin, its standing conditions, and the
23
+ re-pin recipe are recorded in [guides/terminal.md](./guides/terminal.md).
24
+
20
25
  ## Requirements
21
26
 
22
27
  - Node.js >= 22
23
- - Core is ESM; the `./server` subpath ships dual ESM+CJS builds
28
+ - Core and `./server` both ship dual ESM+CJS builds
24
29
 
25
30
  ## Usage
26
31
 
27
- Park a prompt headlessly and answer it from elsewhere (an SSE transport, a
28
- remote terminal):
32
+ Ask one whole form at this machine's keyboard:
29
33
 
30
34
  ```ts
31
- import { createPrompt } from '@orkestrel/terminal'
35
+ import { createForm } from '@orkestrel/form'
36
+ import { createTerminal } from '@orkestrel/terminal/server'
32
37
 
33
- const prompt = createPrompt()
34
- prompt.emitter.on('pending', (pending) => send(pending)) // forward to a remote client
35
- const name = await prompt.input({ message: 'Your name', validate: { required: true } })
38
+ const terminal = createTerminal()
39
+ const values = await terminal.ask(
40
+ createForm({
41
+ fields: [
42
+ { control: 'text', name: 'name', label: 'Your name', rule: { required: true } },
43
+ { control: 'confirm', name: 'terms', label: 'Accept the terms', rule: { required: true } },
44
+ ],
45
+ }),
46
+ )
36
47
  ```
37
48
 
38
- Drive the same six prompt forms locally at this machine's keyboard:
49
+ A bare return binds ABSENCE, not the empty string, so `required` refuses it and
50
+ the walk asks again.
51
+
52
+ Park a live form and answer it from anywhere else:
39
53
 
40
54
  ```ts
41
- import { createTerminal } from '@orkestrel/terminal/server'
55
+ import { createForm } from '@orkestrel/form'
56
+ import { createPrompt } from '@orkestrel/terminal'
42
57
 
43
- const terminal = createTerminal()
44
- const name = await terminal.input({ message: 'Your name' })
45
- const proceed = await terminal.confirm({ message: 'Continue?', default: true })
58
+ const prompt = createPrompt()
59
+ prompt.emitter.on('pending', (form) => send(form)) // the wire-safe record
60
+
61
+ const form = createForm({ fields: [{ control: 'text', name: 'name' }] })
62
+ const id = prompt.park(form) // the id; you await the form's own `answer`
63
+ prompt.answer(id, { name: 'Ada' }) // fills and submits the AUTHORITATIVE form
64
+ const values = await form.answer // { name: 'Ada' }
46
65
  ```
47
66
 
48
- Bridge a remote broker's prompts to a local terminal over SSE:
67
+ Bridge a form parked elsewhere to a local terminal over SSE:
49
68
 
50
69
  ```ts
51
70
  import { createPromptClient } from '@orkestrel/terminal'
52
71
  import { createTerminal } from '@orkestrel/terminal/server'
53
72
 
54
73
  const client = createPromptClient({
55
- url: 'http://localhost:3000/prompts',
74
+ url: 'http://localhost:3000/forms',
56
75
  terminal: createTerminal(),
57
76
  })
58
- await client.connect()
77
+ await client.connect() // renders each parked form here, POSTs { id, values } back
59
78
  ```
60
79
 
61
80
  ## Guide
62
81
 
63
- See [guides/src/terminal.md](./guides/src/terminal.md) for the full
64
- documented surface — the six prompt forms, the headless broker, the SSE
65
- bridge, and the raw-mode terminal driver.
82
+ See [guides/terminal.md](./guides/terminal.md) for the documented surface — the
83
+ driving contract, the pure reducers, the broker, the wire seam, the SSE bridge,
84
+ the multi-endpoint manager, the stores, and the TTY driver.
66
85
 
67
86
  ## Package
68
87
 
69
- Published as two entry points per the `exports` field in `package.json`:
70
- `.` (the environment-agnostic core — the pure prompt reducers, the
71
- `Prompt` broker, and the `PromptClient` bridge) and `./server` (the
72
- Node-only `Terminal` driver). Core is ESM-only; `./server` ships dual
73
- ESM+CJS builds.
88
+ Two entry points, per the `exports` field in `package.json`: `.` (the
89
+ host-independent core — the reducers, the broker, the bridge, the manager, and
90
+ the stores) and `./server` (the Node-only `Terminal` driver). Both entry points
91
+ ship dual ESM+CJS builds.
74
92
 
75
93
  ## License
76
94