@jacebenson/jsn 3.3.1 → 3.3.2
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 -2
- package/src/commands/skill.js +3 -0
- package/scripts/postinstall.mjs +0 -84
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jacebenson/jsn",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
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": {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "NODE_OPTIONS=--require=./suppress-warnings.cjs node --test $(find test -name '*.test.js')",
|
|
12
12
|
"lint": "npx eslint src/ bin/ test/",
|
|
13
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
14
13
|
"start": "NODE_OPTIONS=--require=./suppress-warnings.cjs node bin/jsn.js",
|
|
15
14
|
"tag-reminder": "node scripts/tag-reminder.js",
|
|
16
15
|
"release": "node scripts/release.js"
|
package/src/commands/skill.js
CHANGED
|
@@ -20,6 +20,9 @@ const SKILL_RAW_URL = 'https://raw.githubusercontent.com/jacebenson/jsn/nodejs/s
|
|
|
20
20
|
* Resolve the user's real home directory, even when Hermes overrides $HOME.
|
|
21
21
|
*/
|
|
22
22
|
function realHomeDir() {
|
|
23
|
+
// getent doesn't exist on Windows; os.homedir() is reliable there.
|
|
24
|
+
if (process.platform === 'win32') return os.homedir();
|
|
25
|
+
|
|
23
26
|
try {
|
|
24
27
|
const result = execSync('getent passwd ' + process.env.USER + ' 2>/dev/null', { encoding: 'utf-8', timeout: 3000 });
|
|
25
28
|
const home = result.trim().split(':')[5];
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* postinstall.mjs — Copies the bundled ServiceNow SKILL.md to agent skill directories
|
|
4
|
-
* on npm global install. Mirrors what `basecamp`'s installer does for their skill.
|
|
5
|
-
*
|
|
6
|
-
* Only runs when `npm install -g @jacebenson/jsn`.
|
|
7
|
-
* On `npm install` (local dependency), it's a no-op.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fs from 'node:fs';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
import os from 'node:os';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
14
|
-
|
|
15
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const SKILL_SOURCE = path.resolve(__dirname, '..', 'skills', 'servicenow', 'SKILL.md');
|
|
17
|
-
const AGENTS_DIR = path.join(os.homedir(), '.agents', 'skills', 'servicenow');
|
|
18
|
-
const AGENTS_SKILL = path.join(AGENTS_DIR, 'SKILL.md');
|
|
19
|
-
const CLAUDE_SKILL_DIR = path.join(os.homedir(), '.claude', 'skills');
|
|
20
|
-
const CLAUDE_SYMLINK = path.join(CLAUDE_SKILL_DIR, 'servicenow');
|
|
21
|
-
|
|
22
|
-
function isGlobalInstall() {
|
|
23
|
-
return (
|
|
24
|
-
process.env.npm_config_global === 'true' ||
|
|
25
|
-
process.env.npm_lifecycle_event === 'postinstall'
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function installSkill() {
|
|
30
|
-
// Check if running in a non-interactive/CI environment where .agents
|
|
31
|
-
// doesn't make sense. Skip silently.
|
|
32
|
-
if (!AGENTS_DIR.startsWith(os.homedir())) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!fs.existsSync(SKILL_SOURCE)) {
|
|
37
|
-
console.warn(' ⚠ jsn: ServiceNow SKILL.md not found at', SKILL_SOURCE);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Create ~/.agents/skills/servicenow/
|
|
42
|
-
try {
|
|
43
|
-
fs.mkdirSync(AGENTS_DIR, { recursive: true });
|
|
44
|
-
} catch {
|
|
45
|
-
// user's home might not be writable in container/CI
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Copy the bundled skill file
|
|
50
|
-
try {
|
|
51
|
-
fs.copyFileSync(SKILL_SOURCE, AGENTS_SKILL);
|
|
52
|
-
console.log(' ✓ jsn: ServiceNow skill installed to ' + AGENTS_SKILL);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.warn(' ⚠ jsn: Could not copy skill to ' + AGENTS_SKILL, err.message);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Symlinks require admin on Windows and are pointless outside Unix/Mac.
|
|
59
|
-
// Skip on win32 to avoid "system cannot find the path" errors.
|
|
60
|
-
if (process.platform === 'win32') return;
|
|
61
|
-
|
|
62
|
-
// Create symlink at ~/.claude/skills/servicenow → ../../.agents/skills/servicenow
|
|
63
|
-
// This is the same pattern basecamp's installer uses: ~/.claude/skills/basecamp → ../../.agents/skills/basecamp
|
|
64
|
-
try {
|
|
65
|
-
fs.mkdirSync(CLAUDE_SKILL_DIR, { recursive: true });
|
|
66
|
-
|
|
67
|
-
// Remove stale symlink or directory if it exists
|
|
68
|
-
try {
|
|
69
|
-
fs.unlinkSync(CLAUDE_SYMLINK);
|
|
70
|
-
} catch {
|
|
71
|
-
// doesn't exist — fine
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Relative symlink so it survives user home dir moves
|
|
75
|
-
const relativeTarget = path.relative(CLAUDE_SKILL_DIR, AGENTS_DIR);
|
|
76
|
-
fs.symlinkSync(relativeTarget, CLAUDE_SYMLINK, 'dir');
|
|
77
|
-
console.log(' ✓ jsn: Claude Code skill link at ' + CLAUDE_SYMLINK);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// Claude Code skill dir might not be expected — non-fatal
|
|
80
|
-
console.warn(' ⚠ jsn: Could not create Claude Code symlink:', err.message);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
installSkill();
|