# tj/co-prompt architecture

> Architecture diagram of the GitHub repository tj/co-prompt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tj/co-prompt
- Repository: https://github.com/tj/co-prompt

## Overview

co-prompt is a small Node.js terminal-input library whose API returns thunks for use with co. A co caller yields prompt, multiline, confirmation, or password input; the thunk reads terminal input and returns a value. Confirmation reuses the basic prompt and parses its response as a boolean. The sampled implementation shows terminal stream handling and the password keypress dependency; no separate domain or storage layers are present.

Main entry points: [`index.js`](https://github.com/tj/co-prompt/blob/master/index.js) (Password)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_co(("co Caller"))
node_prompt["Prompt<br/>[index.js]"]
node_multiline["Multiline<br/>[index.js]"]
node_confirm["Confirmation<br/>[index.js]"]
node_password["Password<br/>[index.js]"]
node_terminal["Terminal Streams"]
node_keypress["keypress Package"]

node_co -->|"yields thunk"| node_prompt
node_co -->|"yields thunk"| node_multiline
node_co -->|"yields thunk"| node_confirm
node_co -->|"yields thunk"| node_password
node_prompt -->|"writes and reads"| node_terminal
node_multiline -->|"writes and reads"| node_terminal
node_confirm -->|"calls"| node_prompt
node_password -->|"writes and reads"| node_terminal
node_password -->|"configures input"| node_keypress

click node_prompt "https://github.com/tj/co-prompt/blob/master/index.js"
click node_multiline "https://github.com/tj/co-prompt/blob/master/index.js"
click node_confirm "https://github.com/tj/co-prompt/blob/master/index.js"
click node_password "https://github.com/tj/co-prompt/blob/master/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_co,node_terminal,node_keypress toneIndigo
class node_prompt,node_multiline,node_confirm,node_password toneTeal
```

## Components

### Other components

- **co Caller**
- [Prompt](https://github.com/tj/co-prompt/blob/master/index.js): `index.js`
- [Multiline](https://github.com/tj/co-prompt/blob/master/index.js): `index.js`
- [Confirmation](https://github.com/tj/co-prompt/blob/master/index.js): `index.js`
- [Password](https://github.com/tj/co-prompt/blob/master/index.js): `index.js`
- **Terminal Streams**
- **keypress Package**

## Connections

- co Caller → Prompt: yields thunk (evidence: `Readme.md`)
- co Caller → Multiline: yields thunk (evidence: `Readme.md`)
- co Caller → Confirmation: yields thunk (evidence: `Readme.md`)
- co Caller → Password: yields thunk (evidence: `Readme.md`)
- Prompt → Terminal Streams: writes and reads (evidence: `index.js`)
- Multiline → Terminal Streams: writes and reads (evidence: `index.js`)
- Confirmation → Prompt: calls (evidence: `index.js`)
- Password → Terminal Streams: writes and reads (evidence: `index.js`)
- Password → keypress Package: configures input (evidence: `index.js`)
