Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat(view): real /__ix/remap endpoint with loopback guard; fix WSL bootstrap (#393)

Alot1z41be07b47cdf
diff --git a/docs/api/README.md b/docs/api/README.md
index d1fc53ae..37528ffb 100644
--- a/docs/api/README.md
+++ b/docs/api/README.md
@@ -476,10 +476,43 @@ backend:
1. **`/v1/*` proxy** — every backend request is proxied to `localhost:8090`
with `x-ix-workspace` and `x-ix-system` headers baked in at launch, so the
browser app never knows about workspaces. `--all` opts out of scoping.
-2. **SPA fallback** — any other path serves `index.html`. There is no
- `/__ix/remap` endpoint: a `POST` to it falls through to this handler and
- returns the SPA HTML with a `200`, so a caller cannot tell it did nothing.
- Re-map from the CLI with `ix map .` instead.
+2. **`POST /__ix/remap`** — rebuild the code map for the workspace this
+ visualizer is scoped to, by running `ix map <workspace-root> --silent` with
+ a 30-minute timeout. Responds `{ "ok": true }` on success, or a `500` with
+ `{ "ok": false, "error": ... }` when the map command fails.
+
+ The workspace root is resolved once, by `ix view start`, and baked into the
+ generated server — the same resolution that produces the `x-ix-workspace`
+ header, so a remap rebuilds exactly what the view is showing. It is *not*
+ the server's working directory: under `--all` that need not be a workspace
+ at all, so a view started from a home directory would have mapped the whole
+ of it. Two `409`s follow from that:
+
+ - `--all` leaves the view unscoped and there is no single workspace to
+ rebuild: `{ "ok": false, "error": "remap needs a single workspace; …" }`
+ - a remap is already running: `{ "ok": false, "error": "a remap is already
+ running" }`. `execFile` is asynchronous, so without this every request
+ would start another full ingest over the same workspace.
+
+ It does **not** run `ix reset` — `ix map` reconciles deletions itself, and
+ `ix reset` takes no workspace id, so it would wipe every workspace in the
+ backend rather than rebuilding this one.
+
+ **Loopback only:** the server binds `127.0.0.1`, and the handler rejects
+ requests whose `Host` is not loopback, or whose browser `Origin` is not
+ this exact origin — loopback hostname *and* this server's port
+ (`403 { "ok": false, "error": "forbidden: loopback only" }`). Matching the
+ port matters: any page served on another localhost port can send this POST
+ with no preflight, so treating the whole loopback interface as one origin
+ would let a local dev server trigger a remap. Requests with no `Origin`
+ (e.g. `curl`) are allowed when the `Host` is loopback. The endpoint shells
+ out with the user's privileges, which is what all of this is guarding.
+
+ Interrupting a remap is safe: the client going away kills the child, and the
+ ingest baseline is only persisted after a clean run, so an interrupted map
+ re-ingests next time rather than recording files as done that never landed.
+3. **SPA fallback** — any other path serves `index.html`. A `GET` to
+ `/__ix/remap` (or any other unknown path) falls through to this handler.
## Data Models
diff --git a/ix-cli/src/cli/__tests__/view-server.test.ts b/ix-cli/src/cli/__tests__/view-server.test.ts
new file mode 100644
index 00000000..7eab1be5
--- /dev/null
+++ b/ix-cli/src/cli/__tests__/view-server.test.ts
@@ -0,0 +1,266 @@
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import { spawn, type ChildProcess } from "node:child_process";
+import { mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { createServer } from "node:net";
+import * as http from "node:http";
+import { serverScript } from "../commands/view.js";
+
+/** Pick a free TCP port by binding port 0 and releasing it. */
+function getFreePort(): Promise<number> {
+ return new Promise((resolve, reject) => {
+ const srv = createServer();
+ srv.on("error", reject);
+ srv.listen(0, "127.0.0.1", () => {
+ const port = (srv.address() as { port: number }).port;
+ srv.close(() => resolve(port));
+ });
+ });
+}
+
+/** Wait until a TCP port accepts connections. */
+async function waitForPort(port: number, timeoutMs = 8000): Promise<void> {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ try {
+ const res = await fetch(`http://127.0.0.1:${port}/`, { signal: AbortSignal.timeout(500) });
+ res.body?.cancel();
+ return;
+ } catch {
+ await new Promise((r) => setTimeout(r, 100));
+ }
+ }
+ throw new Error(`server on port ${port} did not start`);
+}
+
+describe("view server (/__ix/remap)", () => {
+ let distDir: string;
+ let mapRoot: string;
+ let stubMain: string;
+ let marker: string;
+ let child: ChildProcess | null = null;
+ let port = 0;
+
+ beforeAll(async () => {
+ // A fake Compass dist: index.html is the SPA entry the fallback serves.
+ distDir = mkdtempSync(join(tmpdir(), "ix-view-dist-"));
+ writeFileSync(join(distDir, "index.html"), "<h1>fake compass</h1>");
+
+ // The workspace the server is scoped to. The endpoint maps this, not its
+ // own cwd, so the test has to supply one.
+ mapRoot = mkdtempSync(join(tmpdir(), "ix-view-root-"));
+
+ // The marker records every stub invocation. It lives in the temp tree and
+ // is passed by env rather than written to process.cwd(): the stub's cwd is
+ // MAP_ROOT now, and writing into the package root left an untracked file
+ // behind whenever a run was interrupted before cleanup.
+ marker = join(distDir, "stub-ran.txt");
+
+ // A stub `ix` CLI main: the server runs `node <MAP_MAIN> map <root> --silent`.
+ // STUB_MS holds it open so overlapping requests are observable; STUB_EXIT
+ // drives the failure path.
+ stubMain = join(distDir, "stub-main.js");
+ writeFileSync(
+ stubMain,
+ [
+ 'const fs = require("fs");',
+ "fs.appendFileSync(process.env.STUB_MARKER, process.argv.slice(2).join(\" \") + \"\\n\");",
+ "const ms = Number(process.env.STUB_MS || 0);",
+ "const done = () => process.exit(Number(process.env.STUB_EXIT || 0));",
+ "if (ms > 0) setTimeout(done, ms); else done();",
+ ].join("\n"),
+ );
+
+ port = await getFreePort();
+ const script = serverScript(distDir, port, "test-workspace", null, mapRoot);
+ // The generated script must survive template-literal emission intact.
+ expect(script).toContain('"/__ix/remap"');
+ expect(script).toContain("IX_VIEW_MAP_MAIN");
+ expect(script).toContain('server.listen(PORT, "127.0.0.1"');
+
+ await startServer({ STUB_EXIT: "0" });
+ });
+
+ afterAll(async () => {
+ await stopServer();
+ rmSync(distDir, { recursive: true, force: true });
+ rmSync(mapRoot, { recursive: true, force: true });
+ });
+
+ /** Kill the running server and wait for the socket to be released. */
+ async function stopServer(): Promise<void> {
+ if (!child) return;
+ const dying = child;
+ child = null;
+ if (dying.exitCode !== null || dying.signalCode !== null) return;
+ await new Promise<void>((resolve) => {
+ dying.once("exit", () => resolve());
+ dying.kill();
+ });
+ }
+
+ /**
+ * Replace the running server.
+ *
+ * Awaiting the old child's exit matters: kill() returns when SIGTERM is sent,
+ * not when it lands, so spawning the replacement on the same port immediately
+ * could lose the bind to EADDRINUSE — invisibly, because stdio is ignored —
+ * while waitForPort was satisfied by the still-dying old server.
+ */
+ async function startServer(extraEnv: Record<string, string>, root: string | null = mapRoot) {
+ await stopServer();
+ const scriptPath = join(distDir, "compass-server.js");
+ writeFileSync(scriptPath, serverScript(distDir, port, "test-workspace", null, root));
+ const spawned = spawn(process.execPath, [scriptPath], {
+ env: {
+ ...process.env,
+ NODE_ENV: "test", // the IX_VIEW_MAP_MAIN seam is honoured only under this
+ IX_VIEW_MAP_MAIN: stubMain,
+ STUB_MARKER: marker,
+ STUB_MS: "0",
+ ...extraEnv,
+ },
+ stdio: "ignore",
+ });
+ // A server that dies on startup would otherwise surface as a timeout in
+ // waitForPort with no indication of why.
+ spawned.once("error", () => { /* surfaced by waitForPort */ });
+ child = spawned;
+ await waitForPort(port);
+ }
+
+ const post = (path: string, headers: Record<string, string> = {}) =>
+ fetch(`http://127.0.0.1:${port}${path}`, { method: "POST", headers });
+
+ const runs = () => (existsSync(marker) ? readFileSync(marker, "utf8").trim().split("\n").filter(Boolean) : []);
+ const resetRuns = () => writeFileSync(marker, "");
+
+ it("rejects a cross-site Origin (CSRF) with 403", async () => {
+ const res = await post("/__ix/remap", { origin: "https://evil.example", host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(403);
+ expect(await res.json()).toEqual({ ok: false, error: "forbidden: loopback only" });
+ });
+
+ it("rejects a DNS-rebinding Host with 403", async () => {
+ // fetch/undici refuses to send a custom Host header, so use http.request,
+ // which lets the Host header differ from the connection target — the exact
+ // DNS-rebinding scenario.
+ const status = await new Promise<number>((resolve, reject) => {
+ const req = http.request(
+ { host: "127.0.0.1", port, path: "/__ix/remap", method: "POST", headers: { host: "attacker.example" } },
+ (res) => {
+ res.resume();
+ res.on("end", () => resolve(res.statusCode ?? 0));
+ },
+ );
+ req.on("error", reject);
+ req.end();
+ });
+ expect(status).toBe(403);
+ });
+
+ it("rejects a malformed Origin with 403", async () => {
+ const res = await post("/__ix/remap", { origin: "not a url", host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(403);
+ });
+
+ it("rejects a non-loopback Origin even when the Host is loopback", async () => {
+ const res = await post("/__ix/remap", { origin: "http://10.0.0.5:8080", host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(403);
+ });
+
+ it("rejects a loopback Origin on a different port", async () => {
+ // Loopback is not one origin. Any page served on another localhost port can
+ // send this exact POST with no preflight, so accepting the whole interface
+ // let a local dev server or docs site trigger a remap.
+ resetRuns();
+ const res = await post("/__ix/remap", { origin: `http://localhost:${port + 1}`, host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(403);
+ expect(runs()).toHaveLength(0);
+ });
+
+ it("accepts a bracketed IPv6 loopback Host ([::1]:port)", async () => {
+ const status = await new Promise<number>((resolve, reject) => {
+ const req = http.request(
+ { host: "127.0.0.1", port, path: "/__ix/remap", method: "POST", headers: { host: `[::1]:${port}` } },
+ (res) => {
+ res.resume();
+ res.on("end", () => resolve(res.statusCode ?? 0));
+ },
+ );
+ req.on("error", reject);
+ req.end();
+ });
+ expect(status).toBe(200);
+ });
+
+ it("accepts a no-Origin (curl-style) POST and maps the scoped workspace", async () => {
+ resetRuns();
+ const res = await post("/__ix/remap", { host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(200);
+ expect(await res.json()).toEqual({ ok: true });
+ // The recorded workspace root, never the server's own cwd, and --silent
+ // because nothing reads the output.
+ expect(runs()).toEqual([`map ${mapRoot} --silent`]);
+ });
+
+ it("accepts a same-origin loopback Origin", async () => {
+ const res = await post("/__ix/remap", { origin: `http://localhost:${port}`, host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(200);
+ expect((await res.json()).ok).toBe(true);
+ });
+
+ it("refuses a second remap while one is in flight", async () => {
+ await startServer({ STUB_MS: "1200" });
+ resetRuns();
+ const first = post("/__ix/remap", { host: `127.0.0.1:${port}` });
+ // Let the first request reach the spawn before the second arrives.
+ await new Promise((r) => setTimeout(r, 300));
+ const second = await post("/__ix/remap", { host: `127.0.0.1:${port}` });
+
+ expect(second.status).toBe(409);
+ expect((await second.json()).error).toMatch(/already running/);
+ expect((await first).status).toBe(200);
+ expect(runs()).toHaveLength(1);
+
+ // The slot is released, so the next one is accepted rather than wedged.
+ await startServer({ STUB_EXIT: "0" });
+ expect((await post("/__ix/remap", { host: `127.0.0.1:${port}` })).status).toBe(200);
+ });
+
+ it("refuses to remap when the view is unscoped (--all)", async () => {
+ await startServer({ STUB_EXIT: "0" }, null);
+ resetRuns();
+ const res = await post("/__ix/remap", { host: `127.0.0.1:${port}` });
+
+ expect(res.status).toBe(409);
+ expect((await res.json()).error).toMatch(/--all/);
+ // The point of the guard: nothing was mapped. Falling back to the server's
+ // cwd here is what could ingest a home directory.
+ expect(runs()).toHaveLength(0);
+
+ await startServer({ STUB_EXIT: "0" });
+ });
+
+ it("returns ok:false when the map command fails", async () => {
+ await startServer({ STUB_EXIT: "1" });
+ const res = await post("/__ix/remap", { host: `127.0.0.1:${port}` });
+ expect(res.status).toBe(500);
+ const body = await res.json();
+ expect(body.ok).toBe(false);
+ expect(typeof body.error).toBe("string");
+ });
+
+ it("still serves the SPA index.html for unknown paths", async () => {
+ const res = await fetch(`http://127.0.0.1:${port}/`);
+ expect(res.status).toBe(200);
+ expect(await res.text()).toContain("fake compass");
+ });
+
+ it("does not treat GET /__ix/remap as the endpoint (SPA fallback)", async () => {
+ const res = await fetch(`http://127.0.0.1:${port}/__ix/remap`);
+ expect(res.status).toBe(200);
+ expect(await res.text()).toContain("fake compass");
+ });
+});
diff --git a/ix-cli/src/cli/commands/view.ts b/ix-cli/src/cli/commands/view.ts
index 17b0360e..59f63555 100644
--- a/ix-cli/src/cli/commands/view.ts
+++ b/ix-cli/src/cli/commands/view.ts
@@ -12,7 +12,7 @@ import { homedir, platform } from "os";
import { fileURLToPath } from "url";
import { createConnection } from "net";
import { resolveWorkspaceId } from "../bootstrap.js";
-import { findWorkspaceForCwd, loadWorkspaces, getEndpoint } from "../config.js";
+import { findWorkspaceForCwd, getDefaultWorkspace, loadWorkspaces, getEndpoint } from "../config.js";
import { detectSystem } from "../system.js";
import { IxClient } from "../../client/api.js";
@@ -177,13 +177,31 @@ function isPortInUse(port: number): Promise<boolean> {
});
}
+/**
+ * Path to the CLI entry point of the install generating this script.
+ *
+ * Taken from this module's own location rather than derived from the compass
+ * dist directory, so it holds for a repo checkout as well as an install.
+ */
+function cliMainForScript(): string {
+ return join(dirname(fileURLToPath(import.meta.url)), "..", "main.js");
+}
+
/** Generate the inline server script that serves static files + proxies /v1. */
-function serverScript(distDir: string, port: number, workspaceId: string | null, systemId: string | null): string {
+export function serverScript(
+ distDir: string,
+ port: number,
+ workspaceId: string | null,
+ systemId: string | null,
+ mapRoot: string | null = null,
+): string {
+ const cliMainPath = cliMainForScript();
return `
const http = require("http");
const fs = require("fs");
const path = require("path");
const url = require("url");
+const { execFile } = require("child_process");
const DIST = ${JSON.stringify(distDir)};
const PORT = ${port};
@@ -191,6 +209,25 @@ const BACKEND = ${JSON.stringify(BACKEND_URL)};
const WORKSPACE_ID = ${JSON.stringify(workspaceId)};
const SYSTEM_ID = ${JSON.stringify(systemId)};
+// The workspace root /__ix/remap maps, resolved by ix view start and baked in
+// rather than re-derived here — null when --all left the view unscoped.
+const MAP_ROOT = ${JSON.stringify(mapRoot)};
+
+// The CLI that generated this script, resolved from its own location at
+// generation time. Deriving it here from DIST only worked for the installed
+// layout; findCompassDist's dev branch returns a repo path, from which the
+// same arithmetic lands on a file that never exists.
+//
+// The env override is a test seam and is honoured only under NODE_ENV=test, so
+// a shipped install cannot be pointed at an arbitrary script through the
+// environment.
+const MAP_MAIN = (process.env.NODE_ENV === "test" && process.env.IX_VIEW_MAP_MAIN)
+ ? process.env.IX_VIEW_MAP_MAIN
+ : ${JSON.stringify(cliMainPath)};
+
+// One map at a time. execFile is asynchronous, so nothing else serialises them.
+let mapInFlight = null;
+
const MIME = {
".html": "text/html",
".js": "application/javascript",
@@ -242,6 +279,91 @@ const server = http.createServer((req, res) => {
return;
}
+ // Real /__ix/remap - rebuild the code map for the workspace this visualizer
+ // was launched from (its cwd), by running the CLI's map command against it. The
+ // stock endpoint was a stub that returned the SPA HTML.
+ //
+ // Loopback-only: this endpoint shells out with the user's privileges, so
+ // reject cross-site requests (CSRF / DNS-rebinding). Browsers send Origin on
+ // cross-site POSTs; curl and same-origin fetches either omit it or send a
+ // loopback origin. The Origin is parsed with the URL API rather than a regex
+ // because this snippet lives inside a template literal and regex backslashes
+ // would be consumed every time the server is regenerated by ix view start.
+ if (pathname === "/__ix/remap" && req.method === "POST") {
+ const origin = req.headers.origin || "";
+ // Strip the port, keeping a bracketed IPv6 literal intact ([::1]:8080 -> [::1]).
+ let host = (req.headers.host || "").toLowerCase();
+ host = host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host.split(":")[0];
+ const loopbackHost = host === "localhost" || host === "127.0.0.1" || host === "[::1]";
+ let loopbackOrigin = !origin;
+ if (origin) {
+ try {
+ const u = new URL(origin);
+ loopbackOrigin =
+ (u.protocol === "http:" || u.protocol === "https:") &&
+ (u.hostname === "localhost" || u.hostname === "127.0.0.1" || u.hostname === "[::1]") &&
+ // Our own port, not merely some loopback one. Any page served on any
+ // other localhost port — a dev server, a local docs site — can send a
+ // simple POST with no preflight, and accepting the whole loopback
+ // interface as one origin let it trigger a remap.
+ u.port === String(PORT);
+ } catch {
+ loopbackOrigin = false;
+ }
+ }
+ if (!loopbackHost || !loopbackOrigin) {
+ res.writeHead(403, { "Content-Type": "application/json" });
+ res.end(JSON.stringify({ ok: false, error: "forbidden: loopback only" }));
+ return;
+ }
+ // Nothing reads the request body, but leaving it unconsumed holds the
+ // stream open for the whole map.
+ req.resume();
+ // MAP_ROOT is the workspace this visualizer is showing, resolved once by
+ // ix view start and baked in. Mapping process.cwd() instead would follow
+ // whatever directory the detached server was launched from: --all does not
+ // require that to be a workspace at all, so "ix view start --all" run from
+ // a home directory turned one click into an ingest of the whole of it.
+ if (!MAP_ROOT) {
+ res.writeHead(409, { "Content-Type": "application/json" });
+ res.end(JSON.stringify({ ok: false, error: "remap needs a single workspace; this view was started with --all" }));
+ return;
+ }
+ if (mapInFlight) {
+ // execFile is async, so without this every POST starts another full
+ // ingest and Louvain pass over the same workspace.
+ res.writeHead(409, { "Content-Type": "application/json" });
+ res.end(JSON.stringify({ ok: false, error: "a remap is already running" }));
+ return;
+ }
+ if (!fs.existsSync(MAP_MAIN)) {
+ res.writeHead(500, { "Content-Type": "application/json" });
+ res.end(JSON.stringify({ ok: false, error: "ix CLI not found at " + MAP_MAIN }));
+ return;
+ }
+ // --silent because nothing here reads stdout, and the default text render
+ // is work done only to be thrown away. maxBuffer is raised anyway: the
+ // default 1 MiB makes Node SIGTERM the child mid-map, which surfaces as a
+ // 500 rather than as the truncation it is.
+ const child = execFile(process.execPath, [MAP_MAIN, "map", MAP_ROOT, "--silent"], { cwd: MAP_ROOT, timeout: 1800000, maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
+ mapInFlight = null;
+ if (res.destroyed) return; // client disconnected while mapping
+ res.writeHead(err ? 500 : 200, { "Content-Type": "application/json" });
+ res.end(JSON.stringify({ ok: !err, error: err ? String(stderr || err.message).slice(0, 400) : undefined }));
+ });
+ mapInFlight = child;
+ // Stop the map if the client goes away before we respond. res "close" fires
+ // on abnormal teardown too; writableEnded tells normal completion apart
+ // from a disconnect (IncomingMessage "close" can fire on request completion
+ // in some Node versions, which would kill the map mid-flight).
+ //
+ // Killing mid-map is safe: the ingest baseline is only persisted after a
+ // clean run, so an interrupted map re-ingests next time rather than
+ // recording files as done that never landed.
+ res.on("close", () => { if (!res.writableEnded) { try { child.kill(); } catch {} } });
+ return;
+ }
+
// Serve static files
let filePath = path.join(DIST, pathname === "/" ? "index.html" : pathname);
@@ -271,7 +393,7 @@ const server = http.createServer((req, res) => {
});
});
-server.listen(PORT, () => {
+server.listen(PORT, "127.0.0.1", () => {
// Server ready — parent already detached
});
`;
@@ -319,6 +441,12 @@ export function registerViewCommand(program: Command): void {
// X-Ix-Workspace on every /v1 call so Compass isolates by workspace without any
// workspace awareness of its own. --all opts out (show the whole backend).
const workspaceId = opts.all ? null : (resolveWorkspaceId() ?? null);
+ // Resolved the same way workspaceId is, so /__ix/remap re-maps exactly
+ // what the visualizer is showing. Null under --all, which deliberately
+ // scopes to nothing — there is no single workspace to rebuild.
+ const mapRoot = opts.all
+ ? null
+ : ((findWorkspaceForCwd(process.cwd()) ?? getDefaultWorkspace())?.root_path ?? null);
// If the launch directory is a multi-repo system, scope by system_id instead of
// workspace_id: co-ingested member repos live under their own workspace_ids, so a
@@ -406,7 +534,7 @@ export function registerViewCommand(program: Command): void {
// Write server script to temp location
const scriptDir = dirname(SERVER_SCRIPT_FILE);
mkdirSync(scriptDir, { recursive: true });
- writeFileSync(SERVER_SCRIPT_FILE, serverScript(distDir, port, workspaceId, systemId));
+ writeFileSync(SERVER_SCRIPT_FILE, serverScript(distDir, port, workspaceId, systemId, mapRoot));
// Spawn detached process
const child = spawn("node", [SERVER_SCRIPT_FILE], {
diff --git a/skills/ix/scripts/bootstrap.sh b/skills/ix/scripts/bootstrap.sh
index c853daa7..c649ef54 100644
--- a/skills/ix/scripts/bootstrap.sh
+++ b/skills/ix/scripts/bootstrap.sh
@@ -39,8 +39,14 @@ info() { printf '\033[1;36m[ix-skill]\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[ix-skill]\033[0m %s\n' "$*"; }
fail() { printf '\033[1;31m[ix-skill]\033[0m %s\n' "$*" >&2; exit 1; }
-# Detect Windows (Git Bash / MSYS2 / Cygwin).
-is_windows() { [ -n "${MSYSTEM:-}" ] || [ -n "${WSL_DISTRO_NAME:-}" ] || case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) return 0 ;; *) return 1 ;; esac; }
+# Detect Windows (Git Bash / MSYS2 / Cygwin). WSL is Linux: it reports
+# uname = Linux and must take the curl|sh path, not the PowerShell installer,
+# so WSL_DISTRO_NAME is deliberately not treated as Windows here.
+#
+# MSYSTEM stays. Dropping it along with the WSL check was collateral — uname
+# does report MINGW*/MSYS* under Git Bash, so it looked redundant, but it is
+# the belt to that braces and its removal was never the fix.
+is_windows() { [ -n "${MSYSTEM:-}" ] || case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) return 0 ;; *) return 1 ;; esac; }
version_ge() { # version_ge <got> <want>
# `sort -C` succeeds when its input is already in order, so feeding it
@@ -55,10 +61,9 @@ command_exists() { command -v "$1" >/dev/null 2>&1; }
info "Ix skill bootstrap — repo: $REPO"
# --- Prerequisites -----------------------------------------------------------
-node_ok=0
if command_exists node; then
node_ver="$(node --version | tr -d 'v')"
- if version_ge "$node_ver" "22"; then node_ok=1; else warn "Node $node_ver detected; Ix requires Node >= 22."; fi
+ if ! version_ge "$node_ver" "22"; then warn "Node $node_ver detected; Ix requires Node >= 22."; fi
else
warn "Node.js not found; Ix requires Node >= 22 (https://nodejs.org)."
fi
@@ -138,7 +143,11 @@ fi
# --- Backend ------------------------------------------------------------------
if [ "$DO_BACKEND" = "1" ]; then
info "Starting the Ix backend (ArangoDB + memory layer)…"
- ix docker start || warn "`ix docker start` reported a problem — run `ix doctor` and `ix status` for details."
+ # Single quotes: inside double quotes these backticks were command
+ # substitutions, so the failure path re-ran 'ix docker start' and then ran
+ # 'ix doctor' and 'ix status', splicing their output into the message and
+ # leaving the user with the command names stripped out of the advice.
+ ix docker start || warn 'ix docker start reported a problem — run: ix doctor, then ix status'
for _ in $(seq 1 15); do
if ix status >/dev/null 2>&1; then break; fi
sleep 2