@herbertgao/pi-extensions 2026.9.17 → 2026.9.18

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 (266) hide show
  1. package/README.md +14 -15
  2. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +4 -1
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +4 -1
  5. package/node_modules/@herbertgao/pi-cc-extensions/package.json +75 -75
  6. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  7. package/node_modules/@herbertgao/pi-subagents/package.json +7 -7
  8. package/node_modules/@herbertgao/resume-from/package.json +4 -2
  9. package/node_modules/@herbertgao/sol-pi/package.json +6 -6
  10. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +99 -99
  11. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  12. package/node_modules/@tifan/pi-handoff/package.json +1 -1
  13. package/node_modules/@tifan/pi-handoff/src/index.ts +56 -26
  14. package/node_modules/@tifan/pi-mermaid-open/package.json +1 -1
  15. package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
  16. package/node_modules/@tifan/pi-recap/package.json +1 -1
  17. package/node_modules/@tifan/pi-rename/package.json +1 -1
  18. package/node_modules/pi-antigravity/package.json +2 -2
  19. package/node_modules/pi-lens/package.json +158 -158
  20. package/node_modules/pi-multi-account/package.json +2 -2
  21. package/node_modules/pi-typesafe/README.md +1 -1
  22. package/node_modules/pi-typesafe/dist/auth.d.ts +9 -5
  23. package/node_modules/pi-typesafe/dist/auth.js +7 -3
  24. package/node_modules/pi-typesafe/dist/backends.d.ts +33 -3
  25. package/node_modules/pi-typesafe/dist/backends.js +95 -1
  26. package/node_modules/pi-typesafe/dist/client.d.ts +5 -5
  27. package/node_modules/pi-typesafe/dist/client.js +12 -9
  28. package/node_modules/pi-typesafe/dist/credentials.d.ts +14 -8
  29. package/node_modules/pi-typesafe/dist/credentials.js +10 -7
  30. package/node_modules/pi-typesafe/dist/errors.d.ts +2 -2
  31. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  32. package/node_modules/pi-typesafe/dist/index.js +1 -1
  33. package/node_modules/pi-typesafe/dist/login.d.ts +2 -2
  34. package/node_modules/pi-typesafe/dist/login.js +2 -2
  35. package/node_modules/pi-typesafe/package.json +5 -5
  36. package/node_modules/pi-web-access/package.json +2 -2
  37. package/node_modules/remote-pi/package.json +5 -1
  38. package/package.json +16 -28
  39. package/node_modules/pi-mcp-adapter/CHANGELOG.md +0 -1013
  40. package/node_modules/pi-mcp-adapter/LICENSE +0 -21
  41. package/node_modules/pi-mcp-adapter/OAUTH.md +0 -369
  42. package/node_modules/pi-mcp-adapter/README.md +0 -1021
  43. package/node_modules/pi-mcp-adapter/abort.ts +0 -34
  44. package/node_modules/pi-mcp-adapter/agent-dir.ts +0 -68
  45. package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +0 -416
  46. package/node_modules/pi-mcp-adapter/agent-plugin-provenance.ts +0 -36
  47. package/node_modules/pi-mcp-adapter/app-bridge.bundle.js +0 -67
  48. package/node_modules/pi-mcp-adapter/banner.png +0 -0
  49. package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +0 -193
  50. package/node_modules/pi-mcp-adapter/claude-plugin-loader.ts +0 -365
  51. package/node_modules/pi-mcp-adapter/cli.js +0 -454
  52. package/node_modules/pi-mcp-adapter/commands.ts +0 -861
  53. package/node_modules/pi-mcp-adapter/config.ts +0 -1565
  54. package/node_modules/pi-mcp-adapter/consent-manager.ts +0 -95
  55. package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +0 -244
  56. package/node_modules/pi-mcp-adapter/direct-tools.ts +0 -428
  57. package/node_modules/pi-mcp-adapter/dist/abort.d.ts +0 -2
  58. package/node_modules/pi-mcp-adapter/dist/abort.js +0 -36
  59. package/node_modules/pi-mcp-adapter/dist/abort.js.map +0 -1
  60. package/node_modules/pi-mcp-adapter/dist/agent-dir.d.ts +0 -10
  61. package/node_modules/pi-mcp-adapter/dist/agent-dir.js +0 -63
  62. package/node_modules/pi-mcp-adapter/dist/agent-dir.js.map +0 -1
  63. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.d.ts +0 -8
  64. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js +0 -398
  65. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js.map +0 -1
  66. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.d.ts +0 -1
  67. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js +0 -31
  68. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js.map +0 -1
  69. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +0 -6
  70. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +0 -194
  71. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +0 -1
  72. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.d.ts +0 -9
  73. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js +0 -362
  74. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js.map +0 -1
  75. package/node_modules/pi-mcp-adapter/dist/config.d.ts +0 -134
  76. package/node_modules/pi-mcp-adapter/dist/config.js +0 -1361
  77. package/node_modules/pi-mcp-adapter/dist/config.js.map +0 -1
  78. package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +0 -18
  79. package/node_modules/pi-mcp-adapter/dist/consent-manager.js +0 -88
  80. package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +0 -1
  81. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +0 -17
  82. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +0 -316
  83. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +0 -1
  84. package/node_modules/pi-mcp-adapter/dist/errors.d.ts +0 -131
  85. package/node_modules/pi-mcp-adapter/dist/errors.js +0 -278
  86. package/node_modules/pi-mcp-adapter/dist/errors.js.map +0 -1
  87. package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +0 -8
  88. package/node_modules/pi-mcp-adapter/dist/http-ca.js +0 -88
  89. package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +0 -1
  90. package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +0 -14
  91. package/node_modules/pi-mcp-adapter/dist/jev-client.js +0 -367
  92. package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +0 -1
  93. package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +0 -77
  94. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +0 -2
  95. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +0 -1
  96. package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +0 -51
  97. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +0 -205
  98. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +0 -1
  99. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +0 -2
  100. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +0 -68
  101. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +0 -1
  102. package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +0 -56
  103. package/node_modules/pi-mcp-adapter/dist/lifecycle.js +0 -410
  104. package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +0 -1
  105. package/node_modules/pi-mcp-adapter/dist/logger.d.ts +0 -51
  106. package/node_modules/pi-mcp-adapter/dist/logger.js +0 -131
  107. package/node_modules/pi-mcp-adapter/dist/logger.js.map +0 -1
  108. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +0 -26
  109. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +0 -103
  110. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +0 -1
  111. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +0 -118
  112. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +0 -1097
  113. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +0 -1
  114. package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +0 -170
  115. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +0 -1142
  116. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +0 -1
  117. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +0 -24
  118. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +0 -203
  119. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +0 -1
  120. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +0 -53
  121. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +0 -441
  122. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +0 -1
  123. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +0 -148
  124. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +0 -689
  125. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +0 -1
  126. package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +0 -6
  127. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +0 -166
  128. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +0 -1
  129. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +0 -102
  130. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +0 -369
  131. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +0 -1
  132. package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +0 -95
  133. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +0 -242
  134. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +0 -1
  135. package/node_modules/pi-mcp-adapter/dist/metadata-cache.d.ts +0 -19
  136. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +0 -301
  137. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +0 -1
  138. package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +0 -6
  139. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +0 -505
  140. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +0 -1
  141. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.d.ts +0 -2
  142. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js +0 -144
  143. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js.map +0 -1
  144. package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +0 -10
  145. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +0 -312
  146. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +0 -1
  147. package/node_modules/pi-mcp-adapter/dist/resource-tools.d.ts +0 -1
  148. package/node_modules/pi-mcp-adapter/dist/resource-tools.js +0 -15
  149. package/node_modules/pi-mcp-adapter/dist/resource-tools.js.map +0 -1
  150. package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +0 -13
  151. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +0 -97
  152. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +0 -1
  153. package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +0 -17
  154. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +0 -203
  155. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +0 -1
  156. package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +0 -11
  157. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +0 -172
  158. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +0 -1
  159. package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +0 -157
  160. package/node_modules/pi-mcp-adapter/dist/server-manager.js +0 -1745
  161. package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +0 -1
  162. package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +0 -34
  163. package/node_modules/pi-mcp-adapter/dist/session-approvals.js +0 -140
  164. package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +0 -1
  165. package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +0 -26
  166. package/node_modules/pi-mcp-adapter/dist/session-recovery.js +0 -142
  167. package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +0 -1
  168. package/node_modules/pi-mcp-adapter/dist/state.d.ts +0 -73
  169. package/node_modules/pi-mcp-adapter/dist/state.js +0 -2
  170. package/node_modules/pi-mcp-adapter/dist/state.js.map +0 -1
  171. package/node_modules/pi-mcp-adapter/dist/types.d.ts +0 -642
  172. package/node_modules/pi-mcp-adapter/dist/types.js +0 -331
  173. package/node_modules/pi-mcp-adapter/dist/types.js.map +0 -1
  174. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.d.ts +0 -6
  175. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -37
  176. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js.map +0 -1
  177. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +0 -17
  178. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +0 -219
  179. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +0 -1
  180. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.d.ts +0 -104
  181. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js +0 -59
  182. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js.map +0 -1
  183. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.d.ts +0 -4
  184. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js +0 -27
  185. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js.map +0 -1
  186. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +0 -15
  187. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +0 -85
  188. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +0 -1
  189. package/node_modules/pi-mcp-adapter/dist/utils.d.ts +0 -41
  190. package/node_modules/pi-mcp-adapter/dist/utils.js +0 -417
  191. package/node_modules/pi-mcp-adapter/dist/utils.js.map +0 -1
  192. package/node_modules/pi-mcp-adapter/elicitation-handler.ts +0 -358
  193. package/node_modules/pi-mcp-adapter/error-signal.ts +0 -32
  194. package/node_modules/pi-mcp-adapter/errors.ts +0 -364
  195. package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +0 -85
  196. package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +0 -34
  197. package/node_modules/pi-mcp-adapter/failure-backoff.ts +0 -23
  198. package/node_modules/pi-mcp-adapter/glimpse-ui.ts +0 -80
  199. package/node_modules/pi-mcp-adapter/host-html-template.ts +0 -515
  200. package/node_modules/pi-mcp-adapter/http-ca.ts +0 -84
  201. package/node_modules/pi-mcp-adapter/index.ts +0 -2106
  202. package/node_modules/pi-mcp-adapter/init.ts +0 -721
  203. package/node_modules/pi-mcp-adapter/jev-client.ts +0 -300
  204. package/node_modules/pi-mcp-adapter/jev-contracts.ts +0 -53
  205. package/node_modules/pi-mcp-adapter/jev-key-store.ts +0 -192
  206. package/node_modules/pi-mcp-adapter/json-schema-validator.ts +0 -83
  207. package/node_modules/pi-mcp-adapter/lazy-loader.ts +0 -7
  208. package/node_modules/pi-mcp-adapter/lifecycle.ts +0 -457
  209. package/node_modules/pi-mcp-adapter/logger.ts +0 -169
  210. package/node_modules/pi-mcp-adapter/mcp-auth-fetch.ts +0 -113
  211. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +0 -1296
  212. package/node_modules/pi-mcp-adapter/mcp-auth.ts +0 -1287
  213. package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -250
  214. package/node_modules/pi-mcp-adapter/mcp-callback-server.ts +0 -534
  215. package/node_modules/pi-mcp-adapter/mcp-code.ts +0 -495
  216. package/node_modules/pi-mcp-adapter/mcp-install.ts +0 -60
  217. package/node_modules/pi-mcp-adapter/mcp-keyring-helper.cjs +0 -89
  218. package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +0 -819
  219. package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +0 -511
  220. package/node_modules/pi-mcp-adapter/mcp-panel-theme.ts +0 -104
  221. package/node_modules/pi-mcp-adapter/mcp-panel.ts +0 -1099
  222. package/node_modules/pi-mcp-adapter/mcp-probe.ts +0 -201
  223. package/node_modules/pi-mcp-adapter/mcp-references.ts +0 -373
  224. package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +0 -137
  225. package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +0 -747
  226. package/node_modules/pi-mcp-adapter/mcp-status.ts +0 -105
  227. package/node_modules/pi-mcp-adapter/mcp-tasks.ts +0 -467
  228. package/node_modules/pi-mcp-adapter/mcp-trace.ts +0 -306
  229. package/node_modules/pi-mcp-adapter/metadata-cache.ts +0 -362
  230. package/node_modules/pi-mcp-adapter/namespace-tools.ts +0 -334
  231. package/node_modules/pi-mcp-adapter/npx-resolver.ts +0 -543
  232. package/node_modules/pi-mcp-adapter/oauth-handler.ts +0 -30
  233. package/node_modules/pi-mcp-adapter/oauth.ts +0 -52
  234. package/node_modules/pi-mcp-adapter/onboarding-state.ts +0 -76
  235. package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +0 -156
  236. package/node_modules/pi-mcp-adapter/package.json +0 -219
  237. package/node_modules/pi-mcp-adapter/panel-keys.ts +0 -53
  238. package/node_modules/pi-mcp-adapter/prompts.ts +0 -385
  239. package/node_modules/pi-mcp-adapter/proxy-modes.ts +0 -1735
  240. package/node_modules/pi-mcp-adapter/request-headers-command.ts +0 -333
  241. package/node_modules/pi-mcp-adapter/resource-tools.ts +0 -17
  242. package/node_modules/pi-mcp-adapter/runtime-owner.ts +0 -106
  243. package/node_modules/pi-mcp-adapter/sampling-handler.ts +0 -261
  244. package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +0 -144
  245. package/node_modules/pi-mcp-adapter/search-ranking.ts +0 -309
  246. package/node_modules/pi-mcp-adapter/secure-keyring.ts +0 -170
  247. package/node_modules/pi-mcp-adapter/semantic-search.ts +0 -186
  248. package/node_modules/pi-mcp-adapter/server-manager.ts +0 -2088
  249. package/node_modules/pi-mcp-adapter/session-approvals.ts +0 -201
  250. package/node_modules/pi-mcp-adapter/session-recovery.ts +0 -158
  251. package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +0 -49
  252. package/node_modules/pi-mcp-adapter/state.ts +0 -71
  253. package/node_modules/pi-mcp-adapter/tool-approval.ts +0 -205
  254. package/node_modules/pi-mcp-adapter/tool-metadata.ts +0 -302
  255. package/node_modules/pi-mcp-adapter/tool-registrar.ts +0 -255
  256. package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +0 -573
  257. package/node_modules/pi-mcp-adapter/ts-shape.ts +0 -149
  258. package/node_modules/pi-mcp-adapter/types.ts +0 -1120
  259. package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +0 -40
  260. package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +0 -266
  261. package/node_modules/pi-mcp-adapter/ui-server.ts +0 -993
  262. package/node_modules/pi-mcp-adapter/ui-session.ts +0 -624
  263. package/node_modules/pi-mcp-adapter/ui-stream-types.ts +0 -89
  264. package/node_modules/pi-mcp-adapter/ui-tool-visibility.ts +0 -25
  265. package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +0 -85
  266. package/node_modules/pi-mcp-adapter/utils.ts +0 -464
