fix(mcp): resolve external preview routing failures and correct monorepo git paths
This commit is contained in:
@@ -203,7 +203,7 @@ Each project has a persistent \`vibn-dev\` container. Edit files via \`fs_*\` an
|
|||||||
**Dev servers (preview URL via \`*.preview.vibnai.com\` wildcard):**
|
**Dev servers (preview URL via \`*.preview.vibnai.com\` wildcard):**
|
||||||
- \`dev_server_start { projectId, command, port?, name? }\` is a **one-shot** call. It kills old processes on the port, checks the port is free, sets HOST=0.0.0.0 + PORT, launches your command, and returns a clickable \`previewUrl\`. Do NOT pre-flight with \`devcontainer_status\`, \`fs_list\`, \`dev_server_logs\`, or manual \`shell_exec\` kills — the function handles all of that. Just call it. The error tells you what to fix: \`PORT_BUSY\` → pick 3001–3009; \`npm: command not found\` → project needs \`npm install\` first.
|
- \`dev_server_start { projectId, command, port?, name? }\` is a **one-shot** call. It kills old processes on the port, checks the port is free, sets HOST=0.0.0.0 + PORT, launches your command, and returns a clickable \`previewUrl\`. Do NOT pre-flight with \`devcontainer_status\`, \`fs_list\`, \`dev_server_logs\`, or manual \`shell_exec\` kills — the function handles all of that. Just call it. The error tells you what to fix: \`PORT_BUSY\` → pick 3001–3009; \`npm: command not found\` → project needs \`npm install\` first.
|
||||||
- \`port\` defaults to 3000, range 3000–3009 (10 Traefik routers pre-allocated per project).
|
- \`port\` defaults to 3000, range 3000–3009 (10 Traefik routers pre-allocated per project).
|
||||||
- **Monorepos:** if the project has packages/apps, start inside the frontend directory. Pass \`name: "frontend"\` so the Preview tab picks it. The command runs from \`/workspace\`, so if the frontend is at \`/workspace/apps/web\`, use \`command: "cd apps/web && npm run dev"\`.
|
- **Directory:** The command runs from the root \`/workspace\` directory, but your project code is inside \`/workspace/${activeProject.slug ?? "<slug>"}/\`. You MUST \`cd\` into your project folder first! Example: \`command: "cd ${activeProject.slug ?? "<slug>"} && npm run dev"\`.
|
||||||
- \`dev_server_stop\` / \`dev_server_list\` / \`dev_server_logs\` — use only AFTER a failed start, and only to diagnose the error the function returned. Never on success.
|
- \`dev_server_stop\` / \`dev_server_list\` / \`dev_server_logs\` — use only AFTER a failed start, and only to diagnose the error the function returned. Never on success.
|
||||||
|
|
||||||
**HMR through the proxy (apply when scaffolding):**
|
**HMR through the proxy (apply when scaffolding):**
|
||||||
|
|||||||
@@ -4960,7 +4960,7 @@ async function toolShip(principal: Principal, params: Record<string, any>) {
|
|||||||
// Capture the resulting HEAD SHA on stdout in a parseable form so we
|
// Capture the resulting HEAD SHA on stdout in a parseable form so we
|
||||||
// can return it to the caller without a second exec round-trip.
|
// can return it to the caller without a second exec round-trip.
|
||||||
const cmd = `set -e
|
const cmd = `set -e
|
||||||
cd /workspace
|
cd /workspace/${project.slug}
|
||||||
if [ ! -d .git ]; then
|
if [ ! -d .git ]; then
|
||||||
git init -q
|
git init -q
|
||||||
git checkout -b ${shq(branch)}
|
git checkout -b ${shq(branch)}
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ export function ensurePreviewListenAllInterfaces(command: string): string {
|
|||||||
if (!cmd) return cmd;
|
if (!cmd) return cmd;
|
||||||
|
|
||||||
const universalEnv =
|
const universalEnv =
|
||||||
"HOST=0.0.0.0 HOSTNAME=0.0.0.0 VITE_DEV_SERVER_HOST=0.0.0.0 WEBPACK_DEV_SERVER_HOST=0.0.0.0 ";
|
"export HOST=0.0.0.0 HOSTNAME=0.0.0.0 VITE_DEV_SERVER_HOST=0.0.0.0 WEBPACK_DEV_SERVER_HOST=0.0.0.0; ";
|
||||||
|
|
||||||
if (/\bnext\s+dev\b/.test(cmd) && !/\b(?:-H|--hostname)\b/.test(cmd)) {
|
if (/\bnext\s+dev\b/.test(cmd) && !/\b(?:-H|--hostname)\b/.test(cmd)) {
|
||||||
cmd = cmd.replace(/\bnext\s+dev\b/, "next dev -H 0.0.0.0");
|
cmd = cmd.replace(/\bnext\s+dev\b/, "next dev -H 0.0.0.0");
|
||||||
@@ -1016,7 +1016,7 @@ export async function autosaveWorkspace(opts: AutosaveOpts): Promise<{
|
|||||||
// runs only when the repo doesn't have git yet.
|
// runs only when the repo doesn't have git yet.
|
||||||
const repo = opts.repo ?? opts.projectSlug;
|
const repo = opts.repo ?? opts.projectSlug;
|
||||||
const cmd = `set -e
|
const cmd = `set -e
|
||||||
cd /workspace
|
cd /workspace/${opts.projectSlug}
|
||||||
if [ ! -d .git ]; then
|
if [ ! -d .git ]; then
|
||||||
echo '(no .git, skipping autosave)'
|
echo '(no .git, skipping autosave)'
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user