Skip to content

Commit fc1cc8a

Browse files
committed
repl related readmes
1 parent 8d008ac commit fc1cc8a

3 files changed

Lines changed: 82 additions & 1 deletion

File tree

KeeperSdk/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ Most examples call the shared `login()` helper, which attempts persistent login
429429

430430
See [`examples/sdk_example/README.md`](../examples/sdk_example/README.md) for the full command list.
431431

432+
Prefer an interactive shell over one-off scripts? See [`examples/repl`](../examples/repl/README.md)
433+
for a REPL that logs in once and runs vault commands (`ls`, `cd`, `get`, `find`, …) until you exit.
434+
432435
---
433436

434437
## Development Setup
@@ -467,6 +470,7 @@ keeper-sdk-javascript/
467470
├── keeperapi/ # @keeper-security/keeperapi
468471
└── examples/
469472
├── sdk_example/ # Runnable Node scripts (auth, records, folders, …)
473+
├── repl/ # Interactive vault shell
470474
├── print-vault-node/ # Additional Node sample
471475
└── print-vault-browser/ # Browser sample
472476
```

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ keeper-sdk-javascript/
1919
├── KeeperSdk/ # @keeper-security/keeper-sdk-javascript
2020
├── keeperapi/ # @keeper-security/keeperapi
2121
└── examples/
22-
└── sdk_example/ # Runnable Node scripts (auth, records, folders, …)
22+
├── sdk_example/ # Runnable Node scripts (auth, records, folders, …)
23+
└── repl/ # Interactive vault shell (see examples/repl/README.md)
2324
```
2425

2526
**Start here for CLI / vault behavior:** [`KeeperSdk/README.md`](KeeperSdk/README.md) — built-in commands, `get` / `whoami` output, and `KeeperCliHost` adapter requirements.
@@ -46,6 +47,15 @@ npm run auth:restore-session -- --from-json /path/to/session.json
4647
npm run records:list:shell-cli -- --from-json /path/to/session.json
4748
```
4849

50+
Or jump into the interactive vault REPL (needs `KeeperSdk` linked via `npm run link-local` above):
51+
52+
```bash
53+
cd examples/repl && npm install
54+
npm start
55+
```
56+
57+
See [`examples/repl/README.md`](examples/repl/README.md) for the command list.
58+
4959
## Package docs
5060

5161
- [`KeeperSdk/README.md`](KeeperSdk/README.md) — API, CLI commands, host adapter

examples/repl/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Keeper Vault REPL
2+
3+
An interactive shell for the Keeper Vault: log in once, then run `ls`, `cd`, `get`, `find`, and
4+
other commands against your vault until you exit.
5+
6+
## Prerequisites
7+
8+
- Node.js 20 LTS or newer
9+
- A Keeper account with credentials
10+
11+
## Setup
12+
13+
This example depends on the sibling `KeeperSdk` and `keeperapi` packages by local path
14+
(`file:../../KeeperSdk`, `file:../../keeperapi`), so those need to be built once before the REPL
15+
can resolve `@keeper-security/keeperapi` at runtime:
16+
17+
```bash
18+
# From the repository root
19+
cd keeperapi && npm install && npm run build
20+
cd ../KeeperSdk && npm install && npm run link-local && npm run build
21+
22+
# Now the REPL itself
23+
cd ../examples/repl
24+
npm install
25+
```
26+
27+
## Run
28+
29+
```bash
30+
npm start
31+
```
32+
33+
There's no config file to set up first — on first run you'll be prompted interactively for
34+
server, username, and password. Credentials/session are then saved to `~/.keeper/config.json` for
35+
persistent login on subsequent runs (same file used by the other examples in this repo).
36+
37+
## Commands
38+
39+
Type `help` inside the REPL for the live list. Summary:
40+
41+
| Command | Description |
42+
|---|---|
43+
| `help` | List available commands |
44+
| `whoami` | Show current session info |
45+
| `pwd` | Print current working folder |
46+
| `ls [path]` | List contents of the current (or given) folder |
47+
| `cd [path]` | Change the current working folder (`cd /` for vault root) |
48+
| `tree [path]` | Show the folder tree from the current (or given) folder |
49+
| `list` | List every record in the vault |
50+
| `find <text>` | Search records by title, login, or URL |
51+
| `get <uid\|title>` | Show details for a single record |
52+
| `sync` | Re-sync the vault with the server |
53+
| `get_controllers` | Call the PAM router API (`pam/get_controllers`) and list enterprise gateways |
54+
| `get_online_controllers` | Call the PAM router API (`loadOnlineControllers`) and list connected gateways |
55+
| `run <script.ts> [args...]` | Execute a TypeScript file exporting `default async function(vault, args)` — see [`scripts/README.md`](scripts/README.md) |
56+
| `history` | Show command history |
57+
| `clear` | Clear the screen |
58+
| `exit` / `quit` | Log out and quit the REPL |
59+
60+
Command history persists across sessions in `~/.keeper/repl_history` (excluding `history`, `exit`,
61+
`quit`, `clear`); use `!<n>` to re-run entry `n` from `history`, bash-style.
62+
63+
## Extending
64+
65+
Drop a `.ts` file under [`scripts/`](scripts/README.md) and run it with `run scripts/<file>.ts` for
66+
one-off tasks against the live, authenticated `vault` — no rebuild needed. Promote anything that
67+
turns out to be a permanent command into `src/commands.ts`.

0 commit comments

Comments
 (0)