@jacebenson/jsn 0.0.9 → 0.1.0

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.
package/README.md CHANGED
@@ -2,82 +2,66 @@
2
2
 
3
3
  A command-line interface for ServiceNow that follows the Unix philosophy: simple, composable, and scriptable.
4
4
 
5
- ## Versions
6
-
7
- | Version | Language | Branch | Install | Status |
8
- |---------|----------|--------|---------|--------|
9
- | Go | Go | `main` | Binary / `go install` | Stable |
10
- | Node.js | JavaScript (Node 18+) | `nodejs` | `npm install -g` | Active development |
11
-
12
- Both versions share the same CLI interface and are tested against the same ServiceNow PDI.
13
-
14
5
  ## Installation
15
6
 
16
- ### npm (Node.js version — cross-platform)
7
+ ### npm (recommended — cross-platform)
17
8
 
18
9
  ```bash
19
- npm install -g @jacebenson/jsn@node
10
+ npm install -g @jacebenson/jsn
20
11
  ```
21
12
 
22
- > **Note:** The `@node` dist-tag is required. The `latest` tag currently points to the Go shim wrapper (v1.0.1).
23
-
24
13
  No compilation needed. Works on macOS, Linux, and Windows with Node.js 18+.
25
14
 
26
- ### Download Binary (Go version)
15
+ > **Note:** As of v0.1.0, the `latest` dist-tag points to the Node.js implementation. This is the version you get with `npm install -g @jacebenson/jsn`.
27
16
 
28
- ```bash
29
- # Download the latest release
30
- curl -L https://github.com/jacebenson/jsn/releases/latest/download/jsn-linux-amd64 -o jsn
31
- chmod +x jsn
32
- sudo mv jsn /usr/local/bin/
33
- ```
34
-
35
- ### Go Install (Go version)
36
-
37
- ```bash
38
- go install github.com/jacebenson/jsn/cmd/jsn@latest
39
- ```
40
-
41
- ## Quick Start
42
-
43
- ### 1. Setup
44
-
45
- Run the interactive setup to configure your first ServiceNow instance:
17
+ ### Quick Start
46
18
 
47
19
  ```bash
20
+ # Interactive setup
48
21
  jsn setup
49
- ```
50
-
51
- This will:
52
- 1. Ask for your ServiceNow instance URL
53
- 2. Open a browser for OAuth authentication
54
- 3. Set the instance as your default
55
22
 
56
- ### 2. Verify Authentication
57
-
58
- ```bash
23
+ # Check auth status
59
24
  jsn auth status
60
- ```
61
-
62
- ### 3. Start Using
63
25
 
64
- ```bash
65
- # List all incidents
26
+ # List incidents
66
27
  jsn incidents
67
28
 
68
- # Show a specific incident
69
- jsn incidents INC0010001
70
-
71
- # Create a new incident
72
- jsn incidents create --description "Server down" --priority 1
73
-
74
- # List change requests
75
- jsn changes
76
-
77
- # Query any table
78
- jsn records list --table incident --query "priority=1^active=true"
29
+ # Check for updates
30
+ jsn version --check
79
31
  ```
80
32
 
33
+ ## What's New in v0.1.0
34
+
35
+ Full feature parity with the original Go implementation — 128 tests, lint clean:
36
+
37
+ | Feature | Status |
38
+ |---------|--------|
39
+ | Incident management (CRUD) | ✅ |
40
+ | Change request management (CRUD) | ✅ |
41
+ | Service catalog requests (with attachments + variables) | ✅ |
42
+ | Catalog tasks, generic tickets | ✅ |
43
+ | User management (CRUD) | ✅ |
44
+ | Group management (CRUD) | ✅ |
45
+ | Group memberships and roles | ✅ |
46
+ | Generic Table API (`jsn records`) | ✅ |
47
+ | OAuth PKCE with keychain (Go-compatible auth store) | ✅ |
48
+ | Bot/CI/CD auth flags (`--code`, `--print-url`) | ✅ |
49
+ | Dev commands: flows, actions, includes, rules, ACLs, etc. | ✅ |
50
+ | Script execution (`jsn dev eval`) via OAuth session flow | ✅ |
51
+ | Interactive search-as-you-type pickers | ✅ |
52
+ | Output formats: JSON, styled, markdown, quiet | ✅ |
53
+ | Enriched `requests show` with attachments + variables | ✅ |
54
+ | Categorized help system (CORE, DATA, DEV, CONFIG) | ✅ |
55
+
56
+ ### New Commands
57
+
58
+ - **`jsn version --check`** — Check npm registry for newer versions
59
+ - **`jsn skill`** — Manage the jsn AI agent skill file (for Hermes, Claude Code, etc.)
60
+ - `jsn skill show` — Display the bundled skill
61
+ - `jsn skill fetch` — Download latest skill from GitHub
62
+ - `jsn skill path` — Show skill file locations
63
+ - `jsn skill install` — Download + save to Hermes skills directory
64
+
81
65
  ## Configuration
82
66
 
83
67
  JSN uses a layered configuration system:
@@ -92,8 +76,6 @@ JSN uses a layered configuration system:
92
76
 
93
77
  ### Profiles
94
78
 
95
- Work with multiple ServiceNow instances using profiles:
96
-
97
79
  ```bash
98
80
  # Login to a new instance
99
81
  jsn auth login https://dev12345.service-now.com
@@ -110,7 +92,7 @@ jsn profiles show
110
92
 
111
93
  ## Commands
112
94
 
113
- ### Work Commands (Day-to-day operations)
95
+ ### CORE
114
96
 
115
97
  | Command | Aliases | Description |
116
98
  |---------|---------|-------------|
@@ -118,207 +100,154 @@ jsn profiles show
118
100
  | `changes` | `change`, `chg` | Manage change requests |
119
101
  | `requests` | `request`, `req`, `ritm` | Manage service catalog requests |
120
102
  | `tasks` | `task`, `sctask` | Manage service catalog tasks |
103
+ | `tickets` | `ticket` | Query generic tickets |
104
+
105
+ ### DATA & ADMIN
106
+
107
+ | Command | Aliases | Description |
108
+ |---------|---------|-------------|
109
+ | `records` | - | Generic Table API for any table |
121
110
  | `users` | `user` | Manage users |
122
111
  | `groups` | `group` | Manage user groups |
123
- | `records` | - | Generic Table API access |
124
-
125
- ### Dev Commands (Development artifacts)
126
-
127
- | Category | Command | Description |
128
- |----------|---------|-------------|
129
- | **Automations** | `dev flows` | Manage Flow Designer flows |
130
- | | `dev actions` | Manage action definitions |
131
- | **Scripts** | `dev includes` | Manage script includes |
132
- | | `dev rules` | Manage business rules |
133
- | | `dev clientscripts` | Manage client scripts |
134
- | | `dev uiactions` | Manage UI actions |
135
- | | `dev uipolicies` | Manage UI policies |
136
- | **Data** | `dev tables` | View table definitions |
137
- | | `dev columns` | Manage column definitions |
138
- | | `dev import` | Manage import sets |
139
- | **Security** | `dev acls` | Manage access controls |
140
- | | `dev roles` | Manage roles |
141
- | **Platform** | `dev updatesets` | Manage update sets |
142
- | | `dev scopes` | Manage application scopes |
143
- | | `dev properties` | Manage system properties |
144
- | | `dev logs` | Query system logs |
145
- | | `dev rest` | Raw REST API calls |
146
- | | `dev eval` | Execute background scripts |
112
+ | `groupmembers` | `gm` | Manage group memberships |
113
+ | `grouproles` | `gr` | Manage group roles |
114
+
115
+ ### DEVELOPMENT
116
+
117
+ | Command | Description |
118
+ |---------|-------------|
119
+ | `dev flows` | Manage Flow Designer flows |
120
+ | `dev actions` | Manage action definitions |
121
+ | `dev includes` | Manage script includes |
122
+ | `dev rules` | Manage business rules |
123
+ | `dev clientscripts` | Manage client scripts |
124
+ | `dev uiactions` | Manage UI actions |
125
+ | `dev uipolicies` | Manage UI policies |
126
+ | `dev tables` | View table definitions |
127
+ | `dev columns` | Manage column definitions |
128
+ | `dev import` | Manage import sets |
129
+ | `dev acls` | Manage access controls |
130
+ | `dev roles` | Manage roles |
131
+ | `dev updatesets` | Manage update sets |
132
+ | `dev scopes` | Manage application scopes |
133
+ | `dev properties` | Manage system properties |
134
+ | `dev logs` | Query system logs |
135
+ | `dev rest` | Raw REST API calls |
136
+ | `dev eval` | Execute background scripts |
137
+
138
+ ### CONFIGURATION
139
+
140
+ | Command | Description |
141
+ |---------|-------------|
142
+ | `setup` | Interactive first-time setup |
143
+ | `auth` | Manage OAuth authentication |
144
+ | `profiles` | Manage instance profiles |
145
+
146
+ ### UTILITY
147
+
148
+ | Command | Description |
149
+ |---------|-------------|
150
+ | `version` | Show version (use `--check` for update check) |
151
+ | `skill` | Manage the jsn AI agent skill file |
147
152
 
148
153
  ## Usage Examples
149
154
 
150
155
  ### Incidents
151
156
 
152
157
  ```bash
153
- # List all incidents
154
- jsn incidents
155
-
156
- # List critical incidents
157
- jsn incidents list --query "priority=1"
158
-
159
- # Show specific incident
160
- jsn incidents INC0010001
161
-
162
- # Create incident
158
+ jsn incidents # List all
159
+ jsn incidents list --query "priority=1" # Critical only
160
+ jsn incidents INC0010001 # Show specific
163
161
  jsn incidents create --description "Server down" --priority 1
164
-
165
- # Update incident
166
162
  jsn incidents update INC0010001 --data '{"state": "6"}'
167
-
168
- # Delete incident
169
- jsn incidents delete INC0010001
170
163
  ```
171
164
 
172
- ### Changes
165
+ ### Requests (with enriched details)
173
166
 
174
167
  ```bash
175
- # List all change requests
176
- jsn changes
177
-
178
- # List high-risk changes
179
- jsn changes list --query "risk=high"
180
-
181
- # Create change request
182
- jsn changes create --description "Deploy feature" --risk medium
183
-
184
- # Update change
185
- jsn changes update CHG0010001 --data '{"state": "3"}'
186
-
187
- # Delete change
188
- jsn changes delete CHG0010001
168
+ jsn requests show RITM0010001
169
+ # Output includes attachments + catalog variables:
170
+ # ─ Attachments ─
171
+ # onboarding_form.pdf (by John Smith, 2026-05-15 14:23:10)
172
+ # ─ Catalog Variables ─
173
+ # Department: Engineering
174
+ # Urgency: High
189
175
  ```
190
176
 
191
- ### Development Artifacts
177
+ ### Development
192
178
 
193
179
  ```bash
