tenjin-cli 0.1.0-alpha.1 → 0.1.0-alpha.11
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/NOTICE.md +33 -0
- package/README.md +596 -79
- package/dist/{_esm-ZH2J4QEH.js → _esm-C5CRWCYU.js} +2 -2
- package/dist/_esm-N4KAVXQR.js +881 -0
- package/dist/buy-THMVOPUH.js +44 -0
- package/dist/ccip-RPPPKTJR.js +19 -0
- package/dist/{ccip-UCLT5VOW.js → ccip-ZGGWQN4X.js} +6 -5
- package/dist/chunk-2I4QTOLB.js +11 -0
- package/dist/chunk-2I4QTOLB.js.map +1 -0
- package/dist/chunk-2SDUV6MQ.js +352 -0
- package/dist/chunk-2SDUV6MQ.js.map +1 -0
- package/dist/chunk-3GSZUADW.js +199 -0
- package/dist/chunk-3GSZUADW.js.map +1 -0
- package/dist/{chunk-BRJHUQSY.js → chunk-47PP7TAG.js} +908 -812
- package/dist/chunk-47PP7TAG.js.map +1 -0
- package/dist/chunk-4NTZETIL.js +158 -0
- package/dist/chunk-4NTZETIL.js.map +1 -0
- package/dist/chunk-4TCU3YRD.js +130 -0
- package/dist/chunk-4TCU3YRD.js.map +1 -0
- package/dist/chunk-6BGYHARE.js +14620 -0
- package/dist/chunk-6BGYHARE.js.map +1 -0
- package/dist/chunk-6UY2UQMY.js +213 -0
- package/dist/chunk-6UY2UQMY.js.map +1 -0
- package/dist/{chunk-IPOWB3G3.js → chunk-7FK2UN2T.js} +3515 -507
- package/dist/chunk-7FK2UN2T.js.map +1 -0
- package/dist/chunk-ALUNME53.js +306 -0
- package/dist/chunk-ALUNME53.js.map +1 -0
- package/dist/{chunk-EXBMF5X7.js → chunk-CNUXRXI2.js} +526 -79
- package/dist/chunk-CNUXRXI2.js.map +1 -0
- package/dist/chunk-E6YOODH7.js +913 -0
- package/dist/chunk-E6YOODH7.js.map +1 -0
- package/dist/chunk-EDVI7RRD.js +317 -0
- package/dist/chunk-EDVI7RRD.js.map +1 -0
- package/dist/chunk-FKSAUOJU.js +137 -0
- package/dist/chunk-FKSAUOJU.js.map +1 -0
- package/dist/chunk-GKV6VZSZ.js +125 -0
- package/dist/chunk-GKV6VZSZ.js.map +1 -0
- package/dist/chunk-GUUAYR3K.js +175 -0
- package/dist/chunk-GUUAYR3K.js.map +1 -0
- package/dist/chunk-IAFYUFIC.js +1408 -0
- package/dist/chunk-IAFYUFIC.js.map +1 -0
- package/dist/chunk-IB63U6BM.js +185 -0
- package/dist/chunk-IB63U6BM.js.map +1 -0
- package/dist/chunk-IXTENA2H.js +235 -0
- package/dist/chunk-IXTENA2H.js.map +1 -0
- package/dist/chunk-JTYIX6OD.js +161 -0
- package/dist/chunk-JTYIX6OD.js.map +1 -0
- package/dist/chunk-KYQVEKP5.js +209 -0
- package/dist/chunk-KYQVEKP5.js.map +1 -0
- package/dist/chunk-KZAAWQNP.js +6199 -0
- package/dist/chunk-KZAAWQNP.js.map +1 -0
- package/dist/{chunk-T4LKNY7T.js → chunk-M2O56UK7.js} +225 -70
- package/dist/chunk-M2O56UK7.js.map +1 -0
- package/dist/chunk-MJZZTKCC.js +323 -0
- package/dist/chunk-MJZZTKCC.js.map +1 -0
- package/dist/chunk-NUF2PKJO.js +207 -0
- package/dist/chunk-NUF2PKJO.js.map +1 -0
- package/dist/chunk-O25VWJCG.js +1357 -0
- package/dist/chunk-O25VWJCG.js.map +1 -0
- package/dist/chunk-OCN27NJV.js +612 -0
- package/dist/chunk-OCN27NJV.js.map +1 -0
- package/dist/chunk-OZHJ3FLR.js +105 -0
- package/dist/chunk-OZHJ3FLR.js.map +1 -0
- package/dist/chunk-P74I3WH4.js +204 -0
- package/dist/chunk-P74I3WH4.js.map +1 -0
- package/dist/chunk-POJRB2AE.js +83 -0
- package/dist/chunk-POJRB2AE.js.map +1 -0
- package/dist/{chunk-YG2DO46P.js → chunk-PZRAAAY2.js} +107 -22
- package/dist/chunk-PZRAAAY2.js.map +1 -0
- package/dist/chunk-PZSUWDF2.js +35 -0
- package/dist/chunk-PZSUWDF2.js.map +1 -0
- package/dist/chunk-QW2Q2KAH.js +27 -0
- package/dist/chunk-QW2Q2KAH.js.map +1 -0
- package/dist/{chunk-CUWUHTIL.js → chunk-RBJPAZFI.js} +16 -202
- package/dist/chunk-RBJPAZFI.js.map +1 -0
- package/dist/chunk-RSBN67PA.js +152 -0
- package/dist/chunk-RSBN67PA.js.map +1 -0
- package/dist/chunk-S5RYMCV6.js +70 -0
- package/dist/chunk-S5RYMCV6.js.map +1 -0
- package/dist/chunk-SFGXAZ3M.js +316 -0
- package/dist/chunk-SFGXAZ3M.js.map +1 -0
- package/dist/chunk-SGK2B724.js +67 -0
- package/dist/chunk-SGK2B724.js.map +1 -0
- package/dist/chunk-TDDN5GXR.js +145 -0
- package/dist/chunk-TDDN5GXR.js.map +1 -0
- package/dist/{chunk-LPRVHM7P.js → chunk-U5S527PP.js} +1655 -114
- package/dist/chunk-U5S527PP.js.map +1 -0
- package/dist/chunk-UFPJBS4C.js +242 -0
- package/dist/chunk-UFPJBS4C.js.map +1 -0
- package/dist/chunk-UHTVXQ2O.js +140 -0
- package/dist/chunk-UHTVXQ2O.js.map +1 -0
- package/dist/chunk-UY6CGULW.js +83 -0
- package/dist/chunk-UY6CGULW.js.map +1 -0
- package/dist/chunk-VWY3U732.js +674 -0
- package/dist/chunk-VWY3U732.js.map +1 -0
- package/dist/{chunk-Q53IYV2G.js → chunk-W6R3HAAG.js} +20 -17
- package/dist/{chunk-Q53IYV2G.js.map → chunk-W6R3HAAG.js.map} +1 -1
- package/dist/chunk-XJN5WUKL.js +204 -0
- package/dist/chunk-XJN5WUKL.js.map +1 -0
- package/dist/chunk-XWHXX2BI.js +149 -0
- package/dist/chunk-XWHXX2BI.js.map +1 -0
- package/dist/{chunk-DXPYFVKG.js → chunk-Y7ERTA7D.js} +35 -15
- package/dist/chunk-Y7ERTA7D.js.map +1 -0
- package/dist/chunk-YLYINX2H.js +7806 -0
- package/dist/chunk-YLYINX2H.js.map +1 -0
- package/dist/chunk-ZE7KOO7A.js +233 -0
- package/dist/chunk-ZE7KOO7A.js.map +1 -0
- package/dist/chunk-ZQIQ55KK.js +51 -0
- package/dist/chunk-ZQIQ55KK.js.map +1 -0
- package/dist/{chunk-3IMLRUZE.js → chunk-ZXTAQYNA.js} +6 -2
- package/dist/{cli-WA65NP4Y.js → cli-Y2HBOSGK.js} +437 -175
- package/dist/cli-Y2HBOSGK.js.map +1 -0
- package/dist/config-WDGMZKHU.js +26 -0
- package/dist/config-WDGMZKHU.js.map +1 -0
- package/dist/dist-U4M6QCKE.js +2842 -0
- package/dist/dist-U4M6QCKE.js.map +1 -0
- package/dist/doctor-CSIWKWM2.js +27 -0
- package/dist/doctor-CSIWKWM2.js.map +1 -0
- package/dist/edit-E7N6F3OY.js +38 -0
- package/dist/edit-E7N6F3OY.js.map +1 -0
- package/dist/ethersCompat-Df4a6QIZ-WHYKB6HA.js +18 -0
- package/dist/ethersCompat-Df4a6QIZ-WHYKB6HA.js.map +1 -0
- package/dist/fund-OKK627GL.js +38 -0
- package/dist/fund-OKK627GL.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/inspect-573WHEV4.js +35 -0
- package/dist/inspect-573WHEV4.js.map +1 -0
- package/dist/install-SQAYMNQC.js +1134 -0
- package/dist/install-SQAYMNQC.js.map +1 -0
- package/dist/{mine.wasm-GQECMSGN.js → mine.wasm-6PIT3DK6.js} +2 -2
- package/dist/outcome-W3KYGF23.js +22 -0
- package/dist/outcome-W3KYGF23.js.map +1 -0
- package/dist/publish-N5U4XYVA.js +40 -0
- package/dist/publish-N5U4XYVA.js.map +1 -0
- package/dist/read-PJ7Z6UGF.js +158 -0
- package/dist/read-PJ7Z6UGF.js.map +1 -0
- package/dist/run-FSO3MMXN.js +16883 -0
- package/dist/run-FSO3MMXN.js.map +1 -0
- package/dist/search-ZWOP4EGK.js +23 -0
- package/dist/search-ZWOP4EGK.js.map +1 -0
- package/dist/{secp256k1-BEZS642W.js → secp256k1-XRPVBC6V.js} +5 -4
- package/dist/secp256k1-XRPVBC6V.js.map +1 -0
- package/dist/send-F34ZDXDZ.js +223 -0
- package/dist/send-F34ZDXDZ.js.map +1 -0
- package/dist/session-4N4ZT3AH.js +88 -0
- package/dist/session-4N4ZT3AH.js.map +1 -0
- package/dist/skill-heal-XBEK272G.js +85 -0
- package/dist/skill-heal-XBEK272G.js.map +1 -0
- package/dist/uninstall-BTKPHPDL.js +68 -0
- package/dist/uninstall-BTKPHPDL.js.map +1 -0
- package/dist/usdc-4VCDHFWX.js +38 -0
- package/dist/usdc-4VCDHFWX.js.map +1 -0
- package/dist/viemAdapter-By13KInL-TUQJBMHM.js +14 -0
- package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +1 -0
- package/dist/wallet-UL4P2JRO.js +42 -0
- package/dist/wallet-UL4P2JRO.js.map +1 -0
- package/dist/wallet-WJ6UP5OU.js +32 -0
- package/dist/wallet-WJ6UP5OU.js.map +1 -0
- package/docs/agent-permissions.md +294 -0
- package/package.json +25 -18
- package/skills/tenjin/SKILL.md +364 -0
- package/skills/tenjin-publish/SKILL.md +232 -0
- package/skills/tenjin-search/SKILL.md +341 -0
- package/dist/chunk-BRJHUQSY.js.map +0 -1
- package/dist/chunk-CUWUHTIL.js.map +0 -1
- package/dist/chunk-DXPYFVKG.js.map +0 -1
- package/dist/chunk-EXBMF5X7.js.map +0 -1
- package/dist/chunk-EZROUI5U.js +0 -135
- package/dist/chunk-EZROUI5U.js.map +0 -1
- package/dist/chunk-IPOWB3G3.js.map +0 -1
- package/dist/chunk-LPRVHM7P.js.map +0 -1
- package/dist/chunk-T4LKNY7T.js.map +0 -1
- package/dist/chunk-YBMMV4Y4.js +0 -51
- package/dist/chunk-YBMMV4Y4.js.map +0 -1
- package/dist/chunk-YG2DO46P.js.map +0 -1
- package/dist/chunk-ZPZFPVDN.js +0 -67
- package/dist/chunk-ZPZFPVDN.js.map +0 -1
- package/dist/cli-WA65NP4Y.js.map +0 -1
- package/dist/config-CEFTL5ZL.js +0 -164
- package/dist/config-CEFTL5ZL.js.map +0 -1
- package/dist/doctor-3QBYN46N.js +0 -338
- package/dist/doctor-3QBYN46N.js.map +0 -1
- package/dist/usdc-44R6XZF2.js +0 -18
- package/dist/wallet-ELBTBMXO.js +0 -20
- package/dist/wallet-XD576HF3.js +0 -173
- package/dist/wallet-XD576HF3.js.map +0 -1
- /package/dist/{_esm-ZH2J4QEH.js.map → _esm-C5CRWCYU.js.map} +0 -0
- /package/dist/{ccip-UCLT5VOW.js.map → _esm-N4KAVXQR.js.map} +0 -0
- /package/dist/{chunk-3IMLRUZE.js.map → buy-THMVOPUH.js.map} +0 -0
- /package/dist/{secp256k1-BEZS642W.js.map → ccip-RPPPKTJR.js.map} +0 -0
- /package/dist/{usdc-44R6XZF2.js.map → ccip-ZGGWQN4X.js.map} +0 -0
- /package/dist/{wallet-ELBTBMXO.js.map → chunk-ZXTAQYNA.js.map} +0 -0
- /package/dist/{mine.wasm-GQECMSGN.js.map → mine.wasm-6PIT3DK6.js.map} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./chunk-PZRAAAY2.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/url.ts
|
|
7
|
+
function trimSlash(url) {
|
|
8
|
+
return url.replace(/\/+$/, "");
|
|
9
|
+
}
|
|
10
|
+
function tryOriginOf(url) {
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = new URL(url);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
|
|
18
|
+
return parsed.origin;
|
|
19
|
+
}
|
|
20
|
+
function originOf(url) {
|
|
21
|
+
const origin = tryOriginOf(url);
|
|
22
|
+
if (origin === null) {
|
|
23
|
+
throw new CliError("USAGE", `Invalid base URL: ${JSON.stringify(url)}`, {
|
|
24
|
+
fix: "Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`."
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return origin;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
trimSlash,
|
|
32
|
+
tryOriginOf,
|
|
33
|
+
originOf
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-PZSUWDF2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/url.ts"],"sourcesContent":["import { CliError } from './errors';\n\n/** Drop trailing slashes from a base URL so `${base}/path` never doubles a slash. */\nexport function trimSlash(url: string): string {\n return url.replace(/\\/+$/, '');\n}\n\n/**\n * The `scheme://host[:port]` of an http(s) URL, or null if it is not one.\n *\n * Non-http schemes are rejected rather than passed through, and that is the whole\n * reason this is not a one-line `new URL(url).origin`: for any non-special\n * scheme the WHATWG origin is the opaque string `\"null\"`, so `foo://tenjin.blog`\n * and `bar://evil.example` compare EQUAL. This value binds a wallet-derived\n * credential to one deployment, so an equal-comparing sentinel is exactly the\n * failure it exists to prevent — the same shape as the unparseable case, just\n * spelled differently.\n */\nexport function tryOriginOf(url: string): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;\n return parsed.origin;\n}\n\n/**\n * `tryOriginOf` for callers that cannot proceed without an origin. Throws USAGE\n * rather than returning a sentinel; anything that must survive a bad base URL\n * (diagnostics, above all) uses `tryOriginOf` and handles the null.\n */\nexport function originOf(url: string): string {\n const origin = tryOriginOf(url);\n if (origin === null) {\n throw new CliError('USAGE', `Invalid base URL: ${JSON.stringify(url)}`, {\n fix: 'Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`.',\n });\n }\n return origin;\n}\n"],"mappings":";;;;;;AAGO,SAAS,UAAU,KAAqB;AAC7C,SAAO,IAAI,QAAQ,QAAQ,EAAE;AAC/B;AAaO,SAAS,YAAY,KAA4B;AACtD,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,aAAa,WAAW,OAAO,aAAa,SAAU,QAAO;AACxE,SAAO,OAAO;AAChB;AAOO,SAAS,SAAS,KAAqB;AAC5C,QAAM,SAAS,YAAY,GAAG;AAC9B,MAAI,WAAW,MAAM;AACnB,UAAM,IAAI,SAAS,SAAS,qBAAqB,KAAK,UAAU,GAAG,CAAC,IAAI;AAAA,MACtE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/prompt.ts
|
|
4
|
+
import { createInterface } from "readline";
|
|
5
|
+
function promptYesNo(prompt, opts = {}) {
|
|
6
|
+
const { defaultYes = false, input = process.stdin, output = process.stderr } = opts;
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const rl = createInterface({ input, output });
|
|
9
|
+
let settled = false;
|
|
10
|
+
const settle = (value) => {
|
|
11
|
+
if (settled) return;
|
|
12
|
+
settled = true;
|
|
13
|
+
rl.close();
|
|
14
|
+
resolve(value);
|
|
15
|
+
};
|
|
16
|
+
rl.once("close", () => settle(false));
|
|
17
|
+
rl.question(prompt, (answer) => {
|
|
18
|
+
const a = answer.trim().toLowerCase();
|
|
19
|
+
settle(a === "" ? defaultYes : a === "y" || a === "yes");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
promptYesNo
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-QW2Q2KAH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/prompt.ts"],"sourcesContent":["import { createInterface } from 'node:readline';\n\nexport interface PromptYesNoOptions {\n /** What an EMPTY answer means; the closing of stdin (ctrl-D) is always false. */\n defaultYes?: boolean;\n /** Injectable streams for tests; label/echo go to stderr, never stdout. */\n input?: NodeJS.ReadableStream;\n output?: NodeJS.WritableStream;\n}\n\n/**\n * The one y/n reader every confirm gate shares (buy, send, install). \"y\"/\"yes\"\n * (any case) is true, an empty answer follows `defaultYes` (explicit at each\n * call site), anything else is false, and stdin closing mid-prompt resolves\n * false rather than hanging. The prompt writes to stderr so stdout stays a\n * single JSON envelope.\n */\nexport function promptYesNo(prompt: string, opts: PromptYesNoOptions = {}): Promise<boolean> {\n const { defaultYes = false, input = process.stdin, output = process.stderr } = opts;\n return new Promise((resolve) => {\n const rl = createInterface({ input, output });\n let settled = false;\n const settle = (value: boolean): void => {\n if (settled) return;\n settled = true;\n rl.close();\n resolve(value);\n };\n rl.once('close', () => settle(false));\n rl.question(prompt, (answer) => {\n const a = answer.trim().toLowerCase();\n settle(a === '' ? defaultYes : a === 'y' || a === 'yes');\n });\n });\n}\n"],"mappings":";;;AAAA,SAAS,uBAAuB;AAiBzB,SAAS,YAAY,QAAgB,OAA2B,CAAC,GAAqB;AAC3F,QAAM,EAAE,aAAa,OAAO,QAAQ,QAAQ,OAAO,SAAS,QAAQ,OAAO,IAAI;AAC/E,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAK,gBAAgB,EAAE,OAAO,OAAO,CAAC;AAC5C,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,UAAyB;AACvC,UAAI,QAAS;AACb,gBAAU;AACV,SAAG,MAAM;AACT,cAAQ,KAAK;AAAA,IACf;AACA,OAAG,KAAK,SAAS,MAAM,OAAO,KAAK,CAAC;AACpC,OAAG,SAAS,QAAQ,CAAC,WAAW;AAC9B,YAAM,IAAI,OAAO,KAAK,EAAE,YAAY;AACpC,aAAO,MAAM,KAAK,aAAa,MAAM,OAAO,MAAM,KAAK;AAAA,IACzD,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
|
@@ -1,149 +1,13 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
4
|
-
import * as nc from "crypto";
|
|
5
|
-
var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
6
|
-
|
|
7
|
-
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
8
|
-
function isBytes(a) {
|
|
9
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
10
|
-
}
|
|
11
|
-
function anumber(n) {
|
|
12
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
13
|
-
throw new Error("positive integer expected, got " + n);
|
|
14
|
-
}
|
|
15
|
-
function abytes(b, ...lengths) {
|
|
16
|
-
if (!isBytes(b))
|
|
17
|
-
throw new Error("Uint8Array expected");
|
|
18
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
19
|
-
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
20
|
-
}
|
|
21
|
-
function ahash(h) {
|
|
22
|
-
if (typeof h !== "function" || typeof h.create !== "function")
|
|
23
|
-
throw new Error("Hash should be wrapped by utils.createHasher");
|
|
24
|
-
anumber(h.outputLen);
|
|
25
|
-
anumber(h.blockLen);
|
|
26
|
-
}
|
|
27
|
-
function aexists(instance, checkFinished = true) {
|
|
28
|
-
if (instance.destroyed)
|
|
29
|
-
throw new Error("Hash instance has been destroyed");
|
|
30
|
-
if (checkFinished && instance.finished)
|
|
31
|
-
throw new Error("Hash#digest() has already been called");
|
|
32
|
-
}
|
|
33
|
-
function aoutput(out, instance) {
|
|
34
|
-
abytes(out);
|
|
35
|
-
const min = instance.outputLen;
|
|
36
|
-
if (out.length < min) {
|
|
37
|
-
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function u32(arr) {
|
|
41
|
-
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
42
|
-
}
|
|
43
|
-
function clean(...arrays) {
|
|
44
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
45
|
-
arrays[i].fill(0);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function createView(arr) {
|
|
49
|
-
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
50
|
-
}
|
|
51
|
-
function rotr(word, shift) {
|
|
52
|
-
return word << 32 - shift | word >>> shift;
|
|
53
|
-
}
|
|
54
|
-
function rotl(word, shift) {
|
|
55
|
-
return word << shift | word >>> 32 - shift >>> 0;
|
|
56
|
-
}
|
|
57
|
-
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
58
|
-
function byteSwap(word) {
|
|
59
|
-
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
60
|
-
}
|
|
61
|
-
function byteSwap32(arr) {
|
|
62
|
-
for (let i = 0; i < arr.length; i++) {
|
|
63
|
-
arr[i] = byteSwap(arr[i]);
|
|
64
|
-
}
|
|
65
|
-
return arr;
|
|
66
|
-
}
|
|
67
|
-
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
68
|
-
var nextTick = async () => {
|
|
69
|
-
};
|
|
70
|
-
async function asyncLoop(iters, tick, cb) {
|
|
71
|
-
let ts = Date.now();
|
|
72
|
-
for (let i = 0; i < iters; i++) {
|
|
73
|
-
cb(i);
|
|
74
|
-
const diff = Date.now() - ts;
|
|
75
|
-
if (diff >= 0 && diff < tick)
|
|
76
|
-
continue;
|
|
77
|
-
await nextTick();
|
|
78
|
-
ts += diff;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function utf8ToBytes(str) {
|
|
82
|
-
if (typeof str !== "string")
|
|
83
|
-
throw new Error("string expected");
|
|
84
|
-
return new Uint8Array(new TextEncoder().encode(str));
|
|
85
|
-
}
|
|
86
|
-
function toBytes(data) {
|
|
87
|
-
if (typeof data === "string")
|
|
88
|
-
data = utf8ToBytes(data);
|
|
89
|
-
abytes(data);
|
|
90
|
-
return data;
|
|
91
|
-
}
|
|
92
|
-
function kdfInputToBytes(data) {
|
|
93
|
-
if (typeof data === "string")
|
|
94
|
-
data = utf8ToBytes(data);
|
|
95
|
-
abytes(data);
|
|
96
|
-
return data;
|
|
97
|
-
}
|
|
98
|
-
function concatBytes(...arrays) {
|
|
99
|
-
let sum = 0;
|
|
100
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
101
|
-
const a = arrays[i];
|
|
102
|
-
abytes(a);
|
|
103
|
-
sum += a.length;
|
|
104
|
-
}
|
|
105
|
-
const res = new Uint8Array(sum);
|
|
106
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
107
|
-
const a = arrays[i];
|
|
108
|
-
res.set(a, pad);
|
|
109
|
-
pad += a.length;
|
|
110
|
-
}
|
|
111
|
-
return res;
|
|
112
|
-
}
|
|
113
|
-
function checkOpts(defaults, opts) {
|
|
114
|
-
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
|
|
115
|
-
throw new Error("options should be object or undefined");
|
|
116
|
-
const merged = Object.assign(defaults, opts);
|
|
117
|
-
return merged;
|
|
118
|
-
}
|
|
119
|
-
var Hash = class {
|
|
120
|
-
};
|
|
121
|
-
function createHasher(hashCons) {
|
|
122
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
123
|
-
const tmp = hashCons();
|
|
124
|
-
hashC.outputLen = tmp.outputLen;
|
|
125
|
-
hashC.blockLen = tmp.blockLen;
|
|
126
|
-
hashC.create = () => hashCons();
|
|
127
|
-
return hashC;
|
|
128
|
-
}
|
|
129
|
-
function randomBytes(bytesLength = 32) {
|
|
130
|
-
if (crypto && typeof crypto.getRandomValues === "function") {
|
|
131
|
-
return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
132
|
-
}
|
|
133
|
-
if (crypto && typeof crypto.randomBytes === "function") {
|
|
134
|
-
return Uint8Array.from(crypto.randomBytes(bytesLength));
|
|
135
|
-
}
|
|
136
|
-
throw new Error("crypto.getRandomValues must be defined");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
3
|
// node_modules/.pnpm/@noble+curves@1.9.1/node_modules/@noble/curves/esm/abstract/utils.js
|
|
140
4
|
var _0n = /* @__PURE__ */ BigInt(0);
|
|
141
5
|
var _1n = /* @__PURE__ */ BigInt(1);
|
|
142
|
-
function
|
|
6
|
+
function isBytes(a) {
|
|
143
7
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
144
8
|
}
|
|
145
|
-
function
|
|
146
|
-
if (!
|
|
9
|
+
function abytes(item) {
|
|
10
|
+
if (!isBytes(item))
|
|
147
11
|
throw new Error("Uint8Array expected");
|
|
148
12
|
}
|
|
149
13
|
function abool(title, value) {
|
|
@@ -165,7 +29,7 @@ var hasHexBuiltin = (
|
|
|
165
29
|
);
|
|
166
30
|
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
167
31
|
function bytesToHex(bytes) {
|
|
168
|
-
|
|
32
|
+
abytes(bytes);
|
|
169
33
|
if (hasHexBuiltin)
|
|
170
34
|
return bytes.toHex();
|
|
171
35
|
let hex = "";
|
|
@@ -209,7 +73,7 @@ function bytesToNumberBE(bytes) {
|
|
|
209
73
|
return hexToNumber(bytesToHex(bytes));
|
|
210
74
|
}
|
|
211
75
|
function bytesToNumberLE(bytes) {
|
|
212
|
-
|
|
76
|
+
abytes(bytes);
|
|
213
77
|
return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
|
|
214
78
|
}
|
|
215
79
|
function numberToBytesBE(n, len) {
|
|
@@ -226,7 +90,7 @@ function ensureBytes(title, hex, expectedLength) {
|
|
|
226
90
|
} catch (e) {
|
|
227
91
|
throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
|
|
228
92
|
}
|
|
229
|
-
} else if (
|
|
93
|
+
} else if (isBytes(hex)) {
|
|
230
94
|
res = Uint8Array.from(hex);
|
|
231
95
|
} else {
|
|
232
96
|
throw new Error(title + " must be hex string or Uint8Array");
|
|
@@ -236,11 +100,11 @@ function ensureBytes(title, hex, expectedLength) {
|
|
|
236
100
|
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
|
237
101
|
return res;
|
|
238
102
|
}
|
|
239
|
-
function
|
|
103
|
+
function concatBytes(...arrays) {
|
|
240
104
|
let sum = 0;
|
|
241
105
|
for (let i = 0; i < arrays.length; i++) {
|
|
242
106
|
const a = arrays[i];
|
|
243
|
-
|
|
107
|
+
abytes(a);
|
|
244
108
|
sum += a.length;
|
|
245
109
|
}
|
|
246
110
|
const res = new Uint8Array(sum);
|
|
@@ -259,7 +123,7 @@ function equalBytes(a, b) {
|
|
|
259
123
|
diff |= a[i] ^ b[i];
|
|
260
124
|
return diff === 0;
|
|
261
125
|
}
|
|
262
|
-
function
|
|
126
|
+
function utf8ToBytes(str) {
|
|
263
127
|
if (typeof str !== "string")
|
|
264
128
|
throw new Error("string expected");
|
|
265
129
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
@@ -316,7 +180,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
316
180
|
out.push(sl);
|
|
317
181
|
len += v.length;
|
|
318
182
|
}
|
|
319
|
-
return
|
|
183
|
+
return concatBytes(...out);
|
|
320
184
|
};
|
|
321
185
|
const genUntil = (seed, pred) => {
|
|
322
186
|
reset();
|
|
@@ -334,7 +198,7 @@ var validatorFns = {
|
|
|
334
198
|
function: (val) => typeof val === "function",
|
|
335
199
|
boolean: (val) => typeof val === "boolean",
|
|
336
200
|
string: (val) => typeof val === "string",
|
|
337
|
-
stringOrUint8Array: (val) => typeof val === "string" ||
|
|
201
|
+
stringOrUint8Array: (val) => typeof val === "string" || isBytes(val),
|
|
338
202
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
339
203
|
array: (val) => Array.isArray(val),
|
|
340
204
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -370,51 +234,9 @@ function memoized(fn) {
|
|
|
370
234
|
};
|
|
371
235
|
}
|
|
372
236
|
|
|
373
|
-
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
374
|
-
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
375
|
-
var _32n = /* @__PURE__ */ BigInt(32);
|
|
376
|
-
function fromBig(n, le = false) {
|
|
377
|
-
if (le)
|
|
378
|
-
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
379
|
-
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
380
|
-
}
|
|
381
|
-
function split(lst, le = false) {
|
|
382
|
-
const len = lst.length;
|
|
383
|
-
let Ah = new Uint32Array(len);
|
|
384
|
-
let Al = new Uint32Array(len);
|
|
385
|
-
for (let i = 0; i < len; i++) {
|
|
386
|
-
const { h, l } = fromBig(lst[i], le);
|
|
387
|
-
[Ah[i], Al[i]] = [h, l];
|
|
388
|
-
}
|
|
389
|
-
return [Ah, Al];
|
|
390
|
-
}
|
|
391
|
-
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
392
|
-
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
393
|
-
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
394
|
-
var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
395
|
-
|
|
396
237
|
export {
|
|
397
|
-
|
|
238
|
+
isBytes,
|
|
398
239
|
abytes,
|
|
399
|
-
ahash,
|
|
400
|
-
aexists,
|
|
401
|
-
aoutput,
|
|
402
|
-
u32,
|
|
403
|
-
clean,
|
|
404
|
-
createView,
|
|
405
|
-
rotr,
|
|
406
|
-
rotl,
|
|
407
|
-
swap32IfBE,
|
|
408
|
-
asyncLoop,
|
|
409
|
-
toBytes,
|
|
410
|
-
kdfInputToBytes,
|
|
411
|
-
concatBytes,
|
|
412
|
-
checkOpts,
|
|
413
|
-
Hash,
|
|
414
|
-
createHasher,
|
|
415
|
-
randomBytes,
|
|
416
|
-
isBytes2 as isBytes,
|
|
417
|
-
abytes2,
|
|
418
240
|
abool,
|
|
419
241
|
numberToHexUnpadded,
|
|
420
242
|
bytesToHex,
|
|
@@ -424,28 +246,20 @@ export {
|
|
|
424
246
|
numberToBytesBE,
|
|
425
247
|
numberToBytesLE,
|
|
426
248
|
ensureBytes,
|
|
427
|
-
|
|
249
|
+
concatBytes,
|
|
428
250
|
equalBytes,
|
|
429
|
-
|
|
251
|
+
utf8ToBytes,
|
|
430
252
|
inRange,
|
|
431
253
|
aInRange,
|
|
432
254
|
bitLen,
|
|
433
255
|
bitMask,
|
|
434
256
|
createHmacDrbg,
|
|
435
257
|
validateObject,
|
|
436
|
-
memoized
|
|
437
|
-
split,
|
|
438
|
-
rotlSH,
|
|
439
|
-
rotlSL,
|
|
440
|
-
rotlBH,
|
|
441
|
-
rotlBL
|
|
258
|
+
memoized
|
|
442
259
|
};
|
|
443
260
|
/*! Bundled license information:
|
|
444
261
|
|
|
445
|
-
@noble/hashes/esm/utils.js:
|
|
446
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
447
|
-
|
|
448
262
|
@noble/curves/esm/abstract/utils.js:
|
|
449
263
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
450
264
|
*/
|
|
451
|
-
//# sourceMappingURL=chunk-
|
|
265
|
+
//# sourceMappingURL=chunk-RBJPAZFI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/.pnpm/@noble+curves@1.9.1/node_modules/@noble/curves/src/abstract/utils.ts"],"sourcesContent":["/**\n * Hex, bytes and number utilities.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// 100 lines of code in the file are duplicated from noble-hashes (utils).\n// This is OK: `abstract` directory does not use noble-hashes.\n// User may opt-in into using different hashing library. This way, noble-hashes\n// won't be included into their bundle.\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nexport type Hex = Uint8Array | string; // hex strings are accepted for simplicity\nexport type PrivKey = Hex | bigint; // bigints are accepted to ease learning curve\nexport type CHash = {\n (message: Uint8Array | string): Uint8Array;\n blockLen: number;\n outputLen: number;\n create(opts?: { dkLen?: number }): any; // For shake\n};\nexport type FHash = (message: Uint8Array | string) => Uint8Array;\n\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\nexport function abytes(item: unknown): void {\n if (!isBytes(item)) throw new Error('Uint8Array expected');\n}\n\nexport function abool(title: string, value: boolean): void {\n if (typeof value !== 'boolean') throw new Error(title + ' boolean expected, got ' + value);\n}\n\n// Used in weierstrass, der\nexport function numberToHexUnpadded(num: number | bigint): string {\n const hex = num.toString(16);\n return hex.length & 1 ? '0' + hex : hex;\n}\n\nexport function hexToNumber(hex: string): bigint {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian\n}\n\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin: boolean =\n // @ts-ignore\n typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function';\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin) return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin) return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n// BE: Big Endian, LE: Little Endian\nexport function bytesToNumberBE(bytes: Uint8Array): bigint {\n return hexToNumber(bytesToHex(bytes));\n}\nexport function bytesToNumberLE(bytes: Uint8Array): bigint {\n abytes(bytes);\n return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));\n}\n\nexport function numberToBytesBE(n: number | bigint, len: number): Uint8Array {\n return hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\nexport function numberToBytesLE(n: number | bigint, len: number): Uint8Array {\n return numberToBytesBE(n, len).reverse();\n}\n// Unpadded, rarely used\nexport function numberToVarBytesBE(n: number | bigint): Uint8Array {\n return hexToBytes(numberToHexUnpadded(n));\n}\n\n/**\n * Takes hex string or Uint8Array, converts to Uint8Array.\n * Validates output length.\n * Will throw error for other types.\n * @param title descriptive title for an error e.g. 'private key'\n * @param hex hex string or Uint8Array\n * @param expectedLength optional, will compare to result array's length\n * @returns\n */\nexport function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array {\n let res: Uint8Array;\n if (typeof hex === 'string') {\n try {\n res = hexToBytes(hex);\n } catch (e) {\n throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);\n }\n } else if (isBytes(hex)) {\n // Uint8Array.from() instead of hash.slice() because node.js Buffer\n // is instance of Uint8Array, and its slice() creates **mutable** copy\n res = Uint8Array.from(hex);\n } else {\n throw new Error(title + ' must be hex string or Uint8Array');\n }\n const len = res.length;\n if (typeof expectedLength === 'number' && len !== expectedLength)\n throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);\n return res;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n// Compares 2 u8a-s in kinda constant time\nexport function equalBytes(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];\n return diff === 0;\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n// Is positive bigint\nconst isPosBig = (n: bigint) => typeof n === 'bigint' && _0n <= n;\n\nexport function inRange(n: bigint, min: bigint, max: bigint): boolean {\n return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;\n}\n\n/**\n * Asserts min <= n < max. NOTE: It's < max and not <= max.\n * @example\n * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)\n */\nexport function aInRange(title: string, n: bigint, min: bigint, max: bigint): void {\n // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?\n // consider P=256n, min=0n, max=P\n // - a for min=0 would require -1: `inRange('x', x, -1n, P)`\n // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`\n // - our way is the cleanest: `inRange('x', x, 0n, P)\n if (!inRange(n, min, max))\n throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);\n}\n\n// Bit operations\n\n/**\n * Calculates amount of bits in a bigint.\n * Same as `n.toString(2).length`\n * TODO: merge with nLength in modular\n */\nexport function bitLen(n: bigint): number {\n let len;\n for (len = 0; n > _0n; n >>= _1n, len += 1);\n return len;\n}\n\n/**\n * Gets single bit at position.\n * NOTE: first bit position is 0 (same as arrays)\n * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`\n */\nexport function bitGet(n: bigint, pos: number): bigint {\n return (n >> BigInt(pos)) & _1n;\n}\n\n/**\n * Sets single bit at position.\n */\nexport function bitSet(n: bigint, pos: number, value: boolean): bigint {\n return n | ((value ? _1n : _0n) << BigInt(pos));\n}\n\n/**\n * Calculate mask for N bits. Not using ** operator with bigints because of old engines.\n * Same as BigInt(`0b${Array(i).fill('1').join('')}`)\n */\nexport const bitMask = (n: number): bigint => (_1n << BigInt(n)) - _1n;\n\n// DRBG\n\nconst u8n = (len: number) => new Uint8Array(len); // creates Uint8Array\nconst u8fr = (arr: ArrayLike<number>) => Uint8Array.from(arr); // another shortcut\ntype Pred<T> = (v: Uint8Array) => T | undefined;\n/**\n * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n * @returns function that will call DRBG until 2nd arg returns something meaningful\n * @example\n * const drbg = createHmacDRBG<Key>(32, 32, hmac);\n * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined\n */\nexport function createHmacDrbg<T>(\n hashLen: number,\n qByteLen: number,\n hmacFn: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array\n): (seed: Uint8Array, predicate: Pred<T>) => T {\n if (typeof hashLen !== 'number' || hashLen < 2) throw new Error('hashLen must be a number');\n if (typeof qByteLen !== 'number' || qByteLen < 2) throw new Error('qByteLen must be a number');\n if (typeof hmacFn !== 'function') throw new Error('hmacFn must be a function');\n // Step B, Step C: set hashLen to 8*ceil(hlen/8)\n let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same\n let i = 0; // Iterations counter, will throw when over 1000\n const reset = () => {\n v.fill(1);\n k.fill(0);\n i = 0;\n };\n const h = (...b: Uint8Array[]) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)\n const reseed = (seed = u8n(0)) => {\n // HMAC-DRBG reseed() function. Steps D-G\n k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed)\n v = h(); // v = hmac(k || v)\n if (seed.length === 0) return;\n k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed)\n v = h(); // v = hmac(k || v)\n };\n const gen = () => {\n // HMAC-DRBG generate() function\n if (i++ >= 1000) throw new Error('drbg: tried 1000 values');\n let len = 0;\n const out: Uint8Array[] = [];\n while (len < qByteLen) {\n v = h();\n const sl = v.slice();\n out.push(sl);\n len += v.length;\n }\n return concatBytes(...out);\n };\n const genUntil = (seed: Uint8Array, pred: Pred<T>): T => {\n reset();\n reseed(seed); // Steps D-G\n let res: T | undefined = undefined; // Step H: grind until k is in [1..n-1]\n while (!(res = pred(gen()))) reseed();\n reset();\n return res;\n };\n return genUntil;\n}\n\n// Validating curves and fields\n\nconst validatorFns = {\n bigint: (val: any): boolean => typeof val === 'bigint',\n function: (val: any): boolean => typeof val === 'function',\n boolean: (val: any): boolean => typeof val === 'boolean',\n string: (val: any): boolean => typeof val === 'string',\n stringOrUint8Array: (val: any): boolean => typeof val === 'string' || isBytes(val),\n isSafeInteger: (val: any): boolean => Number.isSafeInteger(val),\n array: (val: any): boolean => Array.isArray(val),\n field: (val: any, object: any): any => (object as any).Fp.isValid(val),\n hash: (val: any): boolean => typeof val === 'function' && Number.isSafeInteger(val.outputLen),\n} as const;\ntype Validator = keyof typeof validatorFns;\ntype ValMap<T extends Record<string, any>> = { [K in keyof T]?: Validator };\n// type Record<K extends string | number | symbol, T> = { [P in K]: T; }\n\nexport function validateObject<T extends Record<string, any>>(\n object: T,\n validators: ValMap<T>,\n optValidators: ValMap<T> = {}\n): T {\n const checkField = (fieldName: keyof T, type: Validator, isOptional: boolean) => {\n const checkVal = validatorFns[type];\n if (typeof checkVal !== 'function') throw new Error('invalid validator function');\n\n const val = object[fieldName as keyof typeof object];\n if (isOptional && val === undefined) return;\n if (!checkVal(val, object)) {\n throw new Error(\n 'param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val\n );\n }\n };\n for (const [fieldName, type] of Object.entries(validators)) checkField(fieldName, type!, false);\n for (const [fieldName, type] of Object.entries(optValidators)) checkField(fieldName, type!, true);\n return object;\n}\n// validate type tests\n// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };\n// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!\n// // Should fail type-check\n// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });\n// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });\n// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });\n// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });\n\n/**\n * throws not implemented error\n */\nexport const notImplemented = (): never => {\n throw new Error('not implemented');\n};\n\n/**\n * Memoizes (caches) computation result.\n * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.\n */\nexport function memoized<T extends object, R, O extends any[]>(\n fn: (arg: T, ...args: O) => R\n): (arg: T, ...args: O) => R {\n const map = new WeakMap<T, R>();\n return (arg: T, ...args: O): R => {\n const val = map.get(arg);\n if (val !== undefined) return val;\n const computed = fn(arg, ...args);\n map.set(arg, computed);\n return computed;\n };\n}\n"],"mappings":";;;AAUA,IAAM,MAAsB,uBAAO,CAAC;AACpC,IAAM,MAAsB,uBAAO,CAAC;AAW9B,SAAU,QAAQ,GAAU;AAChC,SAAO,aAAa,cAAe,YAAY,OAAO,CAAC,KAAK,EAAE,YAAY,SAAS;AACrF;AAEM,SAAU,OAAO,MAAa;AAClC,MAAI,CAAC,QAAQ,IAAI;AAAG,UAAM,IAAI,MAAM,qBAAqB;AAC3D;AAEM,SAAU,MAAM,OAAe,OAAc;AACjD,MAAI,OAAO,UAAU;AAAW,UAAM,IAAI,MAAM,QAAQ,4BAA4B,KAAK;AAC3F;AAGM,SAAU,oBAAoB,KAAoB;AACtD,QAAM,MAAM,IAAI,SAAS,EAAE;AAC3B,SAAO,IAAI,SAAS,IAAI,MAAM,MAAM;AACtC;AAEM,SAAU,YAAY,KAAW;AACrC,MAAI,OAAO,QAAQ;AAAU,UAAM,IAAI,MAAM,8BAA8B,OAAO,GAAG;AACrF,SAAO,QAAQ,KAAK,MAAM,OAAO,O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_SKILL_NAME,
|
|
4
|
+
readSkillFile
|
|
5
|
+
} from "./chunk-P74I3WH4.js";
|
|
6
|
+
import {
|
|
7
|
+
hasCode
|
|
8
|
+
} from "./chunk-2I4QTOLB.js";
|
|
9
|
+
import {
|
|
10
|
+
CliError,
|
|
11
|
+
writeFileAtomic
|
|
12
|
+
} from "./chunk-PZRAAAY2.js";
|
|
13
|
+
|
|
14
|
+
// src/lib/skill-writer.ts
|
|
15
|
+
import { existsSync } from "fs";
|
|
16
|
+
import { lstat, readFile, readdir, realpath, stat } from "fs/promises";
|
|
17
|
+
import { dirname, join, relative } from "path";
|
|
18
|
+
async function installSkill(srcDir, destDir, dryRun, name, opts = {}) {
|
|
19
|
+
const src = await readTree(srcDir);
|
|
20
|
+
if (src === null) {
|
|
21
|
+
throw new CliError("INTERNAL", `Packaged skill source ${srcDir} is empty`);
|
|
22
|
+
}
|
|
23
|
+
const writeTo = /* @__PURE__ */ new Map();
|
|
24
|
+
await assertReachable(destDir, name);
|
|
25
|
+
await assertNoCaseCollision(destDir, name);
|
|
26
|
+
for (const rel of src.keys()) {
|
|
27
|
+
const declared = join(destDir, rel);
|
|
28
|
+
writeTo.set(
|
|
29
|
+
rel,
|
|
30
|
+
opts.followSymlinks === false ? declared : await resolveThroughLink(declared, name)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
let differs = false;
|
|
34
|
+
let preexisting = false;
|
|
35
|
+
for (const [rel, content] of src) {
|
|
36
|
+
const current = await readShippedFile(writeTo.get(rel), name, destDir);
|
|
37
|
+
if (rel === "SKILL.md") preexisting = current !== null;
|
|
38
|
+
if (current === null || !current.equals(content)) differs = true;
|
|
39
|
+
}
|
|
40
|
+
const change = !preexisting ? "create" : differs ? "update" : "none";
|
|
41
|
+
if (!dryRun && change !== "none") {
|
|
42
|
+
for (const [rel, content] of src) {
|
|
43
|
+
const target = writeTo.get(rel);
|
|
44
|
+
try {
|
|
45
|
+
const current = await stat(target).catch(() => null);
|
|
46
|
+
await writeFileAtomic(
|
|
47
|
+
target,
|
|
48
|
+
content,
|
|
49
|
+
current === null ? {} : { mode: current.mode & 511 }
|
|
50
|
+
);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw wrapWriteError(
|
|
53
|
+
err,
|
|
54
|
+
destDir,
|
|
55
|
+
`the ${name} skill`,
|
|
56
|
+
await deepestExisting(dirname(target)),
|
|
57
|
+
{ expected: ": a skill is a directory holding SKILL.md" }
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (change === "create") return { status: dryRun ? "would-install" : "installed", preexisting };
|
|
63
|
+
if (change === "none") return { status: "up-to-date", preexisting };
|
|
64
|
+
return {
|
|
65
|
+
status: dryRun ? "would-update" : "updated",
|
|
66
|
+
preexisting,
|
|
67
|
+
// The hosted skill is a MIRROR of tenjin.blog/skills.md (roadmap G4), so a
|
|
68
|
+
// differing local copy is a replacement, not the drift warning the CLI skills
|
|
69
|
+
// get. Neither side carries a version or date, so the wording claims no
|
|
70
|
+
// direction: the local file may well be a newer fetch than this package's copy.
|
|
71
|
+
warning: name === HOSTED_SKILL_NAME ? `${destDir}: the hosted Tenjin skill differed and ${dryRun ? "would be" : "was"} replaced by this package's mirror of tenjin.blog/skills.md, which may be older; it stays as the zero-install fallback. Re-fetch it from tenjin.blog/skills.md if you need the current one.` : `${destDir}: local edits to ${name}'s SKILL.md ${dryRun ? "would be" : "were"} overwritten (the packaged copy is canonical).`
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function readShippedFile(path, name, destDir) {
|
|
75
|
+
const read = await readSkillFile(path);
|
|
76
|
+
if (read.kind === "absent") return null;
|
|
77
|
+
if (read.kind === "ok") return read.bytes;
|
|
78
|
+
if (read.kind === "not-regular") {
|
|
79
|
+
throw new CliError("INTERNAL", `${path} is not a regular file, so ${name} was not written.`, {
|
|
80
|
+
fix: `A skill file must be a regular file. Check what is there (\`ls -l ${path}\`) and remove or replace it, then re-run \`tenjin install\`.`
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
throw wrapWriteError(read.err, destDir, `the ${name} skill`, path, { verb: "read" });
|
|
84
|
+
}
|
|
85
|
+
async function resolveThroughLink(path, name) {
|
|
86
|
+
const entry = await lstat(path).catch(() => null);
|
|
87
|
+
if (entry === null || !entry.isSymbolicLink()) return path;
|
|
88
|
+
const target = await realpath(path).catch(() => null);
|
|
89
|
+
if (target !== null) return target;
|
|
90
|
+
throw new CliError("INTERNAL", `${path} is a broken symlink, so ${name} was not written.`, {
|
|
91
|
+
fix: `Point it at a path that exists, or remove it (\`ls -ld ${path}\`), then re-run \`tenjin install\`.`
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async function assertNoCaseCollision(destDir, name) {
|
|
95
|
+
if (!existsSync(destDir)) return;
|
|
96
|
+
const entries = await readdir(dirname(destDir)).catch(() => null);
|
|
97
|
+
if (entries === null || entries.includes(name)) return;
|
|
98
|
+
const variant = entries.find((e) => e.toLowerCase() === name.toLowerCase());
|
|
99
|
+
if (variant === void 0) return;
|
|
100
|
+
const actual = join(dirname(destDir), variant);
|
|
101
|
+
throw new CliError(
|
|
102
|
+
"INTERNAL",
|
|
103
|
+
`${actual} is a case variant of the ${name} skill and this filesystem treats them as the same directory, so ${name} was not written.`,
|
|
104
|
+
{
|
|
105
|
+
fix: `Rename or remove ${actual}, then re-run \`tenjin install\`.`
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
async function assertReachable(destDir, name) {
|
|
110
|
+
const entry = await lstat(destDir).catch(() => null);
|
|
111
|
+
if (entry?.isSymbolicLink() !== true) return;
|
|
112
|
+
if (await realpath(destDir).catch(() => null) !== null) return;
|
|
113
|
+
throw new CliError("INTERNAL", `${destDir} is a broken symlink, so ${name} was not written.`, {
|
|
114
|
+
fix: `Point it at a directory that exists, or remove it (\`ls -ld ${destDir}\`), then re-run \`tenjin install\`.`
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function deepestExisting(dir) {
|
|
118
|
+
for (let cur = dir; ; cur = dirname(cur)) {
|
|
119
|
+
if (existsSync(cur)) return realpath(cur).catch(() => cur);
|
|
120
|
+
if (dirname(cur) === cur) return cur;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function wrapWriteError(err, dest, subject, culprit, opts = {}) {
|
|
124
|
+
const verb = opts.verb ?? "write";
|
|
125
|
+
const denied = hasCode(err, "EACCES") || hasCode(err, "EPERM");
|
|
126
|
+
const missing = hasCode(err, "ENOENT");
|
|
127
|
+
const wrongKind = hasCode(err, "ENOTDIR") || hasCode(err, "EISDIR");
|
|
128
|
+
if (!denied && !missing && !wrongKind) return err;
|
|
129
|
+
const fix = denied ? `Permission denied on ${culprit}. Check it (\`ls -ld ${culprit}\`), then re-run \`tenjin install\`.` : wrongKind ? `${dest} (or a path inside it) is not the kind of thing it needs to be${opts.expected ?? ""}. Check it (\`ls -ld ${dest}\`), then re-run \`tenjin install\`.` : `${dest} could not be created; if it is a symlink, check that its target exists (\`ls -ld ${dest}\`), then re-run \`tenjin install\`.`;
|
|
130
|
+
return new CliError(
|
|
131
|
+
"INTERNAL",
|
|
132
|
+
`Could not ${verb} ${subject} ${verb === "read" ? "at" : "to"} ${dest}.`,
|
|
133
|
+
{ fix, cause: err }
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
async function readTree(dir) {
|
|
137
|
+
if (!existsSync(dir)) return null;
|
|
138
|
+
const entries = await readdir(dir, { recursive: true, withFileTypes: true });
|
|
139
|
+
const files = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
if (!entry.isFile()) continue;
|
|
142
|
+
const full = join(entry.parentPath, entry.name);
|
|
143
|
+
files.set(relative(dir, full), await readFile(full));
|
|
144
|
+
}
|
|
145
|
+
return files;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
installSkill,
|
|
150
|
+
resolveThroughLink
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=chunk-RSBN67PA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/skill-writer.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { lstat, readFile, readdir, realpath, stat } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { writeFileAtomic } from './atomic-json';\nimport { hasCode } from './errno';\nimport { CliError } from './errors';\nimport { HOSTED_SKILL_NAME, readSkillFile } from './skill-wiring';\n\n/**\n * Writing one packaged skill into one harness directory, and the path guards that\n * write needs. Its own module, free of the command layer's dependencies, because\n * `install` and the post-command self-heal both write skills and the heal runs on\n * every command: reaching into commands/install would parse the wallet's viem\n * chunk on a `tenjin config`.\n */\n\nexport type SkillInstallStatus =\n 'installed' | 'updated' | 'up-to-date' | 'would-install' | 'would-update';\n\nexport interface SkillInstallResult {\n status: SkillInstallStatus;\n warning?: string;\n /** Was a real copy (a SKILL.md, not just the directory) already on disk before this run? */\n preexisting: boolean;\n}\n\nexport interface SkillWriteOptions {\n /**\n * Write THROUGH a symlinked destination (default), or replace it. `install`\n * follows the link, because the operator pointed it somewhere on purpose. The\n * unattended self-heal does not, and passes false: it has already refused every\n * link it could see, and this closes the gap between that look and this write,\n * where a link appearing in between would otherwise be followed. `rename` never\n * follows its final component, so the worst a race can now do is leave our\n * regular file where the new link was.\n */\n followSymlinks?: boolean;\n}\n\nexport async function installSkill(\n srcDir: string,\n destDir: string,\n dryRun: boolean,\n name: string,\n opts: SkillWriteOptions = {},\n): Promise<SkillInstallResult> {\n const src = await readTree(srcDir);\n if (src === null) {\n // assertSkillsSource already guards SKILL.md; this is defensive for an empty dir.\n throw new CliError('INTERNAL', `Packaged skill source ${srcDir} is empty`);\n }\n\n // Only the files this package SHIPS are read and written. Everything else in the\n // directory belongs to the operator: never inspected, listed, or removed. That is\n // what package managers do (npm, dpkg, Homebrew all own their files, not the\n // directory), and wholesale replacement was the single cause behind a run of\n // data-loss, symlink and enumeration bugs.\n //\n // Resolved on BOTH paths, dry run included, so a dry run cannot promise a write\n // the real run refuses.\n const writeTo = new Map<string, string>();\n await assertReachable(destDir, name);\n await assertNoCaseCollision(destDir, name);\n for (const rel of src.keys()) {\n const declared = join(destDir, rel);\n writeTo.set(\n rel,\n opts.followSymlinks === false ? declared : await resolveThroughLink(declared, name),\n );\n }\n\n let differs = false;\n let preexisting = false;\n for (const [rel, content] of src) {\n const current = await readShippedFile(writeTo.get(rel)!, name, destDir);\n if (rel === 'SKILL.md') preexisting = current !== null;\n if (current === null || !current.equals(content)) differs = true;\n }\n const change = !preexisting ? 'create' : differs ? 'update' : 'none';\n\n if (!dryRun && change !== 'none') {\n for (const [rel, content] of src) {\n const target = writeTo.get(rel)!;\n try {\n // An existing file keeps the mode it has. A skill an operator (or their\n // dotfiles) made group-readable or read-only is theirs to have set that\n // way, and an update is no reason to hand it back at the default 0644.\n const current = await stat(target).catch(() => null);\n await writeFileAtomic(\n target,\n content,\n current === null ? {} : { mode: current.mode & 0o777 },\n );\n } catch (err) {\n // Culprit is derived from the file that FAILED, not assumed to be the\n // skills root: an existing skill directory that refuses the temp file is\n // itself the thing to chmod, and a symlinked SKILL.md fails in the link's\n // TARGET directory, which no path under destDir names.\n throw wrapWriteError(\n err,\n destDir,\n `the ${name} skill`,\n await deepestExisting(dirname(target)),\n { expected: ': a skill is a directory holding SKILL.md' },\n );\n }\n }\n }\n\n if (change === 'create') return { status: dryRun ? 'would-install' : 'installed', preexisting };\n if (change === 'none') return { status: 'up-to-date', preexisting };\n return {\n status: dryRun ? 'would-update' : 'updated',\n preexisting,\n // The hosted skill is a MIRROR of tenjin.blog/skills.md (roadmap G4), so a\n // differing local copy is a replacement, not the drift warning the CLI skills\n // get. Neither side carries a version or date, so the wording claims no\n // direction: the local file may well be a newer fetch than this package's copy.\n warning:\n name === HOSTED_SKILL_NAME\n ? `${destDir}: the hosted Tenjin skill differed and ${dryRun ? 'would be' : 'was'} replaced by this package's mirror of tenjin.blog/skills.md, which may be older; it stays as the zero-install fallback. Re-fetch it from tenjin.blog/skills.md if you need the current one.`\n : `${destDir}: local edits to ${name}'s SKILL.md ${dryRun ? 'would be' : 'were'} overwritten (the packaged copy is canonical).`,\n };\n}\n\n/**\n * Read a shipped file, or null when it is not there.\n *\n * The node-type guard lives in `readSkillFile`, shared with the wiring check and\n * the staleness check, because all three read the same operator-controlled paths\n * and a pipe at one of them used to hang whichever command got there first.\n */\nasync function readShippedFile(\n path: string,\n name: string,\n destDir: string,\n): Promise<Buffer | null> {\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return null;\n if (read.kind === 'ok') return read.bytes;\n if (read.kind === 'not-regular') {\n throw new CliError('INTERNAL', `${path} is not a regular file, so ${name} was not written.`, {\n fix: `A skill file must be a regular file. Check what is there (\\`ls -l ${path}\\`) and remove or replace it, then re-run \\`tenjin install\\`.`,\n });\n }\n // Names the FILE, not its directory: this is a read failure, and pointing at a\n // perfectly writable parent is what sent operators to chmod the wrong thing.\n throw wrapWriteError(read.err, destDir, `the ${name} skill`, path, { verb: 'read' });\n}\n\n/**\n * A destination the operator manages through a symlink is written THROUGH it, so\n * their link survives and their target is what actually changes. Same call the\n * settings.json writer makes, and the same reason: committing with `rename` over a\n * link would replace it with a regular file and strand the target.\n */\nexport async function resolveThroughLink(path: string, name: string): Promise<string> {\n const entry = await lstat(path).catch(() => null);\n if (entry === null || !entry.isSymbolicLink()) return path;\n const target = await realpath(path).catch(() => null);\n if (target !== null) return target;\n throw new CliError('INTERNAL', `${path} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a path that exists, or remove it (\\`ls -ld ${path}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * On a case-insensitive filesystem (the macOS default), a user directory named a\n * case variant of a shipped skill ALIASES the skill's path, so the write would\n * replace the user's own SKILL.md under a warning naming a path that is not on\n * disk. Detected by the alias itself: the destination resolves but the parent\n * lists only a differently-cased entry, which also means a case-SENSITIVE\n * filesystem (where both names can coexist) never trips this. Dry runs too.\n */\nasync function assertNoCaseCollision(destDir: string, name: string): Promise<void> {\n if (!existsSync(destDir)) return;\n const entries = await readdir(dirname(destDir)).catch(() => null);\n if (entries === null || entries.includes(name)) return;\n const variant = entries.find((e) => e.toLowerCase() === name.toLowerCase());\n if (variant === undefined) return;\n const actual = join(dirname(destDir), variant);\n throw new CliError(\n 'INTERNAL',\n `${actual} is a case variant of the ${name} skill and this filesystem treats them as the same directory, so ${name} was not written.`,\n {\n fix: `Rename or remove ${actual}, then re-run \\`tenjin install\\`.`,\n },\n );\n}\n\n/**\n * Fail a destination directory that is a BROKEN SYMLINK, on dry runs too, so a dry\n * run cannot report `would-install` where the real run cannot write. It checks only\n * that: an unwritable but real directory passes here and fails at the write, with\n * the permission-denied error.\n */\nasync function assertReachable(destDir: string, name: string): Promise<void> {\n const entry = await lstat(destDir).catch(() => null);\n if (entry?.isSymbolicLink() !== true) return;\n if ((await realpath(destDir).catch(() => null)) !== null) return;\n throw new CliError('INTERNAL', `${destDir} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a directory that exists, or remove it (\\`ls -ld ${destDir}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * The directory a denied WRITE should point the operator at: the deepest existing\n * ancestor of the failed target's directory, RESOLVED. An existing skill directory\n * that refuses the temp file names itself; a directory that could not be created\n * names the ancestor that refused to create it, because `ls -ld` on a path that is\n * not there says nothing. Resolved because a destination managed through a symlink\n * denies the write in the link's TARGET, and telling the operator to chmod the\n * link's path leaves them staring at a healthy link.\n */\nexport async function deepestExisting(dir: string): Promise<string> {\n for (let cur = dir; ; cur = dirname(cur)) {\n if (existsSync(cur)) return realpath(cur).catch(() => cur);\n if (dirname(cur) === cur) return cur;\n }\n}\n\n/** A raw errno under INTERNAL reads as a CLI bug and carries no fix. */\nexport function wrapWriteError(\n err: unknown,\n /** The destination as the operator knows it (the declared path, pre-resolution). */\n dest: string,\n /** What could not be written, e.g. `the tenjin-search skill` or `the Tenjin pointer`. */\n subject: string,\n /**\n * The path to point the operator at. A READ failure names the file itself, which\n * is the thing whose mode is wrong. A WRITE failure names the deepest existing\n * directory on the failed target's resolved path.\n */\n culprit: string,\n opts: {\n /** Which side failed; a read error reported as \"could not write\" misleads. */\n verb?: 'read' | 'write';\n /** Sentence tail for the wrong-kind fix, telling the operator the expected shape. */\n expected?: string;\n } = {},\n): unknown {\n const verb = opts.verb ?? 'write';\n const denied = hasCode(err, 'EACCES') || hasCode(err, 'EPERM');\n const missing = hasCode(err, 'ENOENT');\n // A skills directory that resolves to a regular file, or a SKILL.md that resolves\n // to a directory. Pathological, but a raw ENOTDIR/EISDIR says nothing about which\n // path is the wrong kind of thing.\n const wrongKind = hasCode(err, 'ENOTDIR') || hasCode(err, 'EISDIR');\n if (!denied && !missing && !wrongKind) return err;\n const fix = denied\n ? `Permission denied on ${culprit}. Check it (\\`ls -ld ${culprit}\\`), then re-run \\`tenjin install\\`.`\n : wrongKind\n ? `${dest} (or a path inside it) is not the kind of thing it needs to be${opts.expected ?? ''}. Check it (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`\n : `${dest} could not be created; if it is a symlink, check that its target exists (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`;\n return new CliError(\n 'INTERNAL',\n `Could not ${verb} ${subject} ${verb === 'read' ? 'at' : 'to'} ${dest}.`,\n { fix, cause: err },\n );\n}\n\n/**\n * Read a directory tree into a rel-path -> content map, or null when it does not\n * exist. Reads as raw `Buffer`, not `utf8`: today's skills are markdown-only, but\n * this is a general recursive dir-copy, and decoding to a string here would\n * silently corrupt a future non-text asset (an image, a font) on write, or worse,\n * make two different corrupted binaries both decode to U+FFFD and compare equal.\n */\nasync function readTree(dir: string): Promise<Map<string, Buffer> | null> {\n if (!existsSync(dir)) return null;\n const entries = await readdir(dir, { recursive: true, withFileTypes: true });\n const files = new Map<string, Buffer>();\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n const full = join(entry.parentPath, entry.name);\n files.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