tenjin-cli 0.1.0-alpha.27 → 0.1.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -17
- package/dist/alive-3J3CHOQP.js +21 -0
- package/dist/{chunk-SKQQOEWH.js → chunk-3QJREVMX.js} +5 -7
- package/dist/{chunk-SKQQOEWH.js.map → chunk-3QJREVMX.js.map} +1 -1
- package/dist/{chunk-BOAI23CX.js → chunk-6KA4HFX5.js} +21 -15
- package/dist/chunk-6KA4HFX5.js.map +1 -0
- package/dist/chunk-6W5GYG3W.js +128 -0
- package/dist/chunk-6W5GYG3W.js.map +1 -0
- package/dist/{chunk-4L7KMA7P.js → chunk-7H3RN4WJ.js} +7 -9
- package/dist/{chunk-4L7KMA7P.js.map → chunk-7H3RN4WJ.js.map} +1 -1
- package/dist/{chunk-O7CUHHYU.js → chunk-7R37M6WV.js} +7 -9
- package/dist/{chunk-O7CUHHYU.js.map → chunk-7R37M6WV.js.map} +1 -1
- package/dist/{chunk-LAIZ2AQA.js → chunk-A5H3E5QA.js} +2 -2
- package/dist/{update-RJDA5ZY3.js → chunk-AO54FM4H.js} +147 -26
- package/dist/chunk-AO54FM4H.js.map +1 -0
- package/dist/{chunk-VNNXAYJE.js → chunk-BRHREK7E.js} +2 -2
- package/dist/{chunk-YQOQ6XEI.js → chunk-DJYAPACT.js} +35 -33
- package/dist/chunk-DJYAPACT.js.map +1 -0
- package/dist/{chunk-GU4GGKYP.js → chunk-DYSDQE7S.js} +36 -2
- package/dist/chunk-DYSDQE7S.js.map +1 -0
- package/dist/{chunk-YKM2ZTA2.js → chunk-FQ6DHINU.js} +36 -38
- package/dist/{chunk-YKM2ZTA2.js.map → chunk-FQ6DHINU.js.map} +1 -1
- package/dist/{chunk-6ZSGER3A.js → chunk-FZTSGQVK.js} +2 -2
- package/dist/{chunk-AWKQSKUL.js → chunk-KAMRYUK2.js} +2 -2
- package/dist/{chunk-2TYQD22Q.js → chunk-MNTQMZJB.js} +6 -8
- package/dist/{chunk-2TYQD22Q.js.map → chunk-MNTQMZJB.js.map} +1 -1
- package/dist/{chunk-VIOUZW7Z.js → chunk-QTND6XWJ.js} +159 -35
- package/dist/chunk-QTND6XWJ.js.map +1 -0
- package/dist/chunk-RLPLYUME.js +115 -0
- package/dist/{chunk-HC3QEZKT.js.map → chunk-RLPLYUME.js.map} +1 -1
- package/dist/{chunk-5NEHH2E5.js → chunk-UEOWNDQG.js} +8 -10
- package/dist/{chunk-5NEHH2E5.js.map → chunk-UEOWNDQG.js.map} +1 -1
- package/dist/{chunk-OHZYNZSD.js → chunk-UOW5JXYY.js} +5 -7
- package/dist/{chunk-OHZYNZSD.js.map → chunk-UOW5JXYY.js.map} +1 -1
- package/dist/chunk-VSUHGRVB.js +1455 -0
- package/dist/chunk-VSUHGRVB.js.map +1 -0
- package/dist/{chunk-64SE3QC5.js → chunk-W6JX4LYF.js} +12 -4
- package/dist/chunk-W6JX4LYF.js.map +1 -0
- package/dist/{chunk-5FGO6TYT.js → chunk-XVTD7UWR.js} +3 -5
- package/dist/{chunk-5FGO6TYT.js.map → chunk-XVTD7UWR.js.map} +1 -1
- package/dist/{chunk-X7I343ZY.js → chunk-YFJJYHVG.js} +2 -2
- package/dist/{chunk-XVYATBKD.js → chunk-ZG6ZZLO7.js} +898 -521
- package/dist/chunk-ZG6ZZLO7.js.map +1 -0
- package/dist/{chunk-DATCR7AU.js → chunk-ZO3X5NPG.js} +4 -6
- package/dist/{chunk-DATCR7AU.js.map → chunk-ZO3X5NPG.js.map} +1 -1
- package/dist/{chunk-VXIBZ6W5.js → chunk-ZP5PV3JB.js} +3 -3
- package/dist/{chunk-G4AM2SOL.js → chunk-ZP7AHN7Z.js} +4 -6
- package/dist/{chunk-G4AM2SOL.js.map → chunk-ZP7AHN7Z.js.map} +1 -1
- package/dist/{cli-6JNIPZQ6.js → cli-234DNHN6.js} +54 -53
- package/dist/{cli-6JNIPZQ6.js.map → cli-234DNHN6.js.map} +1 -1
- package/dist/{config-G75YT6NC.js → config-IY2OJCAK.js} +10 -13
- package/dist/{doctor-3GMDOW4Y.js → doctor-2UZZF44A.js} +267 -242
- package/dist/doctor-2UZZF44A.js.map +1 -0
- package/dist/{fund-3IPR5YRJ.js → fund-RZ2QFULK.js} +92 -38
- package/dist/{fund-3IPR5YRJ.js.map → fund-RZ2QFULK.js.map} +1 -1
- package/dist/hook-command-PZHKS7ES.js +31 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
- package/dist/hosts/claude/tenjin/.mcp.json +11 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +206 -0
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/install-O5FJ5EP3.js +48 -0
- package/dist/{install-identity-PM4AGFFX.js → install-identity-QM44IQ6Z.js} +7 -8
- package/dist/{install-wallet-6756NOB5.js → install-wallet-Z52EDLPB.js} +14 -15
- package/dist/{install-wallet-6756NOB5.js.map → install-wallet-Z52EDLPB.js.map} +1 -1
- package/dist/{mcp-33FAAZ7F.js → mcp-33HAADDF.js} +80 -67
- package/dist/{mcp-33FAAZ7F.js.map → mcp-33HAADDF.js.map} +1 -1
- package/dist/package-RT24HTTP.js +37 -0
- package/dist/{pay-XOYR4PCH.js → pay-IR2V76FX.js} +16 -17
- package/dist/{payments-UTQDBO7H.js → payments-GFV4HU5R.js} +9 -10
- package/dist/{payments-UTQDBO7H.js.map → payments-GFV4HU5R.js.map} +1 -1
- package/dist/{send-CVGNOQW3.js → send-PI4NUA7I.js} +12 -14
- package/dist/{send-CVGNOQW3.js.map → send-PI4NUA7I.js.map} +1 -1
- package/dist/{status-NACN4DGX.js → status-ZUHTJK46.js} +6 -7
- package/dist/{status-NACN4DGX.js.map → status-ZUHTJK46.js.map} +1 -1
- package/dist/{status-line-3IQKGRUH.js → status-line-2G5JPQAE.js} +6 -7
- package/dist/{status-line-3IQKGRUH.js.map → status-line-2G5JPQAE.js.map} +1 -1
- package/dist/uninstall-THKUH5ZT.js +136 -0
- package/dist/uninstall-THKUH5ZT.js.map +1 -0
- package/dist/update-NPZDP24E.js +18 -0
- package/dist/update-NPZDP24E.js.map +1 -0
- package/dist/{wallet-B3FVHNTS.js → wallet-53EFH4M5.js} +11 -12
- package/dist/wallet-53EFH4M5.js.map +1 -0
- package/docs/agent-permissions.md +27 -17
- package/package.json +1 -1
- package/dist/chunk-64SE3QC5.js.map +0 -1
- package/dist/chunk-BOAI23CX.js.map +0 -1
- package/dist/chunk-DSNXKUXI.js +0 -172
- package/dist/chunk-DSNXKUXI.js.map +0 -1
- package/dist/chunk-GU4GGKYP.js.map +0 -1
- package/dist/chunk-H2L33M7F.js +0 -944
- package/dist/chunk-H2L33M7F.js.map +0 -1
- package/dist/chunk-HC3QEZKT.js +0 -87
- package/dist/chunk-JLEF5WHM.js +0 -132
- package/dist/chunk-JLEF5WHM.js.map +0 -1
- package/dist/chunk-MAQUL5BD.js +0 -99
- package/dist/chunk-MAQUL5BD.js.map +0 -1
- package/dist/chunk-PY7MQUKP.js +0 -755
- package/dist/chunk-PY7MQUKP.js.map +0 -1
- package/dist/chunk-TGLKKLQG.js +0 -11
- package/dist/chunk-TGLKKLQG.js.map +0 -1
- package/dist/chunk-VIOUZW7Z.js.map +0 -1
- package/dist/chunk-XVYATBKD.js.map +0 -1
- package/dist/chunk-YQOQ6XEI.js.map +0 -1
- package/dist/doctor-3GMDOW4Y.js.map +0 -1
- package/dist/hook-command-ZXX4FT4N.js +0 -32
- package/dist/install-6OROTYHZ.js +0 -72
- package/dist/status-line-wiring-QXBOOY2T.js +0 -31
- package/dist/uninstall-NYFKSYW4.js +0 -175
- package/dist/uninstall-NYFKSYW4.js.map +0 -1
- package/dist/update-RJDA5ZY3.js.map +0 -1
- /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
- /package/dist/{chunk-LAIZ2AQA.js.map → chunk-A5H3E5QA.js.map} +0 -0
- /package/dist/{chunk-VNNXAYJE.js.map → chunk-BRHREK7E.js.map} +0 -0
- /package/dist/{chunk-6ZSGER3A.js.map → chunk-FZTSGQVK.js.map} +0 -0
- /package/dist/{chunk-AWKQSKUL.js.map → chunk-KAMRYUK2.js.map} +0 -0
- /package/dist/{chunk-X7I343ZY.js.map → chunk-YFJJYHVG.js.map} +0 -0
- /package/dist/{chunk-VXIBZ6W5.js.map → chunk-ZP5PV3JB.js.map} +0 -0
- /package/dist/{hook-command-ZXX4FT4N.js.map → config-IY2OJCAK.js.map} +0 -0
- /package/dist/{install-6OROTYHZ.js.map → hook-command-PZHKS7ES.js.map} +0 -0
- /package/dist/{install-identity-PM4AGFFX.js.map → install-O5FJ5EP3.js.map} +0 -0
- /package/dist/{pay-XOYR4PCH.js.map → install-identity-QM44IQ6Z.js.map} +0 -0
- /package/dist/{status-line-wiring-QXBOOY2T.js.map → package-RT24HTTP.js.map} +0 -0
- /package/dist/{wallet-B3FVHNTS.js.map → pay-IR2V76FX.js.map} +0 -0
|
@@ -3,27 +3,75 @@ import {
|
|
|
3
3
|
HOOK_TOOL
|
|
4
4
|
} from "./chunk-AKWGE6JQ.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
LEGACY_MCP_SERVER_NAME,
|
|
7
|
+
ROUTER_DEFAULTS
|
|
8
|
+
} from "./chunk-DYSDQE7S.js";
|
|
8
9
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
modeGatedPointer
|
|
11
|
+
} from "./chunk-A36LQPHV.js";
|
|
11
12
|
import {
|
|
13
|
+
confirmChoice
|
|
14
|
+
} from "./chunk-P7LABKCW.js";
|
|
15
|
+
import {
|
|
16
|
+
LockTimeoutError,
|
|
17
|
+
withFileLock
|
|
18
|
+
} from "./chunk-MEFB5KHA.js";
|
|
19
|
+
import {
|
|
20
|
+
style
|
|
21
|
+
} from "./chunk-XVTD7UWR.js";
|
|
22
|
+
import {
|
|
23
|
+
projectRouterPath,
|
|
24
|
+
readProjectRouterFile,
|
|
25
|
+
routerSettings
|
|
26
|
+
} from "./chunk-ZO3X5NPG.js";
|
|
27
|
+
import {
|
|
28
|
+
hasCode
|
|
29
|
+
} from "./chunk-2I4QTOLB.js";
|
|
30
|
+
import {
|
|
31
|
+
isTeamShelfOrigin,
|
|
32
|
+
loadProjectConfig
|
|
33
|
+
} from "./chunk-ZP7AHN7Z.js";
|
|
34
|
+
import {
|
|
35
|
+
parseUsdToAtomic,
|
|
36
|
+
toMoney
|
|
37
|
+
} from "./chunk-FZTSGQVK.js";
|
|
38
|
+
import {
|
|
39
|
+
CONFIG_KEYS,
|
|
12
40
|
CliError,
|
|
41
|
+
EXPERIMENTAL_CONFIG_KEYS,
|
|
13
42
|
HARNESSES,
|
|
43
|
+
HOOKS_CONFIG_KEYS,
|
|
44
|
+
LOOP_CONFIG_KEYS,
|
|
45
|
+
PRODUCTION_ORIGIN,
|
|
46
|
+
PUBLISH_CONFIG_KEYS,
|
|
47
|
+
PublishModeSchema,
|
|
48
|
+
RETIRED_PAYMENT_GUIDANCE,
|
|
49
|
+
ROUTER_CONFIG_KEYS,
|
|
50
|
+
ROUTER_CONTEXTS,
|
|
51
|
+
RawConfigSchema,
|
|
52
|
+
SEND_MAX_UNSET,
|
|
53
|
+
TEAM_CONFIG_KEYS,
|
|
54
|
+
UPDATE_CONFIG_KEYS,
|
|
55
|
+
isSameDeployment,
|
|
56
|
+
loadRawConfig,
|
|
57
|
+
parseAckServerWarnings,
|
|
58
|
+
parseLoopValue,
|
|
59
|
+
parsePublicFallbackFlag,
|
|
60
|
+
parseUpdateModeFlag,
|
|
61
|
+
resolveSettings,
|
|
62
|
+
retiredPaymentKeys,
|
|
14
63
|
writeFileAtomic
|
|
15
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-QTND6XWJ.js";
|
|
16
65
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
daemonPidPath,
|
|
20
|
-
daemonSpawnPath,
|
|
21
|
-
daemonTokenPath,
|
|
22
|
-
hooksDir,
|
|
23
|
-
shimBundlePath,
|
|
24
|
-
vitestReporterPath
|
|
66
|
+
configPath,
|
|
67
|
+
hooksDir
|
|
25
68
|
} from "./chunk-K6AXXYCG.js";
|
|
26
69
|
|
|
70
|
+
// src/commands/config.ts
|
|
71
|
+
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
72
|
+
import { homedir } from "node:os";
|
|
73
|
+
import { dirname as dirname3 } from "node:path";
|
|
74
|
+
|
|
27
75
|
// src/lib/harness-permissions.ts
|
|
28
76
|
import { chmod, lstat, mkdir, readFile, realpath, stat as stat2 } from "node:fs/promises";
|
|
29
77
|
import { dirname, join as join4 } from "node:path";
|
|
@@ -42,13 +90,9 @@ var AGENT_ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
|
|
|
42
90
|
|
|
43
91
|
// src/hooks/constants.ts
|
|
44
92
|
var HARNESS_MS = 5e3;
|
|
45
|
-
var SPAWN_MS = 500;
|
|
46
|
-
var HEALTH_MS = 200;
|
|
47
|
-
var SPAWN_BACKOFF_MS = 6e4;
|
|
48
93
|
var MAX_BODY_BYTES = 4 * 1024 * 1024;
|
|
49
94
|
var LOG_TRUNCATE_BYTES = 5 * 1024 * 1024;
|
|
50
95
|
var CONTEXT_MAX = 1e4;
|
|
51
|
-
var STOP_GRACE_MS = 3e3;
|
|
52
96
|
|
|
53
97
|
// src/lib/codex-trust.ts
|
|
54
98
|
import { spawn } from "node:child_process";
|
|
@@ -259,8 +303,8 @@ async function trustCodexHooks(home, keys, ownedBy, opts = {}) {
|
|
|
259
303
|
}
|
|
260
304
|
async function readCodexTrust(home, keys, opts = {}) {
|
|
261
305
|
const env = opts.env ?? process.env;
|
|
262
|
-
const
|
|
263
|
-
const base = { configPath, trusted: 0, expected: keys.length };
|
|
306
|
+
const configPath2 = codexConfigPath(home, env);
|
|
307
|
+
const base = { configPath: configPath2, trusted: 0, expected: keys.length };
|
|
264
308
|
if (keys.length === 0) return { ...base, state: "unknown", source: "none" };
|
|
265
309
|
const list = await (opts.listHooks ?? ((h, e) => listHooksViaAppServer(h, e, opts.timeoutMs ?? PROBE_MS)))(home, env);
|
|
266
310
|
if (list !== null) {
|
|
@@ -893,33 +937,115 @@ async function inspectAllowlistAt(declaredPath, rules, list = "allow") {
|
|
|
893
937
|
const alreadyPresent = rules.filter((rule) => present.has(rule));
|
|
894
938
|
return { path, raw, settings, permissions, allow, added, alreadyPresent: [...alreadyPresent] };
|
|
895
939
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
940
|
+
|
|
941
|
+
// src/lib/skill-wiring.ts
|
|
942
|
+
import { existsSync, statSync } from "node:fs";
|
|
943
|
+
import { constants, open } from "node:fs/promises";
|
|
944
|
+
import { delimiter, join as join6 } from "node:path";
|
|
945
|
+
|
|
946
|
+
// src/lib/skills-source.ts
|
|
947
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
948
|
+
var SKILL_NAMES = ["tenjin-search", "tenjin-publish", "tenjin"];
|
|
949
|
+
var RETIRED_SKILL_NAMES = ["tenjin-pay"];
|
|
950
|
+
var PACKAGED_SKILL_NAMES = [...SKILL_NAMES];
|
|
951
|
+
var SHIPPED_SKILL_FILES = {
|
|
952
|
+
"tenjin-search": ["SKILL.md", "references/permissions.md"],
|
|
953
|
+
"tenjin-publish": ["SKILL.md", "references/maintain.md"],
|
|
954
|
+
tenjin: ["SKILL.md"],
|
|
955
|
+
"tenjin-pay": ["SKILL.md"]
|
|
956
|
+
};
|
|
957
|
+
var SENTINEL = join5("tenjin", "SKILL.md");
|
|
958
|
+
|
|
959
|
+
// src/lib/skill-wiring.ts
|
|
960
|
+
var CLI_SKILL_NAMES = [
|
|
961
|
+
"tenjin-search",
|
|
962
|
+
"tenjin-publish"
|
|
963
|
+
];
|
|
964
|
+
function skillsDirsFor(home) {
|
|
965
|
+
return [join6(home, ".claude", "skills"), join6(home, ".agents", "skills")];
|
|
966
|
+
}
|
|
967
|
+
function harnessTargetDir(home, harness) {
|
|
968
|
+
if (harness === "claude") return join6(home, ".claude", "skills");
|
|
969
|
+
return join6(home, ".agents", "skills");
|
|
970
|
+
}
|
|
971
|
+
function harnessFlagFor(home, dir) {
|
|
972
|
+
if (dir === join6(home, ".claude", "skills")) return "claude";
|
|
973
|
+
return "codex";
|
|
974
|
+
}
|
|
975
|
+
function harnessDetectedBy(home, harness, which) {
|
|
976
|
+
const reasons = [];
|
|
977
|
+
if (existsSync(join6(home, `.${harness}`))) reasons.push("home-dir");
|
|
978
|
+
if (which(harness)) reasons.push("binary");
|
|
979
|
+
return reasons;
|
|
980
|
+
}
|
|
981
|
+
function detectHarnesses(home, which) {
|
|
982
|
+
return {
|
|
983
|
+
claude: harnessDetectedBy(home, "claude", which).length > 0,
|
|
984
|
+
codex: harnessDetectedBy(home, "codex", which).length > 0
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
function harnessReads(home, dir, present) {
|
|
988
|
+
if (harnessFlagFor(home, dir) === "claude") return present.claude;
|
|
989
|
+
return present.codex;
|
|
990
|
+
}
|
|
991
|
+
function harnessRequested(home, dir, requested) {
|
|
992
|
+
return requested.some((h) => harnessTargetDir(home, h) === dir);
|
|
993
|
+
}
|
|
994
|
+
function harnessInPlay(home, dir, present, requested) {
|
|
995
|
+
if (requested.length > 0) return harnessRequested(home, dir, requested);
|
|
996
|
+
return harnessReads(home, dir, present);
|
|
997
|
+
}
|
|
998
|
+
function onPath(bin, env) {
|
|
999
|
+
const raw = env.PATH ?? "";
|
|
1000
|
+
const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
|
|
1001
|
+
for (const part of raw.split(delimiter)) {
|
|
1002
|
+
if (part.length === 0) continue;
|
|
1003
|
+
for (const ext of exts) {
|
|
1004
|
+
if (isFile(join6(part, bin + ext))) return true;
|
|
1005
|
+
}
|
|
907
1006
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
function isFile(p) {
|
|
1010
|
+
try {
|
|
1011
|
+
return statSync(p).isFile();
|
|
1012
|
+
} catch {
|
|
1013
|
+
return false;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
async function readSkillFile(path) {
|
|
1017
|
+
let handle;
|
|
1018
|
+
try {
|
|
1019
|
+
handle = await open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
if (hasCode(err, "ENOENT")) return { kind: "absent" };
|
|
1022
|
+
return { kind: "unreadable", err };
|
|
1023
|
+
}
|
|
1024
|
+
try {
|
|
1025
|
+
if (!(await handle.stat()).isFile()) return { kind: "not-regular" };
|
|
1026
|
+
return { kind: "ok", bytes: await handle.readFile() };
|
|
1027
|
+
} catch (err) {
|
|
1028
|
+
return { kind: "unreadable", err };
|
|
1029
|
+
} finally {
|
|
1030
|
+
await handle.close().catch(() => void 0);
|
|
920
1031
|
}
|
|
921
|
-
|
|
922
|
-
|
|
1032
|
+
}
|
|
1033
|
+
function skillFrontmatterName(skillMd) {
|
|
1034
|
+
const frontmatter = extractFrontmatter(skillMd);
|
|
1035
|
+
if (frontmatter === null) return null;
|
|
1036
|
+
for (const line of frontmatter) {
|
|
1037
|
+
const m = /^name:\s*(.+?)\s*$/.exec(line);
|
|
1038
|
+
if (m !== null) return (m[1] ?? "").replace(/^["']|["']$/g, "");
|
|
1039
|
+
}
|
|
1040
|
+
return null;
|
|
1041
|
+
}
|
|
1042
|
+
function extractFrontmatter(text) {
|
|
1043
|
+
const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
1044
|
+
const open2 = lines.findIndex((l) => l.trim().length > 0);
|
|
1045
|
+
if (open2 === -1 || lines[open2]?.trim() !== "---") return null;
|
|
1046
|
+
const end = lines.findIndex((l, i) => i > open2 && l.trim() === "---");
|
|
1047
|
+
if (end === -1) return null;
|
|
1048
|
+
return lines.slice(open2 + 1, end);
|
|
923
1049
|
}
|
|
924
1050
|
|
|
925
1051
|
// src/adapters/claude.ts
|
|
@@ -1139,308 +1265,17 @@ var ADAPTERS = {
|
|
|
1139
1265
|
// src/lib/harness-hooks.ts
|
|
1140
1266
|
import { chmod as chmod2, lstat as lstat2, readFile as readFile2, realpath as realpath2, stat as stat3 } from "node:fs/promises";
|
|
1141
1267
|
import { resolve } from "node:path";
|
|
1142
|
-
|
|
1143
|
-
// src/daemon/control.ts
|
|
1144
|
-
import { randomBytes } from "node:crypto";
|
|
1145
|
-
import { copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, renameSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1146
|
-
import { dirname as dirname2, join as join5 } from "node:path";
|
|
1147
|
-
import { fileURLToPath } from "node:url";
|
|
1148
|
-
|
|
1149
|
-
// src/hooks/shim.ts
|
|
1150
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
1151
|
-
import {
|
|
1152
|
-
appendFileSync,
|
|
1153
|
-
closeSync,
|
|
1154
|
-
existsSync,
|
|
1155
|
-
mkdirSync,
|
|
1156
|
-
openSync,
|
|
1157
|
-
readFileSync,
|
|
1158
|
-
statSync,
|
|
1159
|
-
unlinkSync,
|
|
1160
|
-
writeFileSync
|
|
1161
|
-
} from "node:fs";
|
|
1162
|
-
function missingRoutes(h, required) {
|
|
1163
|
-
const served = new Set(Array.isArray(h.harnesses) ? h.harnesses : []);
|
|
1164
|
-
return required.filter((harness) => !served.has(harness));
|
|
1165
|
-
}
|
|
1166
|
-
function readPid(dataDir2) {
|
|
1167
|
-
try {
|
|
1168
|
-
const raw = JSON.parse(readFileSync(daemonPidPath(dataDir2), "utf8"));
|
|
1169
|
-
if (typeof raw.pid === "number" && typeof raw.port === "number" && typeof raw.started_at === "number" && typeof raw.data_dir === "string") {
|
|
1170
|
-
return { pid: raw.pid, port: raw.port, started_at: raw.started_at, data_dir: raw.data_dir };
|
|
1171
|
-
}
|
|
1172
|
-
return null;
|
|
1173
|
-
} catch {
|
|
1174
|
-
return null;
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
function readToken(dataDir2) {
|
|
1178
|
-
try {
|
|
1179
|
-
const t = readFileSync(daemonTokenPath(dataDir2), "utf8").trim();
|
|
1180
|
-
return t.length > 0 ? t : null;
|
|
1181
|
-
} catch {
|
|
1182
|
-
return null;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
async function health(port, timeoutMs = HEALTH_MS) {
|
|
1186
|
-
try {
|
|
1187
|
-
const res = await fetch(`http://127.0.0.1:${port}/health`, {
|
|
1188
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
1189
|
-
});
|
|
1190
|
-
if (!res.ok) return null;
|
|
1191
|
-
const body = await res.json();
|
|
1192
|
-
if (typeof body.pid !== "number" || typeof body.data_dir !== "string") return null;
|
|
1193
|
-
return body;
|
|
1194
|
-
} catch {
|
|
1195
|
-
return null;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
function daemonEnv(dataDir2, env = process.env) {
|
|
1199
|
-
const keep = [
|
|
1200
|
-
"PATH",
|
|
1201
|
-
"HOME",
|
|
1202
|
-
"USERPROFILE",
|
|
1203
|
-
"TMPDIR",
|
|
1204
|
-
"TEMP",
|
|
1205
|
-
"TMP",
|
|
1206
|
-
"HTTP_PROXY",
|
|
1207
|
-
"HTTPS_PROXY",
|
|
1208
|
-
"NO_PROXY",
|
|
1209
|
-
"http_proxy",
|
|
1210
|
-
"https_proxy",
|
|
1211
|
-
"no_proxy"
|
|
1212
|
-
];
|
|
1213
|
-
const out = {};
|
|
1214
|
-
for (const k of keep) if (env[k] !== void 0) out[k] = env[k];
|
|
1215
|
-
out.TENJIN_DATA_DIR = dataDir2;
|
|
1216
|
-
return out;
|
|
1217
|
-
}
|
|
1218
|
-
function inBackoff(dataDir2, now = Date.now()) {
|
|
1219
|
-
try {
|
|
1220
|
-
return now - statSync(daemonSpawnPath(dataDir2)).mtimeMs < SPAWN_BACKOFF_MS;
|
|
1221
|
-
} catch {
|
|
1222
|
-
return false;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
function spawnDaemon(dataDir2, env = process.env) {
|
|
1226
|
-
mkdirSync(dataDir2, { recursive: true, mode: 448 });
|
|
1227
|
-
writeFileSync(daemonSpawnPath(dataDir2), "");
|
|
1228
|
-
const log = openSync(daemonLogPath(dataDir2), "a");
|
|
1229
|
-
try {
|
|
1230
|
-
const child = spawn2(process.execPath, [daemonBundlePath(dataDir2)], {
|
|
1231
|
-
detached: true,
|
|
1232
|
-
stdio: ["ignore", log, log],
|
|
1233
|
-
env: daemonEnv(dataDir2, env),
|
|
1234
|
-
// Never the hook's cwd: a detached daemon would pin a project worktree.
|
|
1235
|
-
cwd: dataDir2,
|
|
1236
|
-
windowsHide: true
|
|
1237
|
-
});
|
|
1238
|
-
child.unref();
|
|
1239
|
-
} finally {
|
|
1240
|
-
closeSync(log);
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
function sleep(ms) {
|
|
1244
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
1245
|
-
}
|
|
1246
|
-
async function ensureDaemon(dataDir2, opts = {}) {
|
|
1247
|
-
const now = opts.now ?? (() => Date.now());
|
|
1248
|
-
const pid = readPid(dataDir2);
|
|
1249
|
-
if (pid !== null) {
|
|
1250
|
-
const h = await health(pid.port);
|
|
1251
|
-
if (h !== null && h.data_dir === dataDir2) return { ok: true, health: h, spawned: false };
|
|
1252
|
-
}
|
|
1253
|
-
if (!existsSync(daemonBundlePath(dataDir2)))
|
|
1254
|
-
return { ok: false, reason: "no bundle; run `tenjin daemon start`" };
|
|
1255
|
-
if (inBackoff(dataDir2, now())) return { ok: false, reason: "spawn backoff" };
|
|
1256
|
-
try {
|
|
1257
|
-
spawnDaemon(dataDir2, opts.env);
|
|
1258
|
-
} catch (err) {
|
|
1259
|
-
return {
|
|
1260
|
-
ok: false,
|
|
1261
|
-
reason: `spawn failed: ${err instanceof Error ? err.message : String(err)}`
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
const budget = opts.spawnMs ?? SPAWN_MS;
|
|
1265
|
-
const until = now() + budget;
|
|
1266
|
-
const settled = async () => {
|
|
1267
|
-
const fresh = readPid(dataDir2);
|
|
1268
|
-
if (fresh === null || pid !== null && fresh.started_at === pid.started_at) return null;
|
|
1269
|
-
const h = await health(fresh.port);
|
|
1270
|
-
return h !== null && h.data_dir === dataDir2 ? h : null;
|
|
1271
|
-
};
|
|
1272
|
-
const won = (h) => {
|
|
1273
|
-
try {
|
|
1274
|
-
unlinkSync(daemonSpawnPath(dataDir2));
|
|
1275
|
-
} catch {
|
|
1276
|
-
}
|
|
1277
|
-
return { ok: true, health: h, spawned: true };
|
|
1278
|
-
};
|
|
1279
|
-
while (now() < until) {
|
|
1280
|
-
await sleep(20);
|
|
1281
|
-
const h = await settled();
|
|
1282
|
-
if (h !== null) return won(h);
|
|
1283
|
-
}
|
|
1284
|
-
const late = await settled();
|
|
1285
|
-
if (late !== null) return won(late);
|
|
1286
|
-
return { ok: false, reason: `spawned but not healthy within ${budget} ms` };
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
// src/daemon/control.ts
|
|
1290
|
-
var INSTALL_SPAWN_MS = 5e3;
|
|
1291
|
-
var BUNDLES = {
|
|
1292
|
-
"tenjin-daemon.mjs": daemonBundlePath,
|
|
1293
|
-
"tenjin-shim.mjs": shimBundlePath,
|
|
1294
|
-
"tenjin-vitest-reporter.mjs": vitestReporterPath
|
|
1295
|
-
};
|
|
1296
|
-
function defaultBundleDir() {
|
|
1297
|
-
return dirname2(fileURLToPath(import.meta.url));
|
|
1298
|
-
}
|
|
1299
|
-
function installDaemonFiles(dataDir2, bundleDir) {
|
|
1300
|
-
const written = [];
|
|
1301
|
-
mkdirSync2(hooksDir(dataDir2), { recursive: true, mode: 448 });
|
|
1302
|
-
for (const [name, target] of Object.entries(BUNDLES)) {
|
|
1303
|
-
const src = join5(bundleDir, name);
|
|
1304
|
-
if (!existsSync2(src)) {
|
|
1305
|
-
throw new CliError("INTERNAL", `Daemon bundle missing: ${src}`, {
|
|
1306
|
-
fix: `Reinstall tenjin-cli; the package ships dist/${Object.keys(BUNDLES).join(", dist/")}.`
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
const dest = target(dataDir2);
|
|
1310
|
-
const staged = `${dest}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
1311
|
-
copyFileSync(src, staged);
|
|
1312
|
-
renameSync(staged, dest);
|
|
1313
|
-
written.push(dest);
|
|
1314
|
-
}
|
|
1315
|
-
if (readToken(dataDir2) === null) {
|
|
1316
|
-
writeFileSync2(daemonTokenPath(dataDir2), randomBytes(32).toString("hex"), { mode: 384 });
|
|
1317
|
-
written.push(daemonTokenPath(dataDir2));
|
|
1318
|
-
}
|
|
1319
|
-
return { written };
|
|
1320
|
-
}
|
|
1321
|
-
function alive(pid, kill) {
|
|
1322
|
-
try {
|
|
1323
|
-
kill(pid, 0);
|
|
1324
|
-
return true;
|
|
1325
|
-
} catch {
|
|
1326
|
-
return false;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
async function stopDaemon(dataDir2, deps = {}) {
|
|
1330
|
-
const kill = deps.kill ?? ((pid, sig) => process.kill(pid, sig));
|
|
1331
|
-
const sleep2 = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
1332
|
-
const now = deps.now ?? (() => Date.now());
|
|
1333
|
-
const rec = readPid(dataDir2);
|
|
1334
|
-
if (rec === null || !alive(rec.pid, kill)) {
|
|
1335
|
-
if (rec !== null) rmSync(daemonPidPath(dataDir2), { force: true });
|
|
1336
|
-
return { state: "not-running" };
|
|
1337
|
-
}
|
|
1338
|
-
const h = await health(rec.port);
|
|
1339
|
-
if (h !== null && (h.pid !== rec.pid || h.data_dir !== dataDir2)) {
|
|
1340
|
-
rmSync(daemonPidPath(dataDir2), { force: true });
|
|
1341
|
-
return { state: "not-running" };
|
|
1342
|
-
}
|
|
1343
|
-
if (h === null) return { state: "unconfirmed", pid: rec.pid };
|
|
1344
|
-
kill(rec.pid, "SIGTERM");
|
|
1345
|
-
const until = now() + STOP_GRACE_MS;
|
|
1346
|
-
while (now() < until) {
|
|
1347
|
-
await sleep2(50);
|
|
1348
|
-
if (!alive(rec.pid, kill)) return { state: "stopped", pid: rec.pid };
|
|
1349
|
-
}
|
|
1350
|
-
try {
|
|
1351
|
-
kill(rec.pid, "SIGKILL");
|
|
1352
|
-
} catch {
|
|
1353
|
-
}
|
|
1354
|
-
rmSync(daemonPidPath(dataDir2), { force: true });
|
|
1355
|
-
return { state: "killed", pid: rec.pid };
|
|
1356
|
-
}
|
|
1357
|
-
async function startDaemon(dataDir2, deps = {}) {
|
|
1358
|
-
const { written } = installDaemonFiles(dataDir2, deps.bundleDir ?? defaultBundleDir());
|
|
1359
|
-
const rec = readPid(dataDir2);
|
|
1360
|
-
const running = rec === null ? null : await health(rec.port);
|
|
1361
|
-
let replaced = null;
|
|
1362
|
-
let reason;
|
|
1363
|
-
let short = [];
|
|
1364
|
-
let unconfirmed = null;
|
|
1365
|
-
if (running !== null && running.data_dir === dataDir2) {
|
|
1366
|
-
short = missingRoutes(running, deps.requires ?? []);
|
|
1367
|
-
const stale = running.version !== package_default.version ? "older-build" : short.length > 0 ? "missing-routes" : void 0;
|
|
1368
|
-
if (stale !== void 0) {
|
|
1369
|
-
const stopped = await stopDaemon(dataDir2, deps);
|
|
1370
|
-
if (stopped.state === "stopped" || stopped.state === "killed") {
|
|
1371
|
-
replaced = rec;
|
|
1372
|
-
reason = stale;
|
|
1373
|
-
} else if (stopped.state === "unconfirmed") unconfirmed = stopped.pid ?? null;
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
const ensured = await ensureDaemon(dataDir2, {
|
|
1377
|
-
...deps.env ? { env: deps.env } : {},
|
|
1378
|
-
spawnMs: deps.spawnMs ?? INSTALL_SPAWN_MS,
|
|
1379
|
-
...deps.now ? { now: deps.now } : {}
|
|
1380
|
-
});
|
|
1381
|
-
if (!ensured.ok) {
|
|
1382
|
-
throw new CliError("INTERNAL", `Daemon did not start: ${ensured.reason}`, {
|
|
1383
|
-
fix: `Read ${join5(dataDir2, "daemon.log")}; if it names a port conflict, set \`tenjin config set loop.port <n>\`.`
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
const stillShort = missingRoutes(ensured.health, deps.requires ?? []);
|
|
1387
|
-
if (stillShort.length > 0) {
|
|
1388
|
-
throw new CliError(
|
|
1389
|
-
"INTERNAL",
|
|
1390
|
-
`The daemon on 127.0.0.1:${ensured.health.port} (v${ensured.health.version}) has no route for ${stillShort.join(", ")}, so its hook entries would answer 404.`,
|
|
1391
|
-
{ fix: "Run `tenjin daemon stop`, then re-run `tenjin install`." }
|
|
1392
|
-
);
|
|
1393
|
-
}
|
|
1394
|
-
return {
|
|
1395
|
-
health: ensured.health,
|
|
1396
|
-
spawned: ensured.spawned,
|
|
1397
|
-
replaced,
|
|
1398
|
-
...reason !== void 0 ? { replacedReason: reason } : {},
|
|
1399
|
-
...reason === "missing-routes" ? { missingRoutes: short } : {},
|
|
1400
|
-
unconfirmed,
|
|
1401
|
-
written
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
// src/lib/harness-hooks.ts
|
|
1406
1268
|
var OUR_HOOK_FILES = ["tenjin-daemon.mjs", "tenjin-shim.mjs"];
|
|
1407
1269
|
var OUR_HOOK_COMMAND = "tenjin hook ";
|
|
1408
1270
|
var LOOP_URL_RE = new RegExp(`^http://127\\.0\\.0\\.1:\\d+/hook/(?:${HARNESSES.join("|")})$`);
|
|
1409
1271
|
var HOOK_TIMEOUT_SECONDS = HARNESS_MS / 1e3;
|
|
1410
|
-
function skip2(reason, args) {
|
|
1411
|
-
return {
|
|
1412
|
-
harness: args.harness,
|
|
1413
|
-
...args.path !== void 0 ? { path: args.path } : {},
|
|
1414
|
-
...args.hooksDir !== void 0 ? { hooksDir: args.hooksDir } : {},
|
|
1415
|
-
entries: 0,
|
|
1416
|
-
wrote: false,
|
|
1417
|
-
skipped: reason,
|
|
1418
|
-
...args.warning !== void 0 ? { warning: args.warning } : {},
|
|
1419
|
-
...args.fix !== void 0 ? { fix: args.fix } : {}
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
function fixFor2(reason) {
|
|
1423
|
-
switch (reason) {
|
|
1424
|
-
case "declined":
|
|
1425
|
-
case "dry-run":
|
|
1426
|
-
return "Wire them with `tenjin install`.";
|
|
1427
|
-
case "daemon-down":
|
|
1428
|
-
return "Run `tenjin daemon start`, then re-run `tenjin install`.";
|
|
1429
|
-
case "changed-since-read":
|
|
1430
|
-
return "Another process changed the file mid-run; re-run `tenjin install`.";
|
|
1431
|
-
case "unwritable":
|
|
1432
|
-
return "The daemon, its bundles and the skills are already in place; only the hooks file could not be written. Fix its permissions (or its directory\u2019s), then re-run `tenjin install`.";
|
|
1433
|
-
default:
|
|
1434
|
-
return "Fix the reported file, then re-run `tenjin install`.";
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
1272
|
function isPlainObject2(value) {
|
|
1438
1273
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1439
1274
|
}
|
|
1440
1275
|
function ownsHandler(handler, dataDir2) {
|
|
1441
1276
|
if (!isPlainObject2(handler)) return false;
|
|
1442
1277
|
if (handler.type === "mcp_tool") {
|
|
1443
|
-
return handler.server ===
|
|
1278
|
+
return handler.server === LEGACY_MCP_SERVER_NAME && handler.tool === HOOK_TOOL;
|
|
1444
1279
|
}
|
|
1445
1280
|
const url = handler.url;
|
|
1446
1281
|
if (typeof url === "string" && LOOP_URL_RE.test(url)) return true;
|
|
@@ -1456,29 +1291,6 @@ function ownsHookEntry(entry, dataDir2) {
|
|
|
1456
1291
|
if (!Array.isArray(handlers)) return false;
|
|
1457
1292
|
return handlers.some((h) => ownsHandler(h, dataDir2));
|
|
1458
1293
|
}
|
|
1459
|
-
function pruneOurHandlers(entry, dataDir2) {
|
|
1460
|
-
if (!isPlainObject2(entry)) return entry;
|
|
1461
|
-
const handlers = entry.hooks;
|
|
1462
|
-
if (!Array.isArray(handlers)) return entry;
|
|
1463
|
-
const kept = handlers.filter((h) => !ownsHandler(h, dataDir2));
|
|
1464
|
-
if (kept.length === handlers.length) return entry;
|
|
1465
|
-
return kept.length === 0 ? null : { ...entry, hooks: kept };
|
|
1466
|
-
}
|
|
1467
|
-
function pruneHooks(hooks, dataDir2) {
|
|
1468
|
-
const next = {};
|
|
1469
|
-
const removed = [];
|
|
1470
|
-
for (const [event, value] of Object.entries(hooks)) {
|
|
1471
|
-
if (!Array.isArray(value)) {
|
|
1472
|
-
next[event] = value;
|
|
1473
|
-
continue;
|
|
1474
|
-
}
|
|
1475
|
-
const kept = value.map((e) => pruneOurHandlers(e, dataDir2)).filter((e) => e !== null);
|
|
1476
|
-
if (kept.length !== value.length) removed.push(event);
|
|
1477
|
-
const emptiedByUs = kept.length === 0 && value.length > 0;
|
|
1478
|
-
if (!emptiedByUs) next[event] = kept;
|
|
1479
|
-
}
|
|
1480
|
-
return { next, removed };
|
|
1481
|
-
}
|
|
1482
1294
|
async function inspectHooksFile(declaredPath) {
|
|
1483
1295
|
const entry = await lstat2(declaredPath).catch(() => null);
|
|
1484
1296
|
let path = declaredPath;
|
|
@@ -1594,195 +1406,760 @@ async function registeredHooks(adapter, homeDir, dataDir2, env = process.env) {
|
|
|
1594
1406
|
}
|
|
1595
1407
|
return out;
|
|
1596
1408
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
const
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1409
|
+
|
|
1410
|
+
// src/lib/harness-presence.ts
|
|
1411
|
+
async function installedHarnessInPlay(adapter, home, dataDir2, options = {}) {
|
|
1412
|
+
const env = options.env ?? process.env;
|
|
1413
|
+
const which = options.which ?? ((bin) => onPath(bin, env));
|
|
1414
|
+
if (harnessInPlay(
|
|
1415
|
+
home,
|
|
1416
|
+
harnessTargetDir(home, adapter.id),
|
|
1417
|
+
detectHarnesses(home, which),
|
|
1418
|
+
options.requested ?? []
|
|
1419
|
+
)) {
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
1422
|
+
return (await registeredHooks(adapter, home, dataDir2, env)).entries > 0;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// src/commands/config.ts
|
|
1426
|
+
var SHELF_KEYS = /* @__PURE__ */ new Set([
|
|
1427
|
+
"allowlistCreators",
|
|
1428
|
+
"publicShelfUrl",
|
|
1429
|
+
"shelfBypassSecret",
|
|
1430
|
+
"evalCohort",
|
|
1431
|
+
...PUBLISH_CONFIG_KEYS,
|
|
1432
|
+
...HOOKS_CONFIG_KEYS,
|
|
1433
|
+
...LOOP_CONFIG_KEYS,
|
|
1434
|
+
...TEAM_CONFIG_KEYS
|
|
1435
|
+
]);
|
|
1436
|
+
var KEY_WIDTH = Math.max(
|
|
1437
|
+
...[...CONFIG_KEYS, ...UPDATE_CONFIG_KEYS, ...ROUTER_CONFIG_KEYS, ...EXPERIMENTAL_CONFIG_KEYS].filter((key) => !SHELF_KEYS.has(key)).map((key) => key.length)
|
|
1438
|
+
);
|
|
1439
|
+
var KEY_DESCRIPTIONS = {
|
|
1440
|
+
maxAutoSpend: "automatic router limit per call",
|
|
1441
|
+
sessionBudget: "automatic router daily limit: 0 blocks automatic spend, none removes the ceiling",
|
|
1442
|
+
sendMaxAmount: "hard cap per tenjin wallet send; unset = send refuses until set, 0 disables send, none = uncapped; never bypassed by --yes",
|
|
1443
|
+
allowlistCreators: "only auto-pay these creators (empty = any)",
|
|
1444
|
+
baseUrl: "Tenjin API base URL the router asks",
|
|
1445
|
+
publicShelfUrl: "the public marketplace, consume-only: the second shelf a team-mode search falls through to",
|
|
1446
|
+
shelfBypassSecret: "the team shelf's Vercel protection-bypass secret; setting it is what turns team mode on (printed as set/unset)",
|
|
1447
|
+
rpcUrl: "Base RPC endpoint for balance reads",
|
|
1448
|
+
evalCohort: "opt in to the search evaluation cohort",
|
|
1449
|
+
bazaarRegistries: "x402 registries used to verify direct-payment listings",
|
|
1450
|
+
"publish.mode": "review=always ask, auto=ask on findings, full-auto=only hard blocks stop it",
|
|
1451
|
+
"publish.defaultPrice": "price used when none is given",
|
|
1452
|
+
"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",
|
|
1453
|
+
"hooks.prompt": "answer the prompt you just typed with what the shelves already know",
|
|
1454
|
+
"hooks.web-search": "ask Tenjin before the agent runs a WebSearch",
|
|
1455
|
+
"hooks.web-fetch": "ask Tenjin before the agent fetches a page",
|
|
1456
|
+
"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",
|
|
1457
|
+
"hooks.failure": "answer a failing command with the fix this machine or a shelf already has",
|
|
1458
|
+
"hooks.publish": "the turn-end ask to publish what this turn settled, spoken to you and to each subagent at its own end",
|
|
1459
|
+
"hooks.primer": "one-paragraph search-first primer at session start",
|
|
1460
|
+
"update.mode": "nudge=report a newer version (stderr line, JSON envelope, hook output), off=neither report nor ask npm",
|
|
1461
|
+
"loop.human_wait_ms": "ms a hook fire may take when a human is waiting on it (prompt, Stop, SessionStart)",
|
|
1462
|
+
"loop.tool_wait_ms": "ms a hook fire may take when a tool call is waiting on it",
|
|
1463
|
+
"loop.idle_exit_min": "minutes without a hook fire before the loop daemon exits",
|
|
1464
|
+
"loop.port": "the loop daemon's loopback port; null derives one from the data dir (set only when doctor reports a foreign listener)",
|
|
1465
|
+
"team.publicFallback": "on=a team-shelf miss falls through to the public marketplace, off=team-only (public-only lookup stages are dropped)",
|
|
1466
|
+
"router.enabled": "false stops every router hook and the request tool; --project sets it for this repository, --project --local for you alone in it",
|
|
1467
|
+
"router.context": "session=a hook packet carries up to six prior messages, turn=the current turn only; --project and --local as for router.enabled",
|
|
1468
|
+
"experimental.bazaar": "EXPERIMENTAL. on=the router may also suggest unreviewed sellers from Coinbase's open x402 Bazaar, off=curated services and Tenjin's reviewed list only"
|
|
1469
|
+
};
|
|
1470
|
+
var EXPERIMENTAL_BAZAAR_WARNING = "Experimental: the router may now also suggest sellers from Coinbase's open x402 Bazaar. They are unreviewed third parties, Tenjin has not checked them, matches can be noisy, prices can vary with the input, and payments are real, under your spend limits. To find them, short snippets of your prompts are sent to Coinbase's public Bazaar search. Tenjin's reviewed list stays on either way. Turn this off with `tenjin config set experimental.bazaar off`.";
|
|
1471
|
+
function isExperimentalKey(key) {
|
|
1472
|
+
return EXPERIMENTAL_CONFIG_KEYS.includes(key);
|
|
1473
|
+
}
|
|
1474
|
+
function isLoopKey(key) {
|
|
1475
|
+
return LOOP_CONFIG_KEYS.includes(key);
|
|
1476
|
+
}
|
|
1477
|
+
function isTeamKey(key) {
|
|
1478
|
+
return TEAM_CONFIG_KEYS.includes(key);
|
|
1479
|
+
}
|
|
1480
|
+
function isRouterKey(key) {
|
|
1481
|
+
return ROUTER_CONFIG_KEYS.includes(key);
|
|
1482
|
+
}
|
|
1483
|
+
function renderRouterSetting(key, settings) {
|
|
1484
|
+
const { value, source, path } = key === "router.enabled" ? settings.enabled : settings.context;
|
|
1485
|
+
return { value, source, ...path !== void 0 ? { path } : {} };
|
|
1486
|
+
}
|
|
1487
|
+
async function resolveRouterFromContext(ctx) {
|
|
1488
|
+
return routerSettings({ cwd: process.cwd(), dataDir: ctx.dataDir });
|
|
1489
|
+
}
|
|
1490
|
+
function renderLoopSetting(key, settings) {
|
|
1491
|
+
const field = key.slice("loop.".length);
|
|
1492
|
+
const { value, source } = settings.loop[field];
|
|
1493
|
+
return { value: value === null ? "null" : String(value), source };
|
|
1494
|
+
}
|
|
1495
|
+
function isPublishKey(key) {
|
|
1496
|
+
return PUBLISH_CONFIG_KEYS.includes(key);
|
|
1497
|
+
}
|
|
1498
|
+
function isHooksKey(key) {
|
|
1499
|
+
return HOOKS_CONFIG_KEYS.includes(key);
|
|
1500
|
+
}
|
|
1501
|
+
function isUpdateKey(key) {
|
|
1502
|
+
return UPDATE_CONFIG_KEYS.includes(key);
|
|
1503
|
+
}
|
|
1504
|
+
async function runConfigList(ctx) {
|
|
1505
|
+
const settings = await resolveFromContext(ctx);
|
|
1506
|
+
const data = {};
|
|
1507
|
+
const humanLines = [];
|
|
1508
|
+
const show = (key, line) => {
|
|
1509
|
+
if (!SHELF_KEYS.has(key)) humanLines.push(line);
|
|
1510
|
+
};
|
|
1511
|
+
for (const key of CONFIG_KEYS) {
|
|
1512
|
+
const entry = renderSetting(key, settings[key].value, settings[key].source);
|
|
1513
|
+
data[key] = entry;
|
|
1514
|
+
show(key, describedLine(key, entry));
|
|
1515
|
+
}
|
|
1516
|
+
for (const key of PUBLISH_CONFIG_KEYS) {
|
|
1517
|
+
const entry = renderPublishSetting(key, settings);
|
|
1518
|
+
data[key] = entry;
|
|
1519
|
+
show(key, describedLine(key, entry, downgradeNote(key, settings)));
|
|
1520
|
+
}
|
|
1521
|
+
for (const key of HOOKS_CONFIG_KEYS) {
|
|
1522
|
+
const entry = renderHooksSetting(key, settings);
|
|
1523
|
+
data[key] = entry;
|
|
1524
|
+
show(key, describedLine(key, entry));
|
|
1525
|
+
}
|
|
1526
|
+
for (const key of UPDATE_CONFIG_KEYS) {
|
|
1527
|
+
const entry = {
|
|
1528
|
+
value: settings.updateMode.value,
|
|
1529
|
+
source: settings.updateMode.source
|
|
1530
|
+
};
|
|
1531
|
+
data[key] = entry;
|
|
1532
|
+
show(key, describedLine(key, entry));
|
|
1533
|
+
}
|
|
1534
|
+
for (const key of LOOP_CONFIG_KEYS) {
|
|
1535
|
+
const entry = renderLoopSetting(key, settings);
|
|
1536
|
+
data[key] = entry;
|
|
1537
|
+
show(key, describedLine(key, entry));
|
|
1538
|
+
}
|
|
1539
|
+
for (const key of TEAM_CONFIG_KEYS) {
|
|
1540
|
+
const entry = {
|
|
1541
|
+
value: settings.teamPublicFallback.value,
|
|
1542
|
+
source: settings.teamPublicFallback.source
|
|
1543
|
+
};
|
|
1544
|
+
data[key] = entry;
|
|
1545
|
+
show(key, describedLine(key, entry));
|
|
1546
|
+
}
|
|
1547
|
+
const router = await resolveRouterFromContext(ctx);
|
|
1548
|
+
for (const key of ROUTER_CONFIG_KEYS) {
|
|
1549
|
+
const entry = renderRouterSetting(key, router);
|
|
1550
|
+
data[key] = entry;
|
|
1551
|
+
show(key, describedLine(key, entry));
|
|
1552
|
+
}
|
|
1553
|
+
for (const key of EXPERIMENTAL_CONFIG_KEYS) {
|
|
1554
|
+
const entry = {
|
|
1555
|
+
value: settings.experimentalBazaar.value,
|
|
1556
|
+
source: settings.experimentalBazaar.source
|
|
1557
|
+
};
|
|
1558
|
+
data[key] = entry;
|
|
1559
|
+
show(key, describedLine(key, entry));
|
|
1560
|
+
}
|
|
1561
|
+
return { data, humanLines };
|
|
1562
|
+
}
|
|
1563
|
+
async function runConfigGet({ key }, ctx) {
|
|
1564
|
+
if (isPublishKey(key)) {
|
|
1565
|
+
const settings2 = await resolveFromContext(ctx);
|
|
1566
|
+
const entry2 = renderPublishSetting(key, settings2);
|
|
1567
|
+
return {
|
|
1568
|
+
data: { key, ...entry2 },
|
|
1569
|
+
humanLines: [withNote(formatLine(key, entry2), downgradeNote(key, settings2))]
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
if (isHooksKey(key)) {
|
|
1573
|
+
const entry2 = renderHooksSetting(key, await resolveFromContext(ctx));
|
|
1574
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1575
|
+
}
|
|
1576
|
+
if (isUpdateKey(key)) {
|
|
1577
|
+
const { updateMode } = await resolveFromContext(ctx);
|
|
1578
|
+
const entry2 = { value: updateMode.value, source: updateMode.source };
|
|
1579
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1623
1580
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1581
|
+
if (isLoopKey(key)) {
|
|
1582
|
+
const entry2 = renderLoopSetting(key, await resolveFromContext(ctx));
|
|
1583
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1584
|
+
}
|
|
1585
|
+
if (isTeamKey(key)) {
|
|
1586
|
+
const { teamPublicFallback } = await resolveFromContext(ctx);
|
|
1587
|
+
const entry2 = {
|
|
1588
|
+
value: teamPublicFallback.value,
|
|
1589
|
+
source: teamPublicFallback.source
|
|
1590
|
+
};
|
|
1591
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1592
|
+
}
|
|
1593
|
+
if (isRouterKey(key)) {
|
|
1594
|
+
const entry2 = renderRouterSetting(key, await resolveRouterFromContext(ctx));
|
|
1595
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1596
|
+
}
|
|
1597
|
+
if (isExperimentalKey(key)) {
|
|
1598
|
+
const { experimentalBazaar } = await resolveFromContext(ctx);
|
|
1599
|
+
const entry2 = {
|
|
1600
|
+
value: experimentalBazaar.value,
|
|
1601
|
+
source: experimentalBazaar.source
|
|
1602
|
+
};
|
|
1603
|
+
return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
|
|
1604
|
+
}
|
|
1605
|
+
const configKey = assertKey(key);
|
|
1606
|
+
const settings = await resolveFromContext(ctx);
|
|
1607
|
+
const entry = renderSetting(configKey, settings[configKey].value, settings[configKey].source);
|
|
1608
|
+
return { data: { key: configKey, ...entry }, humanLines: [formatLine(configKey, entry)] };
|
|
1609
|
+
}
|
|
1610
|
+
async function runConfigSet({
|
|
1611
|
+
key,
|
|
1612
|
+
value,
|
|
1613
|
+
project,
|
|
1614
|
+
local
|
|
1615
|
+
}, ctx, deps = {}) {
|
|
1616
|
+
if (local === true && project !== true) {
|
|
1617
|
+
throw new CliError("USAGE", "--local names the personal project file, so it needs --project", {
|
|
1618
|
+
fix: `Run \`tenjin config set --project --local ${key} ${value}\`.`
|
|
1633
1619
|
});
|
|
1634
1620
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
hooksDir: dir,
|
|
1642
|
-
warning: found.refusal.message,
|
|
1643
|
-
fix: fixFor2(found.refusal.reason)
|
|
1621
|
+
if (isRouterKey(key)) {
|
|
1622
|
+
return setRouterKey(key, value, ctx, project === true ? { local: local === true } : void 0);
|
|
1623
|
+
}
|
|
1624
|
+
if (project === true) {
|
|
1625
|
+
throw new CliError("USAGE", `${key} is not a project key`, {
|
|
1626
|
+
fix: `--project applies to ${ROUTER_CONFIG_KEYS.join(" and ")} only; drop it to set ${key} for this machine.`
|
|
1644
1627
|
});
|
|
1645
1628
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
}
|
|
1661
|
-
const nextHooks = pruneHooks(hooks, dataDir2).next;
|
|
1662
|
-
for (const [event, mine] of planned) {
|
|
1663
|
-
const kept = nextHooks[event];
|
|
1664
|
-
nextHooks[event] = Array.isArray(kept) ? [...kept, ...mine] : mine;
|
|
1665
|
-
}
|
|
1666
|
-
const next = `${JSON.stringify({ ...settings, hooks: nextHooks }, null, 2)}
|
|
1667
|
-
`;
|
|
1668
|
-
const carriesUrl = JSON.stringify(plan).includes(url);
|
|
1669
|
-
const result = {
|
|
1670
|
-
harness,
|
|
1671
|
-
path,
|
|
1672
|
-
hooksDir: dir,
|
|
1673
|
-
entries: plan.length,
|
|
1674
|
-
wrote: next !== raw,
|
|
1675
|
-
daemon: { pid: started.health.pid, port: pid.port, version: started.health.version },
|
|
1676
|
-
...carriesUrl ? { url } : {},
|
|
1677
|
-
...activation
|
|
1629
|
+
if (isPublishKey(key)) return setPublishKey(key, value, ctx, deps);
|
|
1630
|
+
if (isHooksKey(key)) return setHooksKey(key, value, ctx);
|
|
1631
|
+
if (isUpdateKey(key)) return setUpdateKey(key, value, ctx);
|
|
1632
|
+
if (isLoopKey(key)) return setLoopKey(key, value, ctx);
|
|
1633
|
+
if (isTeamKey(key)) return setTeamKey(key, value, ctx);
|
|
1634
|
+
if (isExperimentalKey(key)) return setExperimentalKey(key, value, ctx);
|
|
1635
|
+
const configKey = assertKey(key);
|
|
1636
|
+
const stored = parseValue(configKey, value);
|
|
1637
|
+
await persist(ctx.dataDir, (existing) => ({ ...existing, [configKey]: stored }));
|
|
1638
|
+
const entry = renderSetting(configKey, stored, "file");
|
|
1639
|
+
const warning = await halfWiredTeamShelf(configKey, ctx.dataDir);
|
|
1640
|
+
return {
|
|
1641
|
+
data: { key: configKey, ...entry, ...warning !== void 0 ? { warning } : {} },
|
|
1642
|
+
humanLines: [formatLine(configKey, entry), ...warning !== void 0 ? [warning] : []]
|
|
1678
1643
|
};
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1644
|
+
}
|
|
1645
|
+
async function halfWiredTeamShelf(configKey, dataDir2) {
|
|
1646
|
+
if (configKey !== "shelfBypassSecret" && configKey !== "baseUrl" && configKey !== "publicShelfUrl") {
|
|
1647
|
+
return void 0;
|
|
1648
|
+
}
|
|
1649
|
+
const config = await loadRawConfig(dataDir2).catch(() => void 0);
|
|
1650
|
+
if (config === void 0) return void 0;
|
|
1651
|
+
const s = resolveSettings({ config, flags: {}, env: {} });
|
|
1652
|
+
if (s.shelfBypassSecret.value.length === 0) return void 0;
|
|
1653
|
+
const baseUrl = s.baseUrl.value;
|
|
1654
|
+
if (isTeamShelfOrigin(new URL(baseUrl).origin, s.publicShelfUrl.value)) return void 0;
|
|
1655
|
+
const isProduction = isSameDeployment(new URL(baseUrl).origin, PRODUCTION_ORIGIN);
|
|
1656
|
+
const cause = isProduction ? `baseUrl is the public marketplace (${baseUrl})` : `baseUrl and publicShelfUrl are the same shelf (${baseUrl})`;
|
|
1657
|
+
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}\`.`;
|
|
1658
|
+
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;
|
|
1659
|
+
}
|
|
1660
|
+
async function setPublishKey(key, value, ctx, deps) {
|
|
1661
|
+
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" };
|
|
1662
|
+
const subkey = key === "publish.mode" ? "mode" : key === "publish.ackServerWarnings" ? "ackServerWarnings" : "defaultPrice";
|
|
1663
|
+
const stored = key === "publish.defaultPrice" ? entry.value.atomic : entry.value;
|
|
1664
|
+
const persistEntry = async () => persist(ctx.dataDir, (existing) => ({
|
|
1665
|
+
...existing,
|
|
1666
|
+
publish: { ...existing.publish, [subkey]: stored }
|
|
1667
|
+
}));
|
|
1668
|
+
const humanLines = [formatLine(key, entry)];
|
|
1669
|
+
if (key !== "publish.mode") {
|
|
1670
|
+
await persistEntry();
|
|
1671
|
+
return { data: { key, ...entry }, humanLines };
|
|
1672
|
+
}
|
|
1673
|
+
const allowlist = await syncPublishRule(entry.value, ctx, deps);
|
|
1674
|
+
const failure = grantSyncFailure(allowlist);
|
|
1675
|
+
if (failure !== void 0) {
|
|
1676
|
+
throw new CliError(
|
|
1677
|
+
"REFUSED",
|
|
1678
|
+
`publish.mode was not changed because the ${failure.harness} grant could not be updated: ${failure.reason}`,
|
|
1679
|
+
{
|
|
1680
|
+
fix: failure.fix ?? `Fix the permissions for ${failure.path}, then re-run \`tenjin config set publish.mode ${entry.value}\`.`,
|
|
1681
|
+
details: { key, value: entry.value, allowlist }
|
|
1682
|
+
}
|
|
1683
|
+
);
|
|
1682
1684
|
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1685
|
+
await persistEntry();
|
|
1686
|
+
return {
|
|
1687
|
+
data: { key, ...entry, allowlist },
|
|
1688
|
+
humanLines: [...humanLines, ...allowlistLines(allowlist)]
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
function grantSyncFailure(sync) {
|
|
1692
|
+
for (const [harness, result] of Object.entries(sync.byHarness)) {
|
|
1693
|
+
if ("error" in result && result.error !== void 0) {
|
|
1694
|
+
return { harness, path: result.path, reason: result.error };
|
|
1695
|
+
}
|
|
1696
|
+
if ("warning" in result && result.warning !== void 0) {
|
|
1697
|
+
return {
|
|
1698
|
+
harness,
|
|
1699
|
+
path: result.path ?? "(unknown path)",
|
|
1700
|
+
reason: result.warning,
|
|
1701
|
+
...result.fix !== void 0 ? { fix: result.fix } : {}
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return void 0;
|
|
1706
|
+
}
|
|
1707
|
+
function publishRuleQuestion(mode, pending, harnesses) {
|
|
1708
|
+
const gated = new Set(MODE_GATED_RULES);
|
|
1709
|
+
const others = pending.filter((rule) => !gated.has(rule)).length;
|
|
1710
|
+
const also = others > 0 ? ` Also adds the ${others} command-grant rule(s) \`tenjin install\` writes.` : "";
|
|
1711
|
+
const targets = harnesses.map(
|
|
1712
|
+
(harness) => harness === "claude" ? "Claude Code" : harness === "codex" ? "Codex" : harness
|
|
1713
|
+
).join(" and ");
|
|
1714
|
+
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}`;
|
|
1715
|
+
}
|
|
1716
|
+
async function syncPublishRule(mode, ctx, deps) {
|
|
1717
|
+
const home = deps.homeDir ?? homedir();
|
|
1718
|
+
const nothing = { byHarness: {} };
|
|
1719
|
+
const write = async () => {
|
|
1720
|
+
const result = await (deps.wireAllowlist ?? wireFreeVerbAllowlist)(home, mode);
|
|
1721
|
+
if (result.skipped !== void 0) {
|
|
1722
|
+
return {
|
|
1723
|
+
byHarness: { claude: result },
|
|
1724
|
+
skipped: "unwritable",
|
|
1725
|
+
...result.fix !== void 0 ? { pointer: result.fix } : {}
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
return { byHarness: { claude: result } };
|
|
1729
|
+
};
|
|
1730
|
+
const adapters = deps.adapters ?? ADAPTERS;
|
|
1731
|
+
const env = deps.env ?? process.env;
|
|
1732
|
+
const which = deps.which ?? ((bin) => onPath(bin, env));
|
|
1733
|
+
const requested = await loadRawConfig(ctx.dataDir).then((config) => config.install?.harness ?? []).catch(() => []);
|
|
1734
|
+
const inPlay = deps.harnessesInPlay ?? (await Promise.all(
|
|
1735
|
+
Object.values(adapters).map(async (adapter) => ({
|
|
1736
|
+
adapter,
|
|
1737
|
+
selected: await installedHarnessInPlay(adapter, home, ctx.dataDir, {
|
|
1738
|
+
env,
|
|
1739
|
+
which,
|
|
1740
|
+
requested
|
|
1741
|
+
})
|
|
1742
|
+
}))
|
|
1743
|
+
)).filter((entry) => entry.selected).map((entry) => entry.adapter.id);
|
|
1744
|
+
const selectedAdapters = inPlay.map((harness) => adapters[harness]);
|
|
1745
|
+
const isClaude = inPlay.includes("claude");
|
|
1746
|
+
const withOtherGrants = async (sync) => {
|
|
1747
|
+
const byHarness = { ...sync.byHarness };
|
|
1748
|
+
for (const adapter of selectedAdapters) {
|
|
1749
|
+
if (adapter.id === "claude" || adapter.registrar.grant === void 0) continue;
|
|
1750
|
+
const result = await adapter.registrar.grant.write(home, mode, env);
|
|
1751
|
+
byHarness[adapter.id] = result;
|
|
1752
|
+
}
|
|
1753
|
+
return { ...sync, byHarness };
|
|
1754
|
+
};
|
|
1755
|
+
if (selectedAdapters.every((adapter) => adapter.registrar.grant === void 0)) {
|
|
1756
|
+
return { ...nothing, skipped: "not-claude" };
|
|
1757
|
+
}
|
|
1758
|
+
const probe = isClaude ? await (deps.inspectAllowlist ?? inspectFreeVerbRules)(home, mode) : { pending: [] };
|
|
1759
|
+
const gated = new Set(MODE_GATED_RULES);
|
|
1760
|
+
const missing = (probe.pending ?? []).filter((r) => gated.has(r));
|
|
1761
|
+
const pointer = modeGatedPointer(mode, missing) ?? void 0;
|
|
1762
|
+
if (mode === "review") {
|
|
1763
|
+
const retracted = isClaude ? await (deps.retractModeGated ?? retractModeGatedRules)(home) : void 0;
|
|
1764
|
+
if (retracted?.skipped !== void 0) {
|
|
1765
|
+
return {
|
|
1766
|
+
...nothing,
|
|
1767
|
+
skipped: "unwritable",
|
|
1768
|
+
...retracted.fix !== void 0 ? { pointer: retracted.fix } : {}
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
return await withOtherGrants({
|
|
1772
|
+
byHarness: retracted === void 0 ? {} : { claude: retracted }
|
|
1690
1773
|
});
|
|
1691
1774
|
}
|
|
1775
|
+
if (probe.satisfied !== void 0 && selectedAdapters.length === 1 && isClaude) return nothing;
|
|
1776
|
+
const canPrompt = ctx.flags.json === true ? false : deps.isInteractive ?? Boolean(process.stdin.isTTY);
|
|
1777
|
+
if (!canPrompt) {
|
|
1778
|
+
return { ...nothing, skipped: "no-tty", ...pointer ? { pointer } : {} };
|
|
1779
|
+
}
|
|
1780
|
+
const confirm = deps.confirmRule ?? ((label) => confirmChoice(label, true));
|
|
1781
|
+
const grantable = selectedAdapters.filter((adapter) => adapter.registrar.grant !== void 0).map((adapter) => adapter.id);
|
|
1782
|
+
if (!await confirm(publishRuleQuestion(mode, probe.pending ?? [], grantable))) {
|
|
1783
|
+
return { ...nothing, skipped: "declined", ...pointer ? { pointer } : {} };
|
|
1784
|
+
}
|
|
1785
|
+
return await withOtherGrants(isClaude ? await write() : nothing);
|
|
1786
|
+
}
|
|
1787
|
+
function allowlistLines(sync) {
|
|
1788
|
+
const lines = [];
|
|
1789
|
+
const claude = sync.byHarness.claude;
|
|
1790
|
+
if ((claude?.added.length ?? 0) > 0) {
|
|
1791
|
+
lines.push(`Added ${claude?.added.length ?? 0} harness rule(s) to your allowlist.`);
|
|
1792
|
+
}
|
|
1793
|
+
if ((claude?.removed.length ?? 0) > 0) {
|
|
1794
|
+
lines.push(`Removed ${claude?.removed.join(", ")} from your allowlist.`);
|
|
1795
|
+
}
|
|
1796
|
+
const grant = sync.byHarness.codex;
|
|
1797
|
+
if (grant !== void 0 && grant.error === void 0 && grant.wrote) {
|
|
1798
|
+
lines.push(
|
|
1799
|
+
`Codex now allows ${grant.granted.length} tenjin command prefix(es) in ${grant.path}.`
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
if (grant?.error !== void 0) {
|
|
1803
|
+
lines.push(`Codex's grant at ${grant.path} could not be updated (${grant.error}).`);
|
|
1804
|
+
}
|
|
1805
|
+
if (sync.pointer !== void 0) lines.push(sync.pointer);
|
|
1806
|
+
return lines;
|
|
1807
|
+
}
|
|
1808
|
+
async function setHooksKey(key, value, ctx) {
|
|
1809
|
+
const arm = key.slice("hooks.".length);
|
|
1810
|
+
const parsed = parseBoolean(value);
|
|
1811
|
+
await persistHookArm(ctx.dataDir, arm, parsed);
|
|
1812
|
+
const entry = { value: parsed, source: "file" };
|
|
1813
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
1814
|
+
}
|
|
1815
|
+
async function setUpdateKey(key, value, ctx) {
|
|
1816
|
+
const parsed = parseUpdateModeFlag(value, key);
|
|
1817
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
1818
|
+
...existing,
|
|
1819
|
+
update: { ...existing.update, mode: parsed }
|
|
1820
|
+
}));
|
|
1821
|
+
const entry = { value: parsed, source: "file" };
|
|
1822
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
1823
|
+
}
|
|
1824
|
+
async function setLoopKey(key, value, ctx) {
|
|
1825
|
+
const parsed = parseLoopValue(key, value);
|
|
1826
|
+
const field = key.slice("loop.".length);
|
|
1827
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
1828
|
+
...existing,
|
|
1829
|
+
loop: { ...existing.loop, [field]: parsed }
|
|
1830
|
+
}));
|
|
1831
|
+
const entry = {
|
|
1832
|
+
value: parsed === null ? "null" : String(parsed),
|
|
1833
|
+
source: "file"
|
|
1834
|
+
};
|
|
1835
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
1836
|
+
}
|
|
1837
|
+
async function setTeamKey(key, value, ctx) {
|
|
1838
|
+
const parsed = parsePublicFallbackFlag(value, key);
|
|
1839
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
1840
|
+
...existing,
|
|
1841
|
+
team: { ...existing.team, publicFallback: parsed }
|
|
1842
|
+
}));
|
|
1843
|
+
const entry = { value: parsed, source: "file" };
|
|
1844
|
+
return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
|
|
1845
|
+
}
|
|
1846
|
+
async function setExperimentalKey(key, value, ctx) {
|
|
1847
|
+
const parsed = parsePublicFallbackFlag(value, key);
|
|
1848
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
1849
|
+
...existing,
|
|
1850
|
+
experimental: { ...existing.experimental, bazaar: parsed }
|
|
1851
|
+
}));
|
|
1852
|
+
const entry = { value: parsed, source: "file" };
|
|
1853
|
+
const warning = parsed === "on" ? EXPERIMENTAL_BAZAAR_WARNING : void 0;
|
|
1854
|
+
return {
|
|
1855
|
+
data: { key, ...entry, ...warning !== void 0 ? { warning } : {} },
|
|
1856
|
+
humanLines: [formatLine(key, entry), ...warning !== void 0 ? [warning] : []]
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
async function setRouterKey(key, value, ctx, project) {
|
|
1860
|
+
const field = key === "router.enabled" ? "enabled" : "context";
|
|
1861
|
+
const parsed = field === "enabled" ? parseBoolean(value) : parseRouterContext(value);
|
|
1862
|
+
let written;
|
|
1863
|
+
if (project === void 0) {
|
|
1864
|
+
await persist(ctx.dataDir, (existing) => ({
|
|
1865
|
+
...existing,
|
|
1866
|
+
router: { ...existing.router, [field]: parsed }
|
|
1867
|
+
}));
|
|
1868
|
+
written = { value: parsed, source: "file", path: configPath(ctx.dataDir) };
|
|
1869
|
+
} else {
|
|
1870
|
+
const path = await projectRouterPath({ cwd: process.cwd(), local: project.local });
|
|
1871
|
+
await persistProjectRouter(path, field, parsed);
|
|
1872
|
+
written = { value: parsed, source: project.local ? "local" : "project", path };
|
|
1873
|
+
}
|
|
1874
|
+
const effective = renderRouterSetting(key, await resolveRouterFromContext(ctx));
|
|
1875
|
+
const humanLines = [formatLine(key, written)];
|
|
1876
|
+
if (effective.value !== written.value) {
|
|
1877
|
+
humanLines.push(
|
|
1878
|
+
`Still ${String(effective.value)} here: ${effective.path ?? "the default"} is tighter, and a nearer file can only tighten an outer one.`
|
|
1879
|
+
);
|
|
1880
|
+
}
|
|
1881
|
+
if (project?.local === true) {
|
|
1882
|
+
humanLines.push("Keep .tenjin/config.local.json out of git: add it to .gitignore.");
|
|
1883
|
+
}
|
|
1884
|
+
return { data: { key, ...written, effective }, humanLines };
|
|
1885
|
+
}
|
|
1886
|
+
function parseRouterContext(value) {
|
|
1887
|
+
const found = ROUTER_CONTEXTS.find((context) => context === value);
|
|
1888
|
+
if (found !== void 0) return found;
|
|
1889
|
+
throw new CliError("USAGE", `Invalid router.context: ${JSON.stringify(value)}`, {
|
|
1890
|
+
fix: 'Use "session" or "turn".'
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
async function persistProjectRouter(path, field, value) {
|
|
1894
|
+
await mkdir2(dirname3(path), { recursive: true, mode: 493 });
|
|
1895
|
+
const lockPath = `${path}.lock`;
|
|
1692
1896
|
try {
|
|
1693
|
-
await
|
|
1897
|
+
await withFileLock(lockPath, () => mergeProjectRouter(path, field, value));
|
|
1694
1898
|
} catch (err) {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1899
|
+
if (err instanceof LockTimeoutError) {
|
|
1900
|
+
throw new CliError("INTERNAL", err.message, {
|
|
1901
|
+
fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
|
|
1902
|
+
cause: err
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
throw err;
|
|
1702
1906
|
}
|
|
1907
|
+
}
|
|
1908
|
+
async function mergeProjectRouter(path, field, value) {
|
|
1909
|
+
const existing = await readProjectRouterFile(path);
|
|
1910
|
+
const block = existing?.json.router;
|
|
1911
|
+
const next = {
|
|
1912
|
+
...existing?.json ?? {},
|
|
1913
|
+
router: { ...block !== void 0 ? block : {}, [field]: value }
|
|
1914
|
+
};
|
|
1915
|
+
await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}
|
|
1916
|
+
`, {
|
|
1917
|
+
mode: 420,
|
|
1918
|
+
dirMode: 493
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
function parsePublishMode(value) {
|
|
1922
|
+
const parsed = PublishModeSchema.safeParse(value);
|
|
1923
|
+
if (parsed.success) return parsed.data;
|
|
1924
|
+
throw new CliError("USAGE", `Invalid publish mode: ${JSON.stringify(value)}`, {
|
|
1925
|
+
fix: 'Use "review", "auto", or "full-auto".'
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
async function persistHookArm(dir, arm, value) {
|
|
1929
|
+
await persist(dir, (existing) => ({
|
|
1930
|
+
...existing,
|
|
1931
|
+
hooks: { ...existing.hooks, [arm]: value }
|
|
1932
|
+
}));
|
|
1933
|
+
}
|
|
1934
|
+
async function persistPublishMode(dir, mode) {
|
|
1935
|
+
await persist(dir, (existing) => ({
|
|
1936
|
+
...existing,
|
|
1937
|
+
publish: { ...existing.publish, mode }
|
|
1938
|
+
}));
|
|
1939
|
+
}
|
|
1940
|
+
async function persistRouterProject(dir, projectDir, present = true) {
|
|
1941
|
+
await persist(dir, (existing) => {
|
|
1942
|
+
const known = new Set(existing.install?.routerProjects ?? []);
|
|
1943
|
+
if (present) known.add(projectDir);
|
|
1944
|
+
else known.delete(projectDir);
|
|
1945
|
+
return { ...existing, install: { ...existing.install, routerProjects: [...known].sort() } };
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
async function persistRouterDefaults(dir, refresh = false, limits = ROUTER_DEFAULTS) {
|
|
1949
|
+
const result = { set: [], kept: [], removed: [] };
|
|
1950
|
+
if (refresh && retiredPaymentKeys(await loadRawConfig(dir)).length === 0) return result;
|
|
1951
|
+
await persist(dir, (existing) => {
|
|
1952
|
+
const next = { ...existing };
|
|
1953
|
+
result.removed = retiredPaymentKeys(existing);
|
|
1954
|
+
for (const key of result.removed) delete next[key];
|
|
1955
|
+
if (refresh) return next;
|
|
1956
|
+
for (const key of Object.keys(ROUTER_DEFAULTS)) {
|
|
1957
|
+
const value = limits[key];
|
|
1958
|
+
if (existing[key] !== void 0) result.kept.push(key);
|
|
1959
|
+
else if (value !== void 0) {
|
|
1960
|
+
next[key] = value;
|
|
1961
|
+
result.set.push(key);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
return next;
|
|
1965
|
+
});
|
|
1703
1966
|
return result;
|
|
1704
1967
|
}
|
|
1705
|
-
async function
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1968
|
+
async function persistInstallHarness(dir, harness) {
|
|
1969
|
+
await persist(dir, (existing) => ({
|
|
1970
|
+
...existing,
|
|
1971
|
+
install: { ...existing.install, harness: [...harness] }
|
|
1972
|
+
}));
|
|
1973
|
+
}
|
|
1974
|
+
async function persistGrantDeclined(dir, declined) {
|
|
1975
|
+
await persist(dir, (existing) => ({
|
|
1976
|
+
...existing,
|
|
1977
|
+
install: { ...existing.install, grantDeclined: declined }
|
|
1978
|
+
}));
|
|
1979
|
+
}
|
|
1980
|
+
async function resolveFromContext(ctx) {
|
|
1981
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
1982
|
+
const project = await loadProjectConfig(process.cwd());
|
|
1983
|
+
return resolveSettings({
|
|
1984
|
+
config,
|
|
1985
|
+
flags: { baseUrl: ctx.flags.baseUrl },
|
|
1986
|
+
env: process.env,
|
|
1987
|
+
project: project?.layer
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
function assertKey(key) {
|
|
1991
|
+
if (key === "bazaarPay" || key === "confirm") {
|
|
1992
|
+
throw new CliError("USAGE", `Retired config key: ${key}`, { fix: RETIRED_PAYMENT_GUIDANCE });
|
|
1720
1993
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1994
|
+
if (CONFIG_KEYS.includes(key)) return key;
|
|
1995
|
+
throw new CliError("USAGE", `Unknown config key: ${JSON.stringify(key)}`, {
|
|
1996
|
+
fix: `Valid keys: ${[...CONFIG_KEYS, ...PUBLISH_CONFIG_KEYS, ...HOOKS_CONFIG_KEYS, ...ROUTER_CONFIG_KEYS, ...EXPERIMENTAL_CONFIG_KEYS].join(", ")}.`
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
function renderSetting(key, stored, source) {
|
|
2000
|
+
return { ...renderValue(key, stored), source };
|
|
2001
|
+
}
|
|
2002
|
+
function renderPublishSetting(key, settings) {
|
|
2003
|
+
if (key === "publish.mode") {
|
|
2004
|
+
return { value: settings.publishMode.value, source: settings.publishMode.source };
|
|
1726
2005
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
2006
|
+
if (key === "publish.ackServerWarnings") {
|
|
2007
|
+
return {
|
|
2008
|
+
value: settings.publishAckServerWarnings.value,
|
|
2009
|
+
source: settings.publishAckServerWarnings.source
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
return {
|
|
2013
|
+
value: toMoney(settings.publishDefaultPrice.value),
|
|
2014
|
+
source: settings.publishDefaultPrice.source
|
|
1735
2015
|
};
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
2016
|
+
}
|
|
2017
|
+
function renderHooksSetting(key, settings) {
|
|
2018
|
+
const { value, source } = settings.hooks[key.slice("hooks.".length)];
|
|
2019
|
+
return { value, source };
|
|
2020
|
+
}
|
|
2021
|
+
function renderValue(key, stored) {
|
|
2022
|
+
if (key === "shelfBypassSecret") {
|
|
2023
|
+
return { value: typeof stored === "string" && stored.length > 0 ? "set" : "unset" };
|
|
2024
|
+
}
|
|
2025
|
+
if (Array.isArray(stored) || typeof stored === "boolean") return { value: stored };
|
|
2026
|
+
if (key === "sessionBudget" && stored === "none") return { value: null };
|
|
2027
|
+
if (key === "maxAutoSpend" || key === "sessionBudget") return { value: toMoney(stored) };
|
|
2028
|
+
if (key === "sendMaxAmount") {
|
|
2029
|
+
return { value: stored === "none" || stored === SEND_MAX_UNSET ? stored : toMoney(stored) };
|
|
2030
|
+
}
|
|
2031
|
+
return { value: stored };
|
|
2032
|
+
}
|
|
2033
|
+
function parseValue(key, value) {
|
|
2034
|
+
switch (key) {
|
|
2035
|
+
case "sessionBudget":
|
|
2036
|
+
return value === "none" ? "none" : parseUsdToAtomic(value);
|
|
2037
|
+
case "maxAutoSpend":
|
|
2038
|
+
return parseUsdToAtomic(value);
|
|
2039
|
+
// throws USAGE on a bad amount
|
|
2040
|
+
case "sendMaxAmount":
|
|
2041
|
+
return value === "none" ? "none" : parseUsdToAtomic(value);
|
|
2042
|
+
case "allowlistCreators":
|
|
2043
|
+
return parseAllowlist(value);
|
|
2044
|
+
case "baseUrl":
|
|
2045
|
+
case "publicShelfUrl":
|
|
2046
|
+
case "rpcUrl":
|
|
2047
|
+
return parseHttpUrl(value);
|
|
2048
|
+
case "shelfBypassSecret":
|
|
2049
|
+
return value.trim();
|
|
2050
|
+
case "evalCohort":
|
|
2051
|
+
return parseBoolean(value);
|
|
2052
|
+
case "bazaarRegistries":
|
|
2053
|
+
return parseRegistryList(value);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
function parseRegistryList(value) {
|
|
2057
|
+
return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0).map((entry) => parseHttpUrl(entry));
|
|
2058
|
+
}
|
|
2059
|
+
function parseBoolean(value) {
|
|
2060
|
+
if (value === "true" || value === "on") return true;
|
|
2061
|
+
if (value === "false" || value === "off") return false;
|
|
2062
|
+
throw new CliError("USAGE", `Invalid boolean value: ${JSON.stringify(value)}`, {
|
|
2063
|
+
fix: 'Use "on" or "off" (or "true"/"false").'
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
function parseAllowlist(value) {
|
|
2067
|
+
const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
2068
|
+
for (const entry of entries) {
|
|
2069
|
+
if (/\s/.test(entry)) {
|
|
2070
|
+
throw new CliError("USAGE", `Invalid creator entry: ${JSON.stringify(entry)}`, {
|
|
2071
|
+
fix: "Creator entries cannot contain spaces; separate multiple with commas."
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
1739
2074
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
2075
|
+
return entries;
|
|
2076
|
+
}
|
|
2077
|
+
function parseHttpUrl(value) {
|
|
2078
|
+
let url;
|
|
2079
|
+
try {
|
|
2080
|
+
url = new URL(value);
|
|
2081
|
+
} catch {
|
|
2082
|
+
throw new CliError("USAGE", `Invalid URL: ${JSON.stringify(value)}`, {
|
|
2083
|
+
fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
|
|
1746
2084
|
});
|
|
1747
2085
|
}
|
|
2086
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
2087
|
+
throw new CliError("USAGE", `URL must be http or https: ${JSON.stringify(value)}`, {
|
|
2088
|
+
fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
return value;
|
|
2092
|
+
}
|
|
2093
|
+
async function persist(dir, merge) {
|
|
2094
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
2095
|
+
const lockPath = `${configPath(dir)}.lock`;
|
|
1748
2096
|
try {
|
|
1749
|
-
await
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
2097
|
+
await withFileLock(lockPath, async () => {
|
|
2098
|
+
const existing = await loadRawConfig(dir);
|
|
2099
|
+
const merged = merge(existing);
|
|
2100
|
+
const validated = RawConfigSchema.parse(merged);
|
|
2101
|
+
await writeFileAtomic(configPath(dir), `${JSON.stringify(validated, null, 2)}
|
|
2102
|
+
`, {
|
|
2103
|
+
mode: 384,
|
|
2104
|
+
dirMode: 448
|
|
2105
|
+
});
|
|
1756
2106
|
});
|
|
2107
|
+
} catch (err) {
|
|
2108
|
+
if (err instanceof LockTimeoutError) {
|
|
2109
|
+
throw new CliError("INTERNAL", err.message, {
|
|
2110
|
+
fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
|
|
2111
|
+
cause: err
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
throw err;
|
|
1757
2115
|
}
|
|
1758
|
-
return result;
|
|
1759
2116
|
}
|
|
1760
|
-
function
|
|
1761
|
-
const
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
2117
|
+
function formatLine(key, entry) {
|
|
2118
|
+
const label = key.padEnd(KEY_WIDTH);
|
|
2119
|
+
const where = entry.path !== void 0 && (entry.source === "project" || entry.source === "local") ? ` ${entry.path}` : "";
|
|
2120
|
+
return ` ${label} ${displayValue(entry)} ${style("dim", `(${entry.source}${where})`)}`;
|
|
2121
|
+
}
|
|
2122
|
+
function describedLine(key, entry, note) {
|
|
2123
|
+
const description = KEY_DESCRIPTIONS[key];
|
|
2124
|
+
let line = formatLine(key, entry);
|
|
2125
|
+
if (description !== void 0) line += ` ${style("dim", `- ${description}`)}`;
|
|
2126
|
+
return withNote(line, note);
|
|
2127
|
+
}
|
|
2128
|
+
function withNote(line, note) {
|
|
2129
|
+
return note !== void 0 ? `${line} ${style("dim", `(${note})`)}` : line;
|
|
2130
|
+
}
|
|
2131
|
+
function downgradeNote(key, settings) {
|
|
2132
|
+
if (key !== "publish.mode" || settings.publishMode.downgradedWarning === void 0) {
|
|
2133
|
+
return void 0;
|
|
1768
2134
|
}
|
|
1769
|
-
return
|
|
2135
|
+
return "downgraded from full-auto: committed .tenjin.json (gitignore it to opt in)";
|
|
2136
|
+
}
|
|
2137
|
+
function displayValue(entry) {
|
|
2138
|
+
const { value } = entry;
|
|
2139
|
+
if (Array.isArray(value)) return value.length > 0 ? value.join(", ") : "(empty)";
|
|
2140
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
2141
|
+
if (value === null) return "none (no daily limit)";
|
|
2142
|
+
if (typeof value === "object") return `${value.usd} USD`;
|
|
2143
|
+
return value;
|
|
1770
2144
|
}
|
|
1771
2145
|
|
|
1772
2146
|
export {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
claudeAdapter,
|
|
1780
|
-
ADAPTERS,
|
|
1781
|
-
ownsHookEntry,
|
|
1782
|
-
pruneOurHandlers,
|
|
1783
|
-
pruneHooks,
|
|
2147
|
+
RETIRED_SKILL_NAMES,
|
|
2148
|
+
SHIPPED_SKILL_FILES,
|
|
2149
|
+
CLI_SKILL_NAMES,
|
|
2150
|
+
skillsDirsFor,
|
|
2151
|
+
readSkillFile,
|
|
2152
|
+
skillFrontmatterName,
|
|
1784
2153
|
inspectHooksFile,
|
|
1785
|
-
|
|
1786
|
-
|
|
2154
|
+
EXPERIMENTAL_BAZAAR_WARNING,
|
|
2155
|
+
runConfigList,
|
|
2156
|
+
runConfigGet,
|
|
2157
|
+
runConfigSet,
|
|
2158
|
+
persistHookArm,
|
|
2159
|
+
persistPublishMode,
|
|
2160
|
+
persistRouterProject,
|
|
2161
|
+
persistRouterDefaults,
|
|
2162
|
+
persistInstallHarness,
|
|
2163
|
+
persistGrantDeclined
|
|
1787
2164
|
};
|
|
1788
|
-
//# sourceMappingURL=chunk-
|
|
2165
|
+
//# sourceMappingURL=chunk-ZG6ZZLO7.js.map
|