Skip to content

[bug] opencli antigravity serve fails with ERR_MODULE_NOT_FOUND — dynamic import path off by one .. #1785

@LeoLin990405

Description

@LeoLin990405

Repro

$ opencli antigravity serve --port 8082
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  '/Users/leo/.npm-global/lib/node_modules/@jackwener/opencli/dist/clis/antigravity/serve.js'
    at ModuleLoader.resolveSync (node:internal/modules/esm/loader:749:52)
  • opencli v1.8.0 (npm @jackwener/opencli)
  • macOS 26.4.0 (Darwin arm64)
  • node v26.0.0

Root cause

dist/src/cli.js line 3056:

const { startServe } = await import('../clis/antigravity/serve.js');

cli.js lives at dist/src/cli.js. Relative '../clis/antigravity/serve.js' resolves to dist/clis/antigravity/serve.js, but the bundled source is at <package_root>/clis/antigravity/serve.js (one level up — not under dist/).

Verified the package layout in npm root -g:

@jackwener/opencli/
├── clis/antigravity/serve.js   ← actual location
├── dist/
│   └── src/cli.js              ← contains the broken `import('../clis/...')`
└── package.json

One-line fix

-        const { startServe } = await import('../clis/antigravity/serve.js');
+        const { startServe } = await import('../../clis/antigravity/serve.js');

(Or, if you prefer, use `url.fileURLToPath(import.meta.url)` + `path.resolve` for robustness.)

Local workaround (verified)

sed -i '' \"s|'../clis/antigravity/serve.js'|'../../clis/antigravity/serve.js'|g\" \\
  \$(npm root -g)/@jackwener/opencli/dist/src/cli.js

After patch:

  • `opencli antigravity serve --port 8082` listens correctly
  • `curl -X OPTIONS http://localhost:8082/v1/messages\` returns `HTTP 204`
  • End-to-end Anthropic-API call to Antigravity works

Audit suggestion

Worth grepping the rest of `dist/src/cli.js` for other `import('../clis/...` dynamic imports that may have the same off-by-one issue. If only `antigravity/serve` is affected, single-line fix is enough.

Volunteer

Will follow this up with a PR (forking now).

Discovered while

Building a 5-surface bridge layer on top of opencli for orchestrating multi-agent code review pipelines from Claude Code. opencli's `antigravity serve` HTTP proxy is the cleanest path for synchronous push-and-wait IPC between Claude and Antigravity — losing it forces fallback to fragile DOM polling. Hence the 1-line fix matters disproportionately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions