tenjin-cli 0.1.0-alpha.23 → 0.1.0-alpha.25
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 +1 -1
- package/README.md +7 -8
- package/dist/{chunk-Y3LKUXZA.js → chunk-3ZYPVSIU.js} +145 -36
- package/dist/chunk-3ZYPVSIU.js.map +1 -0
- package/dist/chunk-7EKYXMUO.js +7536 -0
- package/dist/chunk-7EKYXMUO.js.map +1 -0
- package/dist/chunk-AKWGE6JQ.js +49 -0
- package/dist/chunk-AKWGE6JQ.js.map +1 -0
- package/dist/{chunk-3IOS6YG6.js → chunk-CEMXMUIU.js} +3 -3
- package/dist/{chunk-NYJCBQL5.js → chunk-CKDD554V.js} +2 -2
- package/dist/{hook-command-RDT754KQ.js → chunk-CP7O6M55.js} +209 -41
- package/dist/chunk-CP7O6M55.js.map +1 -0
- package/dist/{chunk-YT7A7DLY.js → chunk-DRXDTITB.js} +1821 -141
- package/dist/chunk-DRXDTITB.js.map +1 -0
- package/dist/{chunk-HTC4VJFT.js → chunk-EACMJEF3.js} +206 -16
- package/dist/chunk-EACMJEF3.js.map +1 -0
- package/dist/{chunk-DHCOGDJB.js → chunk-EG7P4SM6.js} +4 -4
- package/dist/{chunk-RGVOODF4.js → chunk-EL56RW2J.js} +164 -7463
- package/dist/chunk-EL56RW2J.js.map +1 -0
- package/dist/{chunk-2RMXTNLT.js → chunk-EOGJKIOG.js} +6 -8
- package/dist/{chunk-2RMXTNLT.js.map → chunk-EOGJKIOG.js.map} +1 -1
- package/dist/{chunk-WXFVJPZD.js → chunk-GT6W3VJM.js} +2 -2
- package/dist/{chunk-UHEMZEGW.js → chunk-HII5HOQV.js} +3 -5
- package/dist/chunk-HII5HOQV.js.map +1 -0
- package/dist/{chunk-GONDQ27X.js → chunk-IYLECN4D.js} +3 -3
- package/dist/{chunk-6O6DFYF3.js → chunk-KGTQRJGS.js} +17 -8
- package/dist/chunk-KGTQRJGS.js.map +1 -0
- package/dist/chunk-LFZJM56J.js +159 -0
- package/dist/chunk-LFZJM56J.js.map +1 -0
- package/dist/{chunk-HJYI52HM.js → chunk-NTYQHAIM.js} +2 -2
- package/dist/{chunk-K63HPLYT.js → chunk-NYPFOHSJ.js} +4 -4
- package/dist/{chunk-RA2J3TWG.js → chunk-ODH7UXIS.js} +17 -14
- package/dist/chunk-ODH7UXIS.js.map +1 -0
- package/dist/{chunk-XBYTP4SP.js → chunk-OZ3LWLCI.js} +3 -3
- package/dist/{chunk-2QYORQBF.js → chunk-P7LABKCW.js} +36 -1
- package/dist/{chunk-2QYORQBF.js.map → chunk-P7LABKCW.js.map} +1 -1
- package/dist/{chunk-N7A5EXJZ.js → chunk-SCAE6PW6.js} +4 -4
- package/dist/{chunk-UGLTSPXQ.js → chunk-UDWGT4FX.js} +2 -2
- package/dist/chunk-VYONGSMQ.js +119 -0
- package/dist/chunk-VYONGSMQ.js.map +1 -0
- package/dist/{chunk-SAN5PFTL.js → chunk-XICKN3CH.js} +49 -4
- package/dist/chunk-XICKN3CH.js.map +1 -0
- package/dist/chunk-YHKXNYTB.js +105 -0
- package/dist/chunk-YHKXNYTB.js.map +1 -0
- package/dist/{chunk-I2GBBIDI.js → chunk-YSW57KUT.js} +46 -32
- package/dist/chunk-YSW57KUT.js.map +1 -0
- package/dist/{chunk-F4IJQBGP.js → chunk-YTM7OURD.js} +2 -2
- package/dist/{cli-MUYFTWWB.js → cli-4WMGZPBP.js} +28 -29
- package/dist/{cli-MUYFTWWB.js.map → cli-4WMGZPBP.js.map} +1 -1
- package/dist/{config-IIRRO3XC.js → config-VU6U7QOU.js} +10 -9
- package/dist/{doctor-KGHM2CAC.js → doctor-26JS2SG3.js} +124 -32
- package/dist/doctor-26JS2SG3.js.map +1 -0
- package/dist/{fund-DOWIT3JT.js → fund-JJN3FRRF.js} +13 -14
- package/dist/fund-JJN3FRRF.js.map +1 -0
- package/dist/hook-command-S2V4UNB3.js +28 -0
- package/dist/index.js +3 -3
- package/dist/{install-BYQUMYBN.js → install-GXQ33J4G.js} +20 -17
- package/dist/{install-identity-KTQPYVAO.js → install-identity-HFQUXPSI.js} +6 -7
- package/dist/{install-wallet-T737X74E.js → install-wallet-27LTEHBI.js} +9 -10
- package/dist/{install-wallet-T737X74E.js.map → install-wallet-27LTEHBI.js.map} +1 -1
- package/dist/{mcp-ZKOTURQN.js → mcp-AHCZVD2U.js} +604 -93
- package/dist/mcp-AHCZVD2U.js.map +1 -0
- package/dist/{pay-LZPU2HUT.js → pay-3TCOPGCX.js} +14 -13
- package/dist/{payments-26NVMFR2.js → payments-H3LSBGSL.js} +6 -7
- package/dist/{payments-26NVMFR2.js.map → payments-H3LSBGSL.js.map} +1 -1
- package/dist/{send-4RUBQQKP.js → send-LKCLN5GA.js} +9 -11
- package/dist/{send-4RUBQQKP.js.map → send-LKCLN5GA.js.map} +1 -1
- package/dist/{status-CEHZKHBU.js → status-2FDGI4LQ.js} +7 -9
- package/dist/{status-CEHZKHBU.js.map → status-2FDGI4LQ.js.map} +1 -1
- package/dist/{status-line-QRAO3Y2E.js → status-line-QKDJYZGV.js} +4 -5
- package/dist/{status-line-QRAO3Y2E.js.map → status-line-QKDJYZGV.js.map} +1 -1
- package/dist/{status-line-wiring-7D2CSV3K.js → status-line-wiring-ZDBYHNYR.js} +6 -4
- package/dist/{uninstall-VR44B4KD.js → uninstall-ZXWABDHS.js} +34 -30
- package/dist/uninstall-ZXWABDHS.js.map +1 -0
- package/dist/{update-SOYQLDBF.js → update-HEIWVOP5.js} +17 -6
- package/dist/update-HEIWVOP5.js.map +1 -0
- package/dist/{wallet-IB2EFAUP.js → wallet-T7JYWI6O.js} +8 -9
- package/dist/wallet-T7JYWI6O.js.map +1 -0
- package/docs/agent-permissions.md +11 -8
- package/docs/safety-model.md +10 -23
- package/package.json +16 -13
- package/dist/chunk-6O6DFYF3.js.map +0 -1
- package/dist/chunk-A2XMQSWI.js +0 -140
- package/dist/chunk-A2XMQSWI.js.map +0 -1
- package/dist/chunk-HTC4VJFT.js.map +0 -1
- package/dist/chunk-I2GBBIDI.js.map +0 -1
- package/dist/chunk-O2JYBOUO.js +0 -47
- package/dist/chunk-O2JYBOUO.js.map +0 -1
- package/dist/chunk-RA2J3TWG.js.map +0 -1
- package/dist/chunk-RGVOODF4.js.map +0 -1
- package/dist/chunk-S2NRVRPF.js +0 -171
- package/dist/chunk-S2NRVRPF.js.map +0 -1
- package/dist/chunk-SAN5PFTL.js.map +0 -1
- package/dist/chunk-UHEMZEGW.js.map +0 -1
- package/dist/chunk-Y3LKUXZA.js.map +0 -1
- package/dist/chunk-YT7A7DLY.js.map +0 -1
- package/dist/doctor-KGHM2CAC.js.map +0 -1
- package/dist/fund-DOWIT3JT.js.map +0 -1
- package/dist/hook-command-RDT754KQ.js.map +0 -1
- package/dist/mcp-ZKOTURQN.js.map +0 -1
- package/dist/tenjin-daemon.mjs +0 -20601
- package/dist/tenjin-shim.mjs +0 -251
- package/dist/tenjin-vitest-reporter.mjs +0 -49
- package/dist/uninstall-VR44B4KD.js.map +0 -1
- package/dist/update-SOYQLDBF.js.map +0 -1
- /package/dist/{chunk-3IOS6YG6.js.map → chunk-CEMXMUIU.js.map} +0 -0
- /package/dist/{chunk-NYJCBQL5.js.map → chunk-CKDD554V.js.map} +0 -0
- /package/dist/{chunk-DHCOGDJB.js.map → chunk-EG7P4SM6.js.map} +0 -0
- /package/dist/{chunk-WXFVJPZD.js.map → chunk-GT6W3VJM.js.map} +0 -0
- /package/dist/{chunk-GONDQ27X.js.map → chunk-IYLECN4D.js.map} +0 -0
- /package/dist/{chunk-HJYI52HM.js.map → chunk-NTYQHAIM.js.map} +0 -0
- /package/dist/{chunk-K63HPLYT.js.map → chunk-NYPFOHSJ.js.map} +0 -0
- /package/dist/{chunk-XBYTP4SP.js.map → chunk-OZ3LWLCI.js.map} +0 -0
- /package/dist/{chunk-N7A5EXJZ.js.map → chunk-SCAE6PW6.js.map} +0 -0
- /package/dist/{chunk-UGLTSPXQ.js.map → chunk-UDWGT4FX.js.map} +0 -0
- /package/dist/{chunk-F4IJQBGP.js.map → chunk-YTM7OURD.js.map} +0 -0
- /package/dist/{config-IIRRO3XC.js.map → config-VU6U7QOU.js.map} +0 -0
- /package/dist/{install-BYQUMYBN.js.map → hook-command-S2V4UNB3.js.map} +0 -0
- /package/dist/{install-identity-KTQPYVAO.js.map → install-GXQ33J4G.js.map} +0 -0
- /package/dist/{pay-LZPU2HUT.js.map → install-identity-HFQUXPSI.js.map} +0 -0
- /package/dist/{status-line-wiring-7D2CSV3K.js.map → pay-3TCOPGCX.js.map} +0 -0
- /package/dist/{wallet-IB2EFAUP.js.map → status-line-wiring-ZDBYHNYR.js.map} +0 -0
package/NOTICE.md
CHANGED
|
@@ -43,7 +43,7 @@ BlockRun MCP is licensed under the MIT License:
|
|
|
43
43
|
|
|
44
44
|
## gitleaks
|
|
45
45
|
|
|
46
|
-
The provider secret-token shape patterns in the
|
|
46
|
+
The provider secret-token shape patterns in the CLI's secret redaction rules are
|
|
47
47
|
adapted from the [gitleaks](https://github.com/gitleaks/gitleaks) ruleset (MIT),
|
|
48
48
|
by Zachary Rice: AWS access keys, GitHub classic and fine-grained tokens,
|
|
49
49
|
Slack/Stripe/npm/Anthropic/OpenAI/Google/Supabase/Twilio/SendGrid/Hugging Face
|
package/README.md
CHANGED
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
|
-
<h3 align="center">The tool router for coding agents.</h3>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
Give your agent superpowers once. Tenjin hands it the right tool when it helps, and you keep working like before.<br>
|
|
12
|
-
No API keys. No pile of MCP servers. No rules to write.
|
|
13
|
-
</p>
|
|
8
|
+
<h3 align="center">The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.</h3>
|
|
14
9
|
|
|
15
10
|
<p align="center">
|
|
16
11
|
<a href="https://www.npmjs.com/package/tenjin-cli"><img src="https://img.shields.io/npm/v/tenjin-cli?color=C85A3B&label=npm" alt="npm version"></a>
|
|
@@ -75,7 +70,7 @@ Each answer names the provider and the price. Your agent keeps its own tools, an
|
|
|
75
70
|
|
|
76
71
|
## What it can do
|
|
77
72
|
|
|
78
|
-
The router picks from a catalog we curate and maintain. When nothing in it fits, it can point your agent at a reviewed third-party pay-per-call service from the [Tenjin list](#tenjin-list-and-experimental-bazaar), and your agent decides whether to use it or to ask you first. Routing is free: you pay the provider's price and nothing else.
|
|
73
|
+
The router picks from a catalog we curate and maintain. When nothing in it fits, it can point your agent at a reviewed third-party pay-per-call service from the [Tenjin list](#tenjin-list-and-experimental-bazaar), and your agent decides whether to use it or to ask you first. Routing is free today: you pay the provider's price and nothing else. A flat [routing fee](#routing-fee) of $0.003 per routing call is coming, under the spend limits you approve at install.
|
|
79
74
|
|
|
80
75
|
| Tool | What your agent gets | Price per call |
|
|
81
76
|
| -------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | -------------- |
|
|
@@ -91,7 +86,7 @@ The router picks from a catalog we curate and maintain. When nothing in it fits,
|
|
|
91
86
|
| **X posts** · [glim](https://glim.sh) | Posts matching a search, or one post with its thread | $0.005 |
|
|
92
87
|
| **Reddit** · [glim](https://glim.sh) | Posts matching a search, or one thread with its comments | $0.01 / $0.005 |
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
Every tool, including the Tenjin list, with current prices: [tenjin.sh/tools](https://tenjin.sh/tools). More are added by demand: [tell us what you want](#request-a-tool).
|
|
95
90
|
|
|
96
91
|
### Tenjin list and experimental Bazaar
|
|
97
92
|
|
|
@@ -142,6 +137,10 @@ Tenjin pays for tools with [x402](https://www.x402.org), an open standard that b
|
|
|
142
137
|
|
|
143
138
|
Tenjin refuses any payment over either limit before it signs anything.
|
|
144
139
|
|
|
140
|
+
### Routing fee
|
|
141
|
+
|
|
142
|
+
Once Tenjin's server turns it on, each routing call costs a flat $0.003, paid over x402 `batch-settlement` by `tenjin mcp` from a channel deposit of up to $0.25 (less when your per-call limit is lower). A deposit is an automatic payment: it counts against the limits above, and approving them at install approves the fee. The fees come out of the deposit and are not counted again. When a call cannot be paid, it takes the free path, and Claude Code tells you once per session why and what fixes it; `tenjin doctor` says the same. Details are in [docs/agent-permissions.md](docs/agent-permissions.md#what-bounds-a-router-payment-on-top-of-that).
|
|
143
|
+
|
|
145
144
|
### Funding
|
|
146
145
|
|
|
147
146
|
`tenjin wallet fund 2` opens a Coinbase Onramp checkout for your wallet: pay by card, or Apple Pay where your region supports it. Sign in to Coinbase or create an account during checkout. You can also send USDC on Base to the address `tenjin wallet show` prints.
|
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
CHANNEL_DEPOSIT_ATOMIC,
|
|
4
|
+
ROUTING_FEE_ATOMIC,
|
|
5
|
+
usd
|
|
6
|
+
} from "./chunk-VYONGSMQ.js";
|
|
6
7
|
import {
|
|
7
8
|
paint
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UDWGT4FX.js";
|
|
9
10
|
import {
|
|
11
|
+
CLI_SKILL_NAMES,
|
|
10
12
|
RETIRED_SKILL_NAMES,
|
|
13
|
+
ROUTER_DEFAULTS,
|
|
14
|
+
SHIPPED_SKILL_FILES,
|
|
11
15
|
onPath,
|
|
12
16
|
persistRouterDefaults,
|
|
13
17
|
readSkillFile,
|
|
14
18
|
skillFrontmatterName,
|
|
15
19
|
skillsDirsFor
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YSW57KUT.js";
|
|
21
|
+
import {
|
|
22
|
+
askText,
|
|
23
|
+
selectOne
|
|
24
|
+
} from "./chunk-P7LABKCW.js";
|
|
17
25
|
import {
|
|
18
26
|
hasCode
|
|
19
27
|
} from "./chunk-2I4QTOLB.js";
|
|
20
28
|
import {
|
|
21
29
|
resolveContextSettings
|
|
22
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-HII5HOQV.js";
|
|
23
31
|
import {
|
|
32
|
+
loadRawConfig,
|
|
33
|
+
parseUsdToAtomic,
|
|
24
34
|
toMoney
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
loadRawConfig
|
|
28
|
-
} from "./chunk-SAN5PFTL.js";
|
|
35
|
+
} from "./chunk-XICKN3CH.js";
|
|
29
36
|
import {
|
|
30
37
|
ensureStatusLine
|
|
31
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-NTYQHAIM.js";
|
|
32
39
|
import {
|
|
33
40
|
appendAllowlistRules,
|
|
34
41
|
claudeAdapter,
|
|
@@ -36,7 +43,15 @@ import {
|
|
|
36
43
|
inspectHooksFile,
|
|
37
44
|
ownsHookEntry,
|
|
38
45
|
writeHooks
|
|
39
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-KGTQRJGS.js";
|
|
47
|
+
import {
|
|
48
|
+
HOOK_TOOL,
|
|
49
|
+
hookToolInput
|
|
50
|
+
} from "./chunk-AKWGE6JQ.js";
|
|
51
|
+
import {
|
|
52
|
+
MCP_SERVER_NAME,
|
|
53
|
+
REQUEST_TOOL
|
|
54
|
+
} from "./chunk-TGLKKLQG.js";
|
|
40
55
|
import {
|
|
41
56
|
CliError
|
|
42
57
|
} from "./chunk-JLEF5WHM.js";
|
|
@@ -51,7 +66,7 @@ import { promisify } from "node:util";
|
|
|
51
66
|
// src/lib/skill-placement.ts
|
|
52
67
|
import { lstatSync } from "node:fs";
|
|
53
68
|
import { readdir, rm, rmdir } from "node:fs/promises";
|
|
54
|
-
import { join } from "node:path";
|
|
69
|
+
import { dirname, join } from "node:path";
|
|
55
70
|
function isRealDirectory(path) {
|
|
56
71
|
try {
|
|
57
72
|
return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
|
|
@@ -74,16 +89,27 @@ async function removeOwnedSkill(name, skillsDir) {
|
|
|
74
89
|
if (read.kind !== "ok" || skillFrontmatterName(read.bytes.toString("utf8")) !== name) {
|
|
75
90
|
return { changed: false };
|
|
76
91
|
}
|
|
92
|
+
const shipped = SHIPPED_SKILL_FILES[name] ?? [];
|
|
93
|
+
const subdirs = /* @__PURE__ */ new Set();
|
|
94
|
+
for (const rel of shipped) {
|
|
95
|
+
if (rel === "SKILL.md") continue;
|
|
96
|
+
const file = join(skillDir, rel);
|
|
97
|
+
if (!isRealDirectory(dirname(file))) continue;
|
|
98
|
+
subdirs.add(dirname(file));
|
|
99
|
+
if (lstatSync(file, { throwIfNoEntry: false })?.isFile() === true) await rm(file);
|
|
100
|
+
}
|
|
77
101
|
await rm(path, { force: true });
|
|
78
|
-
const
|
|
79
|
-
|
|
102
|
+
for (const dir of [...subdirs, skillDir].sort((a, b) => b.length - a.length)) {
|
|
103
|
+
const rest = await readdir(dir).catch(() => null);
|
|
104
|
+
if (rest !== null && rest.length === 0) await rmdir(dir).catch(() => void 0);
|
|
105
|
+
}
|
|
80
106
|
return { changed: true };
|
|
81
107
|
}
|
|
82
108
|
async function removeRetiredSkills(home, project) {
|
|
83
109
|
const removed = [];
|
|
84
110
|
const dirs = [...skillsDirsFor(home), ...project ? skillsDirsFor(project) : []];
|
|
85
111
|
for (const dir of new Set(dirs)) {
|
|
86
|
-
for (const name of RETIRED_SKILL_NAMES) {
|
|
112
|
+
for (const name of [...RETIRED_SKILL_NAMES, ...CLI_SKILL_NAMES]) {
|
|
87
113
|
if ((await removeOwnedSkill(name, dir)).changed) removed.push(join(dir, name));
|
|
88
114
|
}
|
|
89
115
|
}
|
|
@@ -92,9 +118,10 @@ async function removeRetiredSkills(home, project) {
|
|
|
92
118
|
|
|
93
119
|
// src/router/install.ts
|
|
94
120
|
var exec = promisify(execFile);
|
|
95
|
-
var
|
|
121
|
+
var ROUTE_HOOK_TIMEOUT_SECONDS = 5;
|
|
96
122
|
var AFTER_CALL_TIMEOUT_SECONDS = 15;
|
|
97
123
|
var ALLOW_RULE = REQUEST_TOOL;
|
|
124
|
+
var DENY_RULE = `mcp__${MCP_SERVER_NAME}__${HOOK_TOOL}`;
|
|
98
125
|
function mcpScope(project) {
|
|
99
126
|
return project === true ? "project" : "user";
|
|
100
127
|
}
|
|
@@ -113,18 +140,24 @@ var DELEGATION_MATCHER = "Agent|Task";
|
|
|
113
140
|
var NATIVE_MATCHER = "WebSearch|WebFetch";
|
|
114
141
|
var ASK_MATCHER = "AskUserQuestion";
|
|
115
142
|
function routerHookPlan() {
|
|
116
|
-
const
|
|
117
|
-
{
|
|
143
|
+
const leg = (kind, timeout = ROUTE_HOOK_TIMEOUT_SECONDS) => [
|
|
144
|
+
{
|
|
145
|
+
type: "mcp_tool",
|
|
146
|
+
server: MCP_SERVER_NAME,
|
|
147
|
+
tool: HOOK_TOOL,
|
|
148
|
+
input: hookToolInput(kind),
|
|
149
|
+
timeout
|
|
150
|
+
}
|
|
118
151
|
];
|
|
119
|
-
const afterCall = () =>
|
|
152
|
+
const afterCall = () => leg("shortfall", AFTER_CALL_TIMEOUT_SECONDS);
|
|
120
153
|
return [
|
|
121
|
-
{ event: "UserPromptSubmit", hooks:
|
|
122
|
-
{ event: "PreToolUse", matcher: NATIVE_MATCHER, hooks:
|
|
123
|
-
{ event: "PreToolUse", matcher: DELEGATION_MATCHER, hooks:
|
|
154
|
+
{ event: "UserPromptSubmit", hooks: leg("prompt") },
|
|
155
|
+
{ event: "PreToolUse", matcher: NATIVE_MATCHER, hooks: leg("native") },
|
|
156
|
+
{ event: "PreToolUse", matcher: DELEGATION_MATCHER, hooks: leg("agent") },
|
|
124
157
|
{ event: "PostToolUse", matcher: NATIVE_MATCHER, hooks: afterCall() },
|
|
125
158
|
{ event: "PostToolUseFailure", matcher: NATIVE_MATCHER, hooks: afterCall() },
|
|
126
|
-
{ event: "PreToolUse", matcher: ASK_MATCHER, hooks:
|
|
127
|
-
{ event: "PostToolUse", matcher: ASK_MATCHER, hooks:
|
|
159
|
+
{ event: "PreToolUse", matcher: ASK_MATCHER, hooks: leg("ask") },
|
|
160
|
+
{ event: "PostToolUse", matcher: ASK_MATCHER, hooks: leg("answer") }
|
|
128
161
|
];
|
|
129
162
|
}
|
|
130
163
|
var DISCLOSURE = [
|
|
@@ -156,7 +189,7 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
156
189
|
fix: "Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`."
|
|
157
190
|
});
|
|
158
191
|
}
|
|
159
|
-
await loadRawConfig(ctx.dataDir);
|
|
192
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
160
193
|
const cwd = deps.cwd ?? process.cwd();
|
|
161
194
|
const project = args.project ?? (args.refresh === true && await inferRefreshProject(cwd, home, ctx.dataDir, deps.readMcpEntry ?? readMcpEntry));
|
|
162
195
|
const settingsPath = routerSettingsPath({
|
|
@@ -179,7 +212,10 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
179
212
|
);
|
|
180
213
|
}
|
|
181
214
|
}
|
|
182
|
-
const
|
|
215
|
+
const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
|
|
216
|
+
const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
|
|
217
|
+
const limits = args.refresh !== true && canPrompt ? await approveLimits(config, deps) : void 0;
|
|
218
|
+
const spend = await persistRouterDefaults(ctx.dataDir, args.refresh === true, limits);
|
|
183
219
|
const removedKeysLines = spend.removed.length > 0 ? [
|
|
184
220
|
`Removed retired settings: ${spend.removed.join(", ")}. Automatic router limits remain in effect; manual pay always requires consent.`
|
|
185
221
|
] : [];
|
|
@@ -192,7 +228,7 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
192
228
|
plan: routerHookPlan(),
|
|
193
229
|
settingsPath
|
|
194
230
|
});
|
|
195
|
-
const permissions = await
|
|
231
|
+
const permissions = await ensurePermissionRules(settingsPath);
|
|
196
232
|
const statusLine = await ensureStatusLine(settingsPath, {
|
|
197
233
|
...args.statusLine !== void 0 ? { mode: args.statusLine } : {},
|
|
198
234
|
...args.refresh === true ? { refreshOnly: true } : {}
|
|
@@ -224,7 +260,7 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
224
260
|
]
|
|
225
261
|
};
|
|
226
262
|
}
|
|
227
|
-
const { resolveWallet } = await import("./install-wallet-
|
|
263
|
+
const { resolveWallet } = await import("./install-wallet-27LTEHBI.js");
|
|
228
264
|
const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? "flag" : void 0, false);
|
|
229
265
|
const effective = await resolveContextSettings(ctx);
|
|
230
266
|
const data = {
|
|
@@ -254,15 +290,87 @@ async function runRouterInstall(args, ctx, deps = {}) {
|
|
|
254
290
|
]
|
|
255
291
|
};
|
|
256
292
|
}
|
|
257
|
-
async function
|
|
258
|
-
const
|
|
293
|
+
async function approveLimits(config, deps) {
|
|
294
|
+
const shown = {
|
|
295
|
+
maxAutoSpend: config.maxAutoSpend ?? ROUTER_DEFAULTS.maxAutoSpend,
|
|
296
|
+
sessionBudget: config.sessionBudget ?? ROUTER_DEFAULTS.sessionBudget
|
|
297
|
+
};
|
|
298
|
+
const askCall = config.maxAutoSpend === void 0;
|
|
299
|
+
const askDay = config.sessionBudget === void 0;
|
|
300
|
+
if (!askCall && !askDay) return void 0;
|
|
301
|
+
const daily = shown.sessionBudget === "none" ? "no daily limit" : `$${toMoney(shown.sessionBudget).usd} a day`;
|
|
302
|
+
const fee = `
|
|
303
|
+
Routing costs $${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that stay yours until spent; each deposit counts against these limits.
|
|
304
|
+
Using these limits or choosing your own also approves the routing fee.`;
|
|
305
|
+
const choice = await (deps.promptLimits ?? promptLimits)(
|
|
306
|
+
`The router pays for tool calls without asking, up to:
|
|
307
|
+
$${toMoney(shown.maxAutoSpend).usd} a call, ${daily}${fee}`
|
|
308
|
+
);
|
|
309
|
+
if (choice === null) throw installCancelled();
|
|
310
|
+
if (choice === "approve") return shown;
|
|
311
|
+
const ask = deps.promptAmount ?? promptAmount;
|
|
259
312
|
return {
|
|
260
|
-
|
|
313
|
+
maxAutoSpend: askCall ? await askLimit(ask, "Most the router may pay for one call, in USD", "0.25", false) : shown.maxAutoSpend,
|
|
314
|
+
sessionBudget: askDay ? await askLimit(ask, "Most it may pay in a day, in USD, or none", "5", true) : shown.sessionBudget
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async function askLimit(ask, question, placeholder, allowNone) {
|
|
318
|
+
let message = question;
|
|
319
|
+
for (; ; ) {
|
|
320
|
+
const answer = await ask(message, placeholder);
|
|
321
|
+
if (answer === null) throw installCancelled();
|
|
322
|
+
const parsed = parseLimit(answer, allowNone);
|
|
323
|
+
if (!("refusal" in parsed)) return parsed.value;
|
|
324
|
+
message = `${parsed.refusal} ${question}`;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function parseLimit(answer, allowNone) {
|
|
328
|
+
const trimmed = answer.trim();
|
|
329
|
+
if (allowNone && trimmed === "none") return { value: "none" };
|
|
330
|
+
let atomic;
|
|
331
|
+
try {
|
|
332
|
+
atomic = parseUsdToAtomic(trimmed);
|
|
333
|
+
} catch (err) {
|
|
334
|
+
if (err instanceof CliError) return { refusal: `${err.message}.` };
|
|
335
|
+
throw err;
|
|
336
|
+
}
|
|
337
|
+
if (atomic === "0") return { refusal: "The limit must be more than zero." };
|
|
338
|
+
return { value: atomic };
|
|
339
|
+
}
|
|
340
|
+
function installCancelled() {
|
|
341
|
+
return new CliError("REFUSED", "Install cancelled before anything was written.", {
|
|
342
|
+
fix: "Re-run `tenjin install` and choose the spend limits."
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function promptLimits(message) {
|
|
346
|
+
return selectOne({
|
|
347
|
+
message,
|
|
348
|
+
choices: [
|
|
349
|
+
{ value: "approve", label: "Use these limits" },
|
|
350
|
+
{ value: "own", label: "Choose my own" }
|
|
351
|
+
],
|
|
352
|
+
initialValue: "approve"
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function promptAmount(message, placeholder) {
|
|
356
|
+
return askText({ message, placeholder });
|
|
357
|
+
}
|
|
358
|
+
async function ensurePermissionRules(path) {
|
|
359
|
+
const allow = await appendAllowlistRules(path, [ALLOW_RULE]);
|
|
360
|
+
const deny = await appendAllowlistRules(path, [DENY_RULE], "deny");
|
|
361
|
+
const warning = writerWarning(allow) ?? writerWarning(deny);
|
|
362
|
+
return {
|
|
363
|
+
path: allow.path,
|
|
261
364
|
rule: ALLOW_RULE,
|
|
262
|
-
added:
|
|
263
|
-
|
|
365
|
+
added: allow.added.length > 0,
|
|
366
|
+
denyRule: DENY_RULE,
|
|
367
|
+
denyAdded: deny.added.length > 0,
|
|
368
|
+
...warning !== void 0 ? { warning } : {}
|
|
264
369
|
};
|
|
265
370
|
}
|
|
371
|
+
function writerWarning(result) {
|
|
372
|
+
return result.warning ?? (result.skipped !== void 0 ? `${result.path} was left untouched (${result.skipped}).` : void 0);
|
|
373
|
+
}
|
|
266
374
|
async function registerMcpServer(deps, env, project, cwd, home) {
|
|
267
375
|
const scope = mcpScope(project);
|
|
268
376
|
const command = mcpAddCommand(project);
|
|
@@ -430,9 +538,10 @@ async function probeOurEntries(path, dataDir) {
|
|
|
430
538
|
}
|
|
431
539
|
|
|
432
540
|
export {
|
|
433
|
-
|
|
541
|
+
ROUTE_HOOK_TIMEOUT_SECONDS,
|
|
434
542
|
AFTER_CALL_TIMEOUT_SECONDS,
|
|
435
543
|
ALLOW_RULE,
|
|
544
|
+
DENY_RULE,
|
|
436
545
|
mcpScope,
|
|
437
546
|
mcpAddCommand,
|
|
438
547
|
mcpRemoveCommand,
|
|
@@ -448,4 +557,4 @@ export {
|
|
|
448
557
|
readMcpEntry,
|
|
449
558
|
statusLineProblems
|
|
450
559
|
};
|
|
451
|
-
//# sourceMappingURL=chunk-
|
|
560
|
+
//# sourceMappingURL=chunk-3ZYPVSIU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/install.ts","../src/lib/skill-placement.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readFile, realpath } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { claudeAdapter } from '../adapters/claude';\nimport { persistRouterDefaults, ROUTER_DEFAULTS, type RouterLimits } from '../commands/config';\nimport { askText, selectOne } from '../lib/clack';\nimport { CliError } from '../lib/errors';\nimport {\n appendAllowlistRules,\n claudeSettingsPath,\n type AppendAllowlistResult,\n} from '../lib/harness-permissions';\nimport {\n inspectHooksFile,\n ownsHookEntry,\n pruneHooks,\n writeHooks,\n type HooksResult,\n} from '../lib/harness-hooks';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { paint } from '../lib/output';\nimport { resolveContextSettings } from '../lib/settings';\nimport type { SpendPolicy } from '../lib/policy';\nimport { removeRetiredSkills } from '../lib/skill-placement';\nimport { loadRawConfig, type PartialConfig } from '../lib/config';\nimport { onPath } from '../lib/skill-wiring';\nimport type { WalletDeps, WalletOutcome } from '../commands/install-wallet';\nimport type { CommandContext, CommandResult } from '../context';\nimport { CHANNEL_DEPOSIT_ATOMIC, ROUTING_FEE_ATOMIC, usd } from './fee';\nimport { HOOK_TOOL, hookToolInput, type HookKind } from './hook-tool';\nimport { MCP_SERVER_NAME, REQUEST_TOOL } from './names';\nimport { ensureStatusLine, type StatusLineMode, type StatusLineResult } from './status-line-wiring';\n\n/**\n * `tenjin install` for the router product: seven hook entries, one MCP server,\n * one permission rule, the spend defaults, and a wallet when there is none.\n *\n * WHAT IT WRITES IS WHAT IT SAYS. There is no skill to materialize and no\n * daemon to start: each hook entry is a Claude Code `mcp_tool` hook that calls\n * the `hook` tool of the session's own router MCP server (`tenjin mcp`), which\n * runs the leg and holds the wallet, and every other key in the settings file\n * is preserved byte for byte. The one process a leg starts is the free docs\n * fetch beside a search, which exits within `PREFETCH_TIMEOUT_MS`.\n */\n\nconst exec = promisify(execFile);\n\n/**\n * The harness's kill budget for each routing leg: a stuck server never holds a\n * prompt longer than this. Every wait inside the leg is cut from it: the gate's\n * 3.5 s, which holds the paid path's 402, the reads before a deposit and the\n * paid request, with 500 ms left for the transcript read and the reply\n * (`wire.test.ts` pins the sum). A whole leg whose call carried a deposit took\n * 2.8 to 3.3 s on Base Sepolia, so it fits; a slower one (a wallet unlock, a\n * slow settlement) loses only that prompt's hint, and the SDK recovers the\n * channel on the next call.\n *\n * A machine carrying an older entry is converged by the writer, not by the\n * user: the entries are ours by marker, so `install`, `install --refresh` and\n * the refresh `tenjin update` spawns all rewrite them in place.\n */\nexport const ROUTE_HOOK_TIMEOUT_SECONDS = 5;\n/**\n * The after-call entries' kill budget, longer than the rest for the one wait\n * a leg makes: a search the pre-call leg is fetching free docs for waits up to\n * `AUGMENT_WAIT_MS` (9 s) for them, and when none came back and the search was\n * short, the gate's 3.5 s follow, with startup to spare (`wire.test.ts` pins\n * the sum). Every other after-call event\n * returns as fast as before, so the number is a ceiling, not a cost.\n */\nexport const AFTER_CALL_TIMEOUT_SECONDS = 15;\nexport { MCP_SERVER_NAME };\nexport const ALLOW_RULE = REQUEST_TOOL;\n/**\n * THE HOOK ENTRIES' TOOL IS DENIED TO THE MODEL. Its event fields are plain\n * arguments, so the model calling it could forge a routing leg. A deny rule\n * takes the tool out of the model's tool list in every permission mode,\n * bypass included, while Claude Code's own `mcp_tool` hook calls to it still\n * run (checked on Claude Code 2.1.289). The tool's transcript check\n * (`admitHookEvent`) stays for a settings file without the rule.\n */\nexport const DENY_RULE = `mcp__${MCP_SERVER_NAME}__${HOOK_TOOL}`;\n/**\n * The MCP registration follows the SAME SCOPE the hook entries do. A\n * `--project` install that wrote its hooks into the project and then registered\n * the server at user scope would reach into `~/.claude.json` on a run whose\n * whole point is to touch this project and nothing else, and `tenjin uninstall\n * --project` would leave that behind.\n *\n * Project scope writes `<project>/.mcp.json`, so the registration lives beside\n * the settings file that names the hooks and travels with the repository.\n */\nexport function mcpScope(project: boolean | undefined): 'user' | 'project' {\n return project === true ? 'project' : 'user';\n}\n\nexport function mcpAddCommand(project?: boolean): string {\n return `claude mcp add ${MCP_SERVER_NAME} -s ${mcpScope(project)} -- tenjin mcp`;\n}\n\nexport function mcpRemoveCommand(project?: boolean): string {\n return `claude mcp remove ${MCP_SERVER_NAME} -s ${mcpScope(project)}`;\n}\n\n/** The user-scope form, kept as the name the docs and the tests already use. */\nexport const MCP_ADD_COMMAND = mcpAddCommand();\n\n/**\n * Which settings file this machine's router wiring lives in, spelled once so\n * `install`, `uninstall` and `doctor` can never disagree about where to look.\n * A doctor reading the home file on a `--project` install reported a correctly\n * wired machine as unwired and exited 3.\n */\nexport function routerSettingsPath(\n opts: { project?: boolean; homeDir?: string; cwd?: string } = {},\n): string {\n if (opts.project === true) return join(opts.cwd ?? process.cwd(), '.claude', 'settings.json');\n return claudeSettingsPath(opts.homeDir ?? homedir());\n}\n\n/** The subagent tool, under its current name and its older one. */\nexport const DELEGATION_MATCHER = 'Agent|Task';\n\n/** The native tools both native arms watch. */\nexport const NATIVE_MATCHER = 'WebSearch|WebFetch';\n\n/** The host's question to the user, watched before it is asked and after. */\nexport const ASK_MATCHER = 'AskUserQuestion';\n\n/**\n * The seven entries, spelled once so `uninstall`, `doctor` and the tests read\n * the same list. The native tools are routed twice over one lookup: BEFORE the\n * call, as every release has, with a line pointing to a paid lookup when one\n * fits; and AFTER it, only when it came back short and nothing was said before,\n * or to add the free docs the pre-call arm fetched to a search's results. A\n * failed call fires PostToolUseFailure rather than PostToolUse, so the second\n * takes both. The host's question to the user is routed the same two ways:\n * before it is asked, when a service could stand in for what it asks for, and\n * after, with the user's answers read as their own words.\n */\nexport function routerHookPlan(): unknown[] {\n const leg = (kind: HookKind, timeout = ROUTE_HOOK_TIMEOUT_SECONDS) => [\n {\n type: 'mcp_tool',\n server: MCP_SERVER_NAME,\n tool: HOOK_TOOL,\n input: hookToolInput(kind),\n timeout,\n },\n ];\n const afterCall = () => leg('shortfall', AFTER_CALL_TIMEOUT_SECONDS);\n return [\n { event: 'UserPromptSubmit', hooks: leg('prompt') },\n { event: 'PreToolUse', matcher: NATIVE_MATCHER, hooks: leg('native') },\n { event: 'PreToolUse', matcher: DELEGATION_MATCHER, hooks: leg('agent') },\n { event: 'PostToolUse', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PostToolUseFailure', matcher: NATIVE_MATCHER, hooks: afterCall() },\n { event: 'PreToolUse', matcher: ASK_MATCHER, hooks: leg('ask') },\n { event: 'PostToolUse', matcher: ASK_MATCHER, hooks: leg('answer') },\n ];\n}\n\nexport const DISCLOSURE: readonly string[] = [\n \"What leaves this machine: the bounded text of each prompt, each native search query or URL (and, when one came back short, its status, size or error), each task handed to a subagent, and each question your assistant asks you with your answers, sent to Tenjin for the free routing gate, beside this session's id. When the gate offers free library docs for a search, that search query also goes to Tenjin's docs lookup, which asks Context7.\",\n 'What is kept when a lookup is paid: the capability chosen, a hash of the contract, a hash of the arguments, and your wallet address. No prompt text, no arguments, no hint text.',\n 'What never leaves: your private key. It is decrypted in this CLI to sign, and never sent anywhere.',\n];\n\nexport interface RouterInstallArgs {\n /** Write into this project's `.claude/settings.json` instead of your home one. */\n project?: boolean;\n /**\n * Bring the entries this machine ALREADY has up to the running build, and\n * add nothing: no config write, no MCP registration, and a refusal when\n * nothing of ours is here. `tenjin update` spawns exactly this after it swaps\n * the binary, so the flag's name and meaning are a compatibility contract.\n */\n refresh?: boolean;\n /**\n * What to do about Claude Code's `statusLine`. Absent is the default path:\n * write ours when the key is free, and print the composition line when it is\n * not. `compose` wraps the status line already there and appends ours;\n * `skip` leaves the key alone entirely.\n */\n statusLine?: StatusLineMode;\n /** Create no wallet, for CI and scripted machines. */\n noWallet?: boolean;\n}\n\nexport interface RouterInstallDeps extends WalletDeps {\n homeDir?: string;\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n /** PATH probe for the `claude` binary. */\n which?: (bin: string) => boolean;\n /** Runs `claude mcp add`; tests inject it so no binary is spawned. The scope\n * and the working directory are passed, because project scope is decided by\n * where the command runs as much as by the flag. */\n registerMcp?: (\n command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n ) => Promise<void>;\n /** Reads the registration the scope's own file holds; tests inject it. */\n readMcpEntry?: (\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n ) => Promise<{ found: boolean; state: McpEntryState }>;\n /** Whether a person can answer the spend-limit question (a TTY on stdout and\n * stdin, no `--json`); injected in tests. */\n isInteractive?: boolean;\n /** The spend-limit selector; defaults to the clack list. */\n promptLimits?: (message: string) => Promise<LimitsChoice | null>;\n /** One amount question; defaults to the clack text input. */\n promptAmount?: (message: string, placeholder: string) => Promise<string | null>;\n}\n\nexport type LimitsChoice = 'approve' | 'own';\n\nexport interface McpRegistration {\n name: string;\n registered: boolean;\n /** Which scope it went to, following the hook entries rather than the flag\n * being read twice. `project` writes `<project>/.mcp.json`. */\n scope: 'user' | 'project';\n /** The command to run by hand, when this run could not. */\n command: string;\n /**\n * WHAT THIS RUN ACTUALLY DID, which `registered` alone cannot say:\n * `already-registered` (the scope's file already launches `tenjin mcp`, and\n * nothing was spawned), `added`, `repaired` (a same-name entry launching\n * something else was removed and re-added, which only `uninstall` does now),\n * `unrepaired` (a registration this run KNOWS is wrong or unreadable and will\n * not touch) or `unavailable` (it is simply not there and this machine could\n * not add it, e.g. no `claude` on PATH). A refresh fails on `unrepaired`,\n * because reporting convergence over a registration that launches something\n * else is the thing to avoid; it still only prints the manual command for\n * `unavailable`.\n */\n reconciled: 'already-registered' | 'added' | 'repaired' | 'unrepaired' | 'unavailable';\n reason?: string;\n}\n\nasync function inferRefreshProject(\n cwd: string,\n home: string,\n dataDir: string,\n readRegistration: typeof readMcpEntry,\n): Promise<boolean> {\n const hooks = await probeOurEntries(routerSettingsPath({ project: true, cwd }), dataDir);\n if (hooks.state !== 'present') return false;\n const [cwdPath, homePath] = await Promise.all([\n realpath(cwd),\n realpath(home).catch((err: NodeJS.ErrnoException) => {\n // A missing home cannot alias this existing project. Do not require it\n // to exist (or create it) just to refresh the project's own settings.\n if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return null;\n throw err;\n }),\n ]);\n if (cwdPath !== homePath) return true;\n\n // Home shares one hooks file between scopes. Preserve a project-only install,\n // but prefer user scope when both registrations exist (including alpha.18's\n // accidental duplicate). With neither registration, the default is user.\n // Unreadable/conflicting entries stay in their scope so reconciliation refuses\n // them instead of silently creating a registration in the other scope.\n const user = await readRegistration('user', cwd, home);\n if (user.state !== 'absent') return false;\n const project = await readRegistration('project', cwd, home);\n return project.state !== 'absent';\n}\n\nexport async function runRouterInstall(\n args: RouterInstallArgs,\n ctx: CommandContext,\n deps: RouterInstallDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) {\n throw new CliError('INTERNAL', 'The home directory is not an absolute path.', {\n fix: 'Set HOME to your home directory (`export HOME=...`), then re-run `tenjin install`.',\n });\n }\n const config = await loadRawConfig(ctx.dataDir); // Validate before any install writes; retired keys remain readable.\n const cwd = deps.cwd ?? process.cwd();\n // `tenjin update` runs from home, where the hooks file cannot prove scope.\n // An explicit --project still wins, including for a project rooted at home.\n const project =\n args.project ??\n (args.refresh === true &&\n (await inferRefreshProject(cwd, home, ctx.dataDir, deps.readMcpEntry ?? readMcpEntry)));\n const settingsPath = routerSettingsPath({\n ...(project ? { project: true } : {}),\n homeDir: home,\n cwd,\n });\n\n if (args.refresh === true) {\n const probe = await probeOurEntries(settingsPath, ctx.dataDir);\n // An unreadable file is not an absence, and telling someone to install over\n // it is the wrong instruction: the writer would refuse it too.\n if (probe.state === 'unreadable') {\n throw new CliError('CONFIG_INVALID', `Could not inspect ${settingsPath}: ${probe.reason}`, {\n fix: `Fix ${settingsPath}, then re-run: tenjin update`,\n });\n }\n if (probe.state === 'absent') {\n throw new CliError(\n 'REFUSED',\n `Nothing to refresh in ${settingsPath}: no Tenjin hook entries are registered here.`,\n { fix: 'Run `tenjin install` to set this machine up.' },\n );\n }\n }\n // The shelf install's gate: a refresh, `--json`, or a run with no terminal on\n // either side asks nothing and writes the defaults only where the file is silent.\n const humanOutput = ctx.flags.json === true ? false : (deps.isInteractive ?? ctx.io.isTTY);\n const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));\n const limits = args.refresh !== true && canPrompt ? await approveLimits(config, deps) : undefined;\n const spend = await persistRouterDefaults(ctx.dataDir, args.refresh === true, limits);\n const removedKeysLines =\n spend.removed.length > 0\n ? [\n `Removed retired settings: ${spend.removed.join(', ')}. Automatic router limits remain in effect; manual pay always requires consent.`,\n ]\n : [];\n const removedSkills = await removeRetiredSkills(home, project ? cwd : undefined);\n const hooks = await writeHooks({\n adapter: claudeAdapter,\n homeDir: home,\n dataDir: ctx.dataDir,\n env,\n plan: routerHookPlan(),\n settingsPath,\n });\n const permissions = await ensurePermissionRules(settingsPath);\n const statusLine = await ensureStatusLine(settingsPath, {\n ...(args.statusLine !== undefined ? { mode: args.statusLine } : {}),\n ...(args.refresh === true ? { refreshOnly: true } : {}),\n });\n const mcp = await registerMcpServer(deps, env, project, cwd, home);\n if (args.refresh === true) {\n // The SAME writers, minus the one that decides anything: the entries are\n // rewritten in place by their ownership marker so an upgrade never\n // duplicates them, the rule and the registration are re-checked because a\n // new version can change either. Config cleanup only removes retired keys;\n // the wallet, current limits and `spend.json` are unchanged. Widening an agent's spend policy\n // during an unattended upgrade is not a convergence.\n // RECONCILED, not re-added: `claude mcp add` exits 1 on an existing entry,\n // so the registration is read first and only written when it is missing or\n // wrong (see {@link registerMcpServer}).\n // A registration this run KNOWS is wrong and could not repair is not a\n // converged install, and `tenjin update` reporting success over it is how\n // a machine keeps a stale `x402` server across upgrade after upgrade.\n if (mcp.reconciled === 'unrepaired') {\n throw new CliError(\n 'REFUSED',\n `The ${MCP_SERVER_NAME} MCP registration (${mcpScope(project)} scope) is not the router's and this run could not repair it: ${mcp.reason ?? 'unknown reason'}.`,\n { fix: `Run: ${mcp.command}`, details: { settingsPath, hooks, permissions, mcp } },\n );\n }\n return {\n data: {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n mcp,\n refresh: true,\n spend,\n removedSkills,\n scope: mcpScope(project),\n },\n humanLines: [\n ...refreshLines(ctx, problems(ctx, hooks, permissions, statusLine, mcp)),\n ...removedKeysLines,\n ],\n };\n }\n // The shelf install's wallet step, unchanged except that it never asks: a\n // lookup cannot be paid without a wallet, so install makes one. A failure is\n // reported, never fatal; everything above is useful without it.\n const { resolveWallet } = await import('../commands/install-wallet');\n const wallet = await resolveWallet(ctx, deps, args.noWallet === true ? 'flag' : undefined, false);\n // Read back AFTER the write: a machine that already carried its own caps\n // keeps them, and a readout quoting the defaults would describe limits this\n // run did not set.\n const effective = await resolveContextSettings(ctx);\n\n const data = {\n settingsPath,\n hooks,\n permissions,\n statusLine,\n spend: { ...spend, effective: effectiveLimits(effective.policy) },\n mcp,\n wallet,\n disclosure: DISCLOSURE,\n removedSkills,\n };\n return {\n data,\n humanLines: [\n ...lines(ctx, {\n project,\n hooks,\n permissions,\n statusLine,\n mcp,\n wallet,\n policy: effective.policy,\n }),\n ...removedKeysLines,\n ],\n };\n}\n\n/**\n * The one question install asks, before anything is written: approve the\n * automatic spend limits or set your own. Only a key the file does not already\n * name is asked for, because the write fills absent keys and keeps the rest.\n * The question names the routing fee and its deposits too, and either answer\n * approves it. Cancelling at any step writes nothing.\n */\nasync function approveLimits(\n config: PartialConfig,\n deps: RouterInstallDeps,\n): Promise<RouterLimits | undefined> {\n const shown: RouterLimits = {\n maxAutoSpend: config.maxAutoSpend ?? ROUTER_DEFAULTS.maxAutoSpend,\n sessionBudget: config.sessionBudget ?? ROUTER_DEFAULTS.sessionBudget,\n };\n const askCall = config.maxAutoSpend === undefined;\n const askDay = config.sessionBudget === undefined;\n if (!askCall && !askDay) return undefined;\n const daily =\n shown.sessionBudget === 'none'\n ? 'no daily limit'\n : `$${toMoney(shown.sessionBudget).usd} a day`;\n const fee = `\\nRouting costs $${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that stay yours until spent; each deposit counts against these limits.\\nUsing these limits or choosing your own also approves the routing fee.`;\n const choice = await (deps.promptLimits ?? promptLimits)(\n `The router pays for tool calls without asking, up to:\\n $${toMoney(shown.maxAutoSpend).usd} a call, ${daily}${fee}`,\n );\n if (choice === null) throw installCancelled();\n if (choice === 'approve') return shown;\n const ask = deps.promptAmount ?? promptAmount;\n return {\n maxAutoSpend: askCall\n ? await askLimit(ask, 'Most the router may pay for one call, in USD', '0.25', false)\n : shown.maxAutoSpend,\n sessionBudget: askDay\n ? await askLimit(ask, 'Most it may pay in a day, in USD, or none', '5', true)\n : shown.sessionBudget,\n };\n}\n\n/** Asks until the answer is a positive amount (or `none` for the daily limit). */\nasync function askLimit(\n ask: NonNullable<RouterInstallDeps['promptAmount']>,\n question: string,\n placeholder: string,\n allowNone: boolean,\n): Promise<string> {\n let message = question;\n for (;;) {\n const answer = await ask(message, placeholder);\n if (answer === null) throw installCancelled();\n const parsed = parseLimit(answer, allowNone);\n if (!('refusal' in parsed)) return parsed.value;\n message = `${parsed.refusal} ${question}`;\n }\n}\n\n/** Zero is refused: a zero per-call limit means the router can never pay, and\n * `router.enabled false` is how to turn it off. */\nfunction parseLimit(answer: string, allowNone: boolean): { value: string } | { refusal: string } {\n const trimmed = answer.trim();\n if (allowNone && trimmed === 'none') return { value: 'none' };\n let atomic: string;\n try {\n atomic = parseUsdToAtomic(trimmed);\n } catch (err) {\n if (err instanceof CliError) return { refusal: `${err.message}.` };\n throw err;\n }\n if (atomic === '0') return { refusal: 'The limit must be more than zero.' };\n return { value: atomic };\n}\n\nfunction installCancelled(): CliError {\n return new CliError('REFUSED', 'Install cancelled before anything was written.', {\n fix: 'Re-run `tenjin install` and choose the spend limits.',\n });\n}\n\nfunction promptLimits(message: string): Promise<LimitsChoice | null> {\n return selectOne<LimitsChoice>({\n message,\n choices: [\n { value: 'approve', label: 'Use these limits' },\n { value: 'own', label: 'Choose my own' },\n ],\n initialValue: 'approve',\n });\n}\n\nfunction promptAmount(message: string, placeholder: string): Promise<string | null> {\n return askText({ message, placeholder });\n}\n\nexport interface AllowRuleResult {\n path: string;\n rule: string;\n added: boolean;\n /** {@link DENY_RULE}, written to `permissions.deny` beside the allow rule. */\n denyRule: string;\n denyAdded: boolean;\n /** Set when the file could not be written; the rules are then not in force. */\n warning?: string;\n}\n\n/**\n * The two permission rules, through the shared allowlist writer rather than a\n * third hand-rolled one: it resolves a symlinked settings.json before the\n * rename, refuses a file it cannot parse, and compares the bytes it read before\n * committing, none of which a local copy of the merge would have. Each adds\n * only its own rule and keeps every other entry in the list.\n */\nasync function ensurePermissionRules(path: string): Promise<AllowRuleResult> {\n const allow = await appendAllowlistRules(path, [ALLOW_RULE]);\n const deny = await appendAllowlistRules(path, [DENY_RULE], 'deny');\n const warning = writerWarning(allow) ?? writerWarning(deny);\n return {\n path: allow.path,\n rule: ALLOW_RULE,\n added: allow.added.length > 0,\n denyRule: DENY_RULE,\n denyAdded: deny.added.length > 0,\n ...(warning !== undefined ? { warning } : {}),\n };\n}\n\nfunction writerWarning(result: AppendAllowlistResult): string | undefined {\n return (\n result.warning ??\n (result.skipped !== undefined\n ? `${result.path} was left untouched (${result.skipped}).`\n : undefined)\n );\n}\n\n/**\n * RECONCILE, do not re-add blindly. `claude mcp add` is not idempotent: Claude\n * Code 2.1.280 exits 1 on a second identical add with \"MCP server x402 already\n * exists in .mcp.json\". Running it unconditionally therefore reported a\n * perfectly healthy machine as an unregistered one and printed a repair command\n * that would fail the same way, while a same-name entry launching something\n * else never converged, because `add` refuses to overwrite it.\n *\n * So the scope's own file is read first: an entry that already launches\n * `tenjin mcp` is the goal state and nothing is spawned, and a file that cannot\n * be read is refused out loud rather than written over.\n *\n * AN `x402` ENTRY THAT LAUNCHES SOMETHING ELSE IS SOMEBODY ELSE'S. This command\n * will not delete it. It may be another tool of the user's that happens to\n * share the name, and an installer that removes a registration nobody asked it\n * to touch has destroyed configuration to make its own output look tidy. The\n * conflict is reported with the exact two commands to run, and the user decides.\n */\nasync function registerMcpServer(\n deps: RouterInstallDeps,\n env: NodeJS.ProcessEnv,\n project: boolean,\n cwd: string,\n home: string,\n): Promise<McpRegistration> {\n const scope = mcpScope(project);\n const command = mcpAddCommand(project);\n const base = { name: MCP_SERVER_NAME, scope, command };\n const existing = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);\n if (existing.state === 'ok') {\n return { ...base, registered: true, reconciled: 'already-registered' };\n }\n if (existing.state === 'unreadable') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n reason: `the ${scope}-scope registration file could not be read, so nothing was written over it`,\n };\n }\n // REFUSED, NOT REPLACED. Nothing of the user's is removed to make room.\n if (existing.state === 'wrong-command') {\n return {\n ...base,\n registered: false,\n reconciled: 'unrepaired',\n command: `${mcpRemoveCommand(project)} && ${command}`,\n reason: `an MCP server named ${MCP_SERVER_NAME} is already registered at ${scope} scope and launches something else. This command will not remove a registration it did not write; run the two commands above if that entry is stale`,\n };\n }\n const which = deps.which ?? ((bin: string) => onPath(bin, env));\n if (!which('claude')) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: 'the `claude` binary is not on PATH',\n };\n }\n try {\n await (deps.registerMcp ?? runClaudeMcpAdd)(command, { scope, cwd });\n return { ...base, registered: true, reconciled: 'added' };\n } catch (err) {\n return {\n ...base,\n registered: false,\n reconciled: 'unavailable',\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport type McpEntryState = 'ok' | 'absent' | 'wrong-command' | 'unreadable';\n\n/**\n * What an entry named `x402` actually launches. The name proves nothing: a\n * stale entry pointing at another binary would read as a working request tool.\n */\nexport function classifyMcpEntry(entry: unknown): McpEntryState {\n if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) return 'absent';\n const { command, args } = entry as { command?: unknown; args?: unknown };\n if (typeof command !== 'string' || command.length === 0) return 'wrong-command';\n // The basename, so `/opt/homebrew/bin/tenjin` and a bare `tenjin` both pass.\n const binary = command.split(/[\\\\/]/).pop();\n const runsRouter =\n binary === 'tenjin' && Array.isArray(args) && args.length === 1 && args[0] === 'mcp';\n return runsRouter ? 'ok' : 'wrong-command';\n}\n\n/**\n * The file each scope writes: the project's own `.mcp.json`, or the user's\n * `~/.claude.json`. Neither can inherit from the other. Shared by `install`,\n * which reconciles against it, and `doctor`, which reports it.\n */\nexport async function readMcpEntry(\n scope: 'user' | 'project',\n cwd: string,\n home: string,\n): Promise<{ found: boolean; state: McpEntryState }> {\n const path = scope === 'project' ? join(cwd, '.mcp.json') : join(home, '.claude.json');\n // ONLY \"it is not there\" is an absence. A permission or filesystem error on a\n // file that DOES exist says nothing about what is registered in it, and\n // treating it as missing sent the refresh on to `claude mcp add` over a\n // registration it had never read: a failed add then looked like a machine\n // that simply lacks the tooling, and `tenjin update` exited 0 over whatever\n // was actually in there.\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === 'ENOENT' || code === 'ENOTDIR') return { found: false, state: 'absent' };\n return { found: true, state: 'unreadable' };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // NOT an absence: the harness's own file is there and unreadable to this\n // build, so neither \"register it\" nor \"it is missing\" is a true statement.\n return { found: true, state: 'unreadable' };\n }\n const servers = (parsed as { mcpServers?: unknown } | null)?.mcpServers;\n if (servers === undefined) return { found: true, state: 'absent' };\n if (servers === null || typeof servers !== 'object' || Array.isArray(servers)) {\n return { found: true, state: 'unreadable' };\n }\n const entry = (servers as Record<string, unknown>)[MCP_SERVER_NAME];\n if (entry === undefined) return { found: true, state: 'absent' };\n return { found: true, state: classifyMcpEntry(entry) };\n}\n\n/** Project scope is decided by the working directory as well as the flag:\n * `claude` writes `.mcp.json` beside the project it was run in. */\nasync function runClaudeMcpAdd(\n _command: string,\n opts: { scope: 'user' | 'project'; cwd: string },\n): Promise<void> {\n await exec('claude', ['mcp', 'add', MCP_SERVER_NAME, '-s', opts.scope, '--', 'tenjin', 'mcp'], {\n timeout: 20_000,\n cwd: opts.cwd,\n });\n}\n\ninterface EffectiveLimits {\n maxAutoSpend: string;\n sessionBudget: string;\n}\n\nfunction effectiveLimits(policy: SpendPolicy): EffectiveLimits {\n return {\n maxAutoSpend: toMoney(policy.maxAutoSpendAtomic.toString()).usd,\n sessionBudget:\n policy.sessionBudgetAtomic === null\n ? 'no daily ceiling'\n : toMoney(policy.sessionBudgetAtomic.toString()).usd,\n };\n}\n\n/** Only the status-line state that needs the user: one this install would not\n * touch, with the command that adds the footer beside it. */\nexport function statusLineProblems(ctx: CommandContext, result: StatusLineResult): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n if (result.warning !== undefined) {\n return [warn(`The live status line was not registered (${result.warning})`)];\n }\n if (result.state !== 'foreign') return [];\n return [\n warn('You already have a status line, so it was left exactly as it is.'),\n ' To show the live x402 footer beside it, run:',\n ' tenjin install --status-line compose',\n ...(result.compose === undefined\n ? []\n : [' or set this command yourself:', ` ${result.compose}`]),\n ];\n}\n\n/**\n * A few lines a first-time user can read at a glance: it worked, here is your\n * wallet, here is the one thing to do next. The file paths, entry counts and\n * data-handling detail stay in `--json` and the docs; the terminal only grows\n * a line when something needs the user.\n */\nfunction lines(\n ctx: CommandContext,\n s: {\n project: boolean;\n hooks: HooksResult;\n permissions: AllowRuleResult;\n statusLine: StatusLineResult;\n mcp: McpRegistration;\n wallet: WalletOutcome;\n policy: SpendPolicy;\n },\n): string[] {\n const ok = paint(ctx.io, 'green', '✓');\n const limits = effectiveLimits(s.policy);\n const daily =\n s.policy.sessionBudgetAtomic === null ? 'no daily limit' : `$${limits.sessionBudget} a day`;\n // The first line only says \"set up\" when it is: a settings file this run\n // would not write to means nothing was set up, and hooks without the MCP\n // server point at a `request` tool that is not there.\n const blocked = s.hooks.skipped !== undefined;\n const needsMcp = !blocked && !s.mcp.registered;\n const where = s.project ? ' in this project' : '';\n const fund = paint(ctx.io, 'bold', 'tenjin wallet fund');\n return [\n blocked\n ? paint(ctx.io, 'yellow', `! Tenjin could not finish setting up Claude Code${where}`)\n : needsMcp\n ? paint(ctx.io, 'yellow', '! Almost done: Claude Code needs one command')\n : `${ok} Tenjin is set up for Claude Code${where}`,\n ...walletLines(ctx, ok, s.wallet),\n ` Automatic router: up to $${limits.maxAutoSpend} per call; daily limit ${daily}`,\n ...(s.statusLine.state === 'ours' || s.statusLine.state === 'composed'\n ? [' Live status line on: each lookup names its provider while it runs']\n : []),\n ...problems(ctx, s.hooks, s.permissions, s.statusLine, s.mcp),\n '',\n blocked\n ? 'Next: fix the file above, then run tenjin install again'\n : needsMcp\n ? s.wallet.status === 'created'\n ? `Next: run the command above and ${fund}, then restart Claude Code`\n : 'Next: run the command above, then restart Claude Code'\n : s.wallet.status === 'created'\n ? `Next: ${fund}, then restart Claude Code`\n : 'Next: restart Claude Code',\n ];\n}\n\n/** \"Up to date\" only when nothing below it needs the user. */\nfunction refreshLines(ctx: CommandContext, issues: string[]): string[] {\n if (issues.length === 0) return [`${paint(ctx.io, 'green', '✓')} Tenjin is up to date`];\n return [paint(ctx.io, 'yellow', '! Tenjin is updated, but needs one fix'), ...issues];\n}\n\nfunction walletLines(ctx: CommandContext, ok: string, w: WalletOutcome): string[] {\n if (w.status === 'created') return [`${ok} Wallet created: ${w.address}`];\n if (w.status === 'existing') return [`${ok} Wallet: ${w.address}`];\n if (w.reason === 'flag') return [' No wallet yet. Create one with: tenjin wallet create'];\n return [\n paint(ctx.io, 'yellow', `! No wallet was created. ${w.warning ?? ''}`.trimEnd()),\n ` ${w.fix ?? 'Create one with: tenjin wallet create'}`,\n ];\n}\n\n/** Only what needs the user, each with the command that fixes it. */\nfunction problems(\n ctx: CommandContext,\n hooks: HooksResult,\n permissions: AllowRuleResult,\n statusLine: StatusLineResult,\n mcp: McpRegistration,\n): string[] {\n const warn = (text: string) => paint(ctx.io, 'yellow', `! ${text}`);\n const out: string[] = [];\n // The hooks and the permission rule share one settings file, so a file this\n // run would not touch is reported once, not once per writer.\n if (hooks.skipped !== undefined) {\n out.push(\n warn(\n hooks.warning ??\n `${hooks.path ?? 'Your Claude Code settings file'} was left untouched (${hooks.skipped}).`,\n ),\n );\n } else {\n if (hooks.warning !== undefined) out.push(warn(hooks.warning));\n if (permissions.warning !== undefined) out.push(warn(permissions.warning));\n }\n if (!mcp.registered) {\n // The reason stays in --json: raw exec output is noise here, the fix is not.\n out.push(warn('Could not add the request tool to Claude Code. Run:'));\n out.push(` ${mcp.command}`);\n }\n out.push(...statusLineProblems(ctx, statusLine));\n return out;\n}\n\n/**\n * THREE ANSWERS, NOT TWO. A settings file that cannot be read or parsed is not\n * a file without our entries, and collapsing the two let `refreshEveryInstall`\n * read a momentarily broken project settings file as confirmed absence and\n * strike the project off `install.routerProjects` for good: repairing the file\n * afterwards did not bring it back, so every later `tenjin update` from HOME\n * silently skipped it.\n */\ntype EntriesProbe =\n { state: 'present' } | { state: 'absent' } | { state: 'unreadable'; reason: string };\n\nasync function probeOurEntries(path: string, dataDir: string): Promise<EntriesProbe> {\n const found = await inspectHooksFile(path);\n if ('refusal' in found) {\n // `unreadable` here is the inspection's own vocabulary for \"the file exists\n // and this build could not use it\"; a file that is simply not there comes\n // back as an empty, readable inspection rather than a refusal.\n return { state: 'unreadable', reason: found.refusal.reason };\n }\n const present = Object.values(found.hooks).some((list) =>\n list.some((entry) => ownsHookEntry(entry, dataDir)),\n );\n return present ? { state: 'present' } : { state: 'absent' };\n}\n\n/** Shared with `uninstall`: the prune this module's writer already performs. */\nexport { pruneHooks };\n","import { lstatSync } from 'node:fs';\nimport { readdir, rm, rmdir } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport {\n CLI_SKILL_NAMES,\n readSkillFile,\n skillFrontmatterName,\n skillsDirsFor,\n} from './skill-wiring';\nimport { RETIRED_SKILL_NAMES, SHIPPED_SKILL_FILES } from './skills-source';\nimport { hasCode } from './errno';\n\nfunction isRealDirectory(path: string): boolean {\n try {\n return lstatSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n } catch (err) {\n // Linux reports ENOTDIR when an ancestor is a regular file. Nothing can\n // be installed below it, just as with an absent path. Do not follow symlinks.\n if (hasCode(err, 'ENOENT') || hasCode(err, 'ENOTDIR')) return false;\n throw err;\n }\n}\n\n/**\n * Remove only the files our named skill shipped (SKILL.md last, as the ownership\n * proof), then any directory they leave empty; preserve foreign skills and\n * adjacent user files.\n */\nexport async function removeOwnedSkill(\n name: string,\n skillsDir: string,\n): Promise<{ changed: boolean }> {\n if (!isRealDirectory(skillsDir)) {\n return { changed: false };\n }\n const skillDir = join(skillsDir, name);\n if (!isRealDirectory(skillDir)) {\n return { changed: false };\n }\n const path = join(skillDir, 'SKILL.md');\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return { changed: false };\n if (read.kind !== 'ok' || skillFrontmatterName(read.bytes.toString('utf8')) !== name) {\n return { changed: false }; // not ours to delete for sitting at our path\n }\n const shipped = (SHIPPED_SKILL_FILES as Record<string, readonly string[]>)[name] ?? [];\n const subdirs = new Set<string>();\n for (const rel of shipped) {\n if (rel === 'SKILL.md') continue;\n const file = join(skillDir, rel);\n // A symlinked `references/` would route the delete outside the skill.\n if (!isRealDirectory(dirname(file))) continue;\n subdirs.add(dirname(file));\n if (lstatSync(file, { throwIfNoEntry: false })?.isFile() === true) await rm(file);\n }\n await rm(path, { force: true });\n for (const dir of [...subdirs, skillDir].sort((a, b) => b.length - a.length)) {\n const rest = await readdir(dir).catch(() => null);\n if (rest !== null && rest.length === 0) await rmdir(dir).catch(() => undefined);\n }\n return { changed: true };\n}\n\n/**\n * Refresh retires obsolete skills without needing their old packaged source:\n * the retired names, and the shelf's CLI skills, whose `tenjin search` and\n * `tenjin publish` commands the router CLI does not ship.\n */\nexport async function removeRetiredSkills(home: string, project?: string): Promise<string[]> {\n const removed: string[] = [];\n const dirs = [...skillsDirsFor(home), ...(project ? skillsDirsFor(project) : [])];\n for (const dir of new Set(dirs)) {\n for (const name of [...RETIRED_SKILL_NAMES, ...CLI_SKILL_NAMES]) {\n if ((await removeOwnedSkill(name, dir)).changed) removed.push(join(dir, name));\n }\n }\n return removed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,UAAU,gBAAgB;AACnC,SAAS,eAAe;AACxB,SAAS,YAAY,QAAAA,aAAY;AACjC,SAAS,iBAAiB;;;ACJ1B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,IAAI,aAAa;AACnC,SAAS,SAAS,YAAY;AAU9B,SAAS,gBAAgB,MAAuB;AAC9C,MAAI;AACF,WAAO,UAAU,MAAM,EAAE,gBAAgB,MAAM,CAAC,GAAG,YAAY,MAAM;AAAA,EACvE,SAAS,KAAK;AAGZ,QAAI,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,SAAS,EAAG,QAAO;AAC9D,UAAM;AAAA,EACR;AACF;AAOA,eAAsB,iBACpB,MACA,WAC+B;AAC/B,MAAI,CAAC,gBAAgB,SAAS,GAAG;AAC/B,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM,WAAW,KAAK,WAAW,IAAI;AACrC,MAAI,CAAC,gBAAgB,QAAQ,GAAG;AAC9B,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM,OAAO,KAAK,UAAU,UAAU;AACtC,QAAM,OAAO,MAAM,cAAc,IAAI;AACrC,MAAI,KAAK,SAAS,SAAU,QAAO,EAAE,SAAS,MAAM;AACpD,MAAI,KAAK,SAAS,QAAQ,qBAAqB,KAAK,MAAM,SAAS,MAAM,CAAC,MAAM,MAAM;AACpF,WAAO,EAAE,SAAS,MAAM;AAAA,EAC1B;AACA,QAAM,UAAW,oBAA0D,IAA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