Skip to content

Commit 43c15be

Browse files
committed
feat: interactive field editor, document name resolution, and REPL enhancements
Major improvements to the interactive mutation workflow and overall CLI usability: **Field-by-field mutation editor** (field_editor.rs): - Replaces raw JSON input with per-field prompts using live __type introspection - Pre-populates current document values as defaults via stateJSON - Supports nested objects, enums (select picker), arrays (add/remove/replace), booleans - Schema-aware GraphQL serialization (unquoted enum values) - Confirmation preview showing only changed fields before executing **Document name resolution**: - docs get, delete, mutate, and ops now accept document names (not just UUIDs) - New resolve_doc() helper searches all drives for matching name or UUID - Case-insensitive name matching with fallback per-drive queries **Drive auto-detection and selection**: - --drive is now optional in docs list, docs get, docs tree, docs create, mutate, and ops - Interactive drive picker (select_drive helper) when --drive is omitted - docs list without --drive aggregates documents across all drives with Drive column **Drives improvements**: - drives list shows Editor column (preferredEditor metadata) - drives get shows Editor field in detail view - drives create uses a drive type picker queried from existing drives **Operations (ops) improvements**: - Shows operation input data (action.input or inputText) instead of hash - Tries multiple query formats: paginated with action, flat with action, flat basic - Auto-detects drive from document name/UUID **REPL enhancements** (interactive.rs): - Tab completion for document names/IDs, profile names, drive slugs, model types - Animated loading spinner during API queries with immediate first-frame display - Cursor visibility fix after dialoguer widgets hide it - Visual command separators (dimmed header lines) before each command's output - Guide topics work as bare commands (e.g., "overview" instead of "guide overview") - Profile switching via config use rebuilds client and refreshes all completions - Auto-refresh document completions after doc-modifying commands (create/delete/mutate) - Circular tab completion mode for cycling through matches **Config**: - Added profile_names() helper for tab completion
1 parent ce4ba65 commit 43c15be

11 files changed

Lines changed: 1644 additions & 231 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ switchboard models list # List discovered document types
122122

123123
```bash
124124
switchboard docs create --type powerhouse/invoice --name "Q1 Invoice" --drive my-drive
125-
switchboard docs get <doc-id> --drive my-drive
125+
switchboard docs get <doc-id-or-name> # Auto-detects drive
126+
switchboard docs mutate <doc-id-or-name> # Interactive field-by-field editor
126127
switchboard docs mutate <doc-id> editInvoice --input '{"amount": 2000}' --drive my-drive
127128
```
128129

