tenjin-cli 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +572 -79
- package/dist/{_esm-ZH2J4QEH.js → _esm-C5CRWCYU.js} +2 -2
- package/dist/_esm-N4KAVXQR.js +881 -0
- package/dist/buy-FMDBZ4NY.js +44 -0
- package/dist/candidate-7LAELUQD.js +23 -0
- package/dist/ccip-RPPPKTJR.js +19 -0
- package/dist/{ccip-UCLT5VOW.js → ccip-ZGGWQN4X.js} +6 -5
- package/dist/chunk-2GSRYTZS.js +127 -0
- package/dist/chunk-2GSRYTZS.js.map +1 -0
- package/dist/chunk-2I4QTOLB.js +11 -0
- package/dist/chunk-2I4QTOLB.js.map +1 -0
- package/dist/chunk-36X2CA3N.js +311 -0
- package/dist/chunk-36X2CA3N.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-5JMKIDMM.js +316 -0
- package/dist/chunk-5JMKIDMM.js.map +1 -0
- package/dist/chunk-5JXAZP7H.js +206 -0
- package/dist/chunk-5JXAZP7H.js.map +1 -0
- package/dist/chunk-5SE6BJRP.js +135 -0
- package/dist/chunk-5SE6BJRP.js.map +1 -0
- package/dist/chunk-6BZLSRNU.js +149 -0
- package/dist/chunk-6BZLSRNU.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-7WDY4AXV.js +14620 -0
- package/dist/chunk-7WDY4AXV.js.map +1 -0
- package/dist/chunk-A6KCZPNQ.js +83 -0
- package/dist/chunk-A6KCZPNQ.js.map +1 -0
- package/dist/chunk-AWQ6A4CI.js +341 -0
- package/dist/chunk-AWQ6A4CI.js.map +1 -0
- package/dist/chunk-BJJ5BQO6.js +162 -0
- package/dist/chunk-BJJ5BQO6.js.map +1 -0
- package/dist/chunk-BUDHTDKL.js +612 -0
- package/dist/chunk-BUDHTDKL.js.map +1 -0
- package/dist/chunk-DKQMJTG7.js +188 -0
- package/dist/chunk-DKQMJTG7.js.map +1 -0
- package/dist/chunk-FKSAUOJU.js +137 -0
- package/dist/chunk-FKSAUOJU.js.map +1 -0
- package/dist/{chunk-EXBMF5X7.js → chunk-GECSWJ7O.js} +526 -79
- package/dist/chunk-GECSWJ7O.js.map +1 -0
- package/dist/chunk-GSDZRCGF.js +105 -0
- package/dist/chunk-GSDZRCGF.js.map +1 -0
- package/dist/chunk-JSSIMGQT.js +174 -0
- package/dist/chunk-JSSIMGQT.js.map +1 -0
- package/dist/chunk-KYH4KPE5.js +1357 -0
- package/dist/chunk-KYH4KPE5.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-MD7WGYYI.js +125 -0
- package/dist/chunk-MD7WGYYI.js.map +1 -0
- package/dist/chunk-MJZZTKCC.js +323 -0
- package/dist/chunk-MJZZTKCC.js.map +1 -0
- package/dist/chunk-O6CAUZGY.js +317 -0
- package/dist/chunk-O6CAUZGY.js.map +1 -0
- package/dist/chunk-P74I3WH4.js +204 -0
- package/dist/chunk-P74I3WH4.js.map +1 -0
- package/dist/chunk-POF7HPRV.js +145 -0
- package/dist/chunk-POF7HPRV.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-R2VLGNFD.js +181 -0
- package/dist/chunk-R2VLGNFD.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-S5RYMCV6.js +70 -0
- package/dist/chunk-S5RYMCV6.js.map +1 -0
- package/dist/chunk-SGK2B724.js +67 -0
- package/dist/chunk-SGK2B724.js.map +1 -0
- package/dist/chunk-STND72DS.js +242 -0
- package/dist/chunk-STND72DS.js.map +1 -0
- package/dist/chunk-TEL27PR5.js +124 -0
- package/dist/chunk-TEL27PR5.js.map +1 -0
- package/dist/chunk-TWRYSGAW.js +134 -0
- package/dist/chunk-TWRYSGAW.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-UHTVXQ2O.js +140 -0
- package/dist/chunk-UHTVXQ2O.js.map +1 -0
- package/dist/chunk-UOJRKQTZ.js +213 -0
- package/dist/chunk-UOJRKQTZ.js.map +1 -0
- package/dist/chunk-V4WWTZHZ.js +233 -0
- package/dist/chunk-V4WWTZHZ.js.map +1 -0
- package/dist/chunk-VRRLTZ2Q.js +651 -0
- package/dist/chunk-VRRLTZ2Q.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-X3OOVSPX.js +154 -0
- package/dist/chunk-X3OOVSPX.js.map +1 -0
- package/dist/chunk-XJN5WUKL.js +204 -0
- package/dist/chunk-XJN5WUKL.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-ZQIQ55KK.js +51 -0
- package/dist/chunk-ZQIQ55KK.js.map +1 -0
- package/dist/chunk-ZUAQRIVP.js +1369 -0
- package/dist/chunk-ZUAQRIVP.js.map +1 -0
- package/dist/{chunk-3IMLRUZE.js → chunk-ZXTAQYNA.js} +6 -2
- package/dist/chunk-ZXTAQYNA.js.map +1 -0
- package/dist/{cli-WA65NP4Y.js → cli-HK2XAWNW.js} +440 -175
- package/dist/cli-HK2XAWNW.js.map +1 -0
- package/dist/config-LYCHHNAJ.js +26 -0
- package/dist/config-LYCHHNAJ.js.map +1 -0
- package/dist/dist-U4M6QCKE.js +2842 -0
- package/dist/dist-U4M6QCKE.js.map +1 -0
- package/dist/doctor-2KPUQURC.js +27 -0
- package/dist/doctor-2KPUQURC.js.map +1 -0
- package/dist/edit-TST3OCKQ.js +38 -0
- package/dist/edit-TST3OCKQ.js.map +1 -0
- package/dist/ethersCompat-Df4a6QIZ-WHYKB6HA.js +18 -0
- package/dist/ethersCompat-Df4a6QIZ-WHYKB6HA.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/inspect-TPTHVPBB.js +35 -0
- package/dist/inspect-TPTHVPBB.js.map +1 -0
- package/dist/install-PT3XEDJ6.js +1869 -0
- package/dist/install-PT3XEDJ6.js.map +1 -0
- package/dist/{mine.wasm-GQECMSGN.js → mine.wasm-6PIT3DK6.js} +2 -2
- package/dist/outcome-NPNSF2Q7.js +22 -0
- package/dist/outcome-NPNSF2Q7.js.map +1 -0
- package/dist/publish-XP5SEWST.js +41 -0
- package/dist/publish-XP5SEWST.js.map +1 -0
- package/dist/read-D4VXRWOG.js +158 -0
- package/dist/read-D4VXRWOG.js.map +1 -0
- package/dist/run-3IPGEXW7.js +16902 -0
- package/dist/run-3IPGEXW7.js.map +1 -0
- package/dist/search-YOBD6VDI.js +24 -0
- package/dist/search-YOBD6VDI.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-BWNP6WN4.js +223 -0
- package/dist/send-BWNP6WN4.js.map +1 -0
- package/dist/session-GZEZBOMI.js +88 -0
- package/dist/session-GZEZBOMI.js.map +1 -0
- package/dist/skill-heal-OK6YALW6.js +85 -0
- package/dist/skill-heal-OK6YALW6.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-5RHDFPN2.js +32 -0
- package/dist/wallet-5RHDFPN2.js.map +1 -0
- package/dist/wallet-YEGQBWWL.js +42 -0
- package/dist/wallet-YEGQBWWL.js.map +1 -0
- package/docs/agent-permissions.md +281 -0
- package/package.json +25 -18
- package/skills/tenjin/SKILL.md +364 -0
- package/skills/tenjin-publish/SKILL.md +219 -0
- package/skills/tenjin-search/SKILL.md +335 -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-FMDBZ4NY.js.map} +0 -0
- /package/dist/{secp256k1-BEZS642W.js.map → candidate-7LAELUQD.js.map} +0 -0
- /package/dist/{usdc-44R6XZF2.js.map → ccip-RPPPKTJR.js.map} +0 -0
- /package/dist/{wallet-ELBTBMXO.js.map → ccip-ZGGWQN4X.js.map} +0 -0
- /package/dist/{mine.wasm-GQECMSGN.js.map → mine.wasm-6PIT3DK6.js.map} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// package.json
|
|
4
|
+
var package_default = {
|
|
5
|
+
name: "tenjin-cli",
|
|
6
|
+
version: "0.1.0-alpha.10",
|
|
7
|
+
mcpName: "blog.tenjin/tenjin",
|
|
8
|
+
type: "module",
|
|
9
|
+
description: "Tenjin agent CLI for the x402 knowledge marketplace.",
|
|
10
|
+
license: "MIT",
|
|
11
|
+
repository: {
|
|
12
|
+
type: "git",
|
|
13
|
+
url: "git+https://github.com/BackTrackCo/tenjin-agent.git"
|
|
14
|
+
},
|
|
15
|
+
homepage: "https://tenjin.blog/agents",
|
|
16
|
+
bugs: "https://github.com/BackTrackCo/tenjin-agent/issues",
|
|
17
|
+
keywords: [
|
|
18
|
+
"x402",
|
|
19
|
+
"usdc",
|
|
20
|
+
"base",
|
|
21
|
+
"ai-agents",
|
|
22
|
+
"agent-payments",
|
|
23
|
+
"mcp",
|
|
24
|
+
"knowledge-marketplace",
|
|
25
|
+
"micropayments",
|
|
26
|
+
"claude",
|
|
27
|
+
"codex",
|
|
28
|
+
"cli"
|
|
29
|
+
],
|
|
30
|
+
bin: {
|
|
31
|
+
tenjin: "dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
engines: {
|
|
34
|
+
node: ">=22"
|
|
35
|
+
},
|
|
36
|
+
files: [
|
|
37
|
+
"dist",
|
|
38
|
+
"docs",
|
|
39
|
+
"skills",
|
|
40
|
+
"NOTICE.md"
|
|
41
|
+
],
|
|
42
|
+
packageManager: "pnpm@11.11.0",
|
|
43
|
+
scripts: {
|
|
44
|
+
build: "tsup",
|
|
45
|
+
test: "vitest run",
|
|
46
|
+
typecheck: "tsc --noEmit",
|
|
47
|
+
lint: "eslint .",
|
|
48
|
+
format: "prettier --write .",
|
|
49
|
+
"format:check": "prettier --check .",
|
|
50
|
+
check: "pnpm run build && pnpm run test",
|
|
51
|
+
"sync:skill": "node scripts/sync-skill.mjs",
|
|
52
|
+
"pack-smoke": "bash scripts/pack-smoke.sh",
|
|
53
|
+
changeset: "changeset",
|
|
54
|
+
prepublishOnly: "pnpm run build",
|
|
55
|
+
prepare: "git config core.hooksPath .githooks || true"
|
|
56
|
+
},
|
|
57
|
+
devDependencies: {
|
|
58
|
+
"@changesets/cli": "^2.31.1",
|
|
59
|
+
"@clack/prompts": "^1.7.0",
|
|
60
|
+
"@eslint/js": "^10",
|
|
61
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
62
|
+
"@types/node": "^25",
|
|
63
|
+
"@x402/core": "2.17.0",
|
|
64
|
+
"@x402/evm": "2.17.0",
|
|
65
|
+
"@x402/extensions": "2.17.0",
|
|
66
|
+
commander: "^14.0.1",
|
|
67
|
+
eslint: "^10",
|
|
68
|
+
"eslint-config-prettier": "^10",
|
|
69
|
+
ox: "0.14.30",
|
|
70
|
+
prettier: "^3",
|
|
71
|
+
tsup: "^8.5.0",
|
|
72
|
+
typescript: "^6",
|
|
73
|
+
"typescript-eslint": "^8",
|
|
74
|
+
viem: "^2.53.1",
|
|
75
|
+
vitest: "^4.1.9",
|
|
76
|
+
zod: "^4.4.3"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
package_default
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=chunk-A6KCZPNQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.10\",\n \"mcpName\": \"blog.tenjin/tenjin\",\n \"type\": \"module\",\n \"description\": \"Tenjin agent CLI for the x402 knowledge marketplace.\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.blog/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"x402\",\n \"usdc\",\n \"base\",\n \"ai-agents\",\n \"agent-payments\",\n \"mcp\",\n \"knowledge-marketplace\",\n \"micropayments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"skills\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"prepare\": \"git config core.hooksPath .githooks || true\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.31.1\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.29.0\",\n \"@types/node\": \"^25\",\n \"@x402/core\": \"2.17.0\",\n \"@x402/evm\": \"2.17.0\",\n \"@x402/extensions\": \"2.17.0\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,aAAe;AAAA,EACf,SAAW;AAAA,EACX,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,EAClB,SAAW;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,OAAS;AAAA,IACT,cAAc;AAAA,IACd,cAAc;AAAA,IACd,WAAa;AAAA,IACb,gBAAkB;AAAA,IAClB,SAAW;AAAA,EACb;AAAA,EACA,iBAAmB;AAAA,IACjB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,6BAA6B;AAAA,IAC7B,eAAe;AAAA,IACf,cAAc;AAAA,IACd,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,WAAa;AAAA,IACb,QAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,IAAM;AAAA,IACN,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,KAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
PUBLISH_STATUSES,
|
|
4
|
+
dedupeFindings,
|
|
5
|
+
deriveCard,
|
|
6
|
+
deriveProjectMarkers,
|
|
7
|
+
describeFindings,
|
|
8
|
+
localCardEligibility,
|
|
9
|
+
missingSentences,
|
|
10
|
+
needsConfirmation,
|
|
11
|
+
parseAppliesToFlags,
|
|
12
|
+
parseFrontmatter,
|
|
13
|
+
publicFinding,
|
|
14
|
+
publishPost,
|
|
15
|
+
resolveWriteAuth,
|
|
16
|
+
scan,
|
|
17
|
+
writeModeNotices
|
|
18
|
+
} from "./chunk-ZUAQRIVP.js";
|
|
19
|
+
import {
|
|
20
|
+
headingOutline
|
|
21
|
+
} from "./chunk-SGK2B724.js";
|
|
22
|
+
import {
|
|
23
|
+
describeWallet,
|
|
24
|
+
resolveWalletProvider
|
|
25
|
+
} from "./chunk-GECSWJ7O.js";
|
|
26
|
+
import {
|
|
27
|
+
dropCandidate,
|
|
28
|
+
readCandidate
|
|
29
|
+
} from "./chunk-TEL27PR5.js";
|
|
30
|
+
import {
|
|
31
|
+
markSearchResolved
|
|
32
|
+
} from "./chunk-5SE6BJRP.js";
|
|
33
|
+
import {
|
|
34
|
+
trimSlash
|
|
35
|
+
} from "./chunk-PZSUWDF2.js";
|
|
36
|
+
import {
|
|
37
|
+
sanitizeForTerminal
|
|
38
|
+
} from "./chunk-R2VLGNFD.js";
|
|
39
|
+
import {
|
|
40
|
+
resolveContextSettings,
|
|
41
|
+
resolvePublishSettings
|
|
42
|
+
} from "./chunk-BJJ5BQO6.js";
|
|
43
|
+
import {
|
|
44
|
+
UUID_RE,
|
|
45
|
+
parsePublishModeFlag,
|
|
46
|
+
parseUsdToAtomic,
|
|
47
|
+
toMoney
|
|
48
|
+
} from "./chunk-36X2CA3N.js";
|
|
49
|
+
import {
|
|
50
|
+
CliError
|
|
51
|
+
} from "./chunk-PZRAAAY2.js";
|
|
52
|
+
|
|
53
|
+
// src/commands/publish.ts
|
|
54
|
+
import { readFile } from "fs/promises";
|
|
55
|
+
import { dirname, resolve } from "path";
|
|
56
|
+
async function runPublish(args, ctx, deps = {}) {
|
|
57
|
+
const env = deps.env ?? process.env;
|
|
58
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
59
|
+
if (args.mode !== void 0) parsePublishModeFlag(args.mode, "--mode");
|
|
60
|
+
const { raw, candidate } = await resolveSource(args, ctx.dataDir);
|
|
61
|
+
const { frontmatter, body } = parseFrontmatter(raw);
|
|
62
|
+
const status = resolveStatus(args, frontmatter);
|
|
63
|
+
const title = resolveTitle(frontmatter, body);
|
|
64
|
+
const tags = resolveTags(frontmatter);
|
|
65
|
+
const excerpt = expectString(frontmatter, "excerpt");
|
|
66
|
+
const handle = expectString(frontmatter, "handle");
|
|
67
|
+
const cardFlags = cardFlagsFrom(args);
|
|
68
|
+
if (candidate?.meta.question !== void 0 && cardFlags.question === void 0 && frontmatter.questionsAnswered === void 0) {
|
|
69
|
+
cardFlags.question = [candidate.meta.question];
|
|
70
|
+
}
|
|
71
|
+
const card = deriveCard(frontmatter, cardFlags);
|
|
72
|
+
const settings = await resolvePublishSettings({
|
|
73
|
+
dataDir: ctx.dataDir,
|
|
74
|
+
cwd,
|
|
75
|
+
...args.mode !== void 0 ? { flag: args.mode } : {},
|
|
76
|
+
env
|
|
77
|
+
});
|
|
78
|
+
writeModeNotices(
|
|
79
|
+
ctx.io.stderr,
|
|
80
|
+
settings,
|
|
81
|
+
env,
|
|
82
|
+
"each publish asks you once. Set auto to publish clean scans automatically"
|
|
83
|
+
);
|
|
84
|
+
const priceAtomic = resolvePrice(args, frontmatter, settings.defaultPriceAtomic);
|
|
85
|
+
const markerRoot = candidate !== void 0 ? candidate.meta.sourceProject : args.file !== void 0 ? dirname(resolve(cwd, args.file)) : cwd;
|
|
86
|
+
const scanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };
|
|
87
|
+
const findings = dedupeFindings([
|
|
88
|
+
...scan(raw, scanContext),
|
|
89
|
+
...scan(cardScanText(card), scanContext)
|
|
90
|
+
]);
|
|
91
|
+
const blocking = findings.filter((f) => f.severity === "block");
|
|
92
|
+
const warns = findings.filter((f) => f.severity === "warn");
|
|
93
|
+
const eligibility = localCardEligibility(card);
|
|
94
|
+
const price = toMoney(priceAtomic);
|
|
95
|
+
if (blocking.length > 0) {
|
|
96
|
+
throw new CliError("PUBLISH_BLOCKED", blockMessage(blocking), {
|
|
97
|
+
fix: "Remove the secret from the file (it is never masked away by --yes), then re-run.",
|
|
98
|
+
details: {
|
|
99
|
+
mode: settings.mode,
|
|
100
|
+
findings: blocking.map(publicFinding),
|
|
101
|
+
price: { atomic: price.atomic, usd: price.usd }
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (needsConfirmation(settings.mode, warns.length) && args.yes !== true) {
|
|
106
|
+
throw new CliError("NEEDS_CONFIRMATION", confirmMessage(warns.length, price.usd), {
|
|
107
|
+
fix: "Review the findings, then re-run with --yes (or resolve the source and re-run).",
|
|
108
|
+
details: {
|
|
109
|
+
mode: settings.mode,
|
|
110
|
+
price: { atomic: price.atomic, usd: price.usd },
|
|
111
|
+
findings: warns.map(publicFinding),
|
|
112
|
+
card: eligibility,
|
|
113
|
+
target: { status, titlePreview: sanitizeForTerminal(title ?? "(untitled draft)") }
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const runtime = await resolveContextSettings(ctx);
|
|
118
|
+
const provider = resolveWalletProvider(
|
|
119
|
+
ctx,
|
|
120
|
+
deps.provider !== void 0 ? { provider: deps.provider } : {}
|
|
121
|
+
);
|
|
122
|
+
await describeWallet(provider);
|
|
123
|
+
const signer = await provider.getSigner();
|
|
124
|
+
const auth = resolveWriteAuth({
|
|
125
|
+
signer,
|
|
126
|
+
baseUrl: runtime.baseUrl,
|
|
127
|
+
dataDir: ctx.dataDir,
|
|
128
|
+
// A publish always writes.
|
|
129
|
+
scope: "read+write",
|
|
130
|
+
...deps.useSession !== void 0 ? { useSession: deps.useSession } : {},
|
|
131
|
+
env
|
|
132
|
+
});
|
|
133
|
+
const input = {
|
|
134
|
+
...title !== void 0 ? { title } : {},
|
|
135
|
+
bodyMd: body,
|
|
136
|
+
...excerpt !== void 0 ? { excerpt } : {},
|
|
137
|
+
...tags !== void 0 ? { tags } : {},
|
|
138
|
+
priceAtomic,
|
|
139
|
+
...handle !== void 0 ? { handle } : {},
|
|
140
|
+
status,
|
|
141
|
+
...card !== void 0 ? { resource: card } : {}
|
|
142
|
+
};
|
|
143
|
+
const result = await publishPost(input, auth, {
|
|
144
|
+
baseUrl: runtime.baseUrl,
|
|
145
|
+
timeoutMs: ctx.flags.timeout,
|
|
146
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
147
|
+
});
|
|
148
|
+
const candidateInfo = candidate !== void 0 ? await clearPublishedCandidate(ctx, candidate.id) : void 0;
|
|
149
|
+
if (candidate !== void 0) {
|
|
150
|
+
await markSearchResolved(ctx.dataDir, candidate.meta.searchId, "publish");
|
|
151
|
+
}
|
|
152
|
+
return receipt(result, runtime.baseUrl, candidateInfo);
|
|
153
|
+
}
|
|
154
|
+
async function clearPublishedCandidate(ctx, id) {
|
|
155
|
+
try {
|
|
156
|
+
if (await dropCandidate(ctx.dataDir, id)) return { id, cleared: true };
|
|
157
|
+
const warning = `Published, but candidate ${id} was already gone; nothing to clear.`;
|
|
158
|
+
ctx.io.stderr.write(`${warning}
|
|
159
|
+
`);
|
|
160
|
+
return { id, cleared: false, warning };
|
|
161
|
+
} catch (err) {
|
|
162
|
+
const warning = `Published successfully, but could not clear candidate ${id}: ${errorMessage(err)}. Remove it with \`tenjin candidate drop ${id}\`.`;
|
|
163
|
+
ctx.io.stderr.write(`${warning}
|
|
164
|
+
`);
|
|
165
|
+
return { id, cleared: false, warning };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function errorMessage(err) {
|
|
169
|
+
return err instanceof Error ? err.message : String(err);
|
|
170
|
+
}
|
|
171
|
+
async function resolveSource(args, dataDir) {
|
|
172
|
+
if (args.candidate !== void 0) {
|
|
173
|
+
if (args.file !== void 0) {
|
|
174
|
+
throw new CliError("USAGE", "Pass EITHER a file or --candidate, not both.", {
|
|
175
|
+
fix: "Publish a file with `tenjin publish post.md`, or a candidate with `--candidate <id>`."
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (!UUID_RE.test(args.candidate)) {
|
|
179
|
+
throw new CliError("USAGE", `Invalid candidate id: ${JSON.stringify(args.candidate)}`, {
|
|
180
|
+
fix: "Pass a candidate id from `tenjin candidate list`."
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const record = await readCandidate(dataDir, args.candidate);
|
|
184
|
+
if (record === null) {
|
|
185
|
+
throw new CliError("USAGE", `Unknown candidate: ${JSON.stringify(args.candidate)}`, {
|
|
186
|
+
fix: "List parked candidates with `tenjin candidate list`."
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return { raw: await readDraft(record), candidate: record };
|
|
190
|
+
}
|
|
191
|
+
if (args.file === void 0) {
|
|
192
|
+
throw new CliError("USAGE", "Nothing to publish.", {
|
|
193
|
+
fix: "Pass a Markdown file (`tenjin publish post.md`) or `--candidate <id>`."
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return { raw: await readMarkdown(args.file) };
|
|
197
|
+
}
|
|
198
|
+
async function readDraft(record) {
|
|
199
|
+
try {
|
|
200
|
+
return await readFile(record.draftPath, "utf8");
|
|
201
|
+
} catch (err) {
|
|
202
|
+
throw new CliError("INTERNAL", `Candidate ${record.id} is missing its draft.`, {
|
|
203
|
+
fix: `Drop it with \`tenjin candidate drop ${record.id}\` and re-add the draft.`,
|
|
204
|
+
cause: err
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function receipt(result, baseUrl, candidateInfo) {
|
|
209
|
+
const price = toMoney(result.priceAtomic);
|
|
210
|
+
const missing = missingSentences(result.cacheEligibleMissing).map(sanitizeForTerminal);
|
|
211
|
+
const cacheEligible = result.cacheEligible ?? false;
|
|
212
|
+
const deskUrl = `${trimSlash(baseUrl)}/desk`;
|
|
213
|
+
const title = sanitizeForTerminal(result.title);
|
|
214
|
+
const human = [
|
|
215
|
+
`Published ${title} (${sanitizeForTerminal(result.status)}) for ${price.usd} USD \u2192 ${sanitizeForTerminal(result.url)}`,
|
|
216
|
+
cacheEligible ? "Answer card is search-eligible." : missing.length > 0 ? `Answer card not search-eligible yet: ${missing.join(" ")}` : "Published as a browse-only document (no answer card).",
|
|
217
|
+
...candidateInfo?.cleared === true ? [`Cleared candidate ${candidateInfo.id}.`] : [],
|
|
218
|
+
...result.warnings.map((w) => `warning: ${sanitizeForTerminal(w)}`)
|
|
219
|
+
];
|
|
220
|
+
return {
|
|
221
|
+
data: {
|
|
222
|
+
resourceId: result.resourceId,
|
|
223
|
+
url: result.url,
|
|
224
|
+
status: result.status,
|
|
225
|
+
price,
|
|
226
|
+
cacheEligible,
|
|
227
|
+
missing,
|
|
228
|
+
deskUrl,
|
|
229
|
+
...candidateInfo !== void 0 ? { candidate: candidateInfo } : {},
|
|
230
|
+
...result.warnings.length > 0 ? { warnings: result.warnings } : {}
|
|
231
|
+
},
|
|
232
|
+
humanLines: human
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
async function readMarkdown(file) {
|
|
236
|
+
try {
|
|
237
|
+
return await readFile(file, "utf8");
|
|
238
|
+
} catch (err) {
|
|
239
|
+
throw new CliError("USAGE", `Could not read ${JSON.stringify(file)}`, {
|
|
240
|
+
fix: "Pass a path to a readable Markdown file, e.g. `tenjin publish post.md`.",
|
|
241
|
+
cause: err
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function resolveStatus(args, frontmatter) {
|
|
246
|
+
if (args.draft === true) return "draft";
|
|
247
|
+
const fm = frontmatter.status;
|
|
248
|
+
if (fm === void 0) return "published";
|
|
249
|
+
if (typeof fm !== "string" || !PUBLISH_STATUSES.includes(fm)) {
|
|
250
|
+
throw new CliError("USAGE", `Invalid status ${JSON.stringify(fm)} in frontmatter.`, {
|
|
251
|
+
fix: "Use status: draft | published | unlisted, or pass --draft."
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return fm;
|
|
255
|
+
}
|
|
256
|
+
function resolveTitle(frontmatter, body) {
|
|
257
|
+
const fm = frontmatter.title;
|
|
258
|
+
if (fm !== void 0) {
|
|
259
|
+
if (typeof fm !== "string") {
|
|
260
|
+
throw new CliError("USAGE", "frontmatter title must be a single string.");
|
|
261
|
+
}
|
|
262
|
+
return fm.trim();
|
|
263
|
+
}
|
|
264
|
+
const headings = headingOutline(body);
|
|
265
|
+
const h1 = headings.find((h) => h.level === 1) ?? headings[0];
|
|
266
|
+
return h1?.text;
|
|
267
|
+
}
|
|
268
|
+
function resolveTags(frontmatter) {
|
|
269
|
+
const fm = frontmatter.tags;
|
|
270
|
+
if (fm === void 0) return void 0;
|
|
271
|
+
if (typeof fm === "string") return [fm];
|
|
272
|
+
if (Array.isArray(fm)) return fm;
|
|
273
|
+
throw new CliError("USAGE", "frontmatter tags must be a list of strings.");
|
|
274
|
+
}
|
|
275
|
+
function expectString(frontmatter, key) {
|
|
276
|
+
const fm = frontmatter[key];
|
|
277
|
+
if (fm === void 0) return void 0;
|
|
278
|
+
if (typeof fm !== "string") {
|
|
279
|
+
throw new CliError("USAGE", `frontmatter ${key} must be a single string.`);
|
|
280
|
+
}
|
|
281
|
+
return fm;
|
|
282
|
+
}
|
|
283
|
+
function resolvePrice(args, frontmatter, defaultAtomic) {
|
|
284
|
+
if (args.price !== void 0) return parseUsdToAtomic(args.price);
|
|
285
|
+
const fm = frontmatter.price;
|
|
286
|
+
if (fm !== void 0) {
|
|
287
|
+
if (typeof fm !== "string") {
|
|
288
|
+
throw new CliError("USAGE", 'frontmatter price must be a decimal-USD string, e.g. "0.10".');
|
|
289
|
+
}
|
|
290
|
+
return parseUsdToAtomic(fm);
|
|
291
|
+
}
|
|
292
|
+
return defaultAtomic;
|
|
293
|
+
}
|
|
294
|
+
function cardFlagsFrom(args) {
|
|
295
|
+
return {
|
|
296
|
+
...args.question !== void 0 && args.question.length > 0 ? { question: args.question } : {},
|
|
297
|
+
...args.task !== void 0 && args.task.length > 0 ? { task: args.task } : {},
|
|
298
|
+
...args.scope !== void 0 ? { scope: args.scope } : {},
|
|
299
|
+
...args.exclusions !== void 0 ? { exclusions: args.exclusions } : {},
|
|
300
|
+
...args.asOf !== void 0 ? { asOf: args.asOf } : {},
|
|
301
|
+
...args.validUntil !== void 0 ? { validUntil: args.validUntil } : {},
|
|
302
|
+
...args.artifactType !== void 0 ? { artifactType: args.artifactType } : {},
|
|
303
|
+
...args.temporalMode !== void 0 ? { temporalMode: args.temporalMode } : {},
|
|
304
|
+
...args.provenance !== void 0 ? { provenance: args.provenance } : {},
|
|
305
|
+
...args.methodology !== void 0 ? { methodology: args.methodology } : {},
|
|
306
|
+
...args.appliesTo !== void 0 && args.appliesTo.length > 0 ? { appliesTo: parseAppliesToFlags(args.appliesTo) } : {}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function cardScanText(card) {
|
|
310
|
+
if (card === void 0) return "";
|
|
311
|
+
const parts = [];
|
|
312
|
+
const add = (v) => {
|
|
313
|
+
if (v !== void 0) parts.push(v);
|
|
314
|
+
};
|
|
315
|
+
add(card.scope);
|
|
316
|
+
add(card.exclusions);
|
|
317
|
+
add(card.provenanceSummary);
|
|
318
|
+
add(card.methodologySummary);
|
|
319
|
+
add(card.mediaType);
|
|
320
|
+
add(card.maintenanceCadence);
|
|
321
|
+
add(card.asOf);
|
|
322
|
+
add(card.validUntil);
|
|
323
|
+
add(card.estimatedPaidInputCost);
|
|
324
|
+
if (card.questionsAnswered !== void 0) parts.push(...card.questionsAnswered);
|
|
325
|
+
if (card.tasksSupported !== void 0) parts.push(...card.tasksSupported);
|
|
326
|
+
if (card.appliesTo !== void 0) {
|
|
327
|
+
for (const values of Object.values(card.appliesTo)) parts.push(...values);
|
|
328
|
+
}
|
|
329
|
+
return parts.join("\n");
|
|
330
|
+
}
|
|
331
|
+
function blockMessage(blocking) {
|
|
332
|
+
return `Publish blocked: the file contains ${describeFindings(blocking)}.`;
|
|
333
|
+
}
|
|
334
|
+
function confirmMessage(warnCount, priceUsd) {
|
|
335
|
+
return warnCount > 0 ? `Publish needs confirmation: ${warnCount} finding(s), price $${priceUsd}.` : `Publish needs confirmation: price $${priceUsd}.`;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export {
|
|
339
|
+
runPublish
|
|
340
|
+
};
|
|
341
|
+
//# sourceMappingURL=chunk-AWQ6A4CI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/publish.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { resolveContextSettings, resolvePublishSettings } from '../lib/settings';\nimport { parsePublishModeFlag } from '../lib/config';\nimport { readCandidate, dropCandidate, type CandidateRecord } from '../lib/candidate-store';\nimport { markSearchResolved } from '../lib/search-store';\nimport { UUID_RE } from '../lib/ids';\nimport { scan, type ScanContext, type ScanFinding } from '../lib/scan';\nimport { deriveProjectMarkers } from '../lib/scan-context';\nimport { headingOutline } from '../lib/markdown';\nimport { sanitizeForTerminal } from '../lib/output';\nimport { trimSlash } from '../lib/url';\nimport {\n deriveCard,\n localCardEligibility,\n missingSentences,\n parseAppliesToFlags,\n parseFrontmatter,\n type CardFlags,\n type Frontmatter,\n type ResourceCardInput,\n} from '../lib/card';\nimport {\n publishPost,\n PUBLISH_STATUSES,\n type PublishInput,\n type PublishStatus,\n} from '../lib/posts-api';\nimport {\n dedupeFindings,\n describeFindings,\n needsConfirmation,\n publicFinding,\n resolveWriteAuth,\n writeModeNotices,\n} from '../lib/consent';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin publish <file.md>` (or `--candidate <id>`): read the Markdown, parse\n * frontmatter for post + answer-card fields, run the deterministic scan (every\n * mode), gate on the D38\n * consent cascade, then write via the session key (minted on first use) or the\n * plain-SIWX fallback and return a compact receipt. The ordering is the point and\n * is enforced here: scan and consent BEFORE any wallet touch or network write.\n *\n * Exit codes: 0 success (incl. an ineligible-but-published card), 2 usage, 3\n * needs_confirmation / non-bypassable publish_blocked, 4 a write failure after\n * approval.\n */\n\nexport interface PublishArgs {\n /** The Markdown file to publish; mutually exclusive with --candidate. */\n file?: string;\n /** A parked candidate id to publish (its draft.md); mutually exclusive with <file>. */\n candidate?: string;\n draft?: boolean;\n yes?: boolean;\n /** Raw `--mode` (review|auto|full-auto); validated at the edge (USAGE on a bad value). */\n mode?: string;\n /** Top-level post price, decimal USD at the edge (O1). */\n price?: string;\n question?: string[];\n task?: string[];\n scope?: string;\n exclusions?: string;\n appliesTo?: string[];\n asOf?: string;\n validUntil?: string;\n artifactType?: string;\n temporalMode?: string;\n provenance?: string;\n methodology?: string;\n}\n\nexport interface PublishDeps {\n fetchImpl?: typeof fetch;\n provider?: WalletProvider;\n /** Force the plain-SIWX write path (default: session key unless TENJIN_NO_SESSION=1). */\n useSession?: boolean;\n /** Environment seam (mode, base-url, TENJIN_NO_SESSION); defaults to process.env. */\n env?: NodeJS.ProcessEnv;\n /** Working directory for the `.tenjin.json` walk; defaults to process.cwd(). */\n cwd?: string;\n}\n\nexport async function runPublish(\n args: PublishArgs,\n ctx: CommandContext,\n deps: PublishDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const cwd = deps.cwd ?? process.cwd();\n // Validate --mode at the edge (USAGE, exit 2) BEFORE any consent resolution: a\n // typo like `--mode Review` must never be silently dropped onto a looser mode\n // and publish unconfirmed. Mirrors install's --publish-mode edge check.\n if (args.mode !== undefined) parsePublishModeFlag(args.mode, '--mode');\n\n // The content comes from EITHER a <file> or a parked --candidate, never both,\n // never neither. A candidate resolves to its draft.md (and prefills its question).\n const { raw, candidate } = await resolveSource(args, ctx.dataDir);\n const { frontmatter, body } = parseFrontmatter(raw);\n\n const status = resolveStatus(args, frontmatter);\n const title = resolveTitle(frontmatter, body);\n const tags = resolveTags(frontmatter);\n const excerpt = expectString(frontmatter, 'excerpt');\n const handle = expectString(frontmatter, 'handle');\n // A candidate's stored question prefills questionsAnswered, but only as a\n // fallback: an explicit --question OR a frontmatter questionsAnswered still wins.\n const cardFlags = cardFlagsFrom(args);\n if (\n candidate?.meta.question !== undefined &&\n cardFlags.question === undefined &&\n frontmatter.questionsAnswered === undefined\n ) {\n cardFlags.question = [candidate.meta.question];\n }\n const card = deriveCard(frontmatter, cardFlags);\n\n // The consent cascade + resolved price (global < project < env < flag), with the\n // full-auto loosening gate. Its downgrade warnings go to stderr, not the receipt.\n const settings = await resolvePublishSettings({\n dataDir: ctx.dataDir,\n cwd,\n ...(args.mode !== undefined ? { flag: args.mode } : {}),\n env,\n });\n // The resolver's downgrade warnings, a mistyped env mode, and the one-line\n // explainer for an unconfigured mode: all stderr, all invisible to --json.\n writeModeNotices(\n ctx.io.stderr,\n settings,\n env,\n 'each publish asks you once. Set auto to publish clean scans automatically',\n );\n const priceAtomic = resolvePrice(args, frontmatter, settings.defaultPriceAtomic);\n\n // The scan runs in EVERY mode (D38): it gates the gate, it does not replace it.\n // Scan the whole file AND the derived card's text, so a secret reaches the same\n // gates whether it arrives in the body, in frontmatter, or via a card-authoring\n // flag (--provenance, --scope, …) — the card ships to the PUBLIC card, so a flag\n // secret must block exactly like an in-file one. Dedupe by check+excerpt so a\n // frontmatter value (present in both raw and the card) is not double-counted.\n // The scan context carries the source project's git remote slugs (offline FS\n // read, best-effort): a draft quoting its own project's repo/org warns as a\n // private-by-default reference (open-questions publishing-safety check-set).\n // Markers derive from the DRAFT's project, not the shell's cwd (review r5): a\n // file publish walks up from the file's own directory, and a parked candidate\n // uses the source project recorded in its meta at park time — the pen lives\n // under ~/.tenjin, so the process cwd is unrelated to the draft on both paths.\n const markerRoot =\n candidate !== undefined\n ? candidate.meta.sourceProject\n : args.file !== undefined\n ? dirname(resolve(cwd, args.file))\n : cwd;\n const scanContext: ScanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };\n const findings = dedupeFindings([\n ...scan(raw, scanContext),\n ...scan(cardScanText(card), scanContext),\n ]);\n const blocking = findings.filter((f) => f.severity === 'block');\n const warns = findings.filter((f) => f.severity === 'warn');\n\n const eligibility = localCardEligibility(card);\n const price = toMoney(priceAtomic);\n\n // A hard-block finding refuses in EVERY mode and is never clearable by --yes or\n // full-auto — the same non-bypassable posture as buy's price cap.\n if (blocking.length > 0) {\n throw new CliError('PUBLISH_BLOCKED', blockMessage(blocking), {\n fix: 'Remove the secret from the file (it is never masked away by --yes), then re-run.',\n details: {\n mode: settings.mode,\n findings: blocking.map(publicFinding),\n price: { atomic: price.atomic, usd: price.usd },\n },\n });\n }\n\n // --yes clears the soft findings and the review confirm alike.\n if (needsConfirmation(settings.mode, warns.length) && args.yes !== true) {\n throw new CliError('NEEDS_CONFIRMATION', confirmMessage(warns.length, price.usd), {\n fix: 'Review the findings, then re-run with --yes (or resolve the source and re-run).',\n details: {\n mode: settings.mode,\n price: { atomic: price.atomic, usd: price.usd },\n findings: warns.map(publicFinding),\n card: eligibility,\n target: { status, titlePreview: sanitizeForTerminal(title ?? '(untitled draft)') },\n },\n });\n }\n\n // Approved (or nothing to confirm): from here a wallet is required. The write\n // base URL is resolved through the shared settings seam and used for BOTH the\n // SIWX/session header domain and the POST host, so the two never diverge.\n const runtime = await resolveContextSettings(ctx);\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n await describeWallet(provider); // surfaces WALLET_MISSING with its own fix\n const signer = await provider.getSigner();\n const auth = resolveWriteAuth({\n signer,\n baseUrl: runtime.baseUrl,\n dataDir: ctx.dataDir,\n // A publish always writes.\n scope: 'read+write',\n ...(deps.useSession !== undefined ? { useSession: deps.useSession } : {}),\n env,\n });\n\n const input: PublishInput = {\n ...(title !== undefined ? { title } : {}),\n bodyMd: body,\n ...(excerpt !== undefined ? { excerpt } : {}),\n ...(tags !== undefined ? { tags } : {}),\n priceAtomic,\n ...(handle !== undefined ? { handle } : {}),\n status,\n ...(card !== undefined ? { resource: card } : {}),\n };\n\n const result = await publishPost(input, auth, {\n baseUrl: runtime.baseUrl,\n timeoutMs: ctx.flags.timeout,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n // ONLY on a successful publish is the candidate cleared from the pending store\n // (a refusal or a write failure left it parked, above). The clear is BEST-EFFORT:\n // the piece is already published, so a failing drop must NOT report the publish as\n // failed — that would invite a retry and double-publish. Keep ok:true, report\n // cleared:false with a warning, and let the human drop it manually.\n const candidateInfo =\n candidate !== undefined ? await clearPublishedCandidate(ctx, candidate.id) : undefined;\n // The strongest way to close a loop: the answer is on the marketplace. Only a\n // candidate publish can name the search it answers, so a bare file publish\n // leaves the loop open and the Stop hook keeps the reminder. Local bookkeeping,\n // best-effort, never throws.\n if (candidate !== undefined) {\n await markSearchResolved(ctx.dataDir, candidate.meta.searchId, 'publish');\n }\n return receipt(result, runtime.baseUrl, candidateInfo);\n}\n\ninterface CandidateReceipt {\n id: string;\n cleared: boolean;\n warning?: string;\n}\n\nasync function clearPublishedCandidate(ctx: CommandContext, id: string): Promise<CandidateReceipt> {\n try {\n if (await dropCandidate(ctx.dataDir, id)) return { id, cleared: true };\n // The dir was already gone (a concurrent drop): nothing to clear, not an error.\n const warning = `Published, but candidate ${id} was already gone; nothing to clear.`;\n ctx.io.stderr.write(`${warning}\\n`);\n return { id, cleared: false, warning };\n } catch (err) {\n const warning = `Published successfully, but could not clear candidate ${id}: ${errorMessage(err)}. Remove it with \\`tenjin candidate drop ${id}\\`.`;\n ctx.io.stderr.write(`${warning}\\n`);\n return { id, cleared: false, warning };\n }\n}\n\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * Resolve the publish source: a <file>, or a --candidate's draft.md, exclusively.\n * Both or neither is USAGE, and a malformed/unknown candidate id is USAGE before\n * any wallet touch — the whole point of parking it locally is to fail cheap here.\n */\nasync function resolveSource(\n args: PublishArgs,\n dataDir: string,\n): Promise<{ raw: string; candidate?: CandidateRecord }> {\n if (args.candidate !== undefined) {\n if (args.file !== undefined) {\n throw new CliError('USAGE', 'Pass EITHER a file or --candidate, not both.', {\n fix: 'Publish a file with `tenjin publish post.md`, or a candidate with `--candidate <id>`.',\n });\n }\n if (!UUID_RE.test(args.candidate)) {\n throw new CliError('USAGE', `Invalid candidate id: ${JSON.stringify(args.candidate)}`, {\n fix: 'Pass a candidate id from `tenjin candidate list`.',\n });\n }\n // Read-then-act (read here, drop after a successful publish) is not atomic, but\n // the candidate store is a single-user local dir; a concurrent drop between the\n // two is accepted, and the post-success clear is best-effort anyway.\n const record = await readCandidate(dataDir, args.candidate);\n if (record === null) {\n throw new CliError('USAGE', `Unknown candidate: ${JSON.stringify(args.candidate)}`, {\n fix: 'List parked candidates with `tenjin candidate list`.',\n });\n }\n return { raw: await readDraft(record), candidate: record };\n }\n if (args.file === undefined) {\n throw new CliError('USAGE', 'Nothing to publish.', {\n fix: 'Pass a Markdown file (`tenjin publish post.md`) or `--candidate <id>`.',\n });\n }\n return { raw: await readMarkdown(args.file) };\n}\n\n/** Read a candidate's draft.md; a readable dir with an unreadable draft is a torn\n * candidate (INTERNAL), not the caller's usage error. */\nasync function readDraft(record: CandidateRecord): Promise<string> {\n try {\n return await readFile(record.draftPath, 'utf8');\n } catch (err) {\n throw new CliError('INTERNAL', `Candidate ${record.id} is missing its draft.`, {\n fix: `Drop it with \\`tenjin candidate drop ${record.id}\\` and re-add the draft.`,\n cause: err,\n });\n }\n}\n\nfunction receipt(\n result: Awaited<ReturnType<typeof publishPost>>,\n baseUrl: string,\n candidateInfo?: CandidateReceipt,\n): CommandResult {\n const price = toMoney(result.priceAtomic);\n const missing = missingSentences(result.cacheEligibleMissing).map(sanitizeForTerminal);\n const cacheEligible = result.cacheEligible ?? false;\n const deskUrl = `${trimSlash(baseUrl)}/desk`;\n const title = sanitizeForTerminal(result.title);\n // status and url are server-sent open strings (posts-api declares both as bare\n // z.string()), so they get the same treatment as the title beside them: this\n // line is what an author reads to learn where their piece went.\n const human = [\n `Published ${title} (${sanitizeForTerminal(result.status)}) for ${price.usd} USD → ${sanitizeForTerminal(result.url)}`,\n cacheEligible\n ? 'Answer card is search-eligible.'\n : missing.length > 0\n ? `Answer card not search-eligible yet: ${missing.join(' ')}`\n : 'Published as a browse-only document (no answer card).',\n ...(candidateInfo?.cleared === true ? [`Cleared candidate ${candidateInfo.id}.`] : []),\n ...result.warnings.map((w) => `warning: ${sanitizeForTerminal(w)}`),\n ];\n return {\n data: {\n resourceId: result.resourceId,\n url: result.url,\n status: result.status,\n price,\n cacheEligible,\n missing,\n deskUrl,\n ...(candidateInfo !== undefined ? { candidate: candidateInfo } : {}),\n ...(result.warnings.length > 0 ? { warnings: result.warnings } : {}),\n },\n humanLines: human,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Field resolution.\n// ---------------------------------------------------------------------------\n\nasync function readMarkdown(file: string): Promise<string> {\n try {\n return await readFile(file, 'utf8');\n } catch (err) {\n throw new CliError('USAGE', `Could not read ${JSON.stringify(file)}`, {\n fix: 'Pass a path to a readable Markdown file, e.g. `tenjin publish post.md`.',\n cause: err,\n });\n }\n}\n\nfunction resolveStatus(args: PublishArgs, frontmatter: Frontmatter): PublishStatus {\n if (args.draft === true) return 'draft';\n const fm = frontmatter.status;\n if (fm === undefined) return 'published';\n if (typeof fm !== 'string' || !(PUBLISH_STATUSES as readonly string[]).includes(fm)) {\n throw new CliError('USAGE', `Invalid status ${JSON.stringify(fm)} in frontmatter.`, {\n fix: 'Use status: draft | published | unlisted, or pass --draft.',\n });\n }\n return fm as PublishStatus;\n}\n\nfunction resolveTitle(frontmatter: Frontmatter, body: string): string | undefined {\n const fm = frontmatter.title;\n if (fm !== undefined) {\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', 'frontmatter title must be a single string.');\n }\n return fm.trim();\n }\n // Fall back to the first heading (level 1 preferred) so a plain `# Title` post\n // needs no frontmatter.\n const headings = headingOutline(body);\n const h1 = headings.find((h) => h.level === 1) ?? headings[0];\n return h1?.text;\n}\n\nfunction resolveTags(frontmatter: Frontmatter): string[] | undefined {\n const fm = frontmatter.tags;\n if (fm === undefined) return undefined;\n if (typeof fm === 'string') return [fm];\n if (Array.isArray(fm)) return fm;\n throw new CliError('USAGE', 'frontmatter tags must be a list of strings.');\n}\n\nfunction expectString(frontmatter: Frontmatter, key: string): string | undefined {\n const fm = frontmatter[key];\n if (fm === undefined) return undefined;\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', `frontmatter ${key} must be a single string.`);\n }\n return fm;\n}\n\nfunction resolvePrice(args: PublishArgs, frontmatter: Frontmatter, defaultAtomic: string): string {\n if (args.price !== undefined) return parseUsdToAtomic(args.price);\n const fm = frontmatter.price;\n if (fm !== undefined) {\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', 'frontmatter price must be a decimal-USD string, e.g. \"0.10\".');\n }\n return parseUsdToAtomic(fm);\n }\n return defaultAtomic;\n}\n\nfunction cardFlagsFrom(args: PublishArgs): CardFlags {\n return {\n ...(args.question !== undefined && args.question.length > 0 ? { question: args.question } : {}),\n ...(args.task !== undefined && args.task.length > 0 ? { task: args.task } : {}),\n ...(args.scope !== undefined ? { scope: args.scope } : {}),\n ...(args.exclusions !== undefined ? { exclusions: args.exclusions } : {}),\n ...(args.asOf !== undefined ? { asOf: args.asOf } : {}),\n ...(args.validUntil !== undefined ? { validUntil: args.validUntil } : {}),\n ...(args.artifactType !== undefined ? { artifactType: args.artifactType } : {}),\n ...(args.temporalMode !== undefined ? { temporalMode: args.temporalMode } : {}),\n ...(args.provenance !== undefined ? { provenance: args.provenance } : {}),\n ...(args.methodology !== undefined ? { methodology: args.methodology } : {}),\n ...(args.appliesTo !== undefined && args.appliesTo.length > 0\n ? { appliesTo: parseAppliesToFlags(args.appliesTo) }\n : {}),\n };\n}\n\n/**\n * The derived card's free-text values as one newline-joined document, so the scan\n * covers card-flag input (which never touches the file) at the same severity as\n * the body. Empty when there is no card.\n */\nfunction cardScanText(card: ResourceCardInput | undefined): string {\n if (card === undefined) return '';\n const parts: string[] = [];\n const add = (v: string | undefined): void => {\n if (v !== undefined) parts.push(v);\n };\n add(card.scope);\n add(card.exclusions);\n add(card.provenanceSummary);\n add(card.methodologySummary);\n add(card.mediaType);\n add(card.maintenanceCadence);\n add(card.asOf);\n add(card.validUntil);\n add(card.estimatedPaidInputCost);\n if (card.questionsAnswered !== undefined) parts.push(...card.questionsAnswered);\n if (card.tasksSupported !== undefined) parts.push(...card.tasksSupported);\n if (card.appliesTo !== undefined) {\n for (const values of Object.values(card.appliesTo)) parts.push(...values);\n }\n return parts.join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Finding + message shaping.\n// ---------------------------------------------------------------------------\n\nfunction blockMessage(blocking: ScanFinding[]): string {\n return `Publish blocked: the file contains ${describeFindings(blocking)}.`;\n}\n\nfunction confirmMessage(warnCount: number, priceUsd: string): string {\n return warnCount > 0\n ? `Publish needs confirmation: ${warnCount} finding(s), price $${priceUsd}.`\n : `Publish needs confirmation: price $${priceUsd}.`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AAwFjC,eAAsB,WACpB,MACA,KACA,OAAoB,CAAC,GACG;AACxB,QAAM,MAAM,KAAK,OAAO,QAAQ;AAChC,QAAM,MAAM,KAAK,OAAO,QAAQ,IAAI;AAIpC,MAAI,KAAK,SAAS,OAAW,sBAAqB,KAAK,MAAM,QAAQ;AAIrE,QAAM,EAAE,KAAK,UAAU,IAAI,MAAM,cAAc,MAAM,IAAI,OAAO;AAChE,QAAM,EAAE,aAAa,KAAK,IAAI,iBAAiB,GAAG;AAElD,QAAM,SAAS,cAAc,MAAM,WAAW;AAC9C,QAAM,QAAQ,aAAa,aAAa,IAAI;AAC5C,QAAM,OAAO,YAAY,WAAW;AACpC,QAAM,UAAU,aAAa,aAAa,SAAS;AACnD,QAAM,SAAS,aAAa,aAAa,QAAQ;AAGjD,QAAM,YAAY,cAAc,IAAI;AACpC,MACE,WAAW,KAAK,aAAa,UAC7B,UAAU,aAAa,UACvB,YAAY,sBAAsB,QAClC;AACA,cAAU,WAAW,CAAC,UAAU,KAAK,QAAQ;AAAA,EAC/C;AACA,QAAM,OAAO,WAAW,aAAa,SAAS;AAI9C,QAAM,WAAW,MAAM,uBAAuB;AAAA,IAC5C,SAAS,IAAI;AAAA,IACb;AAAA,IACA,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,IACrD;AAAA,EACF,CAAC;AAGD;AAAA,IACE,IAAI,GAAG;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,c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,SAAS,IACxD,EAAE,WAAW,oBAAoB,KAAK,SAAS,EAAE,IACjD,CAAC;AAAA,EACP;AACF;AAOA,SAAS,aAAa,MAA6C;AACjE,MAAI,SAAS,OAAW,QAAO;AAC/B,QAAM,QAAkB,CAAC;AACzB,QAAM,MAAM,CAAC,MAAgC;AAC3C,QAAI,MAAM,OAAW,OAAM,KAAK,CAAC;AAAA,EACnC;AACA,MAAI,KAAK,KAAK;AACd,MAAI,KAAK,UAAU;AACnB,MAAI,KAAK,iBAAiB;AAC1B,MAAI,KAAK,kBAAkB;AAC3B,MAAI,KAAK,SAAS;AAClB,MAAI,KAAK,kBAAkB;AAC3B,MAAI,KAAK,IAAI;AACb,MAAI,KAAK,UAAU;AACnB,MAAI,KAAK,sBAAsB;AAC/B,MAAI,KAAK,sBAAsB,OAAW,OAAM,KAAK,GAAG,KAAK,iBAAiB;AAC9E,MAAI,KAAK,mBAAmB,OAAW,OAAM,KAAK,GAAG,KAAK,cAAc;AACxE,MAAI,KAAK,cAAc,QAAW;AAChC,eAAW,UAAU,OAAO,OAAO,KAAK,SAAS,EAAG,OAAM,KAAK,GAAG,MAAM;AAAA,EAC1E;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AAMA,SAAS,aAAa,UAAiC;AACrD,SAAO,sCAAsC,iBAAiB,QAAQ,CAAC;AACzE;AAEA,SAAS,eAAe,WAAmB,UAA0B;AACnE,SAAO,YAAY,IACf,+BAA+B,SAAS,uBAAuB,QAAQ,MACvE,sCAAsC,QAAQ;AACpD;","names":[]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
parseConfirmPolicy
|
|
4
|
+
} from "./chunk-FKSAUOJU.js";
|
|
5
|
+
import {
|
|
6
|
+
PublishModeSchema,
|
|
7
|
+
SEND_MAX_UNSET,
|
|
8
|
+
loadRawConfig,
|
|
9
|
+
parseUsdToAtomic,
|
|
10
|
+
resolvePublishDefaultPrice,
|
|
11
|
+
resolvePublishMode,
|
|
12
|
+
resolveSettings
|
|
13
|
+
} from "./chunk-36X2CA3N.js";
|
|
14
|
+
import {
|
|
15
|
+
CliError,
|
|
16
|
+
external_exports
|
|
17
|
+
} from "./chunk-PZRAAAY2.js";
|
|
18
|
+
|
|
19
|
+
// src/lib/settings.ts
|
|
20
|
+
import { execFile } from "child_process";
|
|
21
|
+
import { readFile, stat } from "fs/promises";
|
|
22
|
+
import { homedir } from "os";
|
|
23
|
+
import { dirname, join } from "path";
|
|
24
|
+
async function resolveContextSettings(ctx) {
|
|
25
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
26
|
+
const s = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env: process.env });
|
|
27
|
+
return {
|
|
28
|
+
baseUrl: s.baseUrl.value,
|
|
29
|
+
rpcUrl: s.rpcUrl.value,
|
|
30
|
+
evalCohort: s.evalCohort.value,
|
|
31
|
+
sendMaxAmountAtomic: s.sendMaxAmount.value === SEND_MAX_UNSET ? SEND_MAX_UNSET : s.sendMaxAmount.value === "none" ? null : BigInt(s.sendMaxAmount.value),
|
|
32
|
+
policy: {
|
|
33
|
+
maxAutoSpendAtomic: BigInt(s.maxAutoSpend.value),
|
|
34
|
+
sessionBudgetAtomic: BigInt(s.sessionBudget.value),
|
|
35
|
+
confirm: parseConfirmPolicy(s.confirm.value),
|
|
36
|
+
allowlistCreators: s.allowlistCreators.value
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var PROJECT_CONFIG_FILE = ".tenjin.json";
|
|
41
|
+
var ProjectConfigSchema = external_exports.object({
|
|
42
|
+
publish: external_exports.object({
|
|
43
|
+
mode: PublishModeSchema.optional(),
|
|
44
|
+
defaultPrice: external_exports.string().optional()
|
|
45
|
+
}).passthrough().optional()
|
|
46
|
+
}).passthrough();
|
|
47
|
+
async function resolvePublishSettings(input, deps = {}) {
|
|
48
|
+
const env = input.env ?? process.env;
|
|
49
|
+
const config = await loadRawConfig(input.dataDir);
|
|
50
|
+
const project = await loadProjectConfig(input.cwd, deps);
|
|
51
|
+
const layer = project?.layer;
|
|
52
|
+
const mode = resolvePublishMode({ config, project: layer, env, flag: input.flag });
|
|
53
|
+
const price = resolvePublishDefaultPrice({ config, project: layer });
|
|
54
|
+
const warnings = mode.downgradedWarning !== void 0 ? [mode.downgradedWarning] : [];
|
|
55
|
+
return {
|
|
56
|
+
mode: mode.value,
|
|
57
|
+
modeSource: mode.source,
|
|
58
|
+
defaultPriceAtomic: price.value,
|
|
59
|
+
defaultPriceSource: price.source,
|
|
60
|
+
warnings,
|
|
61
|
+
...project !== null ? { projectConfigPath: project.path } : {}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function loadProjectConfig(cwd, deps = {}) {
|
|
65
|
+
const path = await findProjectConfigFile(cwd, deps);
|
|
66
|
+
if (path === null) return null;
|
|
67
|
+
let json;
|
|
68
|
+
try {
|
|
69
|
+
json = JSON.parse(await readFile(path, "utf8"));
|
|
70
|
+
} catch (err) {
|
|
71
|
+
throw new CliError("CONFIG_INVALID", `${PROJECT_CONFIG_FILE} at ${path} could not be read`, {
|
|
72
|
+
fix: `Fix or delete ${path} (must be a readable JSON file).`,
|
|
73
|
+
cause: err
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const parsed = ProjectConfigSchema.safeParse(json);
|
|
77
|
+
if (!parsed.success) {
|
|
78
|
+
throw new CliError("CONFIG_INVALID", `${PROJECT_CONFIG_FILE} at ${path} is invalid`, {
|
|
79
|
+
fix: `Correct the reported keys in ${path}, or delete it.`,
|
|
80
|
+
details: parsed.error.issues
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const isGitignored = deps.isGitignored ?? defaultIsGitignored;
|
|
84
|
+
const gitignored = await isGitignored(path);
|
|
85
|
+
const layer = { gitignored };
|
|
86
|
+
if (parsed.data.publish !== void 0) {
|
|
87
|
+
const { mode, defaultPrice } = parsed.data.publish;
|
|
88
|
+
layer.publish = {
|
|
89
|
+
...mode !== void 0 ? { mode } : {},
|
|
90
|
+
...defaultPrice !== void 0 ? { defaultPrice: parseProjectPrice(defaultPrice, path) } : {}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { path, layer };
|
|
94
|
+
}
|
|
95
|
+
function parseProjectPrice(decimalUsd, path) {
|
|
96
|
+
try {
|
|
97
|
+
return parseUsdToAtomic(decimalUsd);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
throw new CliError(
|
|
100
|
+
"CONFIG_INVALID",
|
|
101
|
+
`${PROJECT_CONFIG_FILE} at ${path} has an invalid publish.defaultPrice`,
|
|
102
|
+
{ fix: 'Use a non-negative decimal USD amount like "0.10".', cause: err }
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function findProjectConfigFile(cwd, deps) {
|
|
107
|
+
const homeDir = deps.homeDir ?? homedir();
|
|
108
|
+
const isForeignOwned = deps.isForeignOwned ?? defaultIsForeignOwned;
|
|
109
|
+
const warn = deps.warn ?? ((message) => process.stderr.write(`${message}
|
|
110
|
+
`));
|
|
111
|
+
let dir = cwd;
|
|
112
|
+
for (; ; ) {
|
|
113
|
+
const candidate = join(dir, PROJECT_CONFIG_FILE);
|
|
114
|
+
if (await pathExists(candidate)) {
|
|
115
|
+
if (await isForeignOwned(candidate)) {
|
|
116
|
+
warn(`Ignoring ${candidate}: not owned by the current user.`);
|
|
117
|
+
} else {
|
|
118
|
+
return candidate;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (await pathExists(join(dir, ".git"))) return null;
|
|
122
|
+
if (dir === homeDir) return null;
|
|
123
|
+
const parent = dirname(dir);
|
|
124
|
+
if (parent === dir) return null;
|
|
125
|
+
dir = parent;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function defaultIsForeignOwned(filePath) {
|
|
129
|
+
const uid = process.getuid?.();
|
|
130
|
+
if (uid === void 0) return false;
|
|
131
|
+
try {
|
|
132
|
+
return (await stat(filePath)).uid !== uid;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function pathExists(path) {
|
|
138
|
+
try {
|
|
139
|
+
await stat(path);
|
|
140
|
+
return true;
|
|
141
|
+
} catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function defaultIsGitignored(filePath) {
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
execFile(
|
|
148
|
+
"git",
|
|
149
|
+
["check-ignore", "--quiet", "--", filePath],
|
|
150
|
+
{ cwd: dirname(filePath) },
|
|
151
|
+
(err) => resolve(err === null)
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export {
|
|
157
|
+
resolveContextSettings,
|
|
158
|
+
resolvePublishSettings,
|
|
159
|
+
loadProjectConfig,
|
|
160
|
+
pathExists
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=chunk-BJJ5BQO6.js.map
|