tenjin-cli 0.1.0-alpha.27 → 0.1.0-alpha.29

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.
Files changed (148) hide show
  1. package/README.md +18 -26
  2. package/dist/alive-3J3CHOQP.js +21 -0
  3. package/dist/{chunk-XVYATBKD.js → chunk-25GGN553.js} +897 -522
  4. package/dist/chunk-25GGN553.js.map +1 -0
  5. package/dist/{chunk-B2L53TMK.js → chunk-2SNUOHAT.js} +28 -23
  6. package/dist/chunk-2SNUOHAT.js.map +1 -0
  7. package/dist/{chunk-5NEHH2E5.js → chunk-3FY5HG7R.js} +86 -19
  8. package/dist/chunk-3FY5HG7R.js.map +1 -0
  9. package/dist/{chunk-YQOQ6XEI.js → chunk-4FYMDRD3.js} +51 -41
  10. package/dist/chunk-4FYMDRD3.js.map +1 -0
  11. package/dist/chunk-6W5GYG3W.js +128 -0
  12. package/dist/chunk-6W5GYG3W.js.map +1 -0
  13. package/dist/{chunk-G4AM2SOL.js → chunk-AMEUXNJT.js} +4 -8
  14. package/dist/{chunk-G4AM2SOL.js.map → chunk-AMEUXNJT.js.map} +1 -1
  15. package/dist/chunk-EWLU46J6.js +100 -0
  16. package/dist/chunk-EWLU46J6.js.map +1 -0
  17. package/dist/chunk-LRCJ2IZ5.js +115 -0
  18. package/dist/{chunk-HC3QEZKT.js.map → chunk-LRCJ2IZ5.js.map} +1 -1
  19. package/dist/{chunk-X7I343ZY.js → chunk-LX5OT4TQ.js} +3 -3
  20. package/dist/{chunk-X7I343ZY.js.map → chunk-LX5OT4TQ.js.map} +1 -1
  21. package/dist/{chunk-DATCR7AU.js → chunk-MG3G644T.js} +5 -7
  22. package/dist/{chunk-DATCR7AU.js.map → chunk-MG3G644T.js.map} +1 -1
  23. package/dist/{chunk-BOAI23CX.js → chunk-MOG7PB3A.js} +21 -15
  24. package/dist/chunk-MOG7PB3A.js.map +1 -0
  25. package/dist/{chunk-GU4GGKYP.js → chunk-MRUPDSUM.js} +14 -59
  26. package/dist/chunk-MRUPDSUM.js.map +1 -0
  27. package/dist/{chunk-AWKQSKUL.js → chunk-OOSRB3OF.js} +2 -2
  28. package/dist/{chunk-PZ5N6BAL.js → chunk-ORWL5BSN.js} +5 -4
  29. package/dist/chunk-ORWL5BSN.js.map +1 -0
  30. package/dist/chunk-P4LVLFO4.js +29 -0
  31. package/dist/chunk-P4LVLFO4.js.map +1 -0
  32. package/dist/{chunk-VXIBZ6W5.js → chunk-QTGUDCIR.js} +5 -5
  33. package/dist/{chunk-YKM2ZTA2.js → chunk-R4AO7GC2.js} +462 -105
  34. package/dist/chunk-R4AO7GC2.js.map +1 -0
  35. package/dist/{chunk-OHZYNZSD.js → chunk-RJEPZMYY.js} +12 -8
  36. package/dist/chunk-RJEPZMYY.js.map +1 -0
  37. package/dist/chunk-SBL4THYT.js +2074 -0
  38. package/dist/chunk-SBL4THYT.js.map +1 -0
  39. package/dist/{chunk-VNNXAYJE.js → chunk-SFEQGENI.js} +2 -2
  40. package/dist/{chunk-K6AXXYCG.js → chunk-SJLTEINJ.js} +10 -2
  41. package/dist/{chunk-K6AXXYCG.js.map → chunk-SJLTEINJ.js.map} +1 -1
  42. package/dist/{chunk-5FGO6TYT.js → chunk-TROZ6HL4.js} +3 -5
  43. package/dist/{chunk-5FGO6TYT.js.map → chunk-TROZ6HL4.js.map} +1 -1
  44. package/dist/{chunk-SKQQOEWH.js → chunk-USOLCBKC.js} +6 -8
  45. package/dist/{chunk-SKQQOEWH.js.map → chunk-USOLCBKC.js.map} +1 -1
  46. package/dist/{chunk-64SE3QC5.js → chunk-VKQXVCZR.js} +54 -5
  47. package/dist/chunk-VKQXVCZR.js.map +1 -0
  48. package/dist/{chunk-VIOUZW7Z.js → chunk-VVAHFCX2.js} +209 -37
  49. package/dist/chunk-VVAHFCX2.js.map +1 -0
  50. package/dist/{chunk-4L7KMA7P.js → chunk-WM7TJEBP.js} +8 -10
  51. package/dist/{chunk-4L7KMA7P.js.map → chunk-WM7TJEBP.js.map} +1 -1
  52. package/dist/{chunk-2TYQD22Q.js → chunk-XDYKZRLN.js} +23 -16
  53. package/dist/chunk-XDYKZRLN.js.map +1 -0
  54. package/dist/{chunk-LAIZ2AQA.js → chunk-XJQ6CH7X.js} +3 -2
  55. package/dist/{chunk-O7CUHHYU.js → chunk-ZQNGTLOC.js} +8 -10
  56. package/dist/{chunk-O7CUHHYU.js.map → chunk-ZQNGTLOC.js.map} +1 -1
  57. package/dist/{cli-6JNIPZQ6.js → cli-JPTDHGRX.js} +58 -52
  58. package/dist/{cli-6JNIPZQ6.js.map → cli-JPTDHGRX.js.map} +1 -1
  59. package/dist/{config-G75YT6NC.js → config-YYKDH2TH.js} +12 -15
  60. package/dist/{doctor-3GMDOW4Y.js → doctor-SSTXGCHX.js} +298 -269
  61. package/dist/doctor-SSTXGCHX.js.map +1 -0
  62. package/dist/{fund-3IPR5YRJ.js → fund-QWVWRVDK.js} +95 -43
  63. package/dist/{fund-3IPR5YRJ.js.map → fund-QWVWRVDK.js.map} +1 -1
  64. package/dist/hook-command-VWJXRT7H.js +31 -0
  65. package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
  66. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +14 -0
  67. package/dist/hosts/claude/tenjin/.mcp.json +12 -0
  68. package/dist/hosts/claude/tenjin/hooks/hooks.json +221 -0
  69. package/dist/index.js +13 -4
  70. package/dist/index.js.map +1 -1
  71. package/dist/install-2GXXD4DK.js +51 -0
  72. package/dist/{install-identity-PM4AGFFX.js → install-identity-FK3YF227.js} +7 -9
  73. package/dist/{install-wallet-6756NOB5.js → install-wallet-TC22U52X.js} +21 -17
  74. package/dist/{install-wallet-6756NOB5.js.map → install-wallet-TC22U52X.js.map} +1 -1
  75. package/dist/{mcp-33FAAZ7F.js → mcp-42H2F4NY.js} +2128 -372
  76. package/dist/mcp-42H2F4NY.js.map +1 -0
  77. package/dist/package-6DJA3Y2O.js +37 -0
  78. package/dist/{paths-MUXHUOCM.js → paths-POPTXJO6.js} +6 -2
  79. package/dist/{pay-XOYR4PCH.js → pay-LSDJBIAZ.js} +20 -18
  80. package/dist/payments-SPECLBRQ.js +105 -0
  81. package/dist/payments-SPECLBRQ.js.map +1 -0
  82. package/dist/{send-CVGNOQW3.js → send-MHAOLPK3.js} +13 -17
  83. package/dist/{send-CVGNOQW3.js.map → send-MHAOLPK3.js.map} +1 -1
  84. package/dist/status-O2RWLPS5.js +114 -0
  85. package/dist/status-O2RWLPS5.js.map +1 -0
  86. package/dist/{status-line-3IQKGRUH.js → status-line-45TVCRM3.js} +7 -9
  87. package/dist/{status-line-3IQKGRUH.js.map → status-line-45TVCRM3.js.map} +1 -1
  88. package/dist/uninstall-VOK2Z5M4.js +146 -0
  89. package/dist/uninstall-VOK2Z5M4.js.map +1 -0
  90. package/dist/update-FGP3HNLD.js +33 -0
  91. package/dist/update-FGP3HNLD.js.map +1 -0
  92. package/dist/{wallet-B3FVHNTS.js → wallet-DA7OFNEW.js} +18 -14
  93. package/dist/wallet-DA7OFNEW.js.map +1 -0
  94. package/docs/agent-permissions.md +35 -22
  95. package/docs/safety-model.md +3 -1
  96. package/package.json +2 -2
  97. package/dist/chunk-2TYQD22Q.js.map +0 -1
  98. package/dist/chunk-5NEHH2E5.js.map +0 -1
  99. package/dist/chunk-64SE3QC5.js.map +0 -1
  100. package/dist/chunk-6ZSGER3A.js +0 -52
  101. package/dist/chunk-6ZSGER3A.js.map +0 -1
  102. package/dist/chunk-B2L53TMK.js.map +0 -1
  103. package/dist/chunk-BOAI23CX.js.map +0 -1
  104. package/dist/chunk-DSNXKUXI.js +0 -172
  105. package/dist/chunk-DSNXKUXI.js.map +0 -1
  106. package/dist/chunk-GU4GGKYP.js.map +0 -1
  107. package/dist/chunk-H2L33M7F.js +0 -944
  108. package/dist/chunk-H2L33M7F.js.map +0 -1
  109. package/dist/chunk-HC3QEZKT.js +0 -87
  110. package/dist/chunk-JLEF5WHM.js +0 -132
  111. package/dist/chunk-JLEF5WHM.js.map +0 -1
  112. package/dist/chunk-MAQUL5BD.js +0 -99
  113. package/dist/chunk-MAQUL5BD.js.map +0 -1
  114. package/dist/chunk-OHZYNZSD.js.map +0 -1
  115. package/dist/chunk-PY7MQUKP.js +0 -755
  116. package/dist/chunk-PY7MQUKP.js.map +0 -1
  117. package/dist/chunk-PZ5N6BAL.js.map +0 -1
  118. package/dist/chunk-TGLKKLQG.js +0 -11
  119. package/dist/chunk-TGLKKLQG.js.map +0 -1
  120. package/dist/chunk-VIOUZW7Z.js.map +0 -1
  121. package/dist/chunk-XVYATBKD.js.map +0 -1
  122. package/dist/chunk-YKM2ZTA2.js.map +0 -1
  123. package/dist/chunk-YQOQ6XEI.js.map +0 -1
  124. package/dist/doctor-3GMDOW4Y.js.map +0 -1
  125. package/dist/hook-command-ZXX4FT4N.js +0 -32
  126. package/dist/install-6OROTYHZ.js +0 -72
  127. package/dist/mcp-33FAAZ7F.js.map +0 -1
  128. package/dist/payments-UTQDBO7H.js +0 -48
  129. package/dist/payments-UTQDBO7H.js.map +0 -1
  130. package/dist/status-NACN4DGX.js +0 -72
  131. package/dist/status-NACN4DGX.js.map +0 -1
  132. package/dist/status-line-wiring-QXBOOY2T.js +0 -31
  133. package/dist/uninstall-NYFKSYW4.js +0 -175
  134. package/dist/uninstall-NYFKSYW4.js.map +0 -1
  135. package/dist/update-RJDA5ZY3.js +0 -442
  136. package/dist/update-RJDA5ZY3.js.map +0 -1
  137. /package/dist/{config-G75YT6NC.js.map → alive-3J3CHOQP.js.map} +0 -0
  138. /package/dist/{chunk-AWKQSKUL.js.map → chunk-OOSRB3OF.js.map} +0 -0
  139. /package/dist/{chunk-VXIBZ6W5.js.map → chunk-QTGUDCIR.js.map} +0 -0
  140. /package/dist/{chunk-VNNXAYJE.js.map → chunk-SFEQGENI.js.map} +0 -0
  141. /package/dist/{chunk-LAIZ2AQA.js.map → chunk-XJQ6CH7X.js.map} +0 -0
  142. /package/dist/{hook-command-ZXX4FT4N.js.map → config-YYKDH2TH.js.map} +0 -0
  143. /package/dist/{install-6OROTYHZ.js.map → hook-command-VWJXRT7H.js.map} +0 -0
  144. /package/dist/{install-identity-PM4AGFFX.js.map → install-2GXXD4DK.js.map} +0 -0
  145. /package/dist/{paths-MUXHUOCM.js.map → install-identity-FK3YF227.js.map} +0 -0
  146. /package/dist/{pay-XOYR4PCH.js.map → package-6DJA3Y2O.js.map} +0 -0
  147. /package/dist/{status-line-wiring-QXBOOY2T.js.map → paths-POPTXJO6.js.map} +0 -0
  148. /package/dist/{wallet-B3FVHNTS.js.map → pay-LSDJBIAZ.js.map} +0 -0
@@ -1,137 +1,135 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- FileClientChannelStorage
4
- } from "./chunk-YHKXNYTB.js";
5
- import "./chunk-LFZJM56J.js";
6
2
  import {
7
3
  agentsWithoutRequestTool,
8
4
  clearRouterMemo,
9
5
  readRouterMemo
10
- } from "./chunk-BOAI23CX.js";
11
- import {
12
- ALLOW_RULE,
13
- mcpAddCommand,
14
- mcpScope,
15
- probeRouter,
16
- readMcpEntry,
17
- routerHookPlan,
18
- routerSettingsPath
19
- } from "./chunk-PY7MQUKP.js";
20
- import "./chunk-64SE3QC5.js";
6
+ } from "./chunk-MOG7PB3A.js";
21
7
  import {
22
- readMcpServers
23
- } from "./chunk-MAQUL5BD.js";
8
+ channelCredit
9
+ } from "./chunk-P4LVLFO4.js";
10
+ import "./chunk-YHKXNYTB.js";
11
+ import "./chunk-LFZJM56J.js";
24
12
  import "./chunk-EL56RW2J.js";
25
- import "./chunk-TTNESUPQ.js";
26
- import {
27
- STATUS_LINE_COMMAND,
28
- inspectStatusLine
29
- } from "./chunk-DSNXKUXI.js";
30
13
  import {
31
14
  describeWallet,
32
15
  resolveWalletProvider,
33
16
  walletFileExists
34
- } from "./chunk-O7CUHHYU.js";
35
- import "./chunk-VXIBZ6W5.js";
17
+ } from "./chunk-ZQNGTLOC.js";
18
+ import "./chunk-QTGUDCIR.js";
36
19
  import {
37
20
  readSpendSummary,
38
21
  spentOf
39
- } from "./chunk-X7I343ZY.js";
40
- import "./chunk-N35E6CM2.js";
41
- import "./chunk-JRGFKVAZ.js";
42
- import "./chunk-EGELTSPU.js";
43
- import "./chunk-KG3D7FIF.js";
44
- import "./chunk-RBJPAZFI.js";
45
- import "./chunk-BPMWXTFX.js";
46
- import "./chunk-S4SAZ7OD.js";
47
- import "./chunk-OHZYNZSD.js";
22
+ } from "./chunk-LX5OT4TQ.js";
23
+ import "./chunk-TTNESUPQ.js";
48
24
  import {
49
- onPath
50
- } from "./chunk-H2L33M7F.js";
25
+ CLAUDE_CODE_FLOOR,
26
+ claudeConfigDir,
27
+ findClaudeBinary,
28
+ folderState,
29
+ inspectLegacyInstall,
30
+ loadStep,
31
+ pluginProof,
32
+ probeRouter,
33
+ projectInstallHere,
34
+ readClaudeCode,
35
+ readMcpServers,
36
+ readPluginListing,
37
+ runClaude,
38
+ settingsInstallPaths
39
+ } from "./chunk-SBL4THYT.js";
40
+ import "./chunk-VKQXVCZR.js";
41
+ import {
42
+ isNewer
43
+ } from "./chunk-WM7TJEBP.js";
44
+ import "./chunk-25GGN553.js";
45
+ import "./chunk-AKWGE6JQ.js";
51
46
  import {
52
47
  ACCEPT_COMMAND,
48
+ OWN_LIMITS_COMMANDS,
49
+ PLUGIN_ID,
50
+ PLUGIN_SERVER,
51
+ REQUEST_TOOL,
52
+ shownLimits,
53
+ spendQuestion
54
+ } from "./chunk-EWLU46J6.js";
55
+ import "./chunk-A36LQPHV.js";
56
+ import "./chunk-P7LABKCW.js";
57
+ import {
53
58
  CHANNEL_DEPOSIT_ATOMIC,
54
59
  MIN_DEPOSIT_ATOMIC,
55
- OWN_LIMITS_COMMANDS,
56
60
  ROUTING_FEE_ATOMIC,
61
+ SUGGESTED_FUND_USD,
57
62
  feeRefusal,
58
- payerDir,
59
- shownLimits,
60
- spendQuestion,
61
63
  unpaid,
62
64
  usd
63
- } from "./chunk-GU4GGKYP.js";
64
- import "./chunk-A36LQPHV.js";
65
- import {
66
- inspectHooksFile,
67
- ownsHookEntry,
68
- pruneOurHandlers
69
- } from "./chunk-XVYATBKD.js";
70
- import "./chunk-AKWGE6JQ.js";
71
- import {
72
- MCP_SERVER_NAME,
73
- REQUEST_TOOL
74
- } from "./chunk-TGLKKLQG.js";
75
- import "./chunk-P7LABKCW.js";
65
+ } from "./chunk-MRUPDSUM.js";
76
66
  import "./chunk-MEFB5KHA.js";
77
67
  import {
78
68
  evaluateSpendPolicy
79
- } from "./chunk-B2L53TMK.js";
80
- import "./chunk-5FGO6TYT.js";
69
+ } from "./chunk-2SNUOHAT.js";
70
+ import "./chunk-TROZ6HL4.js";
71
+ import "./chunk-N35E6CM2.js";
72
+ import "./chunk-JRGFKVAZ.js";
73
+ import "./chunk-EGELTSPU.js";
74
+ import "./chunk-KG3D7FIF.js";
75
+ import "./chunk-RBJPAZFI.js";
76
+ import "./chunk-BPMWXTFX.js";
81
77
  import {
82
78
  routerSettings
83
- } from "./chunk-DATCR7AU.js";
84
- import "./chunk-HC3QEZKT.js";
79
+ } from "./chunk-MG3G644T.js";
80
+ import {
81
+ readAliveStamp
82
+ } from "./chunk-6W5GYG3W.js";
83
+ import "./chunk-S4SAZ7OD.js";
84
+ import "./chunk-RJEPZMYY.js";
85
85
  import "./chunk-2I4QTOLB.js";
86
86
  import {
87
87
  resolveContextSettings
88
- } from "./chunk-G4AM2SOL.js";
89
- import {
90
- toMoney
91
- } from "./chunk-6ZSGER3A.js";
88
+ } from "./chunk-AMEUXNJT.js";
92
89
  import {
90
+ CliError,
93
91
  loadRawConfig,
94
- readUsdcBalance
95
- } from "./chunk-VIOUZW7Z.js";
92
+ readUsdcBalance,
93
+ toMoney
94
+ } from "./chunk-VVAHFCX2.js";
95
+ import "./chunk-SJLTEINJ.js";
96
96
  import {
97
- CliError
98
- } from "./chunk-JLEF5WHM.js";
99
- import "./chunk-K6AXXYCG.js";
97
+ package_default
98
+ } from "./chunk-LRCJ2IZ5.js";
100
99
  import "./chunk-ZXTAQYNA.js";
101
100
 
102
101
  // src/router/doctor.ts
103
- import { execFile } from "node:child_process";
104
- import { readdir } from "node:fs/promises";
102
+ import { readFile } from "node:fs/promises";
105
103
  import { homedir } from "node:os";
106
104
  import { join } from "node:path";
107
- import { promisify } from "node:util";
108
- var exec = promisify(execFile);
109
105
  var NODE_FLOOR = 22;
106
+ var STAMP_FIX = "Start a new Claude Code session and run `tenjin doctor` again: `/reload-plugins` does not run the plugin's `SessionStart`, so only a new session writes the stamp. If it still warns, run `node --version` in that session's shell: Claude Code starts the plugin with the Node on its own PATH, and it must be 22 or newer. Restart Claude Code after installing or updating Node.";
110
107
  async function runRouterDoctor(ctx, deps = {}) {
111
108
  const env = deps.env ?? process.env;
109
+ const home = deps.homeDir ?? homedir();
110
+ const cwd = deps.cwd ?? process.cwd();
111
+ const project = deps.project ?? await projectInstallHere(cwd, home, env);
112
112
  const router = await routerSettings(
113
- { cwd: deps.cwd ?? process.cwd(), dataDir: ctx.dataDir },
113
+ { cwd, dataDir: ctx.dataDir },
114
114
  deps.homeDir !== void 0 ? { homeDir: deps.homeDir } : {}
115
115
  ).catch((err) => err instanceof Error ? err : new Error(String(err)));
116
116
  const settings = await resolveContextSettings(ctx);
117
- const settingsPath = routerSettingsPath({
118
- ...deps.project === true ? { project: true } : {},
119
- ...deps.homeDir !== void 0 ? { homeDir: deps.homeDir } : {},
120
- ...deps.cwd !== void 0 ? { cwd: deps.cwd } : {}
121
- });
117
+ const claude = await readClaudeCode(env, cwd, deps.findClaude ?? findClaudeBinary);
118
+ const scope = project ? "local" : "user";
119
+ const paths = settingsInstallPaths(project, env, home, cwd);
120
+ const legacy = await inspectLegacyInstall(paths.settingsPath, paths.mcpFile);
122
121
  const checks = [nodeCheck(deps.nodeVersion ?? process.version)];
123
- checks.push(await hooksCheck(settingsPath, ctx.dataDir, router));
124
- checks.push(await statusLineCheck(settingsPath));
125
- checks.push(
126
- await mcpCheck(
127
- deps,
128
- env,
129
- deps.project === true,
130
- deps.cwd ?? process.cwd(),
131
- deps.homeDir ?? homedir()
132
- )
133
- );
134
- checks.push((await readMcpServers(deps)).check);
122
+ checks.push(claudeCodeCheck(claude));
123
+ const plugin = await pluginCheck(claude, { scope, env, home, cwd, dataDir: ctx.dataDir, legacy });
124
+ checks.push(plugin.check);
125
+ if (plugin.registered && claude.binary !== null) {
126
+ checks.push(await serverCheck(claude.binary, env, cwd));
127
+ }
128
+ if (legacy.present || legacy.unreadable !== void 0) {
129
+ checks.push(await migrationCheck(legacy, claude, ctx.dataDir, env, cwd));
130
+ }
131
+ checks.push(routingCheck(router));
132
+ checks.push((await readMcpServers(deps, { settingsInstallPending: legacy.present })).check);
135
133
  const rawConfig = await loadRawConfig(ctx.dataDir);
136
134
  const unanswered = rawConfig.maxAutoSpend === void 0 ? { limits: shownLimits(rawConfig) } : null;
137
135
  checks.push(
@@ -158,10 +156,16 @@ async function runRouterDoctor(ctx, deps = {}) {
158
156
  )
159
157
  );
160
158
  }
161
- const agents = await subagentsCheck(deps.cwd ?? process.cwd(), deps.homeDir ?? homedir());
159
+ const agents = await subagentsCheck(cwd, home);
162
160
  if (agents !== null) checks.push(agents);
163
161
  const failure = checks.find((c) => c.status === "fail" && c.required);
164
- const data = { checks, dataDir: ctx.dataDir, baseUrl: settings.baseUrl, settingsPath };
162
+ const data = {
163
+ checks,
164
+ dataDir: ctx.dataDir,
165
+ baseUrl: settings.baseUrl,
166
+ scope,
167
+ settingsPath: paths.settingsPath
168
+ };
165
169
  if (failure !== void 0) {
166
170
  throw new CliError("REFUSED", failure.detail, {
167
171
  ...failure.fix !== void 0 ? { fix: failure.fix } : {},
@@ -190,7 +194,7 @@ function withBackoff(check, memo, now) {
190
194
  };
191
195
  }
192
196
  async function subagentsCheck(cwd, homeDir) {
193
- const excluded = await agentsWithoutRequestTool({ cwd, homeDir });
197
+ const excluded = await agentsWithoutRequestTool({ cwd, homeDir }, REQUEST_TOOL);
194
198
  if (excluded.length === 0) return null;
195
199
  return {
196
200
  name: "subagents",
@@ -209,204 +213,242 @@ function nodeCheck(version) {
209
213
  fix: `Install Node ${NODE_FLOOR} or newer, then re-run \`tenjin doctor\`.`
210
214
  };
211
215
  }
212
- async function statusLineCheck(path) {
213
- const found = await inspectStatusLine(path);
214
- const name = "status line";
215
- if (found.warning !== void 0) {
216
- return { name, status: "warn", required: false, detail: found.warning };
217
- }
218
- switch (found.state) {
219
- case "ours":
220
- return { name, status: "ok", required: false, detail: `\`${STATUS_LINE_COMMAND}\`` };
221
- case "composed":
222
- return {
223
- name,
224
- status: "ok",
225
- required: false,
226
- detail: "yours, with the x402 footer appended"
227
- };
228
- case "foreign":
229
- return {
230
- name,
231
- status: "warn",
232
- required: false,
233
- detail: "yours is registered and was left alone, so there is no live x402 footer",
234
- fix: "Run `tenjin install --status-line compose` to show both."
235
- };
236
- default:
237
- return {
238
- name,
239
- status: "warn",
240
- required: false,
241
- detail: "not registered, so lookups run without the live footer",
242
- fix: "Run `tenjin install` to register it."
243
- };
216
+ function claudeCodeCheck(claude) {
217
+ const name = "claude code";
218
+ if (claude.binary === null) {
219
+ return {
220
+ name,
221
+ status: "warn",
222
+ required: false,
223
+ detail: "no claude binary on PATH or in CLAUDE_CODE_EXECPATH, so the plugin was checked from its folder only",
224
+ fix: "Run `tenjin doctor` from a Claude Code session, where CLAUDE_CODE_EXECPATH names the binary."
225
+ };
244
226
  }
245
- }
246
- async function hooksCheck(path, dataDir, router) {
247
- const found = await inspectHooksFile(path);
248
- if ("refusal" in found) {
227
+ if (claude.version === null) {
249
228
  return {
250
- name: "hooks",
251
- status: "fail",
252
- required: true,
253
- detail: found.refusal.message,
254
- fix: "Fix the reported file, then run `tenjin install`."
229
+ name,
230
+ status: "warn",
231
+ required: false,
232
+ detail: `${claude.binary.path} did not report a version`
255
233
  };
256
234
  }
257
- const events = Object.entries(found.hooks).filter(([, list]) => list.some((entry) => ownsHookEntry(entry, dataDir))).map(([event]) => event);
258
- const allow = allowRules(found.settings);
259
- if (events.length === 0) {
235
+ if (!claude.meetsFloor) {
260
236
  return {
261
- name: "hooks",
237
+ name,
262
238
  status: "fail",
263
239
  required: true,
264
- detail: `no Tenjin hook entries in ${path}`,
265
- fix: "Run `tenjin install`, then restart Claude Code."
240
+ detail: `Claude Code ${claude.version} is older than ${CLAUDE_CODE_FLOOR}, which the Tenjin plugin needs`,
241
+ ...claude.fix !== void 0 ? { fix: claude.fix } : {}
266
242
  };
267
243
  }
268
- if (router instanceof Error) {
269
- return {
270
- name: "hooks",
244
+ return {
245
+ name,
246
+ status: "ok",
247
+ required: true,
248
+ detail: `${claude.version}${claude.binary.source === "execpath" ? " (from CLAUDE_CODE_EXECPATH)" : ""}`
249
+ };
250
+ }
251
+ async function pluginCheck(claude, c) {
252
+ const name = "plugin";
253
+ const missing = (detail) => ({
254
+ registered: false,
255
+ check: c.legacy.present ? {
256
+ name,
271
257
  status: "warn",
272
258
  required: false,
273
- detail: `${events.join(" and ")} registered, but the router is off here: ${router.message}`,
274
- fix: "Fix or delete that file."
259
+ detail: `${detail}; the settings install of an earlier release still routes here`,
260
+ fix: claude.meetsFloor ? `Run \`tenjin install${c.scope === "local" ? " --project" : ""}\` to move this machine to the plugin.` : `Run \`claude update\`, then \`tenjin install${c.scope === "local" ? " --project" : ""}\` to move this machine to the plugin.`
261
+ } : {
262
+ name,
263
+ status: "fail",
264
+ required: true,
265
+ detail,
266
+ fix: `Run \`tenjin install${c.scope === "local" ? " --project" : ""}\`.`
267
+ }
268
+ });
269
+ if (claude.binary !== null) {
270
+ const listing = await readPluginListing(claude.binary, c.env, c.cwd);
271
+ if (!listing.read) {
272
+ return {
273
+ registered: false,
274
+ check: {
275
+ name,
276
+ status: "warn",
277
+ required: false,
278
+ detail: "Claude Code's plugin list could not be read, so the plugin was not checked",
279
+ fix: "Run `tenjin doctor` again in a moment."
280
+ }
281
+ };
282
+ }
283
+ if (listing.id === null) return missing(`${PLUGIN_ID} is not installed in Claude Code`);
284
+ if (!listing.enabled) {
285
+ return {
286
+ registered: false,
287
+ check: {
288
+ name,
289
+ status: "fail",
290
+ required: true,
291
+ detail: `${listing.id} is installed but disabled, so no lookup is routed`,
292
+ fix: `Run \`claude plugin enable ${listing.id}\`, then ${loadStep(c.legacy.present)}.`
293
+ }
294
+ };
295
+ }
296
+ if (listing.version !== package_default.version) {
297
+ return {
298
+ registered: true,
299
+ check: {
300
+ name,
301
+ status: "warn",
302
+ required: false,
303
+ detail: `${listing.id} is enabled at ${listing.version ?? "an unknown version"}, and this CLI is ${package_default.version}`,
304
+ fix: "Run `tenjin install --refresh` to register this version."
305
+ }
306
+ };
307
+ }
308
+ const stamp = await readAliveStamp(c.dataDir);
309
+ if (stamp === null || isNewer(package_default.version, stamp.version)) {
310
+ return {
311
+ registered: true,
312
+ check: {
313
+ name,
314
+ status: "warn",
315
+ required: false,
316
+ detail: `${listing.id} ${package_default.version} is enabled, and no session has started it at this version${stamp !== null ? ` (last ${stamp.version}, at ${stamp.at})` : ""}`,
317
+ fix: STAMP_FIX
318
+ }
319
+ };
320
+ }
321
+ return {
322
+ registered: true,
323
+ check: { name, status: "ok", required: true, detail: `${listing.id} ${package_default.version} enabled` }
275
324
  };
276
325
  }
277
- if (!router.enabled.value) {
278
- const file = router.enabled.path ?? "the config";
326
+ const folder = await folderState(c.scope, c.env, c.home, c.cwd);
327
+ if (folder.state === "foreign") {
279
328
  return {
280
- name: "hooks",
281
- status: "warn",
282
- required: false,
283
- detail: `${events.join(" and ")} registered, but router.enabled is false in ${file}, so nothing is routed from this directory`,
284
- fix: router.enabled.source === "file" ? "Run `tenjin config set router.enabled true` to route again." : `Remove router.enabled from ${file} to route here again.`
329
+ registered: false,
330
+ check: {
331
+ name,
332
+ status: "fail",
333
+ required: true,
334
+ detail: `${folder.path} is there and is not a folder this CLI wrote, so the plugin cannot be written`,
335
+ fix: `Move ${folder.path} aside, then run \`tenjin install\` again.`
336
+ }
285
337
  };
286
338
  }
287
- if (!allow.includes(ALLOW_RULE)) {
339
+ if (folder.state === "ours") {
340
+ const stamp = await readAliveStamp(c.dataDir);
288
341
  return {
289
- name: "hooks",
290
- status: "warn",
291
- required: false,
292
- detail: `${events.join(" and ")} registered, but ${ALLOW_RULE} is not allowed, so every lookup asks`,
293
- fix: "Run `tenjin install` to write the permission rule."
342
+ registered: true,
343
+ check: stamp === null ? {
344
+ name,
345
+ status: "warn",
346
+ required: false,
347
+ detail: `the plugin folder is at ${folder.path} and has not loaded in a session yet`,
348
+ fix: `To load it, ${loadStep(c.legacy.present)}.`
349
+ } : {
350
+ name,
351
+ status: "ok",
352
+ required: true,
353
+ detail: `the plugin folder at ${folder.path} loaded, last at ${stamp.at}`
354
+ }
294
355
  };
295
356
  }
296
- const drift = planDrift(found.hooks, dataDir);
297
- if (drift.missing.length > 0 || drift.stale.length > 0) {
298
- const parts = [
299
- ...drift.missing.length > 0 ? [`missing ${drift.missing.join(", ")}`] : [],
300
- ...drift.stale.length > 0 ? [`stale ${drift.stale.join(", ")}`] : []
301
- ];
357
+ if (await listedInClaudeFiles(c.env, c.home)) {
302
358
  return {
303
- name: "hooks",
304
- status: "warn",
305
- required: false,
306
- detail: `${events.join(" and ")} registered, but not as this build writes them: ${parts.join("; ")}`,
307
- fix: "Run `tenjin install --refresh`."
359
+ registered: true,
360
+ check: {
361
+ name,
362
+ status: "warn",
363
+ required: false,
364
+ detail: `${PLUGIN_ID} is registered, and there is no claude binary here to check it`,
365
+ fix: "Run `tenjin doctor` from a Claude Code session to check it."
366
+ }
308
367
  };
309
368
  }
310
- return {
311
- name: "hooks",
312
- status: "ok",
313
- required: true,
314
- detail: `${events.join(" and ")} registered, ${ALLOW_RULE} allowed`
315
- };
369
+ return missing(`${PLUGIN_ID} is not registered`);
316
370
  }
317
- function entryLabel(event, matcher, handler) {
318
- const h = handler ?? {};
319
- const runs = h.type === "mcp_tool" ? `${String(h.server)} ${String(h.tool)} ${String(h.input?.kind)}` : typeof h.command === "string" ? h.command : typeof h.url === "string" ? h.url : "?";
320
- return `${event}${typeof matcher === "string" ? ` ${matcher}` : ""} \u2192 ${runs}`;
371
+ async function listedInClaudeFiles(env, home) {
372
+ try {
373
+ const raw = await readFile(
374
+ join(claudeConfigDir(env, home), "plugins", "installed_plugins.json"),
375
+ "utf8"
376
+ );
377
+ const plugins = JSON.parse(raw).plugins;
378
+ return plugins !== null && typeof plugins === "object" && PLUGIN_ID in plugins;
379
+ } catch {
380
+ return false;
381
+ }
321
382
  }
322
- function planDrift(hooks, dataDir) {
323
- const planned = routerHookPlan().map(
324
- (entry) => entryLabel(entry.event, entry.matcher, entry.hooks[0])
325
- );
326
- const present = [];
327
- for (const [event, list] of Object.entries(hooks)) {
328
- for (const entry of list) {
329
- if (!ownsHookEntry(entry, dataDir)) continue;
330
- const { matcher, hooks: handlers } = entry;
331
- const kept = pruneOurHandlers(entry, dataDir);
332
- for (const handler of handlers.filter((h) => kept === null || !kept.hooks.includes(h))) {
333
- present.push(entryLabel(event, matcher, handler));
334
- }
335
- }
383
+ async function serverCheck(binary, env, cwd) {
384
+ const name = "router server";
385
+ const run = await runClaude(binary, ["mcp", "get", PLUGIN_SERVER], {
386
+ env,
387
+ cwd,
388
+ timeoutMs: 45e3
389
+ });
390
+ const status = /Status:\s*(.+)/.exec(run.stdout)?.[1]?.trim();
391
+ if (run.code === 0 && status !== void 0 && /connected/i.test(status) && !/fail/i.test(status)) {
392
+ return { name, status: "ok", required: true, detail: `${PLUGIN_SERVER} connected` };
336
393
  }
337
394
  return {
338
- missing: planned.filter((label) => !present.includes(label)),
339
- stale: present.filter((label) => !planned.includes(label))
395
+ name,
396
+ status: "fail",
397
+ required: true,
398
+ detail: `${PLUGIN_SERVER} did not connect${status !== void 0 ? `: ${status.slice(0, 200)}` : ""}`,
399
+ fix: "Restart Claude Code (quit it from the tray) or sign out and in: the plugin starts the CLI with `node` from the PATH Claude Code started with, so a Claude Code opened before Node was installed cannot find it."
340
400
  };
341
401
  }
342
- function allowRules(settings) {
343
- const permissions = settings.permissions;
344
- if (permissions === null || typeof permissions !== "object" || Array.isArray(permissions)) {
345
- return [];
402
+ async function migrationCheck(legacy, claude, dataDir, env, cwd) {
403
+ const name = "settings install";
404
+ if (legacy.unreadable !== void 0) {
405
+ return { name, status: "warn", required: false, detail: legacy.unreadable };
346
406
  }
347
- const allow = permissions.allow;
348
- return Array.isArray(allow) ? allow.filter((r) => typeof r === "string") : [];
407
+ const parts = [
408
+ ...legacy.events.length > 0 ? [`hook entries (${legacy.events.join(", ")})`] : [],
409
+ ...legacy.allowRule || legacy.denyRule ? ["permission rules"] : [],
410
+ ...legacy.statusLine === "ours" || legacy.statusLine === "composed" ? ["a status line"] : [],
411
+ ...legacy.mcp === "ok" ? ["the x402 MCP server"] : []
412
+ ];
413
+ const found = `${parts.join(", ")} from an earlier release in ${legacy.settingsPath}`;
414
+ const lookalikes = legacy.lookalikes.length > 0 ? `; not Tenjin's and left alone: ${legacy.lookalikes.join(", ")}` : "";
415
+ const proof = await pluginProof(claude, dataDir, env, cwd);
416
+ return proof.proven ? {
417
+ name,
418
+ status: "warn",
419
+ required: false,
420
+ detail: `${found}, ready to remove: the plugin has loaded here${lookalikes}`,
421
+ fix: "Run `tenjin install --refresh` to remove it."
422
+ } : {
423
+ name,
424
+ status: "warn",
425
+ required: false,
426
+ detail: `${found}, kept until the plugin loads: ${proof.reason}${lookalikes}`,
427
+ fix: claude.meetsFloor ? `To load the plugin, ${loadStep(true)}; the next \`tenjin install\` or \`tenjin update\` then removes the old entries.` : "Run `claude update`, then `tenjin install`: until then the old entries keep routing."
428
+ };
349
429
  }
350
- async function mcpCheck(deps, env, project, cwd, home) {
351
- const scope = mcpScope(project);
352
- const add = mcpAddCommand(project);
353
- const where = scope === "project" ? "this project's .mcp.json" : "~/.claude.json";
354
- const { found, state } = await (deps.readMcpEntry ?? readMcpEntry)(scope, cwd, home);
355
- if (state === "ok") {
356
- return {
357
- name: "mcp",
358
- status: "ok",
359
- required: true,
360
- detail: `${MCP_SERVER_NAME} registered (${scope} scope), running \`tenjin mcp\``
361
- };
362
- }
363
- if (state === "wrong-command") {
430
+ function routingCheck(router) {
431
+ const name = "routing";
432
+ if (router instanceof Error) {
364
433
  return {
365
- name: "mcp",
366
- status: "fail",
367
- required: true,
368
- detail: `${MCP_SERVER_NAME} registered but not \`tenjin mcp\`: the entry in ${where} launches something else, so the request tool is not there`,
369
- fix: `Remove it and re-run \`tenjin install\`${project ? " --project" : ""}, or: ${add}`
434
+ name,
435
+ status: "warn",
436
+ required: false,
437
+ detail: `the router is off here: ${router.message}`,
438
+ fix: "Fix or delete that file."
370
439
  };
371
440
  }
372
- if (state === "unreadable") {
441
+ if (!router.enabled.value) {
442
+ const file = router.enabled.path ?? "the config";
373
443
  return {
374
- name: "mcp",
375
- status: "fail",
376
- required: true,
377
- detail: `${where} could not be read, so whether ${MCP_SERVER_NAME} is registered is unknown`,
378
- fix: `Fix the JSON in ${where}, then re-run \`tenjin install\`${project ? " --project" : ""}.`
444
+ name,
445
+ status: "warn",
446
+ required: false,
447
+ detail: `router.enabled is false in ${file}, so nothing is routed from this directory`,
448
+ fix: router.enabled.source === "file" ? "Run `tenjin config set router.enabled true` to route again." : `Remove router.enabled from ${file} to route here again.`
379
449
  };
380
450
  }
381
- if (scope === "user") {
382
- const which = deps.which ?? ((bin) => onPath(bin, env));
383
- if (which("claude")) {
384
- const seen = await (deps.readMcp ?? claudeHasServer)({ scope, cwd }).catch(() => false);
385
- if (seen) {
386
- return {
387
- name: "mcp",
388
- status: "warn",
389
- required: false,
390
- detail: `${MCP_SERVER_NAME} is registered somewhere this check cannot read, so what it launches was not verified`,
391
- fix: `Re-run \`tenjin install\` to write a registration this build can check, or: ${add}`
392
- };
393
- }
394
- }
395
- }
396
- return {
397
- name: "mcp",
398
- status: "fail",
399
- required: true,
400
- detail: found ? `${MCP_SERVER_NAME} is not in ${where}, so there is no request tool` : `${where} does not exist, so ${MCP_SERVER_NAME} is not registered`,
401
- fix: `Run \`tenjin install\`${project ? " --project" : ""}, or: ${add}`
402
- };
403
- }
404
- async function claudeHasServer(opts) {
405
- const { stdout } = await exec("claude", ["mcp", "get", MCP_SERVER_NAME], {
406
- timeout: 15e3,
407
- cwd: opts.cwd
408
- });
409
- return stdout.includes(MCP_SERVER_NAME) && !/no mcp server/i.test(stdout);
451
+ return { name, status: "ok", required: false, detail: "on" };
410
452
  }
411
453
  async function routingFeeCheck(ctx, settings, fetchImpl, unanswered) {
412
454
  let host;
@@ -451,7 +493,7 @@ function routingFeeRow(why, host, unanswered) {
451
493
  };
452
494
  }
453
495
  const fixes = {
454
- no_wallet: "Run `tenjin wallet create`, then `tenjin wallet fund 0.25`.",
496
+ no_wallet: `Run \`tenjin wallet create\`, then \`tenjin wallet fund ${SUGGESTED_FUND_USD}\`.`,
455
497
  limit_below_deposit: `Raise it with \`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\`.`,
456
498
  budget_reached: "Room comes back as the rolling day passes, or raise it with `tenjin config set sessionBudget <usd>`.",
457
499
  not_allowlisted: `Add ${host} to allowlistCreators, or clear the allowlist.`
@@ -493,19 +535,6 @@ async function routingFeeBlock(input) {
493
535
  });
494
536
  return balance !== null && balance < deposit ? "wallet_low" : null;
495
537
  }
496
- async function channelCredit(dataDir, address) {
497
- const dir = payerDir(dataDir, address);
498
- const storage = new FileClientChannelStorage({ directory: dir });
499
- let best = 0n;
500
- for (const name of await readdir(join(dir, "client")).catch(() => [])) {
501
- const id = /^(0x[0-9a-f]{64})\.json$/.exec(name)?.[1];
502
- const channel = id === void 0 ? void 0 : await storage.get(id).catch(() => void 0);
503
- if (channel === void 0) continue;
504
- const credit = BigInt(channel.balance ?? "0") - BigInt(channel.chargedCumulativeAmount ?? "0");
505
- if (credit > best) best = credit;
506
- }
507
- return best;
508
- }
509
538
  function experimentalCheck(bazaar) {
510
539
  return {
511
540
  name: "experimental",
@@ -530,7 +559,7 @@ function spendCheck(maxAutoSpendAtomic, sessionBudgetAtomic, unanswered) {
530
559
  status: "warn",
531
560
  required: false,
532
561
  detail: `the spend limits are not answered yet, so automatic payments are off and every lookup needs approval. Ask the user: ${spendQuestion(unanswered.limits)}`,
533
- fix: `Answer the spend question: for a yes, run \`${ACCEPT_COMMAND}\`; for other amounts, ${OWN_LIMITS_COMMANDS}; or run \`tenjin install\` in a terminal to choose.`
562
+ fix: `Answer the spend question: for a yes, run \`${ACCEPT_COMMAND}\`; for other amounts, ${OWN_LIMITS_COMMANDS}.`
534
563
  };
535
564
  }
536
565
  if (maxAutoSpendAtomic === 0n) {
@@ -559,7 +588,7 @@ async function walletCheck(ctx) {
559
588
  status: "fail",
560
589
  required: true,
561
590
  detail: "no wallet on this machine, so nothing can pay",
562
- fix: "Run `tenjin wallet create`, then `tenjin wallet fund`."
591
+ fix: `Run \`tenjin wallet create\`, then \`tenjin wallet fund ${SUGGESTED_FUND_USD}\`.`
563
592
  }
564
593
  ];
565
594
  }
@@ -584,4 +613,4 @@ export {
584
613
  routingFeeRow,
585
614
  runRouterDoctor
586
615
  };
587
- //# sourceMappingURL=doctor-3GMDOW4Y.js.map
616
+ //# sourceMappingURL=doctor-SSTXGCHX.js.map