tenjin-cli 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +54 -7
- package/README.md +161 -257
- package/dist/{_esm-FEASBWRP.js → _esm-CE7KNONL.js} +9 -10
- package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
- package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
- package/dist/chunk-2E6GVIRP.js +888 -0
- package/dist/chunk-2E6GVIRP.js.map +1 -0
- package/dist/chunk-2G2WLVHB.js +102 -0
- package/dist/chunk-2G2WLVHB.js.map +1 -0
- package/dist/chunk-2QYORQBF.js +55 -0
- package/dist/chunk-2QYORQBF.js.map +1 -0
- package/dist/chunk-3BS55ANY.js +245 -0
- package/dist/chunk-3BS55ANY.js.map +1 -0
- package/dist/chunk-3KKKB2AQ.js +40 -0
- package/dist/chunk-3KKKB2AQ.js.map +1 -0
- package/dist/chunk-4AS52HUG.js +165 -0
- package/dist/chunk-4AS52HUG.js.map +1 -0
- package/dist/chunk-4M5FBWT5.js +368 -0
- package/dist/chunk-4M5FBWT5.js.map +1 -0
- package/dist/chunk-5FYKPQNX.js +1784 -0
- package/dist/chunk-5FYKPQNX.js.map +1 -0
- package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
- package/dist/chunk-5KD5HRAJ.js +241 -0
- package/dist/chunk-5KD5HRAJ.js.map +1 -0
- package/dist/chunk-72UHZRG6.js +231 -0
- package/dist/chunk-72UHZRG6.js.map +1 -0
- package/dist/chunk-7ACHDNJA.js +155 -0
- package/dist/chunk-7ACHDNJA.js.map +1 -0
- package/dist/chunk-7QKHZQKW.js +1680 -0
- package/dist/chunk-7QKHZQKW.js.map +1 -0
- package/dist/chunk-A36LQPHV.js +29 -0
- package/dist/chunk-A36LQPHV.js.map +1 -0
- package/dist/{chunk-UGX7YPX2.js → chunk-AWQPGIR6.js} +7 -9
- package/dist/{chunk-UGX7YPX2.js.map → chunk-AWQPGIR6.js.map} +1 -1
- package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
- package/dist/{chunk-XJIW7USF.js → chunk-BTX2QE2Y.js} +115 -11
- package/dist/chunk-BTX2QE2Y.js.map +1 -0
- package/dist/{chunk-OYMYCW7J.js → chunk-CCDOV45D.js} +588 -97
- package/dist/chunk-CCDOV45D.js.map +1 -0
- package/dist/chunk-CXUYCDPX.js +127 -0
- package/dist/chunk-CXUYCDPX.js.map +1 -0
- package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
- package/dist/chunk-HH3PDYIG.js +194 -0
- package/dist/chunk-HH3PDYIG.js.map +1 -0
- package/dist/{chunk-CYOF7ROH.js → chunk-HPWO4O6S.js} +3 -3
- package/dist/chunk-JLEF5WHM.js +132 -0
- package/dist/chunk-JLEF5WHM.js.map +1 -0
- package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
- package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
- package/dist/chunk-LHHMV4GU.js +27 -0
- package/dist/chunk-LHHMV4GU.js.map +1 -0
- package/dist/chunk-LI44XLMB.js +242 -0
- package/dist/chunk-LI44XLMB.js.map +1 -0
- package/dist/chunk-LN2HISWU.js +172 -0
- package/dist/chunk-LN2HISWU.js.map +1 -0
- package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
- package/dist/chunk-MEFB5KHA.js.map +1 -0
- package/dist/{chunk-NCE5NSN6.js → chunk-N35E6CM2.js} +140 -10
- package/dist/chunk-N35E6CM2.js.map +1 -0
- package/dist/chunk-NSG5TVZQ.js +447 -0
- package/dist/chunk-NSG5TVZQ.js.map +1 -0
- package/dist/chunk-O2JYBOUO.js +47 -0
- package/dist/chunk-O2JYBOUO.js.map +1 -0
- package/dist/{chunk-N62ROTMC.js → chunk-P42QX3QF.js} +14 -10
- package/dist/chunk-P42QX3QF.js.map +1 -0
- package/dist/chunk-PO4HAXAW.js +10528 -0
- package/dist/chunk-PO4HAXAW.js.map +1 -0
- package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
- package/dist/{chunk-S3IGX57D.js → chunk-RGVOODF4.js} +7703 -7475
- package/dist/chunk-RGVOODF4.js.map +1 -0
- package/dist/chunk-RPR2C2JO.js +112 -0
- package/dist/chunk-RPR2C2JO.js.map +1 -0
- package/dist/chunk-S2NRVRPF.js +171 -0
- package/dist/chunk-S2NRVRPF.js.map +1 -0
- package/dist/chunk-TGLKKLQG.js +11 -0
- package/dist/chunk-TGLKKLQG.js.map +1 -0
- package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
- package/dist/chunk-TU7XH3JJ.js +97 -0
- package/dist/chunk-TU7XH3JJ.js.map +1 -0
- package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
- package/dist/{chunk-Z6MFJV5Z.js → chunk-YEBNE5NW.js} +851 -500
- package/dist/chunk-YEBNE5NW.js.map +1 -0
- package/dist/chunk-YREKMJPP.js +131 -0
- package/dist/chunk-YREKMJPP.js.map +1 -0
- package/dist/{cli-4NNBEQYH.js → cli-XJQYUOHI.js} +355 -217
- package/dist/cli-XJQYUOHI.js.map +1 -0
- package/dist/config-KMJLFPSI.js +39 -0
- package/dist/dist-3LOO6M4U.js +2842 -0
- package/dist/dist-3LOO6M4U.js.map +1 -0
- package/dist/doctor-KMN55D7U.js +444 -0
- package/dist/doctor-KMN55D7U.js.map +1 -0
- package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
- package/dist/fund-LT6ZPGEQ.js +298 -0
- package/dist/fund-LT6ZPGEQ.js.map +1 -0
- package/dist/hook-command-U5XPEHAJ.js +1052 -0
- package/dist/hook-command-U5XPEHAJ.js.map +1 -0
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/install-MMNXJ5LM.js +61 -0
- package/dist/install-identity-B7FVIWML.js +27 -0
- package/dist/install-wallet-XMVUBCHS.js +107 -0
- package/dist/install-wallet-XMVUBCHS.js.map +1 -0
- package/dist/mcp-TUPRIPSI.js +10000 -0
- package/dist/mcp-TUPRIPSI.js.map +1 -0
- package/dist/paths-LRMWNTJP.js +51 -0
- package/dist/pay-XAWW3NV3.js +44 -0
- package/dist/redact-6W23GGJC.js +15 -0
- package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
- package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
- package/dist/send-HESQYRKM.js +225 -0
- package/dist/send-HESQYRKM.js.map +1 -0
- package/dist/status-ANZPRZJJ.js +71 -0
- package/dist/status-ANZPRZJJ.js.map +1 -0
- package/dist/status-line-J3TUWVRQ.js +87 -0
- package/dist/status-line-J3TUWVRQ.js.map +1 -0
- package/dist/status-line-wiring-HSV7DXO5.js +29 -0
- package/dist/status-line-wiring-HSV7DXO5.js.map +1 -0
- package/dist/tenjin-daemon.mjs +20547 -0
- package/dist/tenjin-shim.mjs +251 -0
- package/dist/tenjin-vitest-reporter.mjs +49 -0
- package/dist/uninstall-GUU34YKP.js +165 -0
- package/dist/uninstall-GUU34YKP.js.map +1 -0
- package/dist/update-KO2NZRJ5.js +433 -0
- package/dist/update-KO2NZRJ5.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
- package/dist/viemAdapter-By13KInL-X2VY6CY3.js.map +1 -0
- package/dist/wallet-3URC5QPK.js +33 -0
- package/dist/wallet-3URC5QPK.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +980 -0
- package/docs/agent-permissions.md +139 -0
- package/docs/safety-model.md +70 -0
- package/package.json +14 -9
- package/LICENSE +0 -21
- package/dist/buy-U35DQ6XM.js +0 -1598
- package/dist/buy-U35DQ6XM.js.map +0 -1
- package/dist/candidate-RLYCQMF5.js +0 -127
- package/dist/candidate-RLYCQMF5.js.map +0 -1
- package/dist/chunk-27ONARHV.js +0 -171
- package/dist/chunk-27ONARHV.js.map +0 -1
- package/dist/chunk-3OV7E5G5.js +0 -18
- package/dist/chunk-3OV7E5G5.js.map +0 -1
- package/dist/chunk-7KUW4MJD.js +0 -59
- package/dist/chunk-7KUW4MJD.js.map +0 -1
- package/dist/chunk-7PHSZKQS.js +0 -333
- package/dist/chunk-7PHSZKQS.js.map +0 -1
- package/dist/chunk-IYLHQMT5.js +0 -211
- package/dist/chunk-IYLHQMT5.js.map +0 -1
- package/dist/chunk-JPHG2JW3.js +0 -96
- package/dist/chunk-JPHG2JW3.js.map +0 -1
- package/dist/chunk-MUBUQVC3.js +0 -67
- package/dist/chunk-MUBUQVC3.js.map +0 -1
- package/dist/chunk-N62ROTMC.js.map +0 -1
- package/dist/chunk-NCE5NSN6.js.map +0 -1
- package/dist/chunk-OYMYCW7J.js.map +0 -1
- package/dist/chunk-QNP7H47L.js +0 -152
- package/dist/chunk-QNP7H47L.js.map +0 -1
- package/dist/chunk-RY4XKNV3.js +0 -140
- package/dist/chunk-RY4XKNV3.js.map +0 -1
- package/dist/chunk-S3IGX57D.js.map +0 -1
- package/dist/chunk-TFGSOPWR.js +0 -261
- package/dist/chunk-TFGSOPWR.js.map +0 -1
- package/dist/chunk-TLCMMYLY.js +0 -126
- package/dist/chunk-TLCMMYLY.js.map +0 -1
- package/dist/chunk-UO22YNY4.js +0 -69
- package/dist/chunk-UO22YNY4.js.map +0 -1
- package/dist/chunk-UPIEAMGH.js +0 -160
- package/dist/chunk-UPIEAMGH.js.map +0 -1
- package/dist/chunk-XJIW7USF.js.map +0 -1
- package/dist/chunk-YBMMV4Y4.js.map +0 -1
- package/dist/chunk-YIYQ2ZNT.js +0 -286
- package/dist/chunk-YIYQ2ZNT.js.map +0 -1
- package/dist/chunk-YN5SHIXQ.js +0 -126
- package/dist/chunk-YN5SHIXQ.js.map +0 -1
- package/dist/chunk-Z52RA3NC.js +0 -137
- package/dist/chunk-Z52RA3NC.js.map +0 -1
- package/dist/chunk-Z6MFJV5Z.js.map +0 -1
- package/dist/cli-4NNBEQYH.js.map +0 -1
- package/dist/config-2VSXWWHK.js +0 -21
- package/dist/doctor-JJPNIBYH.js +0 -20
- package/dist/inspect-JGYJWFDP.js +0 -96
- package/dist/inspect-JGYJWFDP.js.map +0 -1
- package/dist/install-ZQRMSRGW.js +0 -378
- package/dist/install-ZQRMSRGW.js.map +0 -1
- package/dist/lookup-WYVTOMVY.js +0 -113
- package/dist/lookup-WYVTOMVY.js.map +0 -1
- package/dist/outcome-HKKT6QIA.js +0 -66
- package/dist/outcome-HKKT6QIA.js.map +0 -1
- package/dist/publish-D76B3MBK.js +0 -1480
- package/dist/publish-D76B3MBK.js.map +0 -1
- package/dist/usdc-JIAJW4SV.js +0 -22
- package/dist/wallet-6QKS6UHW.js +0 -179
- package/dist/wallet-6QKS6UHW.js.map +0 -1
- package/dist/wallet-PA54CRBL.js +0 -30
- package/skills/tenjin/SKILL.md +0 -199
- package/skills/tenjin-publish/SKILL.md +0 -96
- package/skills/tenjin-search/SKILL.md +0 -122
- /package/dist/{_esm-FEASBWRP.js.map → _esm-CE7KNONL.js.map} +0 -0
- /package/dist/{ccip-NQXCEK2U.js.map → ccip-7RMRLAGV.js.map} +0 -0
- /package/dist/{ccip-XR5NE5QK.js.map → ccip-NLCSCHKI.js.map} +0 -0
- /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
- /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
- /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
- /package/dist/{chunk-CYOF7ROH.js.map → chunk-HPWO4O6S.js.map} +0 -0
- /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
- /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
- /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
- /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
- /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
- /package/dist/{config-2VSXWWHK.js.map → config-KMJLFPSI.js.map} +0 -0
- /package/dist/{doctor-JJPNIBYH.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → install-MMNXJ5LM.js.map} +0 -0
- /package/dist/{secp256k1-N3ZHU7LB.js.map → install-identity-B7FVIWML.js.map} +0 -0
- /package/dist/{usdc-JIAJW4SV.js.map → paths-LRMWNTJP.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → pay-XAWW3NV3.js.map} +0 -0
- /package/dist/{wallet-PA54CRBL.js.map → redact-6W23GGJC.js.map} +0 -0
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
modeGatedPointer
|
|
4
|
+
} from "./chunk-A36LQPHV.js";
|
|
5
|
+
import {
|
|
6
|
+
confirmChoice
|
|
7
|
+
} from "./chunk-2QYORQBF.js";
|
|
8
|
+
import {
|
|
9
|
+
LockTimeoutError,
|
|
10
|
+
withFileLock
|
|
11
|
+
} from "./chunk-MEFB5KHA.js";
|
|
12
|
+
import {
|
|
13
|
+
projectRouterPath,
|
|
14
|
+
readProjectRouterFile,
|
|
15
|
+
routerSettings
|
|
16
|
+
} from "./chunk-CXUYCDPX.js";
|
|
17
|
+
import {
|
|
18
|
+
hasCode
|
|
19
|
+
} from "./chunk-2I4QTOLB.js";
|
|
20
|
+
import {
|
|
21
|
+
isTeamShelfOrigin,
|
|
22
|
+
loadProjectConfig
|
|
23
|
+
} from "./chunk-5KD5HRAJ.js";
|
|
24
|
+
import {
|
|
25
|
+
parseUsdToAtomic,
|
|
26
|
+
toMoney
|
|
27
|
+
} from "./chunk-O2JYBOUO.js";
|
|
28
|
+
import {
|
|
29
|
+
CONFIG_KEYS,
|
|
30
|
+
HOOKS_CONFIG_KEYS,
|
|
31
|
+
LOOP_CONFIG_KEYS,
|
|
32
|
+
PRODUCTION_ORIGIN,
|
|
33
|
+
PUBLISH_CONFIG_KEYS,
|
|
34
|
+
PublishModeSchema,
|
|
35
|
+
RETIRED_PAYMENT_GUIDANCE,
|
|
36
|
+
ROUTER_CONFIG_KEYS,
|
|
37
|
+
ROUTER_CONTEXTS,
|
|
38
|
+
RawConfigSchema,
|
|
39
|
+
SEND_MAX_UNSET,
|
|
40
|
+
TEAM_CONFIG_KEYS,
|
|
41
|
+
UPDATE_CONFIG_KEYS,
|
|
42
|
+
isSameDeployment,
|
|
43
|
+
loadRawConfig,
|
|
44
|
+
parseAckServerWarnings,
|
|
45
|
+
parseLoopValue,
|
|
46
|
+
parsePublicFallbackFlag,
|
|
47
|
+
parseUpdateModeFlag,
|
|
48
|
+
resolveSettings,
|
|
49
|
+
retiredPaymentKeys
|
|
50
|
+
} from "./chunk-CCDOV45D.js";
|
|
51
|
+
import {
|
|
52
|
+
ADAPTERS,
|
|
53
|
+
MODE_GATED_RULES,
|
|
54
|
+
inspectFreeVerbRules,
|
|
55
|
+
registeredHooks,
|
|
56
|
+
retractModeGatedRules,
|
|
57
|
+
wireFreeVerbAllowlist
|
|
58
|
+
} from "./chunk-5FYKPQNX.js";
|
|
59
|
+
import {
|
|
60
|
+
CliError,
|
|
61
|
+
writeFileAtomic
|
|
62
|
+
} from "./chunk-JLEF5WHM.js";
|
|
63
|
+
import {
|
|
64
|
+
configPath
|
|
65
|
+
} from "./chunk-TU7XH3JJ.js";
|
|
66
|
+
|
|
67
|
+
// src/commands/config.ts
|
|
68
|
+
import { mkdir } from "node:fs/promises";
|
|
69
|
+
import { homedir } from "node:os";
|
|
70
|
+
import { dirname as dirname2 } from "node:path";
|
|
71
|
+
import { styleText } from "node:util";
|
|
72
|
+
|
|
73
|
+
// src/lib/skill-wiring.ts
|
|
74
|
+
import { existsSync, statSync } from "node:fs";
|
|
75
|
+
import { constants, open } from "node:fs/promises";
|
|
76
|
+
import { delimiter, join as join2 } from "node:path";
|
|
77
|
+
|
|
78
|
+
// src/lib/skills-source.ts
|
|
79
|
+
import { dirname, join } from "node:path";
|
|
80
|
+
var SKILL_NAMES = ["tenjin-search", "tenjin-publish", "tenjin"];
|
|
81
|
+
var RETIRED_SKILL_NAMES = ["tenjin-pay"];
|
|
82
|
+
var PACKAGED_SKILL_NAMES = [...SKILL_NAMES];
|
|
83
|
+
var SENTINEL = join("tenjin", "SKILL.md");
|
|
84
|
+
|
|
85
|
+
// src/lib/skill-wiring.ts
|
|
86
|
+
function skillsDirsFor(home) {
|
|
87
|
+
return [join2(home, ".claude", "skills"), join2(home, ".agents", "skills")];
|
|
88
|
+
}
|
|
89
|
+
function harnessTargetDir(home, harness) {
|
|
90
|
+
if (harness === "claude") return join2(home, ".claude", "skills");
|
|
91
|
+
return join2(home, ".agents", "skills");
|
|
92
|
+
}
|
|
93
|
+
function harnessFlagFor(home, dir) {
|
|
94
|
+
if (dir === join2(home, ".claude", "skills")) return "claude";
|
|
95
|
+
return "codex";
|
|
96
|
+
}
|
|
97
|
+
function harnessDetectedBy(home, harness, which) {
|
|
98
|
+
const reasons = [];
|
|
99
|
+
if (existsSync(join2(home, `.${harness}`))) reasons.push("home-dir");
|
|
100
|
+
if (which(harness)) reasons.push("binary");
|
|
101
|
+
return reasons;
|
|
102
|
+
}
|
|
103
|
+
function detectHarnesses(home, which) {
|
|
104
|
+
return {
|
|
105
|
+
claude: harnessDetectedBy(home, "claude", which).length > 0,
|
|
106
|
+
codex: harnessDetectedBy(home, "codex", which).length > 0
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function harnessReads(home, dir, present) {
|
|
110
|
+
if (harnessFlagFor(home, dir) === "claude") return present.claude;
|
|
111
|
+
return present.codex;
|
|
112
|
+
}
|
|
113
|
+
function harnessRequested(home, dir, requested) {
|
|
114
|
+
return requested.some((h) => harnessTargetDir(home, h) === dir);
|
|
115
|
+
}
|
|
116
|
+
function harnessInPlay(home, dir, present, requested) {
|
|
117
|
+
if (requested.length > 0) return harnessRequested(home, dir, requested);
|
|
118
|
+
return harnessReads(home, dir, present);
|
|
119
|
+
}
|
|
120
|
+
function onPath(bin, env) {
|
|
121
|
+
const raw = env.PATH ?? "";
|
|
122
|
+
const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
|
|
123
|
+
for (const part of raw.split(delimiter)) {
|
|
124
|
+
if (part.length === 0) continue;
|
|
125
|
+
for (const ext of exts) {
|
|
126
|
+
if (isFile(join2(part, bin + ext))) return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
function isFile(p) {
|
|
132
|
+
try {
|
|
133
|
+
return statSync(p).isFile();
|
|
134
|
+
} catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function readSkillFile(path) {
|
|
139
|
+
let handle;
|
|
140
|
+
try {
|
|
141
|
+
handle = await open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
142
|
+
} catch (err) {
|
|
143
|
+
if (hasCode(err, "ENOENT")) return { kind: "absent" };
|
|
144
|
+
return { kind: "unreadable", err };
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
if (!(await handle.stat()).isFile()) return { kind: "not-regular" };
|
|
148
|
+
return { kind: "ok", bytes: await handle.readFile() };
|
|
149
|
+
} catch (err) {
|
|
150
|
+
return { kind: "unreadable", err };
|
|
151
|
+
} finally {
|
|
152
|
+
await handle.close().catch(() => void 0);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function skillFrontmatterName(skillMd) {
|
|
156
|
+
const frontmatter = extractFrontmatter(skillMd);
|
|
157
|
+
if (frontmatter === null) return null;
|
|
158
|
+
for (const line of frontmatter) {
|
|
159
|
+
const m = /^name:\s*(.+?)\s*$/.exec(line);
|
|
160
|
+
if (m !== null) return (m[1] ?? "").replace(/^["']|["']$/g, "");
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
function extractFrontmatter(text) {
|
|
165
|
+
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
166
|
+
const open2 = lines.findIndex((l) => l.trim().length > 0);
|
|
167
|
+
if (open2 === -1 || lines[open2]?.trim() !== "---") return null;
|
|
168
|
+
const end = lines.findIndex((l, i) => i > open2 && l.trim() === "---");
|
|
169
|
+
if (end === -1) return null;
|
|
170
|
+
return lines.slice(open2 + 1, end);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/lib/harness-presence.ts
|
|
174
|
+
async function installedHarnessInPlay(adapter, home, dataDir, options = {}) {
|
|
175
|
+
const env = options.env ?? process.env;
|
|
176
|
+
const which = options.which ?? ((bin) => onPath(bin, env));
|
|
177
|
+
if (harnessInPlay(
|
|
178
|
+
home,
|
|
179
|
+
harnessTargetDir(home, adapter.id),
|
|
180
|
+
detectHarnesses(home, which),
|
|
181
|
+
options.requested ?? []
|
|
182
|
+
)) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return (await registeredHooks(adapter, home, dataDir, env)).entries > 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/commands/config.ts
|
|
189
|
+
var KEY_WIDTH = Math.max(
|
|
190
|
+
...[
|
|
191
|
+
...CONFIG_KEYS,
|
|
192
|
+
...PUBLISH_CONFIG_KEYS,
|
|
193
|
+
...HOOKS_CONFIG_KEYS,
|
|
194
|
+
...UPDATE_CONFIG_KEYS,
|
|
195
|
+
...LOOP_CONFIG_KEYS,
|
|
196
|
+
...TEAM_CONFIG_KEYS,
|
|
197
|
+
...ROUTER_CONFIG_KEYS
|
|
198
|
+
].map((key) => key.length)
|
|
199
|
+
);
|
|
200
|
+
var KEY_DESCRIPTIONS = {
|
|
201
|
+
maxAutoSpend: "automatic router limit per call",
|
|
202
|
+
sessionBudget: "automatic router daily limit: 0 blocks automatic spend, none removes the ceiling",
|
|
203
|
+
sendMaxAmount: "hard cap per tenjin wallet send; unset = send refuses until set, 0 disables send, none = uncapped; never bypassed by --yes",
|
|
204
|
+
allowlistCreators: "only auto-pay these creators (empty = any)",
|
|
205
|
+
baseUrl: "Tenjin API base URL: what publish/read/search go to (the team shelf, in team mode)",
|
|
206
|
+
publicShelfUrl: "the public marketplace, consume-only: the second shelf a team-mode search falls through to",
|
|
207
|
+
shelfBypassSecret: "the team shelf's Vercel protection-bypass secret; setting it is what turns team mode on (printed as set/unset)",
|
|
208
|
+
rpcUrl: "Base RPC endpoint for balance reads",
|
|
209
|
+
evalCohort: "opt in to the search evaluation cohort",
|
|
210
|
+
bazaarRegistries: "x402 registries used to verify direct-payment listings",
|
|
211
|
+
"publish.mode": "review=always ask, auto=ask on findings, full-auto=only hard blocks stop it",
|
|
212
|
+
"publish.defaultPrice": "price used when none is given",
|
|
213
|
+
"publish.ackServerWarnings": "whether a yes covers the MARKETPLACE scan's warn findings: mode=only the ones an earlier render already showed you (full-auto still acks), on=any of them, off=never",
|
|
214
|
+
"hooks.prompt": "answer the prompt you just typed with what the shelves already know",
|
|
215
|
+
"hooks.web-search": "ask Tenjin before the agent runs a WebSearch",
|
|
216
|
+
"hooks.web-fetch": "ask Tenjin before the agent fetches a page",
|
|
217
|
+
"hooks.subagent": "ask Tenjin with a subagent work order (the most sensitive payload any hook sees) and hand the answer to the child at its start",
|
|
218
|
+
"hooks.failure": "answer a failing command with the fix this machine or a shelf already has",
|
|
219
|
+
"hooks.publish": "the turn-end ask to publish what this turn settled, spoken to you and to each subagent at its own end",
|
|
220
|
+
"hooks.primer": "one-paragraph search-first primer at session start",
|
|
221
|
+
"update.mode": "nudge=report a newer version (stderr line, JSON envelope, hook output), off=neither report nor ask npm",
|
|
222
|
+
"loop.human_wait_ms": "ms a hook fire may take when a human is waiting on it (prompt, Stop, SessionStart)",
|
|
223
|
+
"loop.tool_wait_ms": "ms a hook fire may take when a tool call is waiting on it",
|
|
224
|
+
"loop.idle_exit_min": "minutes without a hook fire before the loop daemon exits",
|
|
225
|
+
"loop.port": "the loop daemon's loopback port; null derives one from the data dir (set only when doctor reports a foreign listener)",
|
|
226
|
+
"team.publicFallback": "on=a team-shelf miss falls through to the public marketplace, off=team-only (public-only lookup stages are dropped)",
|
|
227
|
+
"router.enabled": "false stops every router hook and the request tool; --project sets it for this repository, --project --local for you alone in it",
|
|
228
|
+
"router.context": "session=a hook packet carries up to six prior messages, turn=the current turn only; --project and --local as for router.enabled"
|
|
229
|
+
};
|
|
230
|
+
function isLoopKey(key) {
|
|
231
|
+
return LOOP_CONFIG_KEYS.includes(key);
|
|
232
|
+
}
|
|
233
|
+
function isTeamKey(key) {
|
|
234
|
+
return TEAM_CONFIG_KEYS.includes(key);
|
|
235
|
+
}
|
|
236
|
+
function isRouterKey(key) {
|
|
237
|
+
return ROUTER_CONFIG_KEYS.includes(key);
|
|
238
|
+
}
|
|
239
|
+
function renderRouterSetting(key, settings) {
|
|
240
|
+
const { value, source, path } = key === "router.enabled" ? settings.enabled : settings.context;
|
|
241
|
+
return { value, source, ...path !== void 0 ? { path } : {} };
|
|
242
|
+
}
|
|
243
|
+
async function resolveRouterFromContext(ctx) {
|
|
244
|
+
return routerSettings({ cwd: process.cwd(), dataDir: ctx.dataDir });
|
|
245
|
+
}
|
|
246
|
+
function renderLoopSetting(key, settings) {
|
|
247
|
+
const field = key.slice("loop.".length);
|
|
248
|
+
const { value, source } = settings.loop[field];
|
|
249
|
+
return { value: value === null ? "null" : String(value), source };
|
|
250
|
+
}
|
|
251
|
+
function isPublishKey(key) {
|
|
252
|
+
return PUBLISH_CONFIG_KEYS.includes(key);
|
|
253
|
+
}
|
|
254
|
+
function isHooksKey(key) {
|
|
255
|
+
return HOOKS_CONFIG_KEYS.includes(key);
|
|
256
|
+
}
|
|
257
|
+
function isUpdateKey(key) {
|
|
258
|
+
return UPDATE_CONFIG_KEYS.includes(key);
|
|
259
|
+
}
|
|
260
|
+
async function runConfigList(ctx) {
|
|
261
|
+
const settings = await resolveFromContext(ctx);
|
|
262
|
+
const data = {};
|
|
263
|
+
const humanLines = [];
|
|
264
|
+
for (const key of CONFIG_KEYS) {
|
|
265
|
+
const entry = renderSetting(key, settings[key].value, settings[key].source);
|
|
266
|
+
data[key] = entry;
|
|
267
|
+
humanLines.push(describedLine(key, entry));
|
|
268
|
+
}
|
|
269
|
+
for (const key of PUBLISH_CONFIG_KEYS) {
|
|
270
|
+
const entry = renderPublishSetting(key, settings);
|
|
271
|
+
data[key] = entry;
|
|
272
|
+
humanLines.push(describedLine(key, entry, downgradeNote(key, settings)));
|
|
273
|
+
}
|
|
274
|
+
for (const key of HOOKS_CONFIG_KEYS) {
|
|
275
|
+
const entry = renderHooksSetting(key, settings);
|
|
276
|
+
data[key] = entry;
|
|
277
|
+
humanLines.push(describedLine(key, entry));
|
|
278
|
+
}
|
|
279
|
+
for (const key of UPDATE_CONFIG_KEYS) {
|
|
280
|
+
const entry = {
|
|
281
|
+
value: settings.updateMode.value,
|
|
282
|
+
source: settings.updateMode.source
|
|
283
|
+
};
|
|
284
|
+
data[key] = entry;
|
|
285
|
+
humanLines.push(describedLine(key, entry));
|
|
286
|
+
}
|
|
287
|
+
for (const key of LOOP_CONFIG_KEYS) {
|
|
288
|
+
const entry = renderLoopSetting(key, settings);
|
|
289
|
+
data[key] = entry;
|
|
290
|
+
humanLines.push(describedLine(key, entry));
|
|
291
|
+
}
|
|
292
|
+
for (const key of TEAM_CONFIG_KEYS) {
|
|
293
|
+
const entry = {
|
|
294
|
+
value: settings.teamPublicFallback.value,
|
|
295
|
+
source: settings.teamPublicFallback.source
|
|
296
|
+
};
|
|
297
|
+
data[key] = entry;
|
|
298
|
+
humanLines.push(describedLine(key, entry));
|
|
299
|
+
}
|
|
300
|
+
const router = await resolveRouterFromContext(ctx);
|
|
301
|
+
for (const key of ROUTER_CONFIG_KEYS) {
|
|
302
|
+
const entry = renderRouterSetting(key, router);
|
|
303
|
+
data[key] = entry;
|
|
304
|
+
humanLines.push(describedLine(key, entry));
|
|
305
|
+
}
|
|
306
|
+
return { data, humanLines };
|
|
307
|
+
}
|
|
308
|
+
async function runConfigGet({ key }, ctx) {
|
|
309
|
+
if (isPublishKey(key)) {
|
|
310
|
+
const settings2 = await resolveFromContext(ctx);
|
|
311
|
+
const entry2 = renderPublishSetting(key, settings2);
|
|
312
|
+
return {
|
|
313
|
+
data: { key, ...entry2 },
|
|
314
|
+
humanLines: [withNote(formatLine(key, entry2), downgradeNote(key, settings2))]
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (isHooksKey(key)) {
|
|
318
|
+
const entry2 = renderHooksSetting(key, await resolveFromContext(ctx));
|
|
319
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
320
|
+
}
|
|
321
|
+
if (isUpdateKey(key)) {
|
|
322
|
+
const { updateMode } = await resolveFromContext(ctx);
|
|
323
|
+
const entry2 = { value: updateMode.value, source: updateMode.source };
|
|
324
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
325
|
+
}
|
|
326
|
+
if (isLoopKey(key)) {
|
|
327
|
+
const entry2 = renderLoopSetting(key, await resolveFromContext(ctx));
|
|
328
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
329
|
+
}
|
|
330
|
+
if (isTeamKey(key)) {
|
|
331
|
+
const { teamPublicFallback } = await resolveFromContext(ctx);
|
|
332
|
+
const entry2 = {
|
|
333
|
+
value: teamPublicFallback.value,
|
|
334
|
+
source: teamPublicFallback.source
|
|
335
|
+
};
|
|
336
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
337
|
+
}
|
|
338
|
+
if (isRouterKey(key)) {
|
|
339
|
+
const entry2 = renderRouterSetting(key, await resolveRouterFromContext(ctx));
|
|
340
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
341
|
+
}
|
|
342
|
+
const configKey = assertKey(key);
|
|
343
|
+
const settings = await resolveFromContext(ctx);
|
|
344
|
+
const entry = renderSetting(configKey, settings[configKey].value, settings[configKey].source);
|
|
345
|
+
return { data: { key: configKey, ...entry }, humanLines: [formatLine(configKey, entry)] };
|
|
346
|
+
}
|
|
347
|
+
async function runConfigSet({
|
|
348
|
+
key,
|
|
349
|
+
value,
|
|
350
|
+
project,
|
|
351
|
+
local
|
|
352
|
+
}, ctx, deps = {}) {
|
|
353
|
+
if (local === true && project !== true) {
|
|
354
|
+
throw new CliError("USAGE", "--local names the personal project file, so it needs --project", {
|
|
355
|
+
fix: `Run \`tenjin config set --project --local ${key} ${value}\`.`
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
if (isRouterKey(key)) {
|
|
359
|
+
return setRouterKey(key, value, ctx, project === true ? { local: local === true } : void 0);
|
|
360
|
+
}
|
|
361
|
+
if (project === true) {
|
|
362
|
+
throw new CliError("USAGE", `${key} is not a project key`, {
|
|
363
|
+
fix: `--project applies to ${ROUTER_CONFIG_KEYS.join(" and ")} only; drop it to set ${key} for this machine.`
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (isPublishKey(key)) return setPublishKey(key, value, ctx, deps);
|
|
367
|
+
if (isHooksKey(key)) return setHooksKey(key, value, ctx);
|
|
368
|
+
if (isUpdateKey(key)) return setUpdateKey(key, value, ctx);
|
|
369
|
+
if (isLoopKey(key)) return setLoopKey(key, value, ctx);
|
|
370
|
+
if (isTeamKey(key)) return setTeamKey(key, value, ctx);
|
|
371
|
+
const configKey = assertKey(key);
|
|
372
|
+
const stored = parseValue(configKey, value);
|
|
373
|
+
await persist(ctx.dataDir, (existing) => ({ ...existing, [configKey]: stored }));
|
|
374
|
+
const entry = renderSetting(configKey, stored, "file");
|
|
375
|
+
const warning = await halfWiredTeamShelf(configKey, ctx.dataDir);
|
|
376
|
+
return {
|
|
377
|
+
data: { key: configKey, ...entry, ...warning !== void 0 ? { warning } : {} },
|
|
378
|
+
humanLines: [formatLine(configKey, entry), ...warning !== void 0 ? [warning] : []]
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
async function halfWiredTeamShelf(configKey, dataDir) {
|
|
382
|
+
if (configKey !== "shelfBypassSecret" && configKey !== "baseUrl" && configKey !== "publicShelfUrl") {
|
|
383
|
+
return void 0;
|
|
384
|
+
}
|
|
385
|
+
const config = await loadRawConfig(dataDir).catch(() => void 0);
|
|
386
|
+
if (config === void 0) return void 0;
|
|
387
|
+
const s = resolveSettings({ config, flags: {}, env: {} });
|
|
388
|
+
if (s.shelfBypassSecret.value.length === 0) return void 0;
|
|
389
|
+
const baseUrl = s.baseUrl.value;
|
|
390
|
+
if (isTeamShelfOrigin(new URL(baseUrl).origin, s.publicShelfUrl.value)) return void 0;
|
|
391
|
+
const isProduction = isSameDeployment(new URL(baseUrl).origin, PRODUCTION_ORIGIN);
|
|
392
|
+
const cause = isProduction ? `baseUrl is the public marketplace (${baseUrl})` : `baseUrl and publicShelfUrl are the same shelf (${baseUrl})`;
|
|
393
|
+
const fix = isProduction ? "Point baseUrl at the team deployment to finish team mode: `tenjin config set baseUrl <team shelf url>`." : `A team shelf must differ from the shelf it falls through to: \`tenjin config set publicShelfUrl ${PRODUCTION_ORIGIN}\`.`;
|
|
394
|
+
return `Warning: shelfBypassSecret is set, but ${cause}, so this machine stays in PUBLIC mode \u2014 publishes go to the marketplace with the scan\u2019s warn tier and the confirm cascade on. ` + fix;
|
|
395
|
+
}
|
|
396
|
+
async function setPublishKey(key, value, ctx, deps) {
|
|
397
|
+
const entry = key === "publish.mode" ? { value: parsePublishMode(value), source: "file" } : key === "publish.ackServerWarnings" ? { value: parseAckServerWarnings(value, key), source: "file" } : { value: toMoney(parseUsdToAtomic(value)), source: "file" };
|
|
398
|
+
const subkey = key === "publish.mode" ? "mode" : key === "publish.ackServerWarnings" ? "ackServerWarnings" : "defaultPrice";
|
|
399
|
+
const stored = key === "publish.defaultPrice" ? entry.value.atomic : entry.value;
|
|
400
|
+
const persistEntry = async () => persist(ctx.dataDir, (existing) => ({
|
|
401
|
+
...existing,
|
|
402
|
+
publish: { ...existing.publish, [subkey]: stored }
|
|
403
|
+
}));
|
|
404
|
+
const humanLines = [formatLine(key, entry)];
|
|
405
|
+
if (key !== "publish.mode") {
|
|
406
|
+
await persistEntry();
|
|
407
|
+
return { data: { key, ...entry }, humanLines };
|
|
408
|
+
}
|
|
409
|
+
const allowlist = await syncPublishRule(entry.value, ctx, deps);
|
|
410
|
+
const failure = grantSyncFailure(allowlist);
|
|
411
|
+
if (failure !== void 0) {
|
|
412
|
+
throw new CliError(
|
|
413
|
+
"REFUSED",
|
|
414
|
+
`publish.mode was not changed because the ${failure.harness} grant could not be updated: ${failure.reason}`,
|
|
415
|
+
{
|
|
416
|
+
fix: failure.fix ?? `Fix the permissions for ${failure.path}, then re-run \`tenjin config set publish.mode ${entry.value}\`.`,
|
|
417
|
+
details: { key, value: entry.value, allowlist }
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
await persistEntry();
|
|
422
|
+
return {
|
|
423
|
+
data: { key, ...entry, allowlist },
|
|
424
|
+
humanLines: [...humanLines, ...allowlistLines(allowlist)]
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function grantSyncFailure(sync) {
|
|
428
|
+
for (const [harness, result] of Object.entries(sync.byHarness)) {
|
|
429
|
+
if ("error" in result && result.error !== void 0) {
|
|
430
|
+
return { harness, path: result.path, reason: result.error };
|
|
431
|
+
}
|
|
432
|
+
if ("warning" in result && result.warning !== void 0) {
|
|
433
|
+
return {
|
|
434
|
+
harness,
|
|
435
|
+
path: result.path ?? "(unknown path)",
|
|
436
|
+
reason: result.warning,
|
|
437
|
+
...result.fix !== void 0 ? { fix: result.fix } : {}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return void 0;
|
|
442
|
+
}
|
|
443
|
+
function publishRuleQuestion(mode, pending, harnesses) {
|
|
444
|
+
const gated = new Set(MODE_GATED_RULES);
|
|
445
|
+
const others = pending.filter((rule) => !gated.has(rule)).length;
|
|
446
|
+
const also = others > 0 ? ` Also adds the ${others} command-grant rule(s) \`tenjin install\` writes.` : "";
|
|
447
|
+
const targets = harnesses.map(
|
|
448
|
+
(harness) => harness === "claude" ? "Claude Code" : harness === "codex" ? "Codex" : harness
|
|
449
|
+
).join(" and ");
|
|
450
|
+
return `publish.mode ${mode} is unattended only if ${targets} carries the matching grant for ${MODE_GATED_RULES.join(" and ")}. Update the ${targets} grant now?${also}`;
|
|
451
|
+
}
|
|
452
|
+
async function syncPublishRule(mode, ctx, deps) {
|
|
453
|
+
const home = deps.homeDir ?? homedir();
|
|
454
|
+
const nothing = { byHarness: {} };
|
|
455
|
+
const write = async () => {
|
|
456
|
+
const result = await (deps.wireAllowlist ?? wireFreeVerbAllowlist)(home, mode);
|
|
457
|
+
if (result.skipped !== void 0) {
|
|
458
|
+
return {
|
|
459
|
+
byHarness: { claude: result },
|
|
460
|
+
skipped: "unwritable",
|
|
461
|
+
...result.fix !== void 0 ? { pointer: result.fix } : {}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
return { byHarness: { claude: result } };
|
|
465
|
+
};
|
|
466
|
+
const adapters = deps.adapters ?? ADAPTERS;
|
|
467
|
+
const env = deps.env ?? process.env;
|
|
468
|
+
const which = deps.which ?? ((bin) => onPath(bin, env));
|
|
469
|
+
const requested = await loadRawConfig(ctx.dataDir).then((config) => config.install?.harness ?? []).catch(() => []);
|
|
470
|
+
const inPlay = deps.harnessesInPlay ?? (await Promise.all(
|
|
471
|
+
Object.values(adapters).map(async (adapter) => ({
|
|
472
|
+
adapter,
|
|
473
|
+
selected: await installedHarnessInPlay(adapter, home, ctx.dataDir, {
|
|
474
|
+
env,
|
|
475
|
+
which,
|
|
476
|
+
requested
|
|
477
|
+
})
|
|
478
|
+
}))
|
|
479
|
+
)).filter((entry) => entry.selected).map((entry) => entry.adapter.id);
|
|
480
|
+
const selectedAdapters = inPlay.map((harness) => adapters[harness]);
|
|
481
|
+
const isClaude = inPlay.includes("claude");
|
|
482
|
+
const withOtherGrants = async (sync) => {
|
|
483
|
+
const byHarness = { ...sync.byHarness };
|
|
484
|
+
for (const adapter of selectedAdapters) {
|
|
485
|
+
if (adapter.id === "claude" || adapter.registrar.grant === void 0) continue;
|
|
486
|
+
const result = await adapter.registrar.grant.write(home, mode, env);
|
|
487
|
+
byHarness[adapter.id] = result;
|
|
488
|
+
}
|
|
489
|
+
return { ...sync, byHarness };
|
|
490
|
+
};
|
|
491
|
+
if (selectedAdapters.every((adapter) => adapter.registrar.grant === void 0)) {
|
|
492
|
+
return { ...nothing, skipped: "not-claude" };
|
|
493
|
+
}
|
|
494
|
+
const probe = isClaude ? await (deps.inspectAllowlist ?? inspectFreeVerbRules)(home, mode) : { pending: [] };
|
|
495
|
+
const gated = new Set(MODE_GATED_RULES);
|
|
496
|
+
const missing = (probe.pending ?? []).filter((r) => gated.has(r));
|
|
497
|
+
const pointer = modeGatedPointer(mode, missing) ?? void 0;
|
|
498
|
+
if (mode === "review") {
|
|
499
|
+
const retracted = isClaude ? await (deps.retractModeGated ?? retractModeGatedRules)(home) : void 0;
|
|
500
|
+
if (retracted?.skipped !== void 0) {
|
|
501
|
+
return {
|
|
502
|
+
...nothing,
|
|
503
|
+
skipped: "unwritable",
|
|
504
|
+
...retracted.fix !== void 0 ? { pointer: retracted.fix } : {}
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
return await withOtherGrants({
|
|
508
|
+
byHarness: retracted === void 0 ? {} : { claude: retracted }
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
if (probe.satisfied !== void 0 && selectedAdapters.length === 1 && isClaude) return nothing;
|
|
512
|
+
const canPrompt = ctx.flags.json === true ? false : deps.isInteractive ?? Boolean(process.stdin.isTTY);
|
|
513
|
+
if (!canPrompt) {
|
|
514
|
+
return { ...nothing, skipped: "no-tty", ...pointer ? { pointer } : {} };
|
|
515
|
+
}
|
|
516
|
+
const confirm = deps.confirmRule ?? ((label) => confirmChoice(label, true));
|
|
517
|
+
const grantable = selectedAdapters.filter((adapter) => adapter.registrar.grant !== void 0).map((adapter) => adapter.id);
|
|
518
|
+
if (!await confirm(publishRuleQuestion(mode, probe.pending ?? [], grantable))) {
|
|
519
|
+
return { ...nothing, skipped: "declined", ...pointer ? { pointer } : {} };
|
|
520
|
+
}
|
|
521
|
+
return await withOtherGrants(isClaude ? await write() : nothing);
|
|
522
|
+
}
|
|
523
|
+
function allowlistLines(sync) {
|
|
524
|
+
const lines = [];
|
|
525
|
+
const claude = sync.byHarness.claude;
|
|
526
|
+
if ((claude?.added.length ?? 0) > 0) {
|
|
527
|
+
lines.push(`Added ${claude?.added.length ?? 0} harness rule(s) to your allowlist.`);
|
|
528
|
+
}
|
|
529
|
+
if ((claude?.removed.length ?? 0) > 0) {
|
|
530
|
+
lines.push(`Removed ${claude?.removed.join(", ")} from your allowlist.`);
|
|
531
|
+
}
|
|
532
|
+
const grant = sync.byHarness.codex;
|
|
533
|
+
if (grant !== void 0 && grant.error === void 0 && grant.wrote) {
|
|
534
|
+
lines.push(
|
|
535
|
+
`Codex now allows ${grant.granted.length} tenjin command prefix(es) in ${grant.path}.`
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
if (grant?.error !== void 0) {
|
|
539
|
+
lines.push(`Codex's grant at ${grant.path} could not be updated (${grant.error}).`);
|
|
540
|
+
}
|
|
541
|
+
if (sync.pointer !== void 0) lines.push(sync.pointer);
|
|
542
|
+
return lines;
|
|
543
|
+
}
|
|
544
|
+
async function setHooksKey(key, value, ctx) {
|
|
545
|
+
const arm = key.slice("hooks.".length);
|
|
546
|
+
const parsed = parseBoolean(value);
|
|
547
|
+
await persistHookArm(ctx.dataDir, arm, parsed);
|
|
548
|
+
const entry = { value: parsed, source: "file" };
|
|
549
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
550
|
+
}
|
|
551
|
+
async function setUpdateKey(key, value, ctx) {
|
|
552
|
+
const parsed = parseUpdateModeFlag(value, key);
|
|
553
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
554
|
+
...existing,
|
|
555
|
+
update: { ...existing.update, mode: parsed }
|
|
556
|
+
}));
|
|
557
|
+
const entry = { value: parsed, source: "file" };
|
|
558
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
559
|
+
}
|
|
560
|
+
async function setLoopKey(key, value, ctx) {
|
|
561
|
+
const parsed = parseLoopValue(key, value);
|
|
562
|
+
const field = key.slice("loop.".length);
|
|
563
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
564
|
+
...existing,
|
|
565
|
+
loop: { ...existing.loop, [field]: parsed }
|
|
566
|
+
}));
|
|
567
|
+
const entry = {
|
|
568
|
+
value: parsed === null ? "null" : String(parsed),
|
|
569
|
+
source: "file"
|
|
570
|
+
};
|
|
571
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
572
|
+
}
|
|
573
|
+
async function setTeamKey(key, value, ctx) {
|
|
574
|
+
const parsed = parsePublicFallbackFlag(value, key);
|
|
575
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
576
|
+
...existing,
|
|
577
|
+
team: { ...existing.team, publicFallback: parsed }
|
|
578
|
+
}));
|
|
579
|
+
const entry = { value: parsed, source: "file" };
|
|
580
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
581
|
+
}
|
|
582
|
+
async function setRouterKey(key, value, ctx, project) {
|
|
583
|
+
const field = key === "router.enabled" ? "enabled" : "context";
|
|
584
|
+
const parsed = field === "enabled" ? parseBoolean(value) : parseRouterContext(value);
|
|
585
|
+
let written;
|
|
586
|
+
if (project === void 0) {
|
|
587
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
588
|
+
...existing,
|
|
589
|
+
router: { ...existing.router, [field]: parsed }
|
|
590
|
+
}));
|
|
591
|
+
written = { value: parsed, source: "file", path: configPath(ctx.dataDir) };
|
|
592
|
+
} else {
|
|
593
|
+
const path = await projectRouterPath({ cwd: process.cwd(), local: project.local });
|
|
594
|
+
await persistProjectRouter(path, field, parsed);
|
|
595
|
+
written = { value: parsed, source: project.local ? "local" : "project", path };
|
|
596
|
+
}
|
|
597
|
+
const effective = renderRouterSetting(key, await resolveRouterFromContext(ctx));
|
|
598
|
+
const humanLines = [formatLine(key, written)];
|
|
599
|
+
if (effective.value !== written.value) {
|
|
600
|
+
humanLines.push(
|
|
601
|
+
`Still ${String(effective.value)} here: ${effective.path ?? "the default"} is tighter, and a nearer file can only tighten an outer one.`
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
if (project?.local === true) {
|
|
605
|
+
humanLines.push("Keep .tenjin/config.local.json out of git: add it to .gitignore.");
|
|
606
|
+
}
|
|
607
|
+
return { data: { key, ...written, effective }, humanLines };
|
|
608
|
+
}
|
|
609
|
+
function parseRouterContext(value) {
|
|
610
|
+
const found = ROUTER_CONTEXTS.find((context) => context === value);
|
|
611
|
+
if (found !== void 0) return found;
|
|
612
|
+
throw new CliError("USAGE", `Invalid router.context: ${JSON.stringify(value)}`, {
|
|
613
|
+
fix: 'Use "session" or "turn".'
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
async function persistProjectRouter(path, field, value) {
|
|
617
|
+
await mkdir(dirname2(path), { recursive: true, mode: 493 });
|
|
618
|
+
const lockPath = `${path}.lock`;
|
|
619
|
+
try {
|
|
620
|
+
await withFileLock(lockPath, () => mergeProjectRouter(path, field, value));
|
|
621
|
+
} catch (err) {
|
|
622
|
+
if (err instanceof LockTimeoutError) {
|
|
623
|
+
throw new CliError("INTERNAL", err.message, {
|
|
624
|
+
fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
|
|
625
|
+
cause: err
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
throw err;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
async function mergeProjectRouter(path, field, value) {
|
|
632
|
+
const existing = await readProjectRouterFile(path);
|
|
633
|
+
const block = existing?.json.router;
|
|
634
|
+
const next = {
|
|
635
|
+
...existing?.json ?? {},
|
|
636
|
+
router: { ...block !== void 0 ? block : {}, [field]: value }
|
|
637
|
+
};
|
|
638
|
+
await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}
|
|
639
|
+
`, {
|
|
640
|
+
mode: 420,
|
|
641
|
+
dirMode: 493
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function parsePublishMode(value) {
|
|
645
|
+
const parsed = PublishModeSchema.safeParse(value);
|
|
646
|
+
if (parsed.success) return parsed.data;
|
|
647
|
+
throw new CliError("USAGE", `Invalid publish mode: ${JSON.stringify(value)}`, {
|
|
648
|
+
fix: 'Use "review", "auto", or "full-auto".'
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
async function persistHookArm(dir, arm, value) {
|
|
652
|
+
await persist(dir, (existing) => ({
|
|
653
|
+
...existing,
|
|
654
|
+
hooks: { ...existing.hooks, [arm]: value }
|
|
655
|
+
}));
|
|
656
|
+
}
|
|
657
|
+
async function persistPublishMode(dir, mode) {
|
|
658
|
+
await persist(dir, (existing) => ({
|
|
659
|
+
...existing,
|
|
660
|
+
publish: { ...existing.publish, mode }
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
async function persistRouterProject(dir, projectDir, present = true) {
|
|
664
|
+
await persist(dir, (existing) => {
|
|
665
|
+
const known = new Set(existing.install?.routerProjects ?? []);
|
|
666
|
+
if (present) known.add(projectDir);
|
|
667
|
+
else known.delete(projectDir);
|
|
668
|
+
return { ...existing, install: { ...existing.install, routerProjects: [...known].sort() } };
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
var ROUTER_DEFAULTS = {
|
|
672
|
+
maxAutoSpend: "250000",
|
|
673
|
+
sessionBudget: "5000000"
|
|
674
|
+
};
|
|
675
|
+
async function persistRouterDefaults(dir, refresh = false) {
|
|
676
|
+
const result = { set: [], kept: [], removed: [] };
|
|
677
|
+
if (refresh && retiredPaymentKeys(await loadRawConfig(dir)).length === 0) return result;
|
|
678
|
+
await persist(dir, (existing) => {
|
|
679
|
+
const next = { ...existing };
|
|
680
|
+
result.removed = retiredPaymentKeys(existing);
|
|
681
|
+
for (const key of result.removed) delete next[key];
|
|
682
|
+
if (refresh) return next;
|
|
683
|
+
for (const [key, value] of Object.entries(ROUTER_DEFAULTS)) {
|
|
684
|
+
if (existing[key] === void 0) {
|
|
685
|
+
next[key] = value;
|
|
686
|
+
result.set.push(key);
|
|
687
|
+
} else result.kept.push(key);
|
|
688
|
+
}
|
|
689
|
+
return next;
|
|
690
|
+
});
|
|
691
|
+
return result;
|
|
692
|
+
}
|
|
693
|
+
async function persistInstallHarness(dir, harness) {
|
|
694
|
+
await persist(dir, (existing) => ({
|
|
695
|
+
...existing,
|
|
696
|
+
install: { ...existing.install, harness: [...harness] }
|
|
697
|
+
}));
|
|
698
|
+
}
|
|
699
|
+
async function persistGrantDeclined(dir, declined) {
|
|
700
|
+
await persist(dir, (existing) => ({
|
|
701
|
+
...existing,
|
|
702
|
+
install: { ...existing.install, grantDeclined: declined }
|
|
703
|
+
}));
|
|
704
|
+
}
|
|
705
|
+
async function resolveFromContext(ctx) {
|
|
706
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
707
|
+
const project = await loadProjectConfig(process.cwd());
|
|
708
|
+
return resolveSettings({
|
|
709
|
+
config,
|
|
710
|
+
flags: { baseUrl: ctx.flags.baseUrl },
|
|
711
|
+
env: process.env,
|
|
712
|
+
project: project?.layer
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
function assertKey(key) {
|
|
716
|
+
if (key === "bazaarPay" || key === "confirm") {
|
|
717
|
+
throw new CliError("USAGE", `Retired config key: ${key}`, { fix: RETIRED_PAYMENT_GUIDANCE });
|
|
718
|
+
}
|
|
719
|
+
if (CONFIG_KEYS.includes(key)) return key;
|
|
720
|
+
throw new CliError("USAGE", `Unknown config key: ${JSON.stringify(key)}`, {
|
|
721
|
+
fix: `Valid keys: ${[...CONFIG_KEYS, ...PUBLISH_CONFIG_KEYS, ...HOOKS_CONFIG_KEYS, ...ROUTER_CONFIG_KEYS].join(", ")}.`
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
function renderSetting(key, stored, source) {
|
|
725
|
+
return { ...renderValue(key, stored), source };
|
|
726
|
+
}
|
|
727
|
+
function renderPublishSetting(key, settings) {
|
|
728
|
+
if (key === "publish.mode") {
|
|
729
|
+
return { value: settings.publishMode.value, source: settings.publishMode.source };
|
|
730
|
+
}
|
|
731
|
+
if (key === "publish.ackServerWarnings") {
|
|
732
|
+
return {
|
|
733
|
+
value: settings.publishAckServerWarnings.value,
|
|
734
|
+
source: settings.publishAckServerWarnings.source
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
return {
|
|
738
|
+
value: toMoney(settings.publishDefaultPrice.value),
|
|
739
|
+
source: settings.publishDefaultPrice.source
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function renderHooksSetting(key, settings) {
|
|
743
|
+
const { value, source } = settings.hooks[key.slice("hooks.".length)];
|
|
744
|
+
return { value, source };
|
|
745
|
+
}
|
|
746
|
+
function renderValue(key, stored) {
|
|
747
|
+
if (key === "shelfBypassSecret") {
|
|
748
|
+
return { value: typeof stored === "string" && stored.length > 0 ? "set" : "unset" };
|
|
749
|
+
}
|
|
750
|
+
if (Array.isArray(stored) || typeof stored === "boolean") return { value: stored };
|
|
751
|
+
if (key === "sessionBudget" && stored === "none") return { value: null };
|
|
752
|
+
if (key === "maxAutoSpend" || key === "sessionBudget") return { value: toMoney(stored) };
|
|
753
|
+
if (key === "sendMaxAmount") {
|
|
754
|
+
return { value: stored === "none" || stored === SEND_MAX_UNSET ? stored : toMoney(stored) };
|
|
755
|
+
}
|
|
756
|
+
return { value: stored };
|
|
757
|
+
}
|
|
758
|
+
function parseValue(key, value) {
|
|
759
|
+
switch (key) {
|
|
760
|
+
case "sessionBudget":
|
|
761
|
+
return value === "none" ? "none" : parseUsdToAtomic(value);
|
|
762
|
+
case "maxAutoSpend":
|
|
763
|
+
return parseUsdToAtomic(value);
|
|
764
|
+
// throws USAGE on a bad amount
|
|
765
|
+
case "sendMaxAmount":
|
|
766
|
+
return value === "none" ? "none" : parseUsdToAtomic(value);
|
|
767
|
+
case "allowlistCreators":
|
|
768
|
+
return parseAllowlist(value);
|
|
769
|
+
case "baseUrl":
|
|
770
|
+
case "publicShelfUrl":
|
|
771
|
+
case "rpcUrl":
|
|
772
|
+
return parseHttpUrl(value);
|
|
773
|
+
case "shelfBypassSecret":
|
|
774
|
+
return value.trim();
|
|
775
|
+
case "evalCohort":
|
|
776
|
+
return parseBoolean(value);
|
|
777
|
+
case "bazaarRegistries":
|
|
778
|
+
return parseRegistryList(value);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
function parseRegistryList(value) {
|
|
782
|
+
return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0).map((entry) => parseHttpUrl(entry));
|
|
783
|
+
}
|
|
784
|
+
function parseBoolean(value) {
|
|
785
|
+
if (value === "true" || value === "on") return true;
|
|
786
|
+
if (value === "false" || value === "off") return false;
|
|
787
|
+
throw new CliError("USAGE", `Invalid boolean value: ${JSON.stringify(value)}`, {
|
|
788
|
+
fix: 'Use "on" or "off" (or "true"/"false").'
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
function parseAllowlist(value) {
|
|
792
|
+
const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
793
|
+
for (const entry of entries) {
|
|
794
|
+
if (/\s/.test(entry)) {
|
|
795
|
+
throw new CliError("USAGE", `Invalid creator entry: ${JSON.stringify(entry)}`, {
|
|
796
|
+
fix: "Creator entries cannot contain spaces; separate multiple with commas."
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return entries;
|
|
801
|
+
}
|
|
802
|
+
function parseHttpUrl(value) {
|
|
803
|
+
let url;
|
|
804
|
+
try {
|
|
805
|
+
url = new URL(value);
|
|
806
|
+
} catch {
|
|
807
|
+
throw new CliError("USAGE", `Invalid URL: ${JSON.stringify(value)}`, {
|
|
808
|
+
fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
812
|
+
throw new CliError("USAGE", `URL must be http or https: ${JSON.stringify(value)}`, {
|
|
813
|
+
fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
return value;
|
|
817
|
+
}
|
|
818
|
+
async function persist(dir, merge) {
|
|
819
|
+
await mkdir(dir, { recursive: true, mode: 448 });
|
|
820
|
+
const lockPath = `${configPath(dir)}.lock`;
|
|
821
|
+
try {
|
|
822
|
+
await withFileLock(lockPath, async () => {
|
|
823
|
+
const existing = await loadRawConfig(dir);
|
|
824
|
+
const merged = merge(existing);
|
|
825
|
+
const validated = RawConfigSchema.parse(merged);
|
|
826
|
+
await writeFileAtomic(configPath(dir), `${JSON.stringify(validated, null, 2)}
|
|
827
|
+
`, {
|
|
828
|
+
mode: 384,
|
|
829
|
+
dirMode: 448
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
} catch (err) {
|
|
833
|
+
if (err instanceof LockTimeoutError) {
|
|
834
|
+
throw new CliError("INTERNAL", err.message, {
|
|
835
|
+
fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
|
|
836
|
+
cause: err
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
throw err;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
function formatLine(key, entry) {
|
|
843
|
+
const label = key.padEnd(KEY_WIDTH);
|
|
844
|
+
const where = entry.path !== void 0 && (entry.source === "project" || entry.source === "local") ? ` ${entry.path}` : "";
|
|
845
|
+
return ` ${label} ${displayValue(entry)} ${styleText("dim", `(${entry.source}${where})`)}`;
|
|
846
|
+
}
|
|
847
|
+
function describedLine(key, entry, note) {
|
|
848
|
+
const description = KEY_DESCRIPTIONS[key];
|
|
849
|
+
let line = formatLine(key, entry);
|
|
850
|
+
if (description !== void 0) line += ` ${styleText("dim", `- ${description}`)}`;
|
|
851
|
+
return withNote(line, note);
|
|
852
|
+
}
|
|
853
|
+
function withNote(line, note) {
|
|
854
|
+
return note !== void 0 ? `${line} ${styleText("dim", `(${note})`)}` : line;
|
|
855
|
+
}
|
|
856
|
+
function downgradeNote(key, settings) {
|
|
857
|
+
if (key !== "publish.mode" || settings.publishMode.downgradedWarning === void 0) {
|
|
858
|
+
return void 0;
|
|
859
|
+
}
|
|
860
|
+
return "downgraded from full-auto: committed .tenjin.json (gitignore it to opt in)";
|
|
861
|
+
}
|
|
862
|
+
function displayValue(entry) {
|
|
863
|
+
const { value } = entry;
|
|
864
|
+
if (Array.isArray(value)) return value.length > 0 ? value.join(", ") : "(empty)";
|
|
865
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
866
|
+
if (value === null) return "none (no daily limit)";
|
|
867
|
+
if (typeof value === "object") return `${value.usd} USD`;
|
|
868
|
+
return value;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
export {
|
|
872
|
+
RETIRED_SKILL_NAMES,
|
|
873
|
+
skillsDirsFor,
|
|
874
|
+
onPath,
|
|
875
|
+
readSkillFile,
|
|
876
|
+
skillFrontmatterName,
|
|
877
|
+
runConfigList,
|
|
878
|
+
runConfigGet,
|
|
879
|
+
runConfigSet,
|
|
880
|
+
persistHookArm,
|
|
881
|
+
persistPublishMode,
|
|
882
|
+
persistRouterProject,
|
|
883
|
+
ROUTER_DEFAULTS,
|
|
884
|
+
persistRouterDefaults,
|
|
885
|
+
persistInstallHarness,
|
|
886
|
+
persistGrantDeclined
|
|
887
|
+
};
|
|
888
|
+
//# sourceMappingURL=chunk-2E6GVIRP.js.map
|