bwx 0.4.0 → 0.4.1

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/skill/bwx/SKILL.md +149 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bwx",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bitwarden",
@@ -12,7 +12,8 @@
12
12
  ],
13
13
  "files": [
14
14
  "bin",
15
- "src"
15
+ "src",
16
+ "skill"
16
17
  ],
17
18
  "bin": {
18
19
  "bwx": "bin/bwx"
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: bwx
3
+ description: Bitwarden Extended CLI — retrieve, create, edit, delete vault items with auto-unlock. Use when the agent needs passwords, API keys, TOTP codes, custom fields, or vault management. Triggers on mentions of Bitwarden, bw, bwx, vault, password, secrets, TOTP, save key/token.
4
+ ---
5
+
6
+ # bwx
7
+
8
+ Extended Bitwarden CLI. Wraps `bw` with auto-unlock, session caching, and structured output.
9
+
10
+ ## Quick start
11
+
12
+ ```bash
13
+ bwx get password "GitHub" # retrieve a password (auto-unlocks)
14
+ bwx get totp "AWS (user@example.com)" # TOTP code
15
+ bwx get username "GitHub" # username
16
+ bwx get notes "Deploy key" # secure note content
17
+ bwx get uri "GitHub" # first URI
18
+ bwx get item "GitHub" # full item JSON
19
+ bwx get "API Key" "Acme" # custom field by name
20
+ bwx field "Acme" "API Key" # custom field alias
21
+
22
+ bwx search github # fuzzy search, human table
23
+ bwx search github --json # id/type/name/username only — no secrets
24
+ bwx search github --type login --limit 5
25
+
26
+ # hand a secret to a child process instead of printing it
27
+ bwx run --env KEENETIC_PASS=password:'http://my.keenetic.net' -- expect ./recovery.exp
28
+
29
+ bwx attach list "Apple Developer" # list item attachments
30
+ bwx attach get "Apple Developer" AuthKey.p8
31
+ bwx attach get "Apple Developer" AuthKey.p8 --output ./secrets/
32
+
33
+ bwx create --name "API Key" --notes "sk_live_abc123" --field account=acme
34
+ printf '%s' "$TOKEN" | bwx create --type login --name "GitHub" --username user --password-stdin --uri https://github.com
35
+ bwx create --name "Acme" --field-file '!API Key=./token.txt' --field-env account=ACME_ACCOUNT
36
+ echo "secret" | bwx create --name "Piped Note"
37
+ ```
38
+
39
+ ## Commands
40
+
41
+ ### `bwx get <field> <item>`
42
+
43
+ Built-in fields: `password | username | totp | notes | uri | item`.
44
+ Anything else is looked up as a custom field. Lists available fields on miss.
45
+
46
+ ### `bwx field <item> <name>`
47
+
48
+ Alias for retrieving custom fields with item-first argument order.
49
+
50
+ ### `bwx search <query>` / `bwx list [type]`
51
+
52
+ Flags: `--type login|note|card|identity` (`search`), `--folder <id>`, `--limit <n>`, `--full-items`
53
+
54
+ Human, `--plain`, and `--json` output all carry the same reduced projection — `id`, `type`,
55
+ `name`, `username` — so listings never leak passwords, notes, or custom fields. `--full-items`
56
+ opts into complete item objects and **does** include secrets; avoid it in logged sessions.
57
+
58
+ ### `bwx run --env NAME=<field>:<item> -- <command>`
59
+
60
+ Resolves secrets and injects them into the child's environment only — not stdout, not argv.
61
+ This is the preferred way to give a subprocess a credential.
62
+
63
+ ```bash
64
+ bwx run --env DB_PASS=password:'Prod DB' -- ./migrate.sh
65
+ bwx run --env TOKEN='API Key:Acme' --env USER=username:Acme -- ./deploy.sh
66
+ ```
67
+
68
+ - `--env` is repeatable; the field resolves as in `bwx get` (built-in, else custom field).
69
+ - Only the first `:` splits field from item, so `password:http://my.router` works.
70
+ - Put `--` before the command when it takes its own flags.
71
+ - Child stdio is inherited; bwx exits with the child's status (`128 + signal` if killed).
72
+ - `-v` logs injected variable names only, never values.
73
+
74
+ ### `bwx attach list <item>`
75
+
76
+ Lists attachments for an item. Aliases: `bwx attachment`, `bwx attachments`; `list` has `ls`.
77
+
78
+ ### `bwx attach get <item> <attachment>`
79
+
80
+ Downloads an attachment by ID or filename. Defaults to saving as the attachment filename in the current directory. Use `--output <path>` to choose a file or directory.
81
+
82
+ ### `bwx create [options]`
83
+
84
+ Flags: `--type login|note`, `--name`, `--notes`, `--notes-file`, `--username`, `--password`, `--password-stdin`, `--password-file`, `--password-env`, `--uri` (repeatable), `--field k=v` (repeatable), `--field-file k=path`, `--field-env k=ENV`, `--folder`, `--favorite`, `--from-json`
85
+
86
+ Field syntax: `k=v` (text), `!k=v` (hidden), `bool:k=v` (boolean). The same key syntax works for `--field-file` and `--field-env`, where the value is a path or environment variable name. Stdin is read as `--notes` when piped; prefer `--password-stdin` for login passwords.
87
+
88
+ ### `bwx edit <item> [options]`
89
+
90
+ Fetch → patch → push.
91
+ ```bash
92
+ bwx edit "API Key" --add-field region=us-east-1
93
+ printf '%s' "$TOKEN" | bwx edit "GitHub" --password-stdin --uri https://github.com
94
+ bwx edit "Note" --rm-field old-key
95
+ ```
96
+ Flags: `--name`, `--notes`, `--notes-file`, `--username`, `--password`, `--password-stdin`, `--password-file`, `--password-env`, `--uri` (replaces all), `--add-field k=v`, `--add-field-file k=path`, `--add-field-env k=ENV`, `--rm-field name`, `--folder`, `--favorite/--no-favorite`, `--from-json`
97
+
98
+ ### `bwx delete <item>`
99
+
100
+ ```bash
101
+ bwx delete "Test Note" # prompts in TTY
102
+ bwx delete "Test Note" --force # skip prompt
103
+ bwx delete "Test Note" --permanent # no trash
104
+ ```
105
+
106
+ ### Other
107
+
108
+ | Command | Description |
109
+ |---------|-------------|
110
+ | `bwx status` | Vault state (no auto-unlock) |
111
+ | `bwx sync` | Force vault sync |
112
+ | `bwx unlock` / `bwx lock` | Manual session control |
113
+ | `bwx config list` / `bwx cfg ls` | Show config path + redacted content |
114
+ | `bwx config master-password` | Set/update master password in Keychain |
115
+
116
+ ## Global flags
117
+
118
+ | Flag | Effect |
119
+ |------|--------|
120
+ | `--json` | `{ "data": ... }` on success, `{ "error": { "message", "exitCode" } }` on failure |
121
+ | `--plain` | Stable parseable lines on stdout |
122
+ | `-q` | Suppress logs and warnings |
123
+ | `-v` | Verbose (stack traces on error) |
124
+ | `--timeout <duration>` | Deadline per `bw` call (default `1m`, `0` disables) → exit 8 |
125
+ | `--sync-if-older-than <duration>` | Sync first when the vault last synced longer ago |
126
+
127
+ Durations: `250ms`, `30s`, `15m`, `2h`, `1d`; a bare number is seconds.
128
+
129
+ ## Vault freshness
130
+
131
+ Reads come from the local vault copy. Reads warn on stderr when the last sync is over 24h
132
+ old — a rotated secret can otherwise look valid or missing. Pass
133
+ `--sync-if-older-than 15m` to sync first instead, or run `bwx sync`. Warnings reach stderr
134
+ even under `--json`; `-q` silences them.
135
+
136
+ ## Safety rules
137
+
138
+ - Never use `--full-items` (or `get item` for discovery) in logged sessions.
139
+ - Prefer `bwx run --env ...` over `export VAR="$(bwx get ...)"`; secrets never touch stdout or argv.
140
+ - Request the narrowest field, resolving an exact item ID first.
141
+ - Use `-q` for command substitution so unlock logs cannot contaminate merged output.
142
+ - On writes, prefer `--password-stdin`, `--password-env`, `--field-file`, `--field-env`.
143
+ - Never echo, log, checksum, or commit retrieved values; `unset` temporary variables.
144
+
145
+ ## Auth
146
+
147
+ - Master password: macOS Keychain (account `bitwarden`, service `bitwarden-master`)
148
+ - Session cached to `~/.config/bwx/session` (mode 600), given to `bw` via `BW_SESSION`
149
+ - Freshness snapshot cached to `~/.config/bwx/state.json`