@@ -162,20 +163,20 @@ switchboard import ./backup/*.phd --drive another-drive
162163

163164
| Command | Description |
164165
|---------|-------------|
165-
| `switchboard docs list --drive <slug>` | List documents (add `--type <type>` to filter) |
166-
| `switchboard docs get <id> --drive <slug>` | Get document details and state |
167-
| `switchboard docs tree --drive <slug>` | Hierarchical folder/file view |
168-
| `switchboard docs create` | Interactive creation (or pass `--type`, `--name`, `--drive`) |
169-
| `switchboard docs delete <ids...>` | Delete one or more documents (use `-y` to skip confirmation) |
170-
| `switchboard docs mutate <id> <op> --input '<json>' --drive <slug>` | Apply a model-specific operation |
166+
| `switchboard docs list [--drive <slug>]` | List documents (all drives, or filtered by `--drive`; add `--type` to filter) |
167+
| `switchboard docs get <id-or-name>` | Get document details (auto-detects drive, or pass `--drive`) |
168+
| `switchboard docs tree [--drive <slug>]` | Hierarchical folder/file view (interactive drive picker if omitted) |
169+
| `switchboard docs create` | Interactive creation with drive picker (or pass `--type`, `--name`, `--drive`) |
170+
| `switchboard docs delete <ids-or-names...>` | Delete one or more documents (use `-y` to skip confirmation) |
171+
| `switchboard docs mutate <id-or-name> [<op>] [--input '<json>']` | Apply a mutation with field-by-field editor (or pass `--input` for raw JSON) |
171172

172173
### Models & Operations
173174

174175
| Command | Description |
175176
|---------|-------------|
176177
| `switchboard models list` | List all discovered document types |
177178
| `switchboard models get <type>` | Show available operations for a type |
178-
| `switchboard ops <doc-id> --drive <slug>` | View operation history |
179+
| `switchboard ops <doc-id-or-name>` | View operation history (auto-detects drive, or pass `--drive`) |
179180

180181
### Import / Export
181182

@@ -324,36 +325,39 @@ The REPL supports **every CLI command** — the same syntax you use on the comma
324325

325326
```
326327
staging> drives list
327-
┌──────────────────┬──────────────┬──────────────┐
328-
│ ID │ Name │ Slug │
329-
├──────────────────┼──────────────┼──────────────┤
330-
│ 47cda535-... │ liberum │ liberuum │
331-
│ e5f6g7h8-... │ Vetra │ vetra │
332-
└──────────────────┴──────────────┴──────────────┘
333-
334-
staging> docs tree --drive liberuum
328+
329+
──── drives list ────────────────────────────────────────────
330+
┌──────────────────┬──────────────┬──────────────┬───────────────────┐
331+
│ ID │ Name │ Slug │ Editor │
332+
├──────────────────┼──────────────┼──────────────┼───────────────────┤
333+
│ 47cda535-... │ liberum │ liberuum │ builder-team-admin│
334+
│ e5f6g7h8-... │ Vetra │ vetra │ - │
335+
└──────────────────┴──────────────┴──────────────┴───────────────────┘
336+
337+
staging> docs tree
338+
Select drive: liberuum
335339
liberum-drive/
336340
├── liberuum (powerhouse/builder-profile)
337341
├── 📁 Expense Reports/
338342
└── 📁 Services And Offerings/
339343
├── new service (powerhouse/resource-template)
340344
└── offering (powerhouse/service-offering)
341345
342-
staging> drives delete old-drive-1 old-drive-2 -y
343-
✓ Deleted drive abc123...
344-
✓ Deleted drive def456...
346+
staging> overview # Guide topics work without "guide" prefix
347+
staging> config use local # Profile switch auto-refreshes client and completions
348+
Switched to profile: local (http://localhost:4001/graphql)
345349
346-
staging> docs create --type powerhouse/invoice --name "Q2" --drive liberuum
347-
staging> query { drives }
348-
staging> ping
349-
staging> drives create --help
350-
staging> exit
350+
local> exit
351351
```
352352

353353
Features:
354354

355355
- **Full CLI parity** — every command works inside the REPL (drives, docs, models, auth, access, groups, export, import, watch, jobs, sync, etc.)
356-
- **Tab completion** for commands, drive slugs, model types, and guide topics
356+
- **Tab completion** for commands, drive slugs, document names, profile names, model types, and guide topics
357+
- **Visual command separators** — dimmed header lines before each command's output
358+
- **Loading spinners** — animated feedback during API queries
359+
- **Profile switching**`config use <name>` rebuilds the client and refreshes all completions
360+
- **Guide topic shortcuts** — type `overview` instead of `guide overview`
357361
- **Shell-like quoting** — single quotes, double quotes, and backslash escapes work as expected
358362
- **Per-command flags** — override `--format`, `--profile`, `--quiet` on any command within the REPL
359363
- **`--help` passthrough** — append `--help` to any command to see its usage
@@ -449,10 +453,11 @@ switchboard-cli/
449453
│ │ ├── config.rs Profile management
450454
│ │ ├── introspect.rs Schema discovery
451455
│ │ ├── drives.rs Drive commands (list, get, create, multi-delete)
452-
│ │ ├── docs.rs Document commands (list, get, tree, create, multi-delete, mutate)
456+
│ │ ├── docs.rs Document commands (list, get, tree, create, multi-delete)
453457
│ │ ├── models.rs Model inspection (from cache)
454-
│ │ ├── ops.rs Operations history
455-
│ │ ├── mutate.rs Model-specific mutations
458+
│ │ ├── ops.rs Operations history (with input display)
459+
│ │ ├── mutate.rs Model-specific mutations (interactive field editor)
460+
│ │ ├── field_editor.rs Field-by-field mutation editor (introspection + prompting)
456461
│ │ ├── import_export.rs .phd file import/export
457462
│ │ ├── auth.rs Authentication
458463
│ │ ├── access.rs Permission commands

0 commit comments

Comments
 (0)