Skip to content

Commit 2b2758c

Browse files
committed
feat(cli): Node + browser CLI, exit command, Node export, BDD for both
1 parent fa0abfd commit 2b2758c

39 files changed

+2052
-1007
lines changed

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Context for AI assistants working on this repo.
66

77
**tb-solid-pod** is a browser-based personal data pod inspired by the [Solid Project](https://solidproject.org/), built with [TinyBase](https://tinybase.org/) for reactive state and LocalStorage. It is **not** a real Solid server (no LDP, no WebID-TLS); it simulates Solid-style data (personas, contacts, groups, type indexes, file metadata) in a single-page app.
88

9-
- **Dual interface**: graphical UI (tabs, forms, lists) + CLI terminal.
9+
- **Dual interface**: graphical UI (tabs, forms, lists) + CLI. The CLI runs in the **browser** (Terminal tab) and in **Node** (`npm run cli`); same commands, environment-specific persistence (LocalStorage vs `~/.tb-solid-pod/data/store.json`).
1010
- **Data**: personas (WebID-style), contacts (including agents), groups (org/team/group) with membership of contacts and your personas, type indexes, virtual file system with metadata, settings/preferences.
1111
- **Stack**: React, TinyBase, Zod, Vite, TypeScript. Vocabularies: FOAF, vCard, Dublin Core, W3C Org, `@inrupt/vocab-*`.
1212

@@ -19,7 +19,7 @@ Context for AI assistants working on this repo.
1919
| `src/index.ts` | **Library entry** – re-exports schemas, utils, CLI, components for `import from 'tb-solid-pod'`. |
2020
| `src/schemas/` | Zod schemas + factory functions + **JSON Schema** (json-schema.ts via Zod v4 toJSONSchema; persona, contact, group, file, typeIndex, preferences, base). **Zod is source of truth**—no canonical Solid JSON Schema; we generate from Zod. Static files: `npm run generate:schemas``schema/*.json`. |
2121
| `src/utils/` | settings, storeExport, typeIndex helpers, validation. |
22-
| `src/cli/` | CliTerminal, command registry, parse-args, types. |
22+
| `src/cli/` | CliTerminal (browser), run-node.tsx (Node entry), node-store.ts (file persister), command registry, parse-args, types. |
2323
| `src/components/` | PersonaList/Form, ContactList/Form, GroupList/Form, MembershipManager, FileMetadataPanel. |
2424
| `docs/` | CODING_GUIDELINES.md, DOCUMENTATION_GUIDELINES.md, DESIGN.md, IMPLEMENTATION_PLAN.md, TEST_PLAN.md, testing/. |
2525

@@ -73,8 +73,8 @@ When someone wants to use this in an app they’re working on, point them to the
7373

7474
## Useful docs
7575

76-
- **README.md** – Overview, limitations, Use as a library (Zod + JSON Schema), link to Integration Guide, Getting Started (Node note, Live demo + 404 troubleshooting), Testing (unit, BDD, Storybook link), CLI command list.
77-
- **docs/INTEGRATION_GUIDE.md** – Step-by-step integration (install-from-GitHub vs copy-paste), store setup, Provider, components, CLI, data tables, extending.
76+
- **README.md** – Overview, limitations, Use as a library (Zod + JSON Schema), link to Integration Guide, Getting Started (Node note, Live demo + 404 troubleshooting), Running the CLI in the terminal (`npm run cli`, exit, single-command mode), Testing (unit, BDD, Storybook link), CLI command list.
77+
- **docs/INTEGRATION_GUIDE.md** – Step-by-step integration (install-from-GitHub vs copy-paste), store setup, Provider, components, CLI (browser + terminal), data tables, extending.
7878
- **docs/SDLC_PROCESS.md** – How changes are introduced, documented, and verified; links to Feature Checklist.
7979
- **docs/FEATURE_CHECKLIST.md** – Manual verification checklist ordered by dependency (foundational first); assume features are broken until verified.
8080
- **docs/CODING_GUIDELINES.md** – TypeScript (strict types, no sloppy types), short functions, simple React components, naming, file length.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ npm install
190190
npm run dev
191191
```
192192

193+
## Running the CLI in the terminal
194+
195+
You can run the same CLI from a **real terminal** (Node.js) as well as in the browser’s Terminal tab:
196+
197+
```bash
198+
npm run cli
199+
```
200+
201+
- **Interactive**: Full session with the same commands as the browser. Use **↑/↓** for command history and **Tab** for command-name completion.
202+
- **Single command**: Pass the command as arguments; output is printed and the process exits. Example: `npm run cli -- help` or `npm run cli -- contact list`.
203+
- **Data**: Stored in `~/.tb-solid-pod/data/store.json` (or set `TB_SOLID_POD_DATA_PATH` to a different path). Same store shape as the browser; data is not shared between browser and terminal unless you point both at the same file.
204+
205+
193206
## CLI Commands
194207

195208
```
@@ -203,6 +216,7 @@ config list|get|set|reset
203216
pwd|cd|ls|cat|touch|mkdir|rm File system operations
204217
export|import Data portability
205218
clear Clear terminal
219+
exit Exit the CLI (Node terminal only)
206220
```
207221

208222
## Testing

docs/FEATURE_CHECKLIST.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ Must work to access features.
5454

5555
## Level 3: CLI Terminal
5656

57-
Required for CLI-based features.
57+
Required for CLI-based features. The same CLI runs in the **browser** (Terminal tab) and in **Node** (`npm run cli`). BDD tests cover both (Scenario Outline: browser \| terminal).
5858

5959
- [x] CLI prompt accepts input
6060
- [x] `help` command shows available commands
6161
- [x] `clear` command clears terminal
6262
- [x] Command history (up arrow) works
6363
- [x] Unknown command shows error message
64+
- [x] `exit` command quits Node CLI; in browser shows message that exit is terminal-only
65+
- [x] In Node: `export` prints JSON; `export --download` writes file to cwd
6466

6567
---
6668

@@ -269,7 +271,7 @@ Depends on: Personas, Type Indexes
269271

270272
### Unit Tests
271273
- [x] `npm test` runs without errors
272-
- [x] 385+ tests passing
274+
- [x] 392+ tests passing
273275
- [x] Coverage meets 80% threshold
274276

275277
### Storybook
@@ -280,10 +282,11 @@ Depends on: Personas, Type Indexes
280282
- [x] FileMetadataPanel stories render
281283

282284
### BDD/E2E
283-
- [x] `npm run test:e2e` runs (with dev server running)
285+
- [x] `npm run test:e2e` runs (dev server required for browser scenarios; terminal scenarios run Node CLI)
284286
- [x] App shell scenarios pass
285-
- [x] CLI contact scenarios pass
286-
- [x] CLI persona scenarios pass
287+
- [x] CLI contact scenarios pass (browser and terminal)
288+
- [x] CLI persona scenarios pass (browser and terminal)
289+
- [x] CLI navigation scenarios pass (browser and terminal)
287290

288291
---
289292

docs/IMPLEMENTATION_PLAN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
Phases 1–7 complete. See [Feature Checklist](#feature-checklist) for detailed status.
66

7-
The app has a working browser-based CLI and file browser UI with:
7+
The app has a working CLI (browser Terminal tab and Node: `npm run cli`) and file browser UI with:
88
- Basic file/folder CRUD operations
9-
- TinyBase persistence with LocalStorage
10-
- Import/export functionality
9+
- TinyBase persistence: LocalStorage (browser) or file (Node: `~/.tb-solid-pod/data/store.json`)
10+
- Import/export functionality (export in Node: print JSON or `export --download` to file)
1111
- Tab-based navigation (Data Browser / Personas / Contacts / Groups / Terminal)
1212
- Persona management (Phase 1)
1313
- Contact management with search/filter (Phase 2)

docs/INTEGRATION_GUIDE.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide explains how to integrate **tb-solid-pod** into an application you are building. It is for developers who want to add Solid-style personas, contacts, groups, type indexes, or file metadata to their app, either by installing the package from GitHub or by copying source files.
44

5-
**Terms:** **TinyBase** is the reactive store and persistence library used by this project. **JSON-LD** (JavaScript Object Notation for Linked Data) is the data format used for personas, contacts, and groups. **CLI** (command-line interface) refers to the in-app terminal provided by the library.
5+
**Terms:** **TinyBase** is the reactive store and persistence library used by this project. **JSON-LD** (JavaScript Object Notation for Linked Data) is the data format used for personas, contacts, and groups. **CLI** (command-line interface) refers to the terminal provided by the library: in-app (browser Terminal tab) or Node (`npm run cli`).
66

77
## Two ways to integrate
88

@@ -223,7 +223,9 @@ Settings are stored in TinyBase **values** (not tables):
223223

224224
## Adding the CLI (Optional)
225225

226-
If you want the terminal interface:
226+
The CLI runs in **two environments**: (1) in-app Terminal tab in the browser, and (2) from a real terminal (Node.js).
227+
228+
### In the browser
227229

228230
```tsx
229231
import { CliTerminal } from 'tb-solid-pod'; // or from your cli
@@ -237,6 +239,10 @@ import { CliTerminal } from 'tb-solid-pod'; // or from your cli
237239
/>
238240
```
239241

242+
### In the terminal (Node.js)
243+
244+
From the repo: `npm run cli`. Same commands as the browser. Data is stored in `~/.tb-solid-pod/data/store.json` (override with `TB_SOLID_POD_DATA_PATH`). Interactive mode supports **↑/↓** history and **Tab** completion for command names. Use **`exit`** to quit. **Export:** `export` prints JSON to the terminal; `export --download` writes a file to the current directory (Node has no clipboard). Single-command mode: `npm run cli -- help` or `npm run cli -- contact list`.
245+
240246
---
241247

242248
## Customizing the Base URL

docs/TEST_PLAN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"test:run": "vitest run"
6464
```
6565

66-
**Total: 385 tests passing**
66+
**Total: 392 tests passing** (includes CLI registry test for exit command)
6767

6868
---
6969

@@ -120,7 +120,7 @@
120120

121121
See [docs/testing/bdd-tests.md](testing/bdd-tests.md) for full details.
122122

123-
**Testing boundary:** The same doc defines [what is automated vs manual](testing/bdd-tests.md#testing-boundary-automated-vs-manual): app shell, tab navigation, Contacts/Personas UI, CLI help/clear/contact/persona are covered by BDD; CLI group/file/files/config/data/typeindex, Groups UI, forms, file browser, settings, export/import, and future features (pod connect, sync, ACL) are left for manual verification until scenarios are added.
123+
**Testing boundary:** The same doc defines [what is automated vs manual](testing/bdd-tests.md#testing-boundary-automated-vs-manual): app shell, tab navigation, Contacts/Personas UI, CLI help/clear/contact/persona/navigation are covered by BDD in **both browser and terminal** (Scenario Outline); CLI group/file/files/config/data/typeindex, Groups UI, forms, file browser, settings, export/import, and future features (pod connect, sync, ACL) are left for manual verification until scenarios are added.
124124

125125
### npm Scripts Added
126126
```json
@@ -147,7 +147,7 @@ See [docs/testing/bdd-tests.md](testing/bdd-tests.md) for full details.
147147

148148
## Verification Checklist
149149

150-
- [x] `npm test` - All unit tests pass (385 tests)
150+
- [x] `npm test` - All unit tests pass (392 tests)
151151
- [x] `npm run test:coverage` - Coverage meets 80% threshold
152152
- [x] `npm run storybook` - All stories render without errors
153153
- [ ] `npm run test:e2e` - All BDD scenarios pass (run with server on 5173; see docs/testing/bdd-tests.md)

docs/USE_CASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You can use tb-solid-pod in three ways; the use cases below apply across them.
1414
|----------|--------------|----------------|
1515
| **Schemas only** | Zod schemas, factory functions, types, JSON Schema | You need the data shapes and validation; no UI or store layout required. |
1616
| **Schemas + store** | Same as above, plus a TinyBase store with the expected tables and values | You want to read/write personas, contacts, groups, files, and settings in a standard layout. |
17-
| **Schemas + store + components (and optionally CLI)** | Full UI: lists, forms, membership manager, file metadata panel, terminal | You want ready-made React components and/or the CLI for power users. |
17+
| **Schemas + store + components (and optionally CLI)** | Full UI: lists, forms, membership manager, file metadata panel; CLI in browser (Terminal tab) or Node (`npm run cli`) | You want ready-made React components and/or the CLI for power users. |
1818

1919
Store setup and table layout are described in the [README Integration Guide](../README.md#integration-guide) and summarized in [Data tables](#data-tables) below.
2020

docs/testing/bdd-tests.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ These are implemented in `tests/features/*.feature` and run with Playwright.
5858

5959
**Total:** Six feature files; scenarios above are the current automated boundary. The dev server must be running (see [Starting the app](#starting-the-app)); BDD does not start it.
6060

61+
### CLI in browser vs terminal (Scenario Outline)
62+
63+
The same CLI scenarios run **in the browser** (Terminal tab) and **in the terminal** (Node CLI spawned with piped stdin). One feature file per area (e.g. `cli-contacts.feature`) uses a **Scenario Outline** with `Examples: | context | browser | terminal |`. The step "Given I have the CLI in the <context>" either opens the Terminal tab (browser) or spawns `npx tsx src/cli/run-node.tsx` with a unique temp store path (terminal). "When I run the command" and "Then I should see ... in the output" branch on context. Run with the same command as other E2E: `npm run test:e2e` (dev server must be running for browser; terminal runs without it). In Node, `exit` quits the process; `export` prints JSON (or `--download` writes a file). See README and [INTEGRATION_GUIDE.md](../INTEGRATION_GUIDE.md) for full CLI usage.
64+
6165
### Not yet automated (manual verification)
6266

6367
These are either out of scope for the current BDD suite or not yet implemented as Gherkin scenarios. Verify them manually (or extend the feature files later).

0 commit comments

Comments
 (0)