Skip to content

First-run fixes: OPENAI_BASE_URL and CLI entrypoint regression test - #145

Open
PatrickSys wants to merge 3 commits into
masterfrom
cursor/first-run-fixes-16ec
Open

PatrickSys wants to merge 3 commits into
masterfrom
cursor/first-run-fixes-16ec

Conversation

@PatrickSys

Copy link
Copy Markdown
Owner

First-run report (clean VM, Node v22.23.4)

Followed README.md literally with npx -y codebase-context (published 2.2.0) and compared against this branch’s 2.3.0 tarball (npx -y file:/…/codebase-context-2.3.0.tgz). MCP smoke: single-line initialize over stdio returned serverInfo 2.3.0.

Repos exercised

Repo Language Command Result
sindresorhus/is TypeScript (small) reindex, search, map See below
psf/requests Python reindex --no-embeddings, search --query "session adapter" Index ~0.41s; search returned sessions.py / adapters.py (low-confidence banner shown)
expressjs/express JavaScript reindex --no-embeddings Index ~1.2s, 155 files

What broke or confused (published 2.2.0)

  1. CLI via npx is a silent no-op (blocker).

    • Commands: npx -y codebase-context reindex, npx -y codebase-context --version, npx -y codebase-context status
    • Output: empty stdout/stderr, exit 0, no .codebase-context/ created.
    • Cause: npm’s bin shim resolves to a path that does not end with index.js, so 2.2.0 never sets isDirectRun and skips CLI dispatch.
    • Evidence: node node_modules/codebase-context/dist/index.js reindex on the same install does index (~13s with embeddings on is).
    • Already fixed on master (2.3.0) via canonical realpath entrypoint detection; verified: npx -y file:…/codebase-context-2.3.0.tgz reindex --no-embeddings and --version print 2.3.0 and complete indexing.
  2. First npx install noise (~14s on cold cache). Deprecation warnings (boolean, uuid, glob, node-domexception) — not fatal but noisy for a “5 minute” story.

  3. README vs npm skew. README documents unpublished init / model-free defaults (2.4.0 candidate) while npm is still 2.2.0; accurate but easy to misread. Workspace version is 2.3.0 (unpublished).

  4. OPENAI_BASE_URL ignored (issue Feature Request: Support custom OpenAI-compatible API endpoints (OPENAI_BASE_URL) #70). Workaround for Transformers/onnx mutex (Bug Report: Mutex Lock Failed During Indexing on Intel Mac #68) requires pointing OpenAI provider at Ollama; env var was not wired into defaults.

What this PR fixes

  • OPENAI_BASE_URL → DEFAULT_EMBEDDING_CONFIG.apiEndpoint (trailing slash stripped); documented in docs/capabilities.md; tests in tests/embedding-config-env.test.ts and tests/openai-embeddings.test.ts.

  • Regression test for npm-style bin symlink (codebase-context → index.ts) running reindex --no-embeddings without loading MCP stdio (tests/cli-entrypoint-runtime.test.ts).

What’s left (ranked)

Priority Item Severity Effort
1 Publish ≥2.3.0 to npm so README/npx path matches fixed CLI entrypoint Blocker for new users on 2.2.0 Release process (out of scope here)
2 #71 Native Ollama provider High for local/offline embeddings without OpenAI shim Medium
3 #68 Intel/macOS mutex (onnxruntime 1.21 via Transformers) High on affected Macs Blocked on upstream; mitigated by OpenAI-compat + #70
4 #70 custom endpoints Medium Addressed in this PR (env wiring)
5 Reduce first-install deprecation noise Low Dependency bumps
6 README clarity on published vs unreleased features Low Doc pass

Open issue triage

Verification

  • pnpm test -- tests/openai-embeddings.test.ts tests/embedding-config-env.test.ts tests/cli-entrypoint-runtime.test.ts
  • End-to-end: npx -y file:/workspace/codebase-context-2.3.0.tgz reindex --no-embeddings on sindresorhus/is (after pack) succeeded with status box output.
Open in Web Open in Cursor 

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T22:14:22.497816Z 1d76560 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The runtime effect is limited to OpenAI-compatible embedding requests.

Fix the Windows symlink test before merging; it fails on machines without symlink privileges.

Findings

  1. P1 Windows tests fail ▶
  2. P2 Watch mode falsely fails ▶

Summary

This PR wires OPENAI_BASE_URL into embedding defaults and adds endpoint and CLI regression tests.

  • OpenAI embeddings can use the service named by OPENAI_BASE_URL.
  • The CLI runtime test runs reindex through an npm-style symlink.

Reviews (1) · Last reviewed commit: "test(cli): cover reindex via npm-style b..." · Reviewed by Greptile


await writeFile(join(projectRoot, 'example.ts'), 'export const value = 1;\n');
await mkdir(tempDirectory, { recursive: true });
symlinkSync(entrypoint, linkedEntrypoint, 'file');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Windows tests fail

If a Windows contributor lacks permission to create symlinks, symlinkSync throws before this test reaches its cleanup block. The suite fails and leaves both temporary directories behind. Use the same Windows skip guard as the symlink test immediately below, and clean up both directories when setup fails.

Comment on lines +16 to +17
vi.unstubAllEnvs();
const { DEFAULT_EMBEDDING_CONFIG } = await import('../src/embeddings/types.js');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Watch mode falsely fails

vi.unstubAllEnvs() restores the original environment; it does not unset OPENAI_BASE_URL. If a contributor has that variable set, test:watch gets a false failure because it bypasses the normal test wrapper’s environment filter. Explicitly unset the variable with vi.stubEnv('OPENAI_BASE_URL', undefined) before importing the defaults.

Suggested change
vi.unstubAllEnvs();
const { DEFAULT_EMBEDDING_CONFIG } = await import('../src/embeddings/types.js');
vi.stubEnv('OPENAI_BASE_URL', undefined);
const { DEFAULT_EMBEDDING_CONFIG } = await import('../src/embeddings/types.js');

OPENAI_BASE_URL wiring is useless if a cached OpenAI client keeps the first endpoint.
@cursor

cursor Bot commented Oct 30, 2026

Copy link
Copy Markdown

Adversarial review (maintainer)

Verdict: merge (small, targeted; ship before #142).

What I verified: Built on clean pnpm install, 1307 passed (+7 skipped), symlink entrypoint reindex/--help tests, MCP stdio initialize → 2.3.0, CLI on /workspace and zod (~560 files, ~6s --no-embeddings reindex). OPENAI_BASE_URL tests look correct.

What I fixed (pushed 4f9867d): getEmbeddingProvider cached only provider:model, so changing OPENAI_BASE_URL mid-process (or between tests) could keep hitting the first endpoint. Cache key now includes apiEndpoint and apiKey; added tests/embedding-provider-cache.test.ts.

Left (not this PR): DEFAULT_EMBEDDING_CONFIG still snapshots env at module import (documented limitation); native EMBEDDING_PROVIDER=ollama still warns/falls back (#71); npm 2.2.0 silent CLI remains until publish ≥2.3.0.

Conflict note: #142 touches overlapping init/docs paths — merge this first, then rebase #142.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants