gsd-pi 2.70.1-dev.bef631a → 2.70.1-dev.ec24142
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/dist/resources/extensions/claude-code-cli/stream-adapter.js +127 -30
- package/dist/resources/extensions/get-secrets-from-user.js +17 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +9 -9
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +9 -9
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/env-writer.d.ts +39 -0
- package/packages/mcp-server/dist/env-writer.d.ts.map +1 -0
- package/packages/mcp-server/dist/env-writer.js +158 -0
- package/packages/mcp-server/dist/env-writer.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +11 -2
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +102 -2
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/src/env-writer.test.ts +280 -0
- package/packages/mcp-server/src/env-writer.ts +183 -0
- package/packages/mcp-server/src/secure-env-collect.test.ts +265 -0
- package/packages/mcp-server/src/server.ts +137 -3
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +187 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +78 -21
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +220 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +2 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +102 -27
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +1 -1
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +1 -1
- package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +1 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js +9 -0
- package/packages/pi-tui/dist/components/__tests__/input.test.js.map +1 -1
- package/packages/pi-tui/dist/components/input.d.ts +2 -0
- package/packages/pi-tui/dist/components/input.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/input.js +7 -4
- package/packages/pi-tui/dist/components/input.js.map +1 -1
- package/packages/pi-tui/src/components/__tests__/input.test.ts +11 -0
- package/packages/pi-tui/src/components/input.ts +7 -4
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +164 -31
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +112 -0
- package/src/resources/extensions/get-secrets-from-user.ts +24 -1
- package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +45 -0
- /package/dist/web/standalone/.next/static/{UlX0WGGZ8aBPN0uSZ5Ki4 → 20e8bFnNjxQJflHNodEve}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{UlX0WGGZ8aBPN0uSZ5Ki4 → 20e8bFnNjxQJflHNodEve}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-b868033a5834586d.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-42fdce068d44fa4f.js" async=""></script><script src="/_next/static/chunks/main-app-fdab67f7802d7832.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-b868033a5834586d.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"
|
|
1
|
+
<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-b868033a5834586d.js"/><script src="/_next/static/chunks/4bd1b696-e356ca5ba0218e27.js" async=""></script><script src="/_next/static/chunks/3794-42fdce068d44fa4f.js" async=""></script><script src="/_next/static/chunks/main-app-fdab67f7802d7832.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-b868033a5834586d.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[90484,[],\"ViewportBoundary\"]\na:I[90484,[],\"MetadataBoundary\"]\nc:I[27123,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"20e8bFnNjxQJflHNodEve\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"node":{},"edge":{},"encryptionKey":"
|
|
1
|
+
{"node":{},"edge":{},"encryptionKey":"xVFGnVMH2018ePCbPzJUcwNSBeghR7SjMr02LNiY1A8="}
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check which keys already exist in a .env file or process.env.
|
|
3
|
+
* Returns the subset of `keys` that are already set.
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkExistingEnvKeys(keys: string[], envFilePath: string): Promise<string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Detect the write destination based on project files in basePath.
|
|
8
|
+
* Priority: vercel.json → convex/ dir → fallback "dotenv".
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectDestination(basePath: string): "dotenv" | "vercel" | "convex";
|
|
11
|
+
/**
|
|
12
|
+
* Write a single key=value pair to a .env file.
|
|
13
|
+
* Updates existing keys in-place, appends new ones at the end.
|
|
14
|
+
*/
|
|
15
|
+
export declare function writeEnvKey(filePath: string, key: string, value: string): Promise<void>;
|
|
16
|
+
export declare function isSafeEnvVarKey(key: string): boolean;
|
|
17
|
+
export declare function isSupportedDeploymentEnvironment(env: string): boolean;
|
|
18
|
+
export declare function shellEscapeSingle(value: string): string;
|
|
19
|
+
interface ApplyResult {
|
|
20
|
+
applied: string[];
|
|
21
|
+
errors: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Apply collected secrets to the target destination.
|
|
25
|
+
* Dotenv writes are handled directly; vercel/convex shell out via execFn.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applySecrets(provided: Array<{
|
|
28
|
+
key: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}>, destination: "dotenv" | "vercel" | "convex", opts: {
|
|
31
|
+
envFilePath: string;
|
|
32
|
+
environment?: string;
|
|
33
|
+
execFn?: (cmd: string, args: string[]) => Promise<{
|
|
34
|
+
code: number;
|
|
35
|
+
stderr: string;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<ApplyResult>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=env-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-writer.d.ts","sourceRoot":"","sources":["../src/env-writer.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBjG;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAalF;AAMD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB7F;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErE;AAMD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAMD,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,WAAW,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EAC3C,IAAI,EAAE;IACJ,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrF,GACA,OAAO,CAAC,WAAW,CAAC,CAkDtB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// @gsd-build/mcp-server — Environment variable write utilities
|
|
2
|
+
// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
|
|
3
|
+
//
|
|
4
|
+
// Shared helpers for writing env vars to .env files, detecting project
|
|
5
|
+
// destinations, and checking existing keys. Used by secure_env_collect
|
|
6
|
+
// MCP tool. No TUI dependencies — pure filesystem + process.env operations.
|
|
7
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
8
|
+
import { existsSync, statSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// checkExistingEnvKeys
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Check which keys already exist in a .env file or process.env.
|
|
15
|
+
* Returns the subset of `keys` that are already set.
|
|
16
|
+
*/
|
|
17
|
+
export async function checkExistingEnvKeys(keys, envFilePath) {
|
|
18
|
+
let fileContent = "";
|
|
19
|
+
try {
|
|
20
|
+
fileContent = await readFile(envFilePath, "utf8");
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// ENOENT or other read error — proceed with empty content
|
|
24
|
+
}
|
|
25
|
+
const existing = [];
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
|
+
const regex = new RegExp(`^${escaped}\\s*=`, "m");
|
|
29
|
+
if (regex.test(fileContent) || key in process.env) {
|
|
30
|
+
existing.push(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// detectDestination
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/**
|
|
39
|
+
* Detect the write destination based on project files in basePath.
|
|
40
|
+
* Priority: vercel.json → convex/ dir → fallback "dotenv".
|
|
41
|
+
*/
|
|
42
|
+
export function detectDestination(basePath) {
|
|
43
|
+
if (existsSync(resolve(basePath, "vercel.json"))) {
|
|
44
|
+
return "vercel";
|
|
45
|
+
}
|
|
46
|
+
const convexPath = resolve(basePath, "convex");
|
|
47
|
+
try {
|
|
48
|
+
if (existsSync(convexPath) && statSync(convexPath).isDirectory()) {
|
|
49
|
+
return "convex";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// stat error — treat as not found
|
|
54
|
+
}
|
|
55
|
+
return "dotenv";
|
|
56
|
+
}
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// writeEnvKey
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
/**
|
|
61
|
+
* Write a single key=value pair to a .env file.
|
|
62
|
+
* Updates existing keys in-place, appends new ones at the end.
|
|
63
|
+
*/
|
|
64
|
+
export async function writeEnvKey(filePath, key, value) {
|
|
65
|
+
if (typeof value !== "string") {
|
|
66
|
+
throw new TypeError(`writeEnvKey expects a string value for key "${key}", got ${typeof value}`);
|
|
67
|
+
}
|
|
68
|
+
let content = "";
|
|
69
|
+
try {
|
|
70
|
+
content = await readFile(filePath, "utf8");
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
content = "";
|
|
74
|
+
}
|
|
75
|
+
const escaped = value.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "");
|
|
76
|
+
const line = `${key}=${escaped}`;
|
|
77
|
+
const regex = new RegExp(`^${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*=.*$`, "m");
|
|
78
|
+
if (regex.test(content)) {
|
|
79
|
+
content = content.replace(regex, line);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (content.length > 0 && !content.endsWith("\n"))
|
|
83
|
+
content += "\n";
|
|
84
|
+
content += `${line}\n`;
|
|
85
|
+
}
|
|
86
|
+
await writeFile(filePath, content, "utf8");
|
|
87
|
+
}
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Validation helpers
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
export function isSafeEnvVarKey(key) {
|
|
92
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
|
|
93
|
+
}
|
|
94
|
+
export function isSupportedDeploymentEnvironment(env) {
|
|
95
|
+
return env === "development" || env === "preview" || env === "production";
|
|
96
|
+
}
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// Shell helpers (for vercel/convex CLI)
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
export function shellEscapeSingle(value) {
|
|
101
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Apply collected secrets to the target destination.
|
|
105
|
+
* Dotenv writes are handled directly; vercel/convex shell out via execFn.
|
|
106
|
+
*/
|
|
107
|
+
export async function applySecrets(provided, destination, opts) {
|
|
108
|
+
const applied = [];
|
|
109
|
+
const errors = [];
|
|
110
|
+
if (destination === "dotenv") {
|
|
111
|
+
for (const { key, value } of provided) {
|
|
112
|
+
try {
|
|
113
|
+
await writeEnvKey(opts.envFilePath, key, value);
|
|
114
|
+
applied.push(key);
|
|
115
|
+
// Hydrate process.env so the current session sees the new value
|
|
116
|
+
process.env[key] = value;
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
errors.push(`${key}: ${msg}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if ((destination === "vercel" || destination === "convex") && opts.execFn) {
|
|
125
|
+
const env = opts.environment ?? "development";
|
|
126
|
+
if (!isSupportedDeploymentEnvironment(env)) {
|
|
127
|
+
errors.push(`environment: unsupported target environment "${env}"`);
|
|
128
|
+
return { applied, errors };
|
|
129
|
+
}
|
|
130
|
+
for (const { key, value } of provided) {
|
|
131
|
+
if (!isSafeEnvVarKey(key)) {
|
|
132
|
+
errors.push(`${key}: invalid environment variable name`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const cmd = destination === "vercel"
|
|
136
|
+
? `printf %s ${shellEscapeSingle(value)} | vercel env add ${key} ${env}`
|
|
137
|
+
: "";
|
|
138
|
+
try {
|
|
139
|
+
const result = destination === "vercel"
|
|
140
|
+
? await opts.execFn("sh", ["-c", cmd])
|
|
141
|
+
: await opts.execFn("npx", ["convex", "env", "set", key, value]);
|
|
142
|
+
if (result.code !== 0) {
|
|
143
|
+
errors.push(`${key}: ${result.stderr.slice(0, 200)}`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
applied.push(key);
|
|
147
|
+
process.env[key] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
152
|
+
errors.push(`${key}: ${msg}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { applied, errors };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=env-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-writer.js","sourceRoot":"","sources":["../src/env-writer.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,4DAA4D;AAC5D,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,4EAA4E;AAE5E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAc,EAAE,WAAmB;IAC5E,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,CAAC;QACH,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;IAED,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,OAAO,OAAO,EAAE,GAAG,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC,IAAI,CAAC,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labs.net>\n//\n// Shared helpers for writing env vars to .env files, detecting project\n// destinations, and checking existing keys. Used by secure_env_collect\n// MCP tool. No TUI dependencies — pure filesystem + process.env operations.\n\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n// ---------------------------------------------------------------------------\n// checkExistingEnvKeys\n// ---------------------------------------------------------------------------\n\n/**\n * Check which keys already exist in a .env file or process.env.\n * Returns the subset of `keys` that are already set.\n */\nexport async function checkExistingEnvKeys(keys: string[], envFilePath: string): Promise<string[]> {\n let fileContent = \"\";\n try {\n fileContent = await readFile(envFilePath, \"utf8\");\n } catch {\n // ENOENT or other read error — proceed with empty content\n }\n\n const existing: string[] = [];\n for (const key of keys) {\n const escaped = key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const regex = new RegExp(`^${escaped}\\\\s*=`, \"m\");\n if (regex.test(fileContent) || key in process.env) {\n existing.push(key);\n }\n }\n return existing;\n}\n\n// ---------------------------------------------------------------------------\n// detectDestination\n// ---------------------------------------------------------------------------\n\n/**\n * Detect the write destination based on project files in basePath.\n * Priority: vercel.json → convex/ dir → fallback \"dotenv\".\n */\nexport function detectDestination(basePath: string): \"dotenv\" | \"vercel\" | \"convex\" {\n if (existsSync(resolve(basePath, \"vercel.json\"))) {\n return \"vercel\";\n }\n const convexPath = resolve(basePath, \"convex\");\n try {\n if (existsSync(convexPath) && statSync(convexPath).isDirectory()) {\n return \"convex\";\n }\n } catch {\n // stat error — treat as not found\n }\n return \"dotenv\";\n}\n\n// ---------------------------------------------------------------------------\n// writeEnvKey\n// ---------------------------------------------------------------------------\n\n/**\n * Write a single key=value pair to a .env file.\n * Updates existing keys in-place, appends new ones at the end.\n */\nexport async function writeEnvKey(filePath: string, key: string, value: string): Promise<void> {\n if (typeof value !== \"string\") {\n throw new TypeError(`writeEnvKey expects a string value for key \"${key}\", got ${typeof value}`);\n }\n let content = \"\";\n try {\n content = await readFile(filePath, \"utf8\");\n } catch {\n content = \"\";\n }\n const escaped = value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\");\n const line = `${key}=${escaped}`;\n const regex = new RegExp(`^${key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\\\\s*=.*$`, \"m\");\n if (regex.test(content)) {\n content = content.replace(regex, line);\n } else {\n if (content.length > 0 && !content.endsWith(\"\\n\")) content += \"\\n\";\n content += `${line}\\n`;\n }\n await writeFile(filePath, content, \"utf8\");\n}\n\n// ---------------------------------------------------------------------------\n// Validation helpers\n// ---------------------------------------------------------------------------\n\nexport function isSafeEnvVarKey(key: string): boolean {\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);\n}\n\nexport function isSupportedDeploymentEnvironment(env: string): boolean {\n return env === \"development\" || env === \"preview\" || env === \"production\";\n}\n\n// ---------------------------------------------------------------------------\n// Shell helpers (for vercel/convex CLI)\n// ---------------------------------------------------------------------------\n\nexport function shellEscapeSingle(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\n// ---------------------------------------------------------------------------\n// applySecrets\n// ---------------------------------------------------------------------------\n\ninterface ApplyResult {\n applied: string[];\n errors: string[];\n}\n\n/**\n * Apply collected secrets to the target destination.\n * Dotenv writes are handled directly; vercel/convex shell out via execFn.\n */\nexport async function applySecrets(\n provided: Array<{ key: string; value: string }>,\n destination: \"dotenv\" | \"vercel\" | \"convex\",\n opts: {\n envFilePath: string;\n environment?: string;\n execFn?: (cmd: string, args: string[]) => Promise<{ code: number; stderr: string }>;\n },\n): Promise<ApplyResult> {\n const applied: string[] = [];\n const errors: string[] = [];\n\n if (destination === \"dotenv\") {\n for (const { key, value } of provided) {\n try {\n await writeEnvKey(opts.envFilePath, key, value);\n applied.push(key);\n // Hydrate process.env so the current session sees the new value\n process.env[key] = value;\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n errors.push(`${key}: ${msg}`);\n }\n }\n }\n\n if ((destination === \"vercel\" || destination === \"convex\") && opts.execFn) {\n const env = opts.environment ?? \"development\";\n if (!isSupportedDeploymentEnvironment(env)) {\n errors.push(`environment: unsupported target environment \"${env}\"`);\n return { applied, errors };\n }\n for (const { key, value } of provided) {\n if (!isSafeEnvVarKey(key)) {\n errors.push(`${key}: invalid environment variable name`);\n continue;\n }\n const cmd = destination === \"vercel\"\n ? `printf %s ${shellEscapeSingle(value)} | vercel env add ${key} ${env}`\n : \"\";\n try {\n const result = destination === \"vercel\"\n ? await opts.execFn(\"sh\", [\"-c\", cmd])\n : await opts.execFn(\"npx\", [\"convex\", \"env\", \"set\", key, value]);\n if (result.code !== 0) {\n errors.push(`${key}: ${result.stderr.slice(0, 200)}`);\n } else {\n applied.push(key);\n process.env[key] = value;\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n errors.push(`${key}: ${msg}`);\n }\n }\n }\n\n return { applied, errors };\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* MCP Server — registers GSD orchestration, project-state, and workflow tools.
|
|
3
3
|
*
|
|
4
4
|
* Session tools (6): gsd_execute, gsd_status, gsd_result, gsd_cancel, gsd_query, gsd_resolve_blocker
|
|
5
|
-
* Interactive tools (
|
|
5
|
+
* Interactive tools (2): ask_user_questions, secure_env_collect via MCP form elicitation
|
|
6
6
|
* Read-only tools (6): gsd_progress, gsd_roadmap, gsd_history, gsd_doctor, gsd_captures, gsd_knowledge
|
|
7
7
|
* Workflow tools (29): headless-safe planning, metadata persistence, replanning, completion, validation, reassessment, gate result, status, and journal tools
|
|
8
8
|
*
|
|
@@ -11,10 +11,19 @@
|
|
|
11
11
|
* src/mcp-server.ts in the main package).
|
|
12
12
|
*/
|
|
13
13
|
import type { SessionManager } from './session-manager.js';
|
|
14
|
+
interface ElicitRequestFormParams {
|
|
15
|
+
mode?: 'form';
|
|
16
|
+
message: string;
|
|
17
|
+
requestedSchema: {
|
|
18
|
+
type: 'object';
|
|
19
|
+
properties: Record<string, Record<string, unknown>>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
14
23
|
interface McpServerInstance {
|
|
15
24
|
tool(name: string, description: string, params: Record<string, unknown>, handler: (args: Record<string, unknown>) => Promise<unknown>): unknown;
|
|
16
25
|
server: {
|
|
17
|
-
elicitInput(params: AskUserQuestionsElicitRequest, options?: unknown): Promise<AskUserQuestionsElicitResult>;
|
|
26
|
+
elicitInput(params: AskUserQuestionsElicitRequest | ElicitRequestFormParams, options?: unknown): Promise<AskUserQuestionsElicitResult>;
|
|
18
27
|
};
|
|
19
28
|
connect(transport: unknown): Promise<void>;
|
|
20
29
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAwG3D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACpD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED,UAAU,iBAAiB;IACzB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM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AAkC,CAChD,SAAS,EAAE,eAAe,EAAE,EAC5B,MAAM,EAAE,4BAA4B,GACnC,MAAM,CAkBR;AAMD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC;IAC7E,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC,CAwbD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* MCP Server — registers GSD orchestration, project-state, and workflow tools.
|
|
3
3
|
*
|
|
4
4
|
* Session tools (6): gsd_execute, gsd_status, gsd_result, gsd_cancel, gsd_query, gsd_resolve_blocker
|
|
5
|
-
* Interactive tools (
|
|
5
|
+
* Interactive tools (2): ask_user_questions, secure_env_collect via MCP form elicitation
|
|
6
6
|
* Read-only tools (6): gsd_progress, gsd_roadmap, gsd_history, gsd_doctor, gsd_captures, gsd_knowledge
|
|
7
7
|
* Workflow tools (29): headless-safe planning, metadata persistence, replanning, completion, validation, reassessment, gate result, status, and journal tools
|
|
8
8
|
*
|
|
@@ -20,6 +20,7 @@ import { readCaptures } from './readers/captures.js';
|
|
|
20
20
|
import { readKnowledge } from './readers/knowledge.js';
|
|
21
21
|
import { runDoctorLite } from './readers/doctor-lite.js';
|
|
22
22
|
import { registerWorkflowTools } from './workflow-tools.js';
|
|
23
|
+
import { applySecrets, checkExistingEnvKeys, detectDestination } from './env-writer.js';
|
|
23
24
|
// ---------------------------------------------------------------------------
|
|
24
25
|
// Constants
|
|
25
26
|
// ---------------------------------------------------------------------------
|
|
@@ -192,7 +193,7 @@ export async function createMcpServer(sessionManager) {
|
|
|
192
193
|
// Dynamic import — same workaround as src/mcp-server.ts
|
|
193
194
|
const mcpMod = await import(`${MCP_PKG}/server/mcp.js`);
|
|
194
195
|
const McpServer = mcpMod.McpServer;
|
|
195
|
-
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {} } });
|
|
196
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {}, elicitation: {} } });
|
|
196
197
|
// -----------------------------------------------------------------------
|
|
197
198
|
// gsd_execute — start a new GSD auto-mode session
|
|
198
199
|
// -----------------------------------------------------------------------
|
|
@@ -339,6 +340,105 @@ export async function createMcpServer(sessionManager) {
|
|
|
339
340
|
return errorContent(err instanceof Error ? err.message : String(err));
|
|
340
341
|
}
|
|
341
342
|
});
|
|
343
|
+
// -----------------------------------------------------------------------
|
|
344
|
+
// secure_env_collect — collect secrets via MCP form elicitation
|
|
345
|
+
// -----------------------------------------------------------------------
|
|
346
|
+
server.tool('secure_env_collect', 'Collect environment variables securely via form input. Values are written directly to .env (or Vercel/Convex) and NEVER appear in tool output — only key names and applied/skipped status are returned. Use this instead of asking users to manually edit .env files or paste secrets into chat.', {
|
|
347
|
+
projectDir: z.string().describe('Absolute path to the project directory'),
|
|
348
|
+
keys: z.array(z.object({
|
|
349
|
+
key: z.string().describe('Env var name, e.g. OPENAI_API_KEY'),
|
|
350
|
+
hint: z.string().optional().describe('Format hint shown to user, e.g. "starts with sk-"'),
|
|
351
|
+
guidance: z.array(z.string()).optional().describe('Step-by-step instructions for obtaining this key'),
|
|
352
|
+
})).min(1).describe('Environment variables to collect'),
|
|
353
|
+
destination: z.enum(['dotenv', 'vercel', 'convex']).optional().describe('Where to write secrets. Auto-detected from project files if omitted.'),
|
|
354
|
+
envFilePath: z.string().optional().describe('Path to .env file (dotenv only). Defaults to .env in projectDir.'),
|
|
355
|
+
environment: z.enum(['development', 'preview', 'production']).optional().describe('Target environment (vercel/convex only)'),
|
|
356
|
+
}, async (args) => {
|
|
357
|
+
const { projectDir, keys, destination, envFilePath, environment } = args;
|
|
358
|
+
try {
|
|
359
|
+
const resolvedProjectDir = resolve(projectDir);
|
|
360
|
+
const resolvedEnvPath = resolve(resolvedProjectDir, envFilePath ?? '.env');
|
|
361
|
+
// (1) Check which keys already exist
|
|
362
|
+
const allKeyNames = keys.map((k) => k.key);
|
|
363
|
+
const existingKeys = await checkExistingEnvKeys(allKeyNames, resolvedEnvPath);
|
|
364
|
+
const existingSet = new Set(existingKeys);
|
|
365
|
+
const pendingKeys = keys.filter((k) => !existingSet.has(k.key));
|
|
366
|
+
// If all keys already exist, return immediately
|
|
367
|
+
if (pendingKeys.length === 0) {
|
|
368
|
+
const lines = existingKeys.map((k) => `• ${k}: already set`);
|
|
369
|
+
return textContent(`All ${existingKeys.length} key(s) already set.\n${lines.join('\n')}`);
|
|
370
|
+
}
|
|
371
|
+
// (2) Build elicitation form — one string field per pending key
|
|
372
|
+
const properties = {};
|
|
373
|
+
const required = [];
|
|
374
|
+
for (const item of pendingKeys) {
|
|
375
|
+
const descParts = [];
|
|
376
|
+
if (item.hint)
|
|
377
|
+
descParts.push(`Format: ${item.hint}`);
|
|
378
|
+
if (item.guidance && item.guidance.length > 0) {
|
|
379
|
+
descParts.push('How to get this:');
|
|
380
|
+
item.guidance.forEach((step, i) => descParts.push(`${i + 1}. ${step}`));
|
|
381
|
+
}
|
|
382
|
+
descParts.push('Leave empty to skip.');
|
|
383
|
+
properties[item.key] = {
|
|
384
|
+
type: 'string',
|
|
385
|
+
title: item.key,
|
|
386
|
+
description: descParts.join('\n'),
|
|
387
|
+
};
|
|
388
|
+
// Don't mark as required — empty string = skip
|
|
389
|
+
}
|
|
390
|
+
// (3) Elicit input from the MCP client
|
|
391
|
+
const elicitation = await server.server.elicitInput({
|
|
392
|
+
message: `Enter values for ${pendingKeys.length} environment variable(s). Values are written directly to the project and never shown to the AI.`,
|
|
393
|
+
requestedSchema: {
|
|
394
|
+
type: 'object',
|
|
395
|
+
properties,
|
|
396
|
+
required,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
if (elicitation.action !== 'accept' || !elicitation.content) {
|
|
400
|
+
return textContent('secure_env_collect was cancelled by user.');
|
|
401
|
+
}
|
|
402
|
+
// (4) Separate provided vs skipped from form response
|
|
403
|
+
const provided = [];
|
|
404
|
+
const skipped = [];
|
|
405
|
+
for (const item of pendingKeys) {
|
|
406
|
+
const raw = elicitation.content[item.key];
|
|
407
|
+
const value = typeof raw === 'string' ? raw.trim() : '';
|
|
408
|
+
if (value.length > 0) {
|
|
409
|
+
provided.push({ key: item.key, value });
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
skipped.push(item.key);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// (5) Auto-detect destination if not specified
|
|
416
|
+
const resolvedDestination = destination ?? detectDestination(resolvedProjectDir);
|
|
417
|
+
// (6) Write secrets to destination
|
|
418
|
+
const { applied, errors } = await applySecrets(provided, resolvedDestination, {
|
|
419
|
+
envFilePath: resolvedEnvPath,
|
|
420
|
+
environment,
|
|
421
|
+
});
|
|
422
|
+
// (7) Build result — NEVER include secret values
|
|
423
|
+
const lines = [
|
|
424
|
+
`destination: ${resolvedDestination}${!destination ? ' (auto-detected)' : ''}${environment ? ` (${environment})` : ''}`,
|
|
425
|
+
];
|
|
426
|
+
for (const k of applied)
|
|
427
|
+
lines.push(`✓ ${k}: applied`);
|
|
428
|
+
for (const k of skipped)
|
|
429
|
+
lines.push(`• ${k}: skipped`);
|
|
430
|
+
for (const k of existingKeys)
|
|
431
|
+
lines.push(`• ${k}: already set`);
|
|
432
|
+
for (const e of errors)
|
|
433
|
+
lines.push(`✗ ${e}`);
|
|
434
|
+
return errors.length > 0 && applied.length === 0
|
|
435
|
+
? errorContent(lines.join('\n'))
|
|
436
|
+
: textContent(lines.join('\n'));
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
return errorContent(err instanceof Error ? err.message : String(err));
|
|
440
|
+
}
|
|
441
|
+
});
|
|
342
442
|
// =======================================================================
|
|
343
443
|
// READ-ONLY TOOLS — no session required, pure filesystem reads
|
|
344
444
|
// =======================================================================
|