@jacebenson/jsn 4.3.13-dev.75.1 → 4.3.13-dev.77.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/package.json +1 -1
- package/skills/servicenow/SKILL.md +3 -6
- package/src/cli-adapter.js +8 -0
- package/src/cli.js +4 -1
- package/src/commands/_generic.js +7 -0
- package/src/commands/_ticket.js +1 -0
- package/src/commands/auth.js +42 -12
- package/src/commands/discover.js +54 -0
- package/src/commands/setup.js +30 -9
- package/src/help.js +8 -2
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ compatibility: |
|
|
|
14
14
|
Works with Claude Code, OpenCode, Cursor, and agentskills-compatible tools.
|
|
15
15
|
metadata:
|
|
16
16
|
author: jacebenson
|
|
17
|
-
version: "4.3.
|
|
17
|
+
version: "4.3.12"
|
|
18
18
|
repository: https://github.com/jacebenson/jsn
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -150,8 +150,5 @@ Check order (priority):
|
|
|
150
150
|
|
|
151
151
|
## Configuration
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
├── config.json # Profiles and settings
|
|
156
|
-
└── credentials/ # Auth tokens (fallback, one file per key)
|
|
157
|
-
```
|
|
153
|
+
Use `jsn setup` for interactive configuration. `jsn setup --help` lists the
|
|
154
|
+
scriptable `jsn auth` equivalents and secure authentication input options.
|
package/src/cli-adapter.js
CHANGED
|
@@ -116,6 +116,7 @@ export class LocalCLI {
|
|
|
116
116
|
|
|
117
117
|
scriptName(value) { this.script = value; return this; }
|
|
118
118
|
usage(value) { this.root.usageText = value; return this; }
|
|
119
|
+
epilogue(value) { this.root.epilogueText = value; return this; }
|
|
119
120
|
middleware(fn) { this.middlewares.push(...(Array.isArray(fn) ? fn : [fn])); return this; }
|
|
120
121
|
option(name, config) { this.root.options.set(name, { ...config, name }); return this; }
|
|
121
122
|
options(config) { for (const [name, value] of Object.entries(config)) this.option(name, value); return this; }
|
|
@@ -294,6 +295,13 @@ export class LocalCLI {
|
|
|
294
295
|
aliases: [...node.aliases],
|
|
295
296
|
description: node.definition.describe || '',
|
|
296
297
|
subcommands: node.children.filter(visible).map((child) => child.name),
|
|
298
|
+
discovery: node.definition.discovery || null,
|
|
299
|
+
help: `jsn ${node.name} --help`,
|
|
300
|
+
actions: node.children.filter(visible).map((child) => ({
|
|
301
|
+
name: child.name,
|
|
302
|
+
description: child.definition.describe || '',
|
|
303
|
+
help: `jsn ${node.name} ${child.name} --help`,
|
|
304
|
+
})),
|
|
297
305
|
};
|
|
298
306
|
};
|
|
299
307
|
return {
|
package/src/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import fs from 'node:fs';
|
|
|
7
7
|
import { loadConfig, globalConfigDir } from './config.js';
|
|
8
8
|
import { App } from './app.js';
|
|
9
9
|
import { resolveSession, applySession } from './session.js';
|
|
10
|
-
import { renderHelp } from './help.js';
|
|
10
|
+
import { renderHelp, renderTips } from './help.js';
|
|
11
11
|
import { isMutationCommand, refreshMutationCommands } from './mutations.js';
|
|
12
12
|
import { skippedUpdatesCmd } from './commands/skipped-updates.js';
|
|
13
13
|
import { noInstanceCommands, dailyCheckSkipCommands, contextHeaderSkipCommands } from './capabilities.js';
|
|
@@ -15,6 +15,7 @@ import { guardExit, exitWithError, AppError, CodeUsage } from './errors.js';
|
|
|
15
15
|
import { formatCommandList } from './helpers.js';
|
|
16
16
|
|
|
17
17
|
// Command modules
|
|
18
|
+
import { discoverCmd } from './commands/discover.js';
|
|
18
19
|
import { setupCmd } from './commands/setup.js';
|
|
19
20
|
import { authCmd } from './commands/auth.js';
|
|
20
21
|
import { recordsCmd } from './commands/records.js';
|
|
@@ -419,6 +420,7 @@ export function buildCLI() {
|
|
|
419
420
|
.command(skillCmd(wrap))
|
|
420
421
|
.command(docsCmd(wrap))
|
|
421
422
|
.command(versionCmd(wrap))
|
|
423
|
+
.command(discoverCmd(wrap, () => cliInstance.commandRegistry()))
|
|
422
424
|
.demandCommand(1, 'You must specify a command')
|
|
423
425
|
// Completion plumbing under a hidden command name, so the explicit
|
|
424
426
|
// 'completion' command below owns the UX. (#176)
|
|
@@ -499,6 +501,7 @@ export function buildCLI() {
|
|
|
499
501
|
}, { summary });
|
|
500
502
|
})(argv);
|
|
501
503
|
})
|
|
504
|
+
.epilogue(renderTips())
|
|
502
505
|
.help('help', 'Show help')
|
|
503
506
|
.version(false)
|
|
504
507
|
.strictCommands()
|
package/src/commands/_generic.js
CHANGED
|
@@ -280,6 +280,13 @@ export function buildDevCmd(name, table, aliases, defaultColumns, wrap, opts = {
|
|
|
280
280
|
command: `${name} [subcommand]`,
|
|
281
281
|
aliases: aliases || [],
|
|
282
282
|
describe: `Manage ${name} (e.g. "${name} list --query nameLIKEincident")`,
|
|
283
|
+
discovery: {
|
|
284
|
+
table,
|
|
285
|
+
defaultColumns,
|
|
286
|
+
benefits: ['Configured list columns', 'Lookup by name or sys_id',
|
|
287
|
+
...(showFields ? ['Configured show fields'] : []),
|
|
288
|
+
...(opts.onShow ? ['Additional table-specific show processing'] : [])],
|
|
289
|
+
},
|
|
283
290
|
builder,
|
|
284
291
|
handler: (_argv) => {
|
|
285
292
|
// This handler only runs when no subcommand is matched (the default case).
|
package/src/commands/_ticket.js
CHANGED
|
@@ -14,6 +14,7 @@ export function buildTicketCommands(table, displayName, alias, defaultColumns, s
|
|
|
14
14
|
command: `${displayName} [subcommand]`,
|
|
15
15
|
aliases: [table, alias],
|
|
16
16
|
describe: `Manage ${displayName} (e.g. "${displayName} list --query priority=1")`,
|
|
17
|
+
discovery: { table, defaultColumns, benefits: ['Configured list columns', 'Ticket-specific create/update flags'] },
|
|
17
18
|
builder: (yargs) => {
|
|
18
19
|
return yargs
|
|
19
20
|
.command({
|
package/src/commands/auth.js
CHANGED
|
@@ -3,6 +3,7 @@ import { errUsage, errUsageHint, errConfirmationRequired } from '../errors.js';
|
|
|
3
3
|
import { canUsePicker, formatCommandList, quoteShellArg } from '../helpers.js';
|
|
4
4
|
import { declareCapabilities } from '../capabilities.js';
|
|
5
5
|
import process from 'node:process';
|
|
6
|
+
import { readFile } from 'node:fs/promises';
|
|
6
7
|
import { refreshSession } from '../session.js';
|
|
7
8
|
|
|
8
9
|
function syncSession(app) {
|
|
@@ -139,7 +140,7 @@ export function resolveTargetProfile(argv = {}, cfg = {}, instanceURL = '') {
|
|
|
139
140
|
*/
|
|
140
141
|
export function shouldUseBasicAuth(argv = {}, cfg = {}, instanceURL = '', targetProfile = null) {
|
|
141
142
|
if (argv.basic || argv.password) return true;
|
|
142
|
-
if (argv.oauth || argv.code || argv.printUrl || argv.browser || argv.gck || argv.headers) return false;
|
|
143
|
+
if (argv.oauth || argv.code || argv.printUrl || argv.browser || argv.gck || argv.headers || argv.headersFile !== undefined) return false;
|
|
143
144
|
if (targetProfile) return targetProfile.auth_method === 'basic';
|
|
144
145
|
return Object.values(cfg.profiles || {}).some(profile =>
|
|
145
146
|
profile.instance_url === instanceURL && profile.auth_method === 'basic'
|
|
@@ -147,7 +148,7 @@ export function shouldUseBasicAuth(argv = {}, cfg = {}, instanceURL = '', target
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
export function shouldUseGckAuth(argv = {}, cfg = {}, instanceURL = '', targetProfile = null) {
|
|
150
|
-
if (argv.gck || argv.headers || argv.browser) return true;
|
|
151
|
+
if (argv.gck || argv.headers || argv.browser || argv.headersFile !== undefined) return true;
|
|
151
152
|
if (argv.basic || argv.password || argv.oauth || argv.code || argv.printUrl) return false;
|
|
152
153
|
if (targetProfile) return targetProfile.auth_method === 'gck';
|
|
153
154
|
return Object.values(cfg.profiles || {}).some(profile =>
|
|
@@ -157,10 +158,11 @@ export function shouldUseGckAuth(argv = {}, cfg = {}, instanceURL = '', targetPr
|
|
|
157
158
|
|
|
158
159
|
export function validateLoginSelectors(argv = {}, targetProfile = null) {
|
|
159
160
|
const basic = argv.basic === true || argv.password === true;
|
|
160
|
-
const gck = argv.gck === true || argv.headers !== undefined || argv.browser === true;
|
|
161
|
+
const gck = argv.gck === true || argv.headers !== undefined || argv.headersFile !== undefined || argv.browser === true;
|
|
161
162
|
const oauth = argv.oauth === true || argv.code !== undefined || argv.printUrl === true || argv.waitFile !== undefined;
|
|
162
163
|
if (oauth && (basic || gck)) throw errUsage('Choose only one authentication method: --oauth, --basic, or --browser/--gck.');
|
|
163
164
|
if (argv.waitFile && !argv.printUrl) throw errUsage('--wait-file requires --print-url.');
|
|
165
|
+
if (argv.headers !== undefined && argv.headersFile !== undefined) throw errUsage('Choose --headers-file or --headers, not both.');
|
|
164
166
|
if (argv.code !== undefined && argv.printUrl) throw errUsage('--code cannot be combined with --print-url.');
|
|
165
167
|
if (argv.browserUrl !== undefined && !argv.browser) {
|
|
166
168
|
throw errUsage('--browser-url requires --browser.');
|
|
@@ -168,8 +170,8 @@ export function validateLoginSelectors(argv = {}, targetProfile = null) {
|
|
|
168
170
|
if (argv.browserName !== undefined && (!argv.browser || argv.browserUrl !== undefined)) {
|
|
169
171
|
throw errUsage('--browser-name requires --browser and cannot be combined with --browser-url.');
|
|
170
172
|
}
|
|
171
|
-
if (argv.browser && (argv.headers !== undefined || argv.code !== undefined || argv.printUrl || argv.waitFile)) {
|
|
172
|
-
throw errUsage('--browser cannot be combined with --headers, --code, --print-url, or --wait-file.');
|
|
173
|
+
if (argv.browser && (argv.headers !== undefined || argv.headersFile !== undefined || argv.code !== undefined || argv.printUrl || argv.waitFile)) {
|
|
174
|
+
throw errUsage('--browser cannot be combined with --headers-file, --headers, --code, --print-url, or --wait-file.');
|
|
173
175
|
}
|
|
174
176
|
if (basic && gck) {
|
|
175
177
|
throw errUsage('Basic and browser-session selectors are mutually exclusive; choose --basic/--password or --gck/--headers.');
|
|
@@ -278,6 +280,22 @@ export async function readBrowserSessionInput() {
|
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
|
|
283
|
+
/** Read captured session data without putting it in argv or printing a prompt. */
|
|
284
|
+
async function readBrowserSessionFile(file) {
|
|
285
|
+
let content;
|
|
286
|
+
if (file === '-') {
|
|
287
|
+
if (process.stdin.isTTY) throw errUsageHint('--headers-file - requires piped or redirected input.', 'Pipe captured headers into this command, or pass a file path.');
|
|
288
|
+
const chunks = [];
|
|
289
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
290
|
+
content = Buffer.concat(chunks).toString('utf8');
|
|
291
|
+
} else {
|
|
292
|
+
try { content = await readFile(file, 'utf8'); }
|
|
293
|
+
catch { throw errUsageHint('Could not read browser-session input file.', 'Check the --headers-file path and file permissions.'); }
|
|
294
|
+
}
|
|
295
|
+
if (!content.trim()) throw errUsage('Browser-session input is empty. Supply captured headers or a cURL request.');
|
|
296
|
+
return content;
|
|
297
|
+
}
|
|
298
|
+
|
|
281
299
|
/** Collect human answers, then call the same login operation as auth login. */
|
|
282
300
|
export async function loginWizard(app, argv = {}) {
|
|
283
301
|
const { input, select, confirm, password } = await import('../prompts.js');
|
|
@@ -593,8 +611,9 @@ Find your instance URL in your browser's address bar when logged into ServiceNow
|
|
|
593
611
|
const useBasic = shouldUseBasicAuth(argv, methodConfig, instanceURL, targetProfile);
|
|
594
612
|
const useGck = shouldUseGckAuth(argv, methodConfig, instanceURL, targetProfile);
|
|
595
613
|
const interactive = canUsePicker(app, argv);
|
|
596
|
-
|
|
597
|
-
|
|
614
|
+
const capturedHeaders = argv.headers !== undefined || argv.headersFile !== undefined;
|
|
615
|
+
if (useGck && !argv.browser && !capturedHeaders && !interactive) {
|
|
616
|
+
throw errUsage('Browser sign-in needs a human. Pass --browser to explicitly open a login window, or supply a captured session with --headers-file <path|->.');
|
|
598
617
|
}
|
|
599
618
|
if (!useGck && !useBasic && !argv.printUrl && !argv.code && !interactive) {
|
|
600
619
|
throw errUsage('OAuth login requires --print-url followed by --code <code> when noninteractive.');
|
|
@@ -611,9 +630,9 @@ Find your instance URL in your browser's address bar when logged into ServiceNow
|
|
|
611
630
|
// --basic (with --password as a compatibility alias): authenticate
|
|
612
631
|
// with basic auth from env vars and persist it for this profile.
|
|
613
632
|
if (useGck) {
|
|
614
|
-
const credentials = (argv.browser || (!argv.gck && !
|
|
633
|
+
const credentials = (argv.browser || (!argv.gck && !capturedHeaders))
|
|
615
634
|
? await loginUsingBrowser(app, instanceURL, argv, targetUsername || null)
|
|
616
|
-
: await app.auth.loginWithGck(instanceURL, argv.headers || await readBrowserSessionInput(), targetUsername || null);
|
|
635
|
+
: await app.auth.loginWithGck(instanceURL, argv.headersFile !== undefined ? await readBrowserSessionFile(argv.headersFile) : argv.headers || await readBrowserSessionInput(), targetUsername || null);
|
|
617
636
|
targetUsername = credentials?.username || targetUsername;
|
|
618
637
|
} else if (useBasic) {
|
|
619
638
|
let credentials;
|
|
@@ -994,10 +1013,16 @@ Examples:
|
|
|
994
1013
|
|
|
995
1014
|
const target = resolveTargetProfile(argv, app.config, instanceURL);
|
|
996
1015
|
const targetProfile = target.profile;
|
|
1016
|
+
const browser = argv.browser || (targetProfile?.auth_method === 'gck'
|
|
1017
|
+
&& argv.headers === undefined && argv.headersFile === undefined && canUsePicker(app, argv));
|
|
1018
|
+
validateLoginSelectors({ ...argv, browser }, targetProfile);
|
|
1019
|
+
if (targetProfile?.auth_method !== 'gck' && (argv.headersFile !== undefined || argv.headers !== undefined || argv.browser)) {
|
|
1020
|
+
throw errUsage('Browser-session input requires a browser-session profile. Select it with --profile, or add a separate connection with auth login --name <name>.');
|
|
1021
|
+
}
|
|
997
1022
|
if (targetProfile?.auth_method === 'gck') {
|
|
998
1023
|
return loginProfile({
|
|
999
1024
|
...argv, instance: instanceURL, profile: target.name,
|
|
1000
|
-
browser
|
|
1025
|
+
browser,
|
|
1001
1026
|
}, app);
|
|
1002
1027
|
}
|
|
1003
1028
|
const targetAuthOptions = {
|
|
@@ -1083,7 +1108,11 @@ export function authCmd(wrap) {
|
|
|
1083
1108
|
type: 'boolean',
|
|
1084
1109
|
})
|
|
1085
1110
|
.option('headers', {
|
|
1086
|
-
describe: '
|
|
1111
|
+
describe: 'Inline browser headers (compatibility); prefer --headers-file to keep secrets out of arguments',
|
|
1112
|
+
type: 'string',
|
|
1113
|
+
})
|
|
1114
|
+
.option('headers-file', {
|
|
1115
|
+
describe: 'Read browser headers/cURL from a file, or - for stdin; no secrets in arguments',
|
|
1087
1116
|
type: 'string',
|
|
1088
1117
|
})
|
|
1089
1118
|
.option('browser', {
|
|
@@ -1143,7 +1172,8 @@ export function authCmd(wrap) {
|
|
|
1143
1172
|
.option('browser', { type: 'boolean', describe: 'Explicitly open a browser to renew the session' })
|
|
1144
1173
|
.option('browser-name', { type: 'string', describe: 'Browser to launch: chromium, chrome, or edge' })
|
|
1145
1174
|
.option('browser-url', { type: 'string', describe: 'Advanced: local browser debugging URL (requires --browser)' })
|
|
1146
|
-
.option('headers', { type: 'string', describe: '
|
|
1175
|
+
.option('headers', { type: 'string', describe: 'Inline captured headers (compatibility); prefer --headers-file' })
|
|
1176
|
+
.option('headers-file', { type: 'string', describe: 'Captured headers/cURL file, or - for stdin; keeps secrets out of arguments' }),
|
|
1147
1177
|
handler: wrap(refreshProfile),
|
|
1148
1178
|
})
|
|
1149
1179
|
.command({
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { declareCapabilities } from '../capabilities.js';
|
|
2
|
+
|
|
3
|
+
declareCapabilities('discover', { noInstance: true, skipDailyChecks: true });
|
|
4
|
+
|
|
5
|
+
// The live registrations supply names, descriptions, aliases, actions, and
|
|
6
|
+
// factory configuration. No separate inventory of table commands lives here.
|
|
7
|
+
export function discoverCommands(registry, { query = '', table = '' } = {}) {
|
|
8
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
9
|
+
return registry.commands.filter(command => {
|
|
10
|
+
const metadata = command.discovery;
|
|
11
|
+
if (table && metadata?.table !== table) return false;
|
|
12
|
+
const haystack = [command.name, ...command.aliases, command.description,
|
|
13
|
+
metadata?.table, ...(metadata?.benefits || []),
|
|
14
|
+
...(command.actions || []).map(action => `${action.name} ${action.description}`)].join(' ').toLowerCase();
|
|
15
|
+
return words.every(word => haystack.includes(word));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function discoverCmd(wrap, getRegistry) {
|
|
20
|
+
return {
|
|
21
|
+
command: 'discover [query]',
|
|
22
|
+
describe: 'Find commands by words in their names, aliases, descriptions, or configured table',
|
|
23
|
+
builder: y => y
|
|
24
|
+
.positional('query', { type: 'string', describe: 'Search words (quote multiple words)' })
|
|
25
|
+
.option('table', { type: 'string', describe: 'Find specialized commands configured for this exact table' })
|
|
26
|
+
.epilogue([
|
|
27
|
+
'Choose by intent:',
|
|
28
|
+
' Cross-table tasks: jsn records list --table task --query "active=true" --json',
|
|
29
|
+
' Custom tables: jsn records list --table x_example_record --limit 5 --json',
|
|
30
|
+
' Table-specific defaults and views: jsn discover --table incident',
|
|
31
|
+
' Rich request views (attachments and variables): jsn requests show --help',
|
|
32
|
+
' Raw endpoints when needed: jsn rest --help',
|
|
33
|
+
'Generic records supports any accessible table; specialized commands provide configured defaults and table-specific behavior.',
|
|
34
|
+
'Discovery matches registered text; try fewer words if there are no matches.',
|
|
35
|
+
'Use --json for structured results or --json --get data.commands for only matches.',
|
|
36
|
+
].join('\n')),
|
|
37
|
+
handler: wrap(async (argv, app) => {
|
|
38
|
+
const commands = discoverCommands(getRegistry(), { query: argv.query, table: argv.table });
|
|
39
|
+
const lines = commands.flatMap(command => [
|
|
40
|
+
`${command.name}: ${command.description}`,
|
|
41
|
+
...(command.discovery ? [
|
|
42
|
+
` Table: ${command.discovery.table}; default columns: ${command.discovery.defaultColumns.join(', ')}`,
|
|
43
|
+
...command.discovery.benefits.map(benefit => ` ${benefit}`),
|
|
44
|
+
] : []),
|
|
45
|
+
` ${command.help}`,
|
|
46
|
+
...(command.actions || []).map(action => ` ${action.help} — ${action.description}`),
|
|
47
|
+
]);
|
|
48
|
+
if (!commands.length) lines.push('No registered matches. Try fewer words or use generic records for any accessible table: jsn records list --help');
|
|
49
|
+
app.ok({ commands, _formatted: lines.join('\n') }, {
|
|
50
|
+
summary: `${commands.length} matching command(s). Use jsn discover --help for guidance by intent.`,
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
package/src/commands/setup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loginWizard, loginProfile, showAuthStatus, switchProfile, modifyProfile, logoutProfile, removeConnection } from './auth.js';
|
|
2
|
-
import {
|
|
2
|
+
import { errUsageHint } from '../errors.js';
|
|
3
3
|
import { declareCapabilities } from '../capabilities.js';
|
|
4
4
|
|
|
5
5
|
// Setup manages local profile config — runs without a configured instance.
|
|
@@ -7,15 +7,35 @@ import { declareCapabilities } from '../capabilities.js';
|
|
|
7
7
|
declareCapabilities('setup', { noInstance: true, skipContextHeader: true });
|
|
8
8
|
|
|
9
9
|
const HUB_CHOICES = [
|
|
10
|
-
{ name: 'Add a connection', value: 'add' },
|
|
11
|
-
{ name: 'Sign in again', value: 'login' },
|
|
12
|
-
{ name: 'Check connections', value: 'status' },
|
|
13
|
-
{ name: 'Choose the default profile', value: 'switch' },
|
|
14
|
-
{ name: 'Change settings', value: 'modify' },
|
|
15
|
-
{ name: 'Sign out (keep the profile)', value: 'logout' },
|
|
16
|
-
{ name: 'Remove a connection', value: 'remove' },
|
|
10
|
+
{ name: 'Add a connection', value: 'add', command: 'jsn auth login <instance> --name <name> --basic' },
|
|
11
|
+
{ name: 'Sign in again', value: 'login', command: 'jsn auth login --profile <name> (with the authentication options below)' },
|
|
12
|
+
{ name: 'Check connections', value: 'status', command: 'jsn auth status --details --json (use --local to skip instance probes)' },
|
|
13
|
+
{ name: 'Choose the default profile', value: 'switch', command: 'jsn auth switch <name>' },
|
|
14
|
+
{ name: 'Change settings', value: 'modify', command: 'jsn auth modify --profile <name> --read-only --confirm-deletes --no-include-counts' },
|
|
15
|
+
{ name: 'Sign out (keep the profile)', value: 'logout', command: 'jsn auth logout --profile <name> --force (only after explicit approval)' },
|
|
16
|
+
{ name: 'Remove a connection', value: 'remove', command: 'jsn auth remove <name>' },
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
+
const setupHelp = () => [
|
|
20
|
+
'With no profiles, setup opens the add-connection wizard; otherwise it opens the management menu.',
|
|
21
|
+
'The wizard and these scriptable commands share the same authentication and configuration operations:',
|
|
22
|
+
...HUB_CHOICES.map(choice => ` ${choice.name}: ${choice.command}`),
|
|
23
|
+
'',
|
|
24
|
+
'Authentication input without secrets in command arguments:',
|
|
25
|
+
' Basic: set SN_USERNAME and SN_PASSWORD through your environment, then use --basic.',
|
|
26
|
+
' OAuth: jsn auth login <instance> --name <name> --oauth --print-url --wait-file <code-file> --json',
|
|
27
|
+
' Browser session: jsn auth login <instance> --name <name> --headers-file <session-file> --json',
|
|
28
|
+
' Piped browser session: jsn auth login <instance> --name <name> --headers-file - --json',
|
|
29
|
+
' A browser window can also be requested explicitly with --browser; it requires a human to sign in.',
|
|
30
|
+
' Refresh OAuth: jsn auth refresh --profile <name>',
|
|
31
|
+
' Renew captured browser headers: jsn auth refresh --profile <name> --headers-file <session-file>',
|
|
32
|
+
'',
|
|
33
|
+
'New-profile preferences: --read-only, --confirm-deletes, --include-counts and --make-default.',
|
|
34
|
+
'Use --no-read-only, --no-confirm-deletes, --no-include-counts or --no-make-default for the opposite value.',
|
|
35
|
+
'Use --json for structured output. Explicit flags avoid implicit pickers; ambiguous targets return an error.',
|
|
36
|
+
'Discover all options with jsn auth <command> --help.',
|
|
37
|
+
].join('\n');
|
|
38
|
+
|
|
19
39
|
/** The setup hub prompt; q and Escape resolve with no selected action. */
|
|
20
40
|
export const authHubPrompt = async (...args) => {
|
|
21
41
|
const { createPrompt, useKeypress, usePagination, useState, isDownKey, isEnterKey, isUpKey } = await import('@inquirer/core');
|
|
@@ -81,10 +101,11 @@ export function setupCmd(wrap) {
|
|
|
81
101
|
return {
|
|
82
102
|
command: 'setup',
|
|
83
103
|
describe: 'Set up and manage your ServiceNow instances (interactive)',
|
|
104
|
+
builder: y => y.epilogue(setupHelp()),
|
|
84
105
|
handler: wrap(async (argv, app) => {
|
|
85
106
|
const { canUsePicker } = await import('../helpers.js');
|
|
86
107
|
if (!app.isInteractive() || !canUsePicker(app, argv)) {
|
|
87
|
-
throw
|
|
108
|
+
throw errUsageHint('"jsn setup" is interactive. Use explicit auth commands instead.', setupHelp());
|
|
88
109
|
}
|
|
89
110
|
const profileNames = Object.keys(app.config.profiles || {});
|
|
90
111
|
if (profileNames.length === 0) {
|
package/src/help.js
CHANGED
|
@@ -200,14 +200,20 @@ function renderFlags(options) {
|
|
|
200
200
|
return `\nFLAGS\n${lines.join('\n')}`;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
function renderTips() {
|
|
203
|
+
export function renderTips() {
|
|
204
204
|
return `
|
|
205
205
|
TIPS
|
|
206
|
-
|
|
206
|
+
Find commands by task words: "jsn discover catalog"; by configured table: "jsn discover --table incident"
|
|
207
|
+
Cross-table task searches and custom tables: "jsn records list --help"
|
|
208
|
+
Specialized commands offer configured columns, lookup, and table-specific views; inspect discovery results for details
|
|
209
|
+
Raw endpoints when needed: "jsn rest --help"; examples and intent guidance: "jsn discover --help"
|
|
207
210
|
Use "jsn <command> --help" for details, or "jsn <command> list --help" for list options
|
|
208
211
|
"jsn --json" prints the registered command surface as JSON for scripts and agents
|
|
209
212
|
|
|
210
213
|
LEARN MORE
|
|
214
|
+
Some list commands offer a picker in an interactive terminal with automatic output.
|
|
215
|
+
Arrow keys browse (10 visible items); type to search; scroll to load more; Enter selects; Esc cancels.
|
|
216
|
+
Picker eligibility and search fields vary by command. Explicit output formats (including --json) skip pickers.
|
|
211
217
|
Use "jsn <command> --help" for more information about a command.`;
|
|
212
218
|
}
|
|
213
219
|
|