@jacebenson/jsn 1.0.6 → 2.0.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.
- package/README.md +196 -243
- package/bin/jsn.js +2 -57
- package/package.json +35 -32
- package/skills/servicenow/SKILL.md +137 -0
- package/src/app.js +172 -0
- package/src/auth.js +517 -0
- package/src/cli.js +174 -0
- package/src/commands/_ticket.js +260 -0
- package/src/commands/auth.js +227 -0
- package/src/commands/catalog.js +325 -0
- package/src/commands/changes.js +7 -0
- package/src/commands/dev/_generic.js +342 -0
- package/src/commands/dev/_simple.js +89 -0
- package/src/commands/dev/eval.js +38 -0
- package/src/commands/dev/flows.js +573 -0
- package/src/commands/dev/forms.js +313 -0
- package/src/commands/dev/lists.js +233 -0
- package/src/commands/dev/logs.js +64 -0
- package/src/commands/dev/rest.js +64 -0
- package/src/commands/dev/scopes.js +156 -0
- package/src/commands/dev/updatesets.js +184 -0
- package/src/commands/dev.js +53 -0
- package/src/commands/groupmembers.js +152 -0
- package/src/commands/grouproles.js +152 -0
- package/src/commands/groups.js +141 -0
- package/src/commands/incidents.js +7 -0
- package/src/commands/profiles.js +91 -0
- package/src/commands/records.js +171 -0
- package/src/commands/requests.js +59 -0
- package/src/commands/setup.js +39 -0
- package/src/commands/skill.js +144 -0
- package/src/commands/tasks.js +7 -0
- package/src/commands/tickets.js +121 -0
- package/src/commands/users.js +144 -0
- package/src/commands/version.js +81 -0
- package/src/config.js +154 -0
- package/src/context.js +62 -0
- package/src/errors.js +101 -0
- package/src/help.js +85 -0
- package/src/helpers.js +182 -0
- package/src/output.js +440 -0
- package/src/sdk.js +615 -0
- package/scripts/install.sh +0 -227
- package/scripts/npm-install.js +0 -235
- package/scripts/pre-commit-check.sh +0 -61
package/README.md
CHANGED
|
@@ -4,69 +4,64 @@ A command-line interface for ServiceNow that follows the Unix philosophy: simple
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
### npm (
|
|
7
|
+
### npm (recommended — cross-platform)
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install -g @jacebenson/jsn
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Works on macOS, Linux, and Windows
|
|
13
|
+
No compilation needed. Works on macOS, Linux, and Windows with Node.js 18+.
|
|
14
14
|
|
|
15
|
-
|
|
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`.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
# Download the latest release
|
|
19
|
-
curl -L https://github.com/jacebenson/jsn/releases/latest/download/jsn-linux-amd64 -o jsn
|
|
20
|
-
chmod +x jsn
|
|
21
|
-
sudo mv jsn /usr/local/bin/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Go Install
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
go install github.com/jacebenson/jsn/cmd/jsn@latest
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
### 1. Setup
|
|
33
|
-
|
|
34
|
-
Run the interactive setup to configure your first ServiceNow instance:
|
|
17
|
+
### Quick Start
|
|
35
18
|
|
|
36
19
|
```bash
|
|
20
|
+
# Interactive setup
|
|
37
21
|
jsn setup
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
This will:
|
|
41
|
-
1. Ask for your ServiceNow instance URL
|
|
42
|
-
2. Open a browser for OAuth authentication
|
|
43
|
-
3. Set the instance as your default
|
|
44
|
-
|
|
45
|
-
### 2. Verify Authentication
|
|
46
22
|
|
|
47
|
-
|
|
23
|
+
# Check auth status
|
|
48
24
|
jsn auth status
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 3. Start Using
|
|
52
25
|
|
|
53
|
-
|
|
54
|
-
# List all incidents
|
|
26
|
+
# List incidents
|
|
55
27
|
jsn incidents
|
|
56
28
|
|
|
57
|
-
#
|
|
58
|
-
jsn
|
|
59
|
-
|
|
60
|
-
# Create a new incident
|
|
61
|
-
jsn incidents create --description "Server down" --priority 1
|
|
62
|
-
|
|
63
|
-
# List change requests
|
|
64
|
-
jsn changes
|
|
65
|
-
|
|
66
|
-
# Query any table
|
|
67
|
-
jsn records list --table incident --query "priority=1^active=true"
|
|
29
|
+
# Check for updates
|
|
30
|
+
jsn version --check
|
|
68
31
|
```
|
|
69
32
|
|
|
33
|
+
## What's New in v0.1.0
|
|
34
|
+
|
|
35
|
+
Full feature parity — 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 (shared 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
|
+
|
|
70
65
|
## Configuration
|
|
71
66
|
|
|
72
67
|
JSN uses a layered configuration system:
|
|
@@ -81,8 +76,6 @@ JSN uses a layered configuration system:
|
|
|
81
76
|
|
|
82
77
|
### Profiles
|
|
83
78
|
|
|
84
|
-
Work with multiple ServiceNow instances using profiles:
|
|
85
|
-
|
|
86
79
|
```bash
|
|
87
80
|
# Login to a new instance
|
|
88
81
|
jsn auth login https://dev12345.service-now.com
|
|
@@ -99,7 +92,7 @@ jsn profiles show
|
|
|
99
92
|
|
|
100
93
|
## Commands
|
|
101
94
|
|
|
102
|
-
###
|
|
95
|
+
### CORE
|
|
103
96
|
|
|
104
97
|
| Command | Aliases | Description |
|
|
105
98
|
|---------|---------|-------------|
|
|
@@ -107,207 +100,154 @@ jsn profiles show
|
|
|
107
100
|
| `changes` | `change`, `chg` | Manage change requests |
|
|
108
101
|
| `requests` | `request`, `req`, `ritm` | Manage service catalog requests |
|
|
109
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 |
|
|
110
110
|
| `users` | `user` | Manage users |
|
|
111
111
|
| `groups` | `group` | Manage user groups |
|
|
112
|
-
| `
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
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 |
|
|
136
152
|
|
|
137
153
|
## Usage Examples
|
|
138
154
|
|
|
139
155
|
### Incidents
|
|
140
156
|
|
|
141
157
|
```bash
|
|
142
|
-
# List all
|
|
143
|
-
jsn incidents
|
|
144
|
-
|
|
145
|
-
# List critical incidents
|
|
146
|
-
jsn incidents list --query "priority=1"
|
|
147
|
-
|
|
148
|
-
# Show specific incident
|
|
149
|
-
jsn incidents INC0010001
|
|
150
|
-
|
|
151
|
-
# Create incident
|
|
158
|
+
jsn incidents # List all
|
|
159
|
+
jsn incidents list --query "priority=1" # Critical only
|
|
160
|
+
jsn incidents INC0010001 # Show specific
|
|
152
161
|
jsn incidents create --description "Server down" --priority 1
|
|
153
|
-
|
|
154
|
-
# Update incident
|
|
155
162
|
jsn incidents update INC0010001 --data '{"state": "6"}'
|
|
156
|
-
|
|
157
|
-
# Delete incident
|
|
158
|
-
jsn incidents delete INC0010001
|
|
159
163
|
```
|
|
160
164
|
|
|
161
|
-
###
|
|
165
|
+
### Requests (with enriched details)
|
|
162
166
|
|
|
163
167
|
```bash
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
#
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
#
|
|
171
|
-
jsn changes create --description "Deploy feature" --risk medium
|
|
172
|
-
|
|
173
|
-
# Update change
|
|
174
|
-
jsn changes update CHG0010001 --data '{"state": "3"}'
|
|
175
|
-
|
|
176
|
-
# Delete change
|
|
177
|
-
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
|
|
178
175
|
```
|
|
179
176
|
|
|
180
|
-
### Development
|
|
177
|
+
### Development
|
|
181
178
|
|
|
182
179
|
```bash
|
|
183
|
-
#
|
|
184
|
-
#
|
|
185
|
-
jsn dev
|
|
186
|
-
|
|
187
|
-
#
|
|
188
|
-
jsn dev actions
|
|
189
|
-
|
|
190
|
-
# SCRIPTS
|
|
191
|
-
# List script includes
|
|
192
|
-
jsn dev includes
|
|
193
|
-
|
|
194
|
-
# Get a specific script include
|
|
195
|
-
jsn dev includes MyScriptInclude
|
|
196
|
-
|
|
197
|
-
# List business rules
|
|
198
|
-
jsn dev rules
|
|
199
|
-
|
|
200
|
-
# List client scripts
|
|
201
|
-
jsn dev clientscripts
|
|
202
|
-
|
|
203
|
-
# List UI actions
|
|
204
|
-
jsn dev uiactions
|
|
205
|
-
|
|
206
|
-
# List UI policies
|
|
207
|
-
jsn dev uipolicies
|
|
208
|
-
|
|
209
|
-
# DATA
|
|
210
|
-
# View table definition
|
|
211
|
-
jsn dev tables incident
|
|
212
|
-
|
|
213
|
-
# List table columns
|
|
214
|
-
jsn dev columns --table incident
|
|
215
|
-
|
|
216
|
-
# SECURITY
|
|
217
|
-
# List access controls (ACLs)
|
|
218
|
-
jsn dev acls
|
|
219
|
-
|
|
220
|
-
# List roles
|
|
221
|
-
jsn dev roles
|
|
222
|
-
|
|
223
|
-
# PLATFORM
|
|
224
|
-
# List update sets
|
|
225
|
-
jsn dev updatesets
|
|
226
|
-
|
|
227
|
-
# Set current update set
|
|
228
|
-
jsn dev updatesets set "My Update Set"
|
|
229
|
-
|
|
230
|
-
# List application scopes
|
|
231
|
-
jsn dev scopes
|
|
232
|
-
|
|
233
|
-
# Query system properties
|
|
234
|
-
jsn dev properties
|
|
235
|
-
|
|
236
|
-
# Query system logs
|
|
237
|
-
jsn dev logs --level error
|
|
238
|
-
jsn dev logs --source "Business Rule" --level warn
|
|
239
|
-
|
|
240
|
-
# Execute background script
|
|
241
|
-
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
|
|
242
185
|
```
|
|
243
186
|
|
|
244
187
|
### Generic Table API
|
|
245
188
|
|
|
246
189
|
```bash
|
|
247
|
-
# List any table
|
|
248
190
|
jsn records list --table incident --limit 10
|
|
249
|
-
|
|
250
|
-
# Query with encoded query
|
|
251
191
|
jsn records list --table incident --query "priority=1^active=true"
|
|
252
|
-
|
|
253
|
-
# Show specific columns
|
|
254
|
-
jsn records list --table incident --columns "number,short_description,priority"
|
|
255
|
-
|
|
256
|
-
# Get a record by sys_id
|
|
257
192
|
jsn records get --table incident --sys-id abc123
|
|
258
|
-
|
|
259
|
-
# Create a record
|
|
260
193
|
jsn records create --table incident --data '{"short_description": "Test"}'
|
|
261
|
-
|
|
262
|
-
# Update a record
|
|
263
|
-
jsn records update --table incident --sys-id abc123 --data '{"priority": "1"}'
|
|
264
|
-
|
|
265
|
-
# Delete a record
|
|
266
|
-
jsn records delete --table incident --sys-id abc123
|
|
267
194
|
```
|
|
268
195
|
|
|
269
196
|
## Output Formats
|
|
270
197
|
|
|
271
|
-
JSN supports multiple output formats:
|
|
272
|
-
|
|
273
198
|
| Format | Flag | Description |
|
|
274
199
|
|--------|------|-------------|
|
|
275
200
|
| Auto (default) | `--format=auto` | JSON for pipes, styled for TTY |
|
|
276
201
|
| JSON | `--json` or `--format=json` | Machine-readable JSON |
|
|
277
|
-
| Styled | `--styled` | ANSI-styled tables
|
|
202
|
+
| Styled | `--styled` | ANSI-styled tables |
|
|
278
203
|
| Markdown | `--markdown` | Markdown tables |
|
|
279
204
|
| Quiet | `--quiet` or `-q` | Data only, no envelope |
|
|
280
205
|
|
|
281
206
|
```bash
|
|
282
|
-
|
|
283
|
-
jsn incidents --json
|
|
284
|
-
|
|
285
|
-
# Styled table output
|
|
207
|
+
jsn incidents --json | jq '.[].number'
|
|
286
208
|
jsn incidents --styled
|
|
287
|
-
|
|
288
|
-
# Markdown output for documentation
|
|
289
|
-
jsn incidents --markdown
|
|
290
|
-
|
|
291
|
-
# Quiet mode for piping
|
|
292
209
|
jsn incidents -q | jq '.[].number'
|
|
293
210
|
```
|
|
294
211
|
|
|
295
212
|
## Authentication
|
|
296
213
|
|
|
297
|
-
|
|
214
|
+
OAuth 2.0 with PKCE. Credentials stored in `~/.config/servicenow/credentials/`.
|
|
298
215
|
|
|
299
216
|
```bash
|
|
300
|
-
# Login to an instance
|
|
301
217
|
jsn auth login https://dev12345.service-now.com
|
|
302
218
|
|
|
303
|
-
#
|
|
304
|
-
jsn auth
|
|
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
|
+
```
|
|
225
|
+
|
|
226
|
+
### CI/CD Integration
|
|
305
227
|
|
|
306
|
-
|
|
307
|
-
|
|
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
|
|
308
232
|
```
|
|
309
233
|
|
|
310
|
-
|
|
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
|
+
```
|
|
311
251
|
|
|
312
252
|
## Environment Variables
|
|
313
253
|
|
|
@@ -316,83 +256,96 @@ Credentials are securely stored in your OS keychain (or file fallback at `~/.con
|
|
|
316
256
|
| `SERVICENOW_INSTANCE_URL` | Default instance URL |
|
|
317
257
|
| `SERVICENOW_FORMAT` | Default output format |
|
|
318
258
|
| `SERVICENOW_OAUTH_TOKEN` | OAuth token (for CI/CD) |
|
|
259
|
+
| `JSN_NO_HEADER` | Suppress context header |
|
|
319
260
|
|
|
320
|
-
##
|
|
321
|
-
|
|
322
|
-
For automated environments, use the OAuth token:
|
|
261
|
+
## Getting Help
|
|
323
262
|
|
|
324
263
|
```bash
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
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
|
|
330
268
|
```
|
|
331
269
|
|
|
332
|
-
##
|
|
270
|
+
## Development
|
|
333
271
|
|
|
334
272
|
```bash
|
|
335
|
-
|
|
336
|
-
|
|
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
|
+
```
|
|
337
281
|
|
|
338
|
-
|
|
339
|
-
source <(jsn completion zsh)
|
|
282
|
+
### Project Structure
|
|
340
283
|
|
|
341
|
-
|
|
342
|
-
|
|
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
|
|
343
302
|
```
|
|
344
303
|
|
|
345
|
-
|
|
304
|
+
### Releasing
|
|
346
305
|
|
|
347
306
|
```bash
|
|
348
|
-
#
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
# Command help
|
|
352
|
-
jsn incidents --help
|
|
353
|
-
|
|
354
|
-
# Subcommand help
|
|
355
|
-
jsn incidents create --help
|
|
307
|
+
npm run release -- patch # or minor, major
|
|
308
|
+
# Creates node-v* tag, pushes to GitHub, publishes to npm
|
|
356
309
|
```
|
|
357
310
|
|
|
358
311
|
## Troubleshooting
|
|
359
312
|
|
|
360
313
|
### Not authenticated
|
|
361
314
|
|
|
362
|
-
```
|
|
315
|
+
```
|
|
363
316
|
⚠️ Not authenticated to https://dev12345.service-now.com
|
|
364
317
|
|
|
365
318
|
To get started, run:
|
|
366
|
-
jsn setup
|
|
367
|
-
jsn auth login
|
|
319
|
+
jsn setup
|
|
320
|
+
jsn auth login
|
|
368
321
|
```
|
|
369
322
|
|
|
370
|
-
**Solution**: Run `jsn setup` or `jsn auth login <instance>`
|
|
371
|
-
|
|
372
323
|
### Instance URL required
|
|
373
324
|
|
|
374
|
-
```
|
|
375
|
-
Error (usage): Instance URL required. Set via --instance flag,
|
|
325
|
+
```
|
|
326
|
+
Error (usage): Instance URL required. Set via --instance flag,
|
|
327
|
+
SERVICENOW_INSTANCE_URL env, or config file.
|
|
376
328
|
```
|
|
377
329
|
|
|
378
|
-
|
|
379
|
-
- `jsn setup`
|
|
380
|
-
- `jsn auth login <instance>`
|
|
381
|
-
- `--instance` flag
|
|
382
|
-
- `SERVICENOW_INSTANCE_URL` environment variable
|
|
383
|
-
|
|
384
|
-
## Contributing
|
|
330
|
+
### Outdated version
|
|
385
331
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
332
|
+
```bash
|
|
333
|
+
jsn version --check
|
|
334
|
+
# → jsn 0.0.10 — newer version 0.1.0 available
|
|
335
|
+
npm install -g @jacebenson/jsn
|
|
336
|
+
```
|
|
391
337
|
|
|
392
338
|
## License
|
|
393
339
|
|
|
394
|
-
MIT License
|
|
340
|
+
MIT License — see LICENSE file for details
|
|
395
341
|
|
|
396
342
|
## Acknowledgments
|
|
397
343
|
|
|
398
|
-
This project follows
|
|
344
|
+
This project follows architectural patterns from [basecamp-cli](https://github.com/basecamp/basecamp-cli).
|
|
345
|
+
|
|
346
|
+
| Project | What we learned |
|
|
347
|
+
|---------|----------------|
|
|
348
|
+
| [Abey's `sn` CLI](https://github.com/tehubersheezy/servicenow-cli) (Rust) | Table API patterns, aggregate stats, raw REST passthrough |
|
|
349
|
+
| [ServiceNow `now-sdk`](https://www.npmjs.com/package/@servicenow/sdk) | OAuth session flow for UI pages |
|
|
350
|
+
| [ServiceNow VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ServiceNow.now-vscode) | `sys.scripts.do` CSRF extraction |
|
|
351
|
+
| [Getting Real](https://basecamp.com/gettingreal) by Basecamp | Build less, start with no, embrace constraints |
|
package/bin/jsn.js
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* JSN CLI binary wrapper
|
|
4
|
-
*
|
|
5
|
-
* This script finds the downloaded platform-specific binary and spawns it,
|
|
6
|
-
* forwarding all arguments, stdin, stdout, and stderr.
|
|
7
|
-
*/
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
const path = require('path');
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
const os = require('os');
|
|
3
|
+
import { cli } from '../src/cli.js';
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
const binaryDir = path.join(__dirname, '..', 'binary');
|
|
16
|
-
const binaryName = os.platform() === 'win32' ? 'jsn.exe' : 'jsn';
|
|
17
|
-
const binaryPath = path.join(binaryDir, binaryName);
|
|
18
|
-
|
|
19
|
-
if (fs.existsSync(binaryPath)) {
|
|
20
|
-
return binaryPath;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Fallback: check if running from source/build
|
|
24
|
-
const devPath = path.join(__dirname, '..', 'jsn');
|
|
25
|
-
if (fs.existsSync(devPath)) {
|
|
26
|
-
return devPath;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Another fallback for dev
|
|
30
|
-
const devPath2 = path.join(__dirname, '..', 'jsn.exe');
|
|
31
|
-
if (fs.existsSync(devPath2)) {
|
|
32
|
-
return devPath2;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
console.error('Error: JSN binary not found.');
|
|
36
|
-
console.error('');
|
|
37
|
-
console.error('The binary should have been downloaded during npm install.');
|
|
38
|
-
console.error('Try reinstalling the package:');
|
|
39
|
-
console.error(' npm uninstall -g @jacebenson/jsn');
|
|
40
|
-
console.error(' npm install -g @jacebenson/jsn');
|
|
41
|
-
console.error('');
|
|
42
|
-
console.error('Or download manually from:');
|
|
43
|
-
console.error(' https://github.com/jacebenson/jsn/releases');
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const binaryPath = getBinaryPath();
|
|
48
|
-
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
49
|
-
stdio: 'inherit',
|
|
50
|
-
windowsHide: true,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
child.on('exit', (code) => {
|
|
54
|
-
process.exit(code ?? 0);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
child.on('error', (err) => {
|
|
58
|
-
console.error(`Failed to start JSN: ${err.message}`);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
});
|
|
5
|
+
cli.parse();
|