@zabuti/tools 0.1.1 → 0.1.3
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 +31 -14
- package/dist/installer/src/index.js +23 -9
- package/dist/installer/src/skills.js +79 -5
- package/package.json +33 -33
package/README.md
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
# @zabuti/tools
|
|
2
|
-
|
|
3
|
-
Installs the licensed Zabuti developer tools (Logic Map, Logic Optimizer) as Claude Code
|
|
4
|
-
skills. Needs a Zabuti license and a download token from zabuti.com/account (CLI access).
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
npx @zabuti/tools login zct_…
|
|
8
|
-
npx @zabuti/tools add logic-map
|
|
9
|
-
npx @zabuti/tools add logic-optimizer
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
The skill is written to `~/.claude/skills/<name>/`. The server checks your token and your
|
|
13
|
-
organization's license on every download. Nothing from your project is sent. The free
|
|
14
|
-
`zabuti` CLI (components and icons) is a separate package and makes no network calls.
|
|
1
|
+
# @zabuti/tools
|
|
2
|
+
|
|
3
|
+
Installs the licensed Zabuti developer tools (Logic Map, Logic Optimizer) as Claude Code
|
|
4
|
+
skills. Needs a Zabuti license and a download token from zabuti.com/account (CLI access).
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
npx @zabuti/tools login zct_…
|
|
8
|
+
npx @zabuti/tools add logic-map
|
|
9
|
+
npx @zabuti/tools add logic-optimizer
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The skill is written to `~/.claude/skills/<name>/`. The server checks your token and your
|
|
13
|
+
organization's license on every download. Nothing from your project is sent. The free
|
|
14
|
+
`zabuti` CLI (components and icons) is a separate package and makes no network calls.
|
|
15
|
+
|
|
16
|
+
## Behind a corporate network
|
|
17
|
+
|
|
18
|
+
If `add` says it couldn't reach zabuti.com and the cause is a certificate error
|
|
19
|
+
(`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`, `SELF_SIGNED_CERT_IN_CHAIN`, `CERT_HAS_EXPIRED`), your
|
|
20
|
+
network is probably re-signing secure traffic with a company certificate. The browser trusts it
|
|
21
|
+
because the operating system does; Node keeps its own list. Tell Node to use the system's
|
|
22
|
+
certificates (Node 22.15 or later), then run the command again:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
$env:NODE_OPTIONS = "--use-system-ca" # PowerShell, this window only
|
|
26
|
+
npx @zabuti/tools add logic-map
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Make it permanent with `setx NODE_OPTIONS "--use-system-ca"`. On older Node, set
|
|
30
|
+
`NODE_EXTRA_CA_CERTS` to your company's root certificate file instead. Please don't use
|
|
31
|
+
`NODE_TLS_REJECT_UNAUTHORIZED=0`: it turns certificate checks off entirely.
|
|
@@ -3,20 +3,25 @@
|
|
|
3
3
|
* zabuti-tools: installs the licensed Zabuti developer tools as Claude Code skills.
|
|
4
4
|
* Kept separate from the free `zabuti` CLI so that one never touches the network.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
zabuti-tools
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { cmdAddSkill, cmdLogin, cmdStatus, SKILL_NAMES } from "./skills.js";
|
|
8
|
+
const USAGE = `zabuti-tools: install the licensed Zabuti developer tools
|
|
9
|
+
|
|
10
|
+
zabuti-tools login <token> save your download token (make one at zabuti.com/account)
|
|
11
|
+
zabuti-tools add <skill> install a skill into ~/.claude/skills/
|
|
12
|
+
skills: ${SKILL_NAMES.join(", ")}
|
|
13
|
+
|
|
14
|
+
zabuti-tools status show what is installed
|
|
15
|
+
zabuti-tools --version
|
|
16
|
+
|
|
17
|
+
Options: --dry-run (list the files without writing), --out=<folder> (install there instead)`;
|
|
14
18
|
function die(msg) {
|
|
15
19
|
console.error(`zabuti-tools: ${msg}`);
|
|
16
20
|
process.exit(1);
|
|
17
21
|
}
|
|
18
22
|
const args = process.argv.slice(2);
|
|
19
23
|
const flags = new Set(args.filter((a) => a.startsWith("--")));
|
|
24
|
+
const outDir = args.find((a) => a.startsWith("--out="))?.slice(6);
|
|
20
25
|
const positionals = args.filter((a) => !a.startsWith("--"));
|
|
21
26
|
const [command, name] = positionals;
|
|
22
27
|
try {
|
|
@@ -28,9 +33,18 @@ try {
|
|
|
28
33
|
if (!name || !SKILL_NAMES.includes(name) || positionals.length > 2) {
|
|
29
34
|
die(`add: name one skill (${SKILL_NAMES.join(" or ")}), e.g. \`zabuti-tools add logic-map\`.`);
|
|
30
35
|
}
|
|
31
|
-
await cmdAddSkill(name, flags.has("--dry-run"));
|
|
36
|
+
await cmdAddSkill(name, flags.has("--dry-run"), outDir);
|
|
37
|
+
break;
|
|
38
|
+
case "status":
|
|
39
|
+
await cmdStatus();
|
|
32
40
|
break;
|
|
33
41
|
case undefined:
|
|
42
|
+
if (flags.has("--version")) {
|
|
43
|
+
console.log(JSON.parse(readFileSync(new URL("../../../package.json", import.meta.url), "utf8")).version);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
console.log(USAGE);
|
|
47
|
+
break;
|
|
34
48
|
case "help":
|
|
35
49
|
console.log(USAGE);
|
|
36
50
|
break;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* the site and writes it to ~/.claude/skills/<name>/. The server checks the token and
|
|
5
5
|
* the account's license on every download. Nothing else is sent: no project files.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
8
9
|
import { homedir } from "node:os";
|
|
9
10
|
import { dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
10
11
|
export const SKILL_NAMES = ["logic-map", "logic-optimizer"];
|
|
@@ -45,6 +46,32 @@ function safeJoin(root, rel) {
|
|
|
45
46
|
}
|
|
46
47
|
return full;
|
|
47
48
|
}
|
|
49
|
+
// Node's fetch says only "fetch failed"; the real reason is on err.cause.
|
|
50
|
+
const CERT_CODES = new Set([
|
|
51
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
52
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
53
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
54
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
55
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
56
|
+
"CERT_HAS_EXPIRED",
|
|
57
|
+
]);
|
|
58
|
+
/** Why the request failed, with the cause code, and a fix when it's a certificate problem. */
|
|
59
|
+
function unreachableMessage(e) {
|
|
60
|
+
const err = e;
|
|
61
|
+
const code = err.cause?.code;
|
|
62
|
+
const detail = [err.message, code ?? err.cause?.message].filter(Boolean).join(": ");
|
|
63
|
+
let msg = `couldn't reach ${BASE_URL} (${detail}).`;
|
|
64
|
+
if (code && CERT_CODES.has(code)) {
|
|
65
|
+
msg +=
|
|
66
|
+
"\nThis usually means your network re-signs secure traffic with a company certificate that Node doesn't trust (SSL inspection)." +
|
|
67
|
+
"\nFix (Node 22.15 or later): trust the operating system's certificates, then run the command again:" +
|
|
68
|
+
'\n PowerShell: $env:NODE_OPTIONS = "--use-system-ca"' +
|
|
69
|
+
"\n macOS/Linux: export NODE_OPTIONS=--use-system-ca" +
|
|
70
|
+
"\nOn older Node, point NODE_EXTRA_CA_CERTS at your company's root certificate file instead." +
|
|
71
|
+
"\nDon't turn certificate checks off (NODE_TLS_REJECT_UNAUTHORIZED=0).";
|
|
72
|
+
}
|
|
73
|
+
return msg;
|
|
74
|
+
}
|
|
48
75
|
export async function cmdAddSkill(name, dryRun, outDir) {
|
|
49
76
|
const token = storedToken();
|
|
50
77
|
if (!token)
|
|
@@ -54,25 +81,72 @@ export async function cmdAddSkill(name, dryRun, outDir) {
|
|
|
54
81
|
res = await fetch(`${BASE_URL}/api/cli/skills/${encodeURIComponent(name)}`, { headers: { authorization: `Bearer ${token}` } });
|
|
55
82
|
}
|
|
56
83
|
catch (e) {
|
|
57
|
-
throw new Error(
|
|
84
|
+
throw new Error(unreachableMessage(e));
|
|
58
85
|
}
|
|
59
86
|
const body = (await res.json().catch(() => null));
|
|
60
87
|
if (!res.ok || !body?.files)
|
|
61
88
|
throw new Error(body?.error ?? `the server answered ${res.status}.`);
|
|
62
89
|
const root = outDir ? resolve(outDir) : join(homedir(), ".claude", "skills", name);
|
|
63
|
-
const files = body.files.map((f) => ({ full: safeJoin(root, f.path), rel: f.path, content: f.content }));
|
|
90
|
+
const files = body.files.map((f) => ({ full: safeJoin(root, f.path), rel: f.path, content: f.content, sha256: f.sha256 }));
|
|
91
|
+
for (const f of files) {
|
|
92
|
+
if (f.sha256 && createHash("sha256").update(f.content, "utf8").digest("hex") !== f.sha256) {
|
|
93
|
+
throw new Error(`${f.rel} did not match its checksum; nothing was written. Run the command again.`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
64
96
|
if (dryRun) {
|
|
65
97
|
console.log(`Would write ${files.length} files to ${root}:`);
|
|
66
98
|
for (const f of files)
|
|
67
99
|
console.log(` ${f.rel}`);
|
|
68
100
|
return;
|
|
69
101
|
}
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
// Keep one previous copy so a bad update can be rolled back.
|
|
103
|
+
const previous = `${root}.previous`;
|
|
104
|
+
if (existsSync(root)) {
|
|
105
|
+
rmSync(previous, { recursive: true, force: true });
|
|
106
|
+
renameSync(root, previous);
|
|
107
|
+
}
|
|
72
108
|
for (const f of files) {
|
|
73
109
|
mkdirSync(dirname(f.full), { recursive: true });
|
|
74
110
|
writeFileSync(f.full, f.content);
|
|
75
111
|
}
|
|
112
|
+
const manifest = { name, installedAt: new Date().toISOString(), source: BASE_URL, files: files.map((f) => ({ path: f.rel, sha256: createHash("sha256").update(f.content, "utf8").digest("hex") })) };
|
|
113
|
+
writeFileSync(join(root, ".zabuti-install.json"), JSON.stringify(manifest, null, 2));
|
|
76
114
|
console.log(`✓ Installed ${name} (${files.length} files) → ${root}`);
|
|
115
|
+
if (existsSync(previous))
|
|
116
|
+
console.log(` Previous copy kept at ${previous}`);
|
|
77
117
|
console.log(" Open Claude Code in your project and ask it to use the skill.");
|
|
78
118
|
}
|
|
119
|
+
/** What is installed, from the manifest written at install time. */
|
|
120
|
+
export async function cmdStatus() {
|
|
121
|
+
const token = storedToken();
|
|
122
|
+
for (const name of SKILL_NAMES) {
|
|
123
|
+
const root = join(homedir(), ".claude", "skills", name);
|
|
124
|
+
let m;
|
|
125
|
+
try {
|
|
126
|
+
m = JSON.parse(readFileSync(join(root, ".zabuti-install.json"), "utf8"));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
console.log(`${name}: ${existsSync(root) ? "installed (no manifest; reinstall to add one)" : "not installed"}`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
console.log(`${name}: installed ${m.installedAt ?? "?"} from ${m.source ?? "?"} (${m.files?.length ?? "?"} files) at ${root}`);
|
|
133
|
+
if (!token) {
|
|
134
|
+
console.log(" Update check skipped (not signed in).");
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const res = await fetch(`${BASE_URL}/api/cli/skills/${encodeURIComponent(name)}?check=1`, { headers: { authorization: `Bearer ${token}` } });
|
|
139
|
+
const body = (await res.json().catch(() => null));
|
|
140
|
+
if (!res.ok || !body?.files) {
|
|
141
|
+
console.log(` Update check skipped (the server answered ${res.status}).`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const have = new Map((m.files ?? []).map((f) => [f.path, f.sha256]));
|
|
145
|
+
const same = body.files.length === have.size && body.files.every((f) => have.get(f.path) === f.sha256);
|
|
146
|
+
console.log(same ? " Up to date." : ` Update available: run \`zabuti-tools add ${name}\` (your current copy is kept as ${name}.previous).`);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
console.log(" Update check skipped (couldn't reach the server).");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zabuti/tools",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Installs the licensed Zabuti developer tools (Logic Map, Logic Optimizer) as Claude Code skills. Needs a license and a download token from zabuti.com.",
|
|
5
|
-
"homepage": "https://zabuti.com",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"bin": {
|
|
9
|
-
"zabuti-tools": "dist/installer/src/index.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"README.md"
|
|
14
|
-
],
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=20"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"claude-code",
|
|
20
|
-
"skills",
|
|
21
|
-
"zabuti"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsc -p tsconfig.json",
|
|
25
|
-
"check": "tsc -p tsconfig.json --noEmit",
|
|
26
|
-
"smoke": "node scripts/smoke.mjs",
|
|
27
|
-
"prepack": "npm run build"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@types/node": "^22.0.0",
|
|
31
|
-
"typescript": "^5.6.0"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@zabuti/tools",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Installs the licensed Zabuti developer tools (Logic Map, Logic Optimizer) as Claude Code skills. Needs a license and a download token from zabuti.com.",
|
|
5
|
+
"homepage": "https://zabuti.com",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"zabuti-tools": "dist/installer/src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"claude-code",
|
|
20
|
+
"skills",
|
|
21
|
+
"zabuti"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
26
|
+
"smoke": "node scripts/smoke.mjs",
|
|
27
|
+
"prepack": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.0.0",
|
|
31
|
+
"typescript": "^5.6.0"
|
|
32
|
+
}
|
|
33
|
+
}
|