194
- # AUTOMATIONS
195
- # List Flow Designer flows
196
- jsn dev flows
197
-
198
- # List action definitions
199
- jsn dev actions
200
-
201
- # SCRIPTS
202
- # List script includes
203
- jsn dev includes
204
-
205
- # Get a specific script include
206
- jsn dev includes MyScriptInclude
207
-
208
- # List business rules
209
- jsn dev rules
210
-
211
- # List client scripts
212
- jsn dev clientscripts
213
-
214
- # List UI actions
215
- jsn dev uiactions
216
-
217
- # List UI policies
218
- jsn dev uipolicies
219
-
220
- # DATA
221
- # View table definition
222
- jsn dev tables incident
223
-
224
- # List table columns
225
- jsn dev columns --table incident
226
-
227
- # SECURITY
228
- # List access controls (ACLs)
229
- jsn dev acls
230
-
231
- # List roles
232
- jsn dev roles
233
-
234
- # PLATFORM
235
- # List update sets
236
- jsn dev updatesets
237
-
238
- # Set current update set
239
- jsn dev updatesets set "My Update Set"
240
-
241
- # List application scopes
242
- jsn dev scopes
243
-
244
- # Query system properties
245
- jsn dev properties
246
-
247
- # Query system logs
248
- jsn dev logs --level error
249
- jsn dev logs --source "Business Rule" --level warn
250
-
251
- # Execute background script
252
- jsn dev eval "gs.info('Hello World')"
180
+ jsn dev flows # List flows
181
+ jsn dev includes MyScriptInclude # Show a script include
182
+ jsn dev rules # List business rules
183
+ jsn dev updatesets set "My Update Set" # Set current updateset
184
+ jsn dev eval "gs.info('Hello World')" # Run background script
253
185
  ```
254
186
 
255
187
  ### Generic Table API
256
188
 
257
189
  ```bash
258
- # List any table
259
190
  jsn records list --table incident --limit 10
260
-
261
- # Query with encoded query
262
191
  jsn records list --table incident --query "priority=1^active=true"
263
-
264
- # Show specific columns
265
- jsn records list --table incident --columns "number,short_description,priority"
266
-
267
- # Get a record by sys_id
268
192
  jsn records get --table incident --sys-id abc123
269
-
270
- # Create a record
271
193
  jsn records create --table incident --data '{"short_description": "Test"}'
272
-
273
- # Update a record
274
- jsn records update --table incident --sys-id abc123 --data '{"priority": "1"}'
275
-
276
- # Delete a record
277
- jsn records delete --table incident --sys-id abc123
278
194
  ```
279
195
 
280
196
  ## Output Formats
281
197
 
282
- JSN supports multiple output formats:
283
-
284
198
  | Format | Flag | Description |
285
199
  |--------|------|-------------|
286
200
  | Auto (default) | `--format=auto` | JSON for pipes, styled for TTY |
287
201
  | JSON | `--json` or `--format=json` | Machine-readable JSON |
288
- | Styled | `--styled` | ANSI-styled tables (for humans) |
202
+ | Styled | `--styled` | ANSI-styled tables |
289
203
  | Markdown | `--markdown` | Markdown tables |
290
204
  | Quiet | `--quiet` or `-q` | Data only, no envelope |
291
205
 
292
206
  ```bash
293
- # JSON output
294
- jsn incidents --json
295
-
296
- # Styled table output
207
+ jsn incidents --json | jq '.[].number'
297
208
  jsn incidents --styled
298
-
299
- # Markdown output for documentation
300
- jsn incidents --markdown
301
-
302
- # Quiet mode for piping
303
209
  jsn incidents -q | jq '.[].number'
304
210
  ```
305
211
 
306
212
  ## Authentication
307
213
 
308
- JSN uses OAuth 2.0 with PKCE for secure authentication:
214
+ OAuth 2.0 with PKCE. Credentials stored in `~/.config/servicenow/credentials/` — shared with the legacy Go version.
309
215
 
310
216
  ```bash
311
- # Login to an instance
312
217
  jsn auth login https://dev12345.service-now.com
313
218
 
314
- # Check authentication status
315
- jsn auth status
219
+ # Bot-friendly: print auth URL instead of opening a browser
220
+ jsn auth login https://dev12345.service-now.com --print-url
221
+
222
+ # Paste code from browser
223
+ jsn auth login https://dev12345.service-now.com --code ABC123
224
+ ```
316
225
 
317
- # Logout
318
- jsn auth logout
226
+ ### CI/CD Integration
227
+
228
+ ```bash
229
+ export SERVICENOW_INSTANCE_URL="https://dev12345.service-now.com"
230
+ export SERVICENOW_OAUTH_TOKEN="***"
231
+ jsn incidents list # No interactive auth needed
319
232
  ```
320
233
 
321
- Credentials are stored in `~/.config/servicenow/credentials/` (file-based, OS keychain coming soon).
234
+ ## AI Agent Integration
235
+
236
+ JSN includes a built-in skill file for AI agents:
237
+
238
+ ```bash
239
+ # View the skill file
240
+ jsn skill show
241
+
242
+ # Download the latest skill from GitHub
243
+ jsn skill fetch | head -30
244
+
245
+ # Install to Hermes skills directory
246
+ jsn skill install
247
+
248
+ # Install to a custom location
249
+ jsn skill install /path/to/skills/
250
+ ```
322
251
 
323
252
  ## Environment Variables
324
253
 
@@ -327,114 +256,100 @@ Credentials are stored in `~/.config/servicenow/credentials/` (file-based, OS ke
327
256
  | `SERVICENOW_INSTANCE_URL` | Default instance URL |
328
257
  | `SERVICENOW_FORMAT` | Default output format |
329
258
  | `SERVICENOW_OAUTH_TOKEN` | OAuth token (for CI/CD) |
259
+ | `JSN_NO_HEADER` | Suppress context header |
330
260
 
331
- ## CI/CD Integration
332
-
333
- For automated environments, use the OAuth token:
261
+ ## Getting Help
334
262
 
335
263
  ```bash
336
- export SERVICENOW_INSTANCE_URL="https://dev12345.service-now.com"
337
- export SERVICENOW_OAUTH_TOKEN="your-oauth-token"
338
-
339
- # Now run commands without interactive auth
340
- jsn incidents list
264
+ jsn # Categorized help with command groups
265
+ jsn incidents --help # Command details
266
+ jsn version # Show version
267
+ jsn version --check # Check for npm updates
341
268
  ```
342
269
 
343
- ## Shell Completion
344
-
345
- > **Note:** Shell completion is available in the Go version only.
270
+ ## Development
346
271
 
347
272
  ```bash
348
- # Bash
349
- source <(jsn completion bash)
273
+ git clone https://github.com/jacebenson/jsn.git
274
+ cd jsn
275
+ git checkout nodejs
276
+ npm install
277
+ npm test # 128+ tests
278
+ npm run lint # ESLint
279
+ npm run start # Run CLI locally
280
+ ```
350
281
 
351
- # Zsh
352
- source <(jsn completion zsh)
282
+ ### Project Structure
353
283
 
354
- # Fish
355
- jsn completion fish | source
284
+ ```
285
+ ├── src/
286
+ │ ├── cli.js # Root CLI (yargs setup)
287
+ │ ├── app.js # App context
288
+ │ ├── auth.js # OAuth PKCE manager
289
+ │ ├── sdk.js # ServiceNow REST API client
290
+ │ ├── output.js # Output formatting
291
+ │ ├── config.js # Configuration loader
292
+ │ ├── context.js # Runtime context
293
+ │ ├── errors.js # Structured error types
294
+ │ ├── helpers.js # Shared utilities
295
+ │ ├── help.js # Custom grouped help renderer
296
+ │ └── commands/ # CLI command modules
297
+ ├── skills/
298
+ │ └── servicenow/
299
+ │ └── SKILL.md # AI agent skill file
300
+ ├── test/ # Test suite
301
+ └── package.json
356
302
  ```
357
303
 
358
- ## Getting Help
304
+ ### Releasing
359
305
 
360
306
  ```bash
361
- # General help
362
- jsn --help
363
-
364
- # Command help
365
- jsn incidents --help
366
-
367
- # Subcommand help
368
- jsn incidents create --help
307
+ npm run release -- patch # or minor, major
308
+ # Creates node-v* tag, pushes to GitHub, publishes to npm
369
309
  ```
370
310
 
371
311
  ## Troubleshooting
372
312
 
373
313
  ### Not authenticated
374
314
 
375
- ```bash
315
+ ```
376
316
  ⚠️ Not authenticated to https://dev12345.service-now.com
377
317
 
378
318
  To get started, run:
379
- jsn setup # Interactive setup
380
- jsn auth login # Login to instance
319
+ jsn setup
320
+ jsn auth login
381
321
  ```
382
322
 
383
- **Solution**: Run `jsn setup` or `jsn auth login <instance>`
384
-
385
323
  ### Instance URL required
386
324
 
387
- ```bash
388
- Error (usage): Instance URL required. Set via --instance flag, SERVICENOW_INSTANCE_URL env, or config file.
389
325
  ```
390
-
391
- **Solution**: Set the instance with one of:
392
- - `jsn setup`
393
- - `jsn auth login <instance>`
394
- - `--instance` flag
395
- - `SERVICENOW_INSTANCE_URL` environment variable
396
-
397
- ## Development
398
-
399
- This repository maintains two parallel implementations:
400
-
401
- - **`main`** — Go implementation (stable)
402
- - **`nodejs`** — Node.js implementation (active development)
403
-
404
- Both branches share the same CLI interface and are kept in sync for feature parity.
405
-
406
- ### Node.js version
407
-
408
- ```bash
409
- git checkout nodejs
410
- npm install
411
- npm test # Run tests
412
- npm run lint # Run ESLint
413
- npm run start # Run CLI locally
326
+ Error (usage): Instance URL required. Set via --instance flag,
327
+ SERVICENOW_INSTANCE_URL env, or config file.
414
328
  ```
415
329
 
416
- ### Releasing
330
+ ### Outdated version
417
331
 
418
332
  ```bash
419
- # From nodejs branch — creates node-v* tag and publishes to npm
420
- npm run release -- patch
421
-
422
- # From main branch — creates go-v* tag and builds binaries
423
- npm run release -- patch
333
+ jsn version --check
334
+ # → jsn 0.0.10 — newer version 0.1.0 available
335
+ npm install -g @jacebenson/jsn
424
336
  ```
425
337
 
426
- ## Contributing
338
+ ## Historical Note
427
339
 
428
- 1. Fork the repository
429
- 2. Create a feature branch (target the appropriate branch: `main` or `nodejs`)
430
- 3. Make your changes
431
- 4. Add tests
432
- 5. Submit a pull request
340
+ JSN was originally implemented in Go (on the `main` branch) and migrated to Node.js for broader cross-platform support and simpler installation. As of v0.1.0, the Node.js version has full feature parity. The Go source remains available on the `main` branch for reference.
433
341
 
434
342
  ## License
435
343
 
436
- MIT License - see LICENSE file for details
344
+ MIT License — see LICENSE file for details
437
345
 
438
346
  ## Acknowledgments
439
347
 
440
- This project follows the architectural patterns from [basecamp-cli](https://github.com/basecamp/basecamp-cli).
348
+ This project follows architectural patterns from [basecamp-cli](https://github.com/basecamp/basecamp-cli).
349
+
350
+ | Project | What we learned |
351
+ |---------|----------------|
352
+ | [Abey's `sn` CLI](https://github.com/tehubersheezy/servicenow-cli) (Rust) | Table API patterns, aggregate stats, raw REST passthrough |
353
+ | [ServiceNow `now-sdk`](https://www.npmjs.com/package/@servicenow/sdk) | OAuth session flow for UI pages |
354
+ | [ServiceNow VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ServiceNow.now-vscode) | `sys.scripts.do` CSRF extraction |
355
+ | [Getting Real](https://basecamp.com/gettingreal) by Basecamp | Build less, start with no, embrace constraints |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacebenson/jsn",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "A command-line interface for ServiceNow that follows the Unix philosophy: simple, composable, and scriptable.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,11 +33,13 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@eslint/js": "^10.0.1",
36
+ "@inquirer/search": "^4.2.0",
36
37
  "globals": "^17.6.0"
37
38
  },
38
39
  "files": [
39
40
  "bin/jsn.js",
40
41
  "src/",
42
+ "skills/",
41
43
  "README.md",
42
44
  "LICENSE"
43
45
  ]