@@ -1,454 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import os from "node:os";
6
- import { pathToFileURL } from "node:url";
7
- import stripJsonComments from "strip-json-comments";
8
-
9
- const HOME = os.homedir();
10
-
11
- function expandHome(input) {
12
- if (input === "~") return HOME;
13
- if (input.startsWith("~/")) return path.resolve(HOME, input.slice(2));
14
- return path.resolve(input);
15
- }
16
-
17
- function readPiConfig() {
18
- const dir = process.env.PI_PACKAGE_DIR?.trim();
19
- if (!dir) return undefined;
20
- try {
21
- return JSON.parse(fs.readFileSync(path.join(path.resolve(dir), "package.json"), "utf8")).piConfig;
22
- } catch {
23
- return undefined;
24
- }
25
- }
26
-
27
- function getConfigDirName() {
28
- const configDir = readPiConfig()?.configDir;
29
- return typeof configDir === "string" && configDir.trim() ? configDir.trim() : ".pi";
30
- }
31
-
32
- function getAgentDir() {
33
- const piConfig = readPiConfig();
34
- const appName = typeof piConfig?.name === "string" && piConfig.name.trim() ? piConfig.name.trim() : "pi";
35
- const configured = process.env[`${appName.toUpperCase()}_CODING_AGENT_DIR`]?.trim();
36
- if (configured) return expandHome(configured);
37
- return path.join(HOME, getConfigDirName(), "agent");
38
- }
39
-
40
- const AGENT_DIR = getAgentDir();
41
- const PI_CONFIG_PATH = path.join(AGENT_DIR, "mcp.json");
42
- const GENERIC_GLOBAL_CONFIG_PATH = path.join(HOME, ".config", "mcp", "mcp.json");
43
- const AGENTS_GLOBAL_CONFIG_PATH = path.join(HOME, ".agents", "mcp.json");
44
- const AGENTS_NESTED_GLOBAL_CONFIG_PATH = path.join(HOME, ".agents", "mcp", "mcp.json");
45
- const PROJECT_CONFIG_PATH = path.resolve(process.cwd(), ".mcp.json");
46
- const PROJECT_PI_CONFIG_PATH = path.resolve(process.cwd(), getConfigDirName(), "mcp.json");
47
-
48
- const IMPORT_PATHS = {
49
- cursor: [path.join(HOME, ".cursor", "mcp.json")],
50
- "claude-code": [
51
- path.join(HOME, ".claude", "mcp.json"),
52
- path.join(HOME, ".claude.json"),
53
- path.join(HOME, ".claude", "claude_desktop_config.json"),
54
- ],
55
- "claude-desktop": [path.join(HOME, "Library", "Application Support", "Claude", "claude_desktop_config.json")],
56
- codex: [
57
- path.join(HOME, ".codex", "config.toml"),
58
- path.join(HOME, ".codex", "config.json"),
59
- ],
60
- opencode: [
61
- path.join(HOME, ".config", "opencode", "opencode.json"),
62
- path.resolve(process.cwd(), "opencode.json"),
63
- ],
64
- windsurf: [path.join(HOME, ".windsurf", "mcp.json")],
65
- vscode: [path.resolve(process.cwd(), ".vscode", "mcp.json")],
66
- };
67
-
68
- function printHelp(log = console.log) {
69
- log("pi-mcp-adapter helper\n");
70
- log("Install the package with:");
71
- log(" pi install npm:pi-mcp-adapter\n");
72
- log("Then optionally run:");
73
- log(" pi-mcp-adapter init Detect host configs and scaffold Pi imports");
74
- log(" pi-mcp-adapter init --dry-run");
75
- log(" pi-mcp-adapter init --discover-host-configs Opt in to host config fallback discovery");
76
- log("");
77
- log("Bearer token storage (servers configured with auth: \"bearer\" and bearerTokenStore: true):");
78
- log(" pi-mcp-adapter token set <server> Store a token read from stdin (masked prompt or pipe; never argv)");
79
- log(" pi-mcp-adapter token status <server> Report whether a stored token matches the configured URL");
80
- log(" pi-mcp-adapter token remove <server> Remove the stored token");
81
- log("");
82
- log("Jev API key storage (SYSTEMONE_ENDPOINT selects the provider endpoint):");
83
- log(" pi-mcp-adapter key set systemone Store a key read from stdin (masked prompt or pipe; never argv)");
84
- log(" pi-mcp-adapter key status systemone Report the effective credential source without revealing it");
85
- log(" pi-mcp-adapter key remove systemone Remove the stored key");
86
- }
87
-
88
- function readJsonFile(filePath) {
89
- return JSON.parse(stripJsonComments(fs.readFileSync(filePath, "utf-8"), { trailingCommas: true }));
90
- }
91
-
92
- function loadPiConfig() {
93
- if (!fs.existsSync(PI_CONFIG_PATH)) {
94
- return { mcpServers: {} };
95
- }
96
-
97
- const raw = readJsonFile(PI_CONFIG_PATH);
98
- const mcpServers = raw.mcpServers ?? raw["mcp-servers"] ?? {};
99
- if (!mcpServers || typeof mcpServers !== "object" || Array.isArray(mcpServers)) {
100
- throw new Error(`Invalid MCP config at ${PI_CONFIG_PATH}: expected \"mcpServers\" to be an object`);
101
- }
102
-
103
- const normalized = { ...raw };
104
- delete normalized["mcp-servers"];
105
-
106
- const imports = Array.isArray(raw.imports) ? raw.imports.filter((value) => typeof value === "string") : undefined;
107
- return {
108
- ...normalized,
109
- mcpServers,
110
- imports,
111
- };
112
- }
113
-
114
- function findAvailableImports() {
115
- const found = [];
116
-
117
- for (const [kind, candidates] of Object.entries(IMPORT_PATHS)) {
118
- const existing = candidates.find((candidate) => fs.existsSync(candidate));
119
- if (existing) {
120
- found.push({ kind, path: existing });
121
- }
122
- }
123
-
124
- return found;
125
- }
126
-
127
- function printDiscovery(log, imports) {
128
- log("Config discovery:\n");
129
-
130
- const paths = [
131
- ["User-global standard MCP", GENERIC_GLOBAL_CONFIG_PATH],
132
- ["User-global .agents MCP", AGENTS_GLOBAL_CONFIG_PATH],
133
- ["User-global .agents nested MCP", AGENTS_NESTED_GLOBAL_CONFIG_PATH],
134
- ["Pi global override", PI_CONFIG_PATH],
135
- ["Project standard MCP", PROJECT_CONFIG_PATH],
136
- ["Project Pi override", PROJECT_PI_CONFIG_PATH],
137
- ];
138
-
139
- for (const [label, filePath] of paths) {
140
- const prefix = fs.existsSync(filePath) ? "✓" : "-";
141
- log(`${prefix} ${label}: ${filePath}`);
142
- }
143
-
144
- log("\nCompatibility imports:\n");
145
- if (imports.length === 0) {
146
- log("- No host-specific MCP configs detected");
147
- return;
148
- }
149
-
150
- for (const entry of imports) {
151
- log(`✓ ${entry.kind}: ${entry.path}`);
152
- }
153
- }
154
-
155
- function writePiConfig(config) {
156
- fs.mkdirSync(path.dirname(PI_CONFIG_PATH), { recursive: true });
157
- fs.writeFileSync(PI_CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
158
- }
159
-
160
- async function runInit(argv, log = console.log) {
161
- const dryRun = argv.includes("--dry-run");
162
- const discoverHostConfigs = argv.includes("--discover-host-configs");
163
- const foundImports = findAvailableImports();
164
- const existingConfig = loadPiConfig();
165
- const existingImports = new Set(existingConfig.imports ?? []);
166
- const importsToAdd = foundImports
167
- .map((entry) => entry.kind)
168
- .filter((kind) => !existingImports.has(kind));
169
-
170
- printDiscovery(log, foundImports);
171
-
172
- const discoverySettingChanged = discoverHostConfigs && existingConfig.settings?.hostConfigDiscovery !== "on";
173
- if (importsToAdd.length === 0 && !discoverySettingChanged) {
174
- log("\nNo Pi config changes needed.");
175
- log("Standard MCP configs are discovered automatically, and host-specific imports are already configured or unavailable.");
176
- return 0;
177
- }
178
-
179
- const nextConfig = {
180
- ...existingConfig,
181
- ...(discoverySettingChanged ? { settings: { ...existingConfig.settings, hostConfigDiscovery: "on" } } : {}),
182
- ...(importsToAdd.length > 0 ? { imports: [...existingImports, ...importsToAdd] } : {}),
183
- mcpServers: existingConfig.mcpServers ?? {},
184
- };
185
-
186
- if (importsToAdd.length > 0) {
187
- log(`\nDetected host configs to import into Pi: ${importsToAdd.join(", ")}`);
188
- }
189
- if (discoverySettingChanged) {
190
- log("Opting in to host-specific fallback discovery (standard and Pi-owned configs still take precedence).");
191
- }
192
-
193
- if (dryRun) {
194
- log(`Dry run: would update ${PI_CONFIG_PATH}`);
195
- return 0;
196
- }
197
-
198
- writePiConfig(nextConfig);
199
- log(`Updated ${PI_CONFIG_PATH}`);
200
- log("Pi will now keep reading standard MCP configs automatically, while these imports cover host-specific config formats.");
201
- if (discoverySettingChanged) {
202
- log("Host config discovery is explicit and does not write to or execute commands from external host files.");
203
- }
204
- return 0;
205
- }
206
-
207
- async function importTokenModules(error) {
208
- try {
209
- const [store, config, utils] = await Promise.all([
210
- import("./dist/mcp-bearer-store.js"),
211
- import("./dist/config.js"),
212
- import("./dist/utils.js"),
213
- ]);
214
- return { store, config, utils };
215
- } catch (err) {
216
- error("Unable to load token command modules.");
217
- error(`Import failed: ${err instanceof Error ? err.message : String(err)}`);
218
- return undefined;
219
- }
220
- }
221
-
222
- function readSecretFromStdin(stdin, prompt = "Enter bearer token (input hidden): ") {
223
- if (stdin.isTTY) return readSecretMasked(stdin, prompt);
224
- return new Promise((resolve, reject) => {
225
- let data = "";
226
- stdin.setEncoding("utf8");
227
- stdin.on("data", (chunk) => {
228
- data += chunk;
229
- });
230
- stdin.on("end", () => resolve(data.replace(/[\r\n]+$/, "")));
231
- stdin.on("error", reject);
232
- });
233
- }
234
-
235
- // Raw-mode masked prompt: the token never echoes to the terminal.
236
- function readSecretMasked(stdin, prompt) {
237
- return new Promise((resolve, reject) => {
238
- process.stderr.write(prompt);
239
- stdin.setRawMode(true);
240
- stdin.resume();
241
- stdin.setEncoding("utf8");
242
- let token = "";
243
- const onData = (chunk) => {
244
- for (const char of chunk) {
245
- if (char === "\u0003") {
246
- cleanup();
247
- reject(new Error("Token entry cancelled"));
248
- return;
249
- }
250
- if (char === "\r" || char === "\n") {
251
- cleanup();
252
- resolve(token);
253
- return;
254
- }
255
- if (char === "\u007f" || char === "\b") {
256
- token = token.slice(0, -1);
257
- continue;
258
- }
259
- token += char;
260
- }
261
- };
262
- const cleanup = () => {
263
- stdin.setRawMode(false);
264
- stdin.pause();
265
- stdin.off("data", onData);
266
- process.stderr.write("\n");
267
- };
268
- stdin.on("data", onData);
269
- });
270
- }
271
-
272
- async function runToken(argv, log, error, stdin) {
273
- const [action, serverName, ...extra] = argv;
274
- if (!["set", "status", "remove"].includes(action) || !serverName) {
275
- error("Usage: pi-mcp-adapter token <set|status|remove> <server>");
276
- error("`token set` reads the token from stdin only. Never pass the token as an argument.");
277
- return 1;
278
- }
279
- if (extra.length > 0) {
280
- error("Unexpected extra arguments. The token must not be passed on the command line; pipe it on stdin or use the interactive prompt.");
281
- return 1;
282
- }
283
-
284
- const modules = await importTokenModules(error);
285
- if (!modules) return 1;
286
-
287
- // Argv-derived text is sanitized before terminal output, and the resolved
288
- // URL is never printed: it can embed userinfo or interpolated secrets.
289
- const safeName = modules.utils.sanitizeTerminalText(serverName);
290
- const definition = modules.config.loadMcpConfig(undefined, process.cwd()).mcpServers[serverName];
291
- if (!definition) {
292
- error(`Server "${safeName}" not found in the effective MCP config.`);
293
- return 1;
294
- }
295
- if (definition.auth !== "bearer" || definition.bearerTokenStore !== true) {
296
- error(`Server "${safeName}" is not configured for bearerTokenStore. Set "auth": "bearer" and "bearerTokenStore": true.`);
297
- return 1;
298
- }
299
- // resolveServerUrl embeds the interpolated URL in its exceptions, so catch
300
- // and redact: the URL can carry userinfo or interpolated secrets.
301
- let serverUrl;
302
- try {
303
- serverUrl = modules.utils.resolveServerUrl(definition);
304
- } catch {
305
- error(`Server "${safeName}" has an invalid or unresolvable URL. Fix the server's url in the MCP config and retry.`);
306
- return 1;
307
- }
308
- if (!serverUrl) {
309
- error(`Server "${safeName}" has no URL configured.`);
310
- return 1;
311
- }
312
-
313
- if (action === "set") {
314
- const token = await readSecretFromStdin(stdin);
315
- if (!token) {
316
- error("No token provided on stdin.");
317
- return 1;
318
- }
319
- try {
320
- modules.store.saveBearerTokenForUrl(serverName, token, serverUrl);
321
- } catch (err) {
322
- error(modules.utils.sanitizeTerminalText(err instanceof Error ? err.message : String(err)));
323
- return 1;
324
- }
325
- log(`Bearer token stored for "${safeName}" and bound to the configured server URL.`);
326
- if (definition.bearerToken !== undefined || definition.bearerTokenEnv !== undefined) {
327
- log("Note: this server also configures bearerToken or bearerTokenEnv, which take precedence over the stored token.");
328
- }
329
- return 0;
330
- }
331
-
332
- if (action === "status") {
333
- const status = modules.store.inspectBearerTokenForUrl(serverName, serverUrl);
334
- if (status.status === "present") {
335
- log(`Bearer token is stored for "${safeName}".`);
336
- return 0;
337
- }
338
- if (status.status === "url-mismatch") {
339
- log(`Bearer token is stored for "${safeName}", but its URL does not match the current server URL. Run \`pi-mcp-adapter token set ${safeName}\` to rebind it.`);
340
- return 1;
341
- }
342
- if (status.status === "unavailable") {
343
- error(status.message);
344
- return 1;
345
- }
346
- log(`No bearer token is stored for "${safeName}".`);
347
- return 1;
348
- }
349
-
350
- try {
351
- modules.store.removeBearerToken(serverName);
352
- } catch (err) {
353
- error(modules.utils.sanitizeTerminalText(err instanceof Error ? err.message : String(err)));
354
- return 1;
355
- }
356
- log(`Bearer token removed for "${safeName}".`);
357
- return 0;
358
- }
359
-
360
- async function runKey(argv, log, error, stdin) {
361
- const [action, provider, ...extra] = argv;
362
- // `typesafe` is the pre-endpoint provider name, kept for existing scripts.
363
- if (!["set", "status", "remove"].includes(action) || (provider !== "systemone" && provider !== "typesafe")) {
364
- error("Usage: pi-mcp-adapter key <set|status|remove> systemone");
365
- error("`key set` reads the API key from stdin only. Never pass the key as an argument.");
366
- return 1;
367
- }
368
- if (extra.length > 0) {
369
- error("Unexpected extra arguments. The API key must not be passed on the command line; pipe it on stdin or use the interactive prompt.");
370
- return 1;
371
- }
372
- let store;
373
- try { store = await import("./dist/jev-key-store.js"); }
374
- catch (err) {
375
- error("Unable to load Jev key command module.");
376
- error(`Import failed: ${err instanceof Error ? err.message : String(err)}`);
377
- return 1;
378
- }
379
- const resolution = store.resolveJevEndpoint();
380
- if (resolution.status === "unavailable") {
381
- error("SYSTEMONE_ENDPOINT is set but invalid, so no key can be stored or read for it.");
382
- error(resolution.message);
383
- return 1;
384
- }
385
- const endpoint = resolution.endpoint;
386
-
387
- if (action === "status") {
388
- const status = store.resolveJevCredential(process.env, endpoint);
389
- if (status.status === "present") { log(`source=${status.source}`); log(`endpoint=${endpoint.href}`); return 0; }
390
- if (status.status === "unavailable") { error(`unavailable: ${status.message}`); return 1; }
391
- log("missing");
392
- return 1;
393
- }
394
- if (action === "set") {
395
- const apiKey = await readSecretFromStdin(stdin, `Enter Jev API key for ${endpoint.href} (input hidden): `);
396
- if (!apiKey) { error("No API key provided on stdin."); return 1; }
397
- try { store.saveJevApiKey(apiKey, endpoint); }
398
- catch (err) { error(err instanceof Error ? err.message : "Jev API key could not be stored."); return 1; }
399
- log("Jev API key stored in the OS secure credential store.");
400
- log(`endpoint=${endpoint.href}`);
401
- } else {
402
- try { store.removeJevApiKey(endpoint); }
403
- catch (err) { error(err instanceof Error ? err.message : "Jev API key could not be removed."); return 1; }
404
- log("Jev API key removed from the OS secure credential store.");
405
- }
406
- if (Object.hasOwn(process.env, "SYSTEMONE_API_KEY")) log("Note: SYSTEMONE_API_KEY is present and overrides the stored key.");
407
- else if (Object.hasOwn(process.env, "TYPESAFE_API_KEY")) log(endpoint.href === store.JEV_DEFAULT_ENDPOINT
408
- ? "Note: TYPESAFE_API_KEY is present and overrides the stored key."
409
- : `Note: TYPESAFE_API_KEY is ignored for ${endpoint.href}; it is a TypeSafe credential and is never sent there.`);
410
- return 0;
411
- }
412
-
413
- export async function main(argv = process.argv.slice(2), log = console.log, error = console.error, stdin = process.stdin) {
414
- const [command, ...rest] = argv;
415
-
416
- if (!command || command === "help" || command === "--help" || command === "-h") {
417
- printHelp(log);
418
- return 0;
419
- }
420
-
421
- if (command === "token") {
422
- return runToken(rest, log, error, stdin);
423
- }
424
-
425
- if (command === "key") {
426
- return runKey(rest, log, error, stdin);
427
- }
428
-
429
- if (command === "install") {
430
- error("The custom downloader has been retired.");
431
- error("Use `pi install npm:pi-mcp-adapter` instead, then optionally run `pi-mcp-adapter init`.");
432
- return 1;
433
- }
434
-
435
- if (command === "init") {
436
- return runInit(rest, log);
437
- }
438
-
439
- error(`Unknown command: ${command}`);
440
- printHelp(log);
441
- return 1;
442
- }
443
-
444
- const resolvedEntrypoint = process.argv[1] ? fs.realpathSync(process.argv[1]) : undefined;
445
- const isEntrypoint = resolvedEntrypoint && import.meta.url === pathToFileURL(resolvedEntrypoint).href;
446
-
447
- if (isEntrypoint) {
448
- main().then((code) => {
449
- process.exitCode = code;
450
- }).catch((err) => {
451
- console.error(`\nHelper failed: ${err instanceof Error ? err.message : String(err)}`);
452
- process.exit(1);
453
- });
454
- }