Skip to content

feat: npx support — no global install required#9

Merged
willynikes2 merged 6 commits intomasterfrom
feat/npx-support
Mar 23, 2026
Merged

feat: npx support — no global install required#9
willynikes2 merged 6 commits intomasterfrom
feat/npx-support

Conversation

@willynikes2
Copy link
Copy Markdown
Owner

Summary

  • Config (.env, setup-config.json, docker-compose.yml) now lives in ~/.knowledge-base/ alongside the DB
  • npx knowledge-base-server start works out of the box from any directory
  • Setup wizard detects npx context and warns about persistent service limitations
  • systemd/launchd services use resolved kb binary path via which kb
  • Docker compose uses image: node:22-slim + npx instead of build: .
  • Lean npm package via files field (bin/, src/, openapi.json only)

What changed

  • src/paths.js — canonical .env loading from ~/.knowledge-base/.env, exports ENV_PATH
  • bin/kb.js, bin/weekly-synthesis.js — use paths.js instead of dotenv/config
  • src/cli/setup.js — removed PROJECT_ROOT, writes to KB_DIR, npx detection, docker fix
  • kb-server-install.sh, kb-server.service.example — use resolved kb path
  • bin/cron-capture.sh — uses ~/.knowledge-base/.env and kb CLI
  • EXTENDING.md — updated .env documentation
  • package.json — fixed main entry, added files field

Test plan

  • 37 tests passing (9 suites, 0 failures)
  • New tests/paths.test.js — verifies ENV_PATH export
  • New tests/setup.test.js — verifies no PROJECT_ROOT references remain
  • New tests/npx-compat.test.js — 5 integration tests (run from /tmp, .env loading, openapi.json)
  • MCP stdio works from /tmp (no CWD dependency)
  • Server starts from /tmp, API responds
  • kb-server systemd service restarted and healthy
  • OpenAPI endpoint serves correctly

Review history

Plan reviewed by Claude, OpenAI Codex (GPT-5.4), and Google Gemini across 3 rounds. Issues found and fixed:

  • Codex: openapi.json missing from files whitelist, CWD fallback breaks with systemd WD=$HOME
  • Gemini: docker build: . breaks in ~/.knowledge-base/, cron-capture.sh stale paths, EXTENDING.md docs
  • Claude: PROJECT_ROOT not fully removed, weak tests, weekly-synthesis.js missed

Closes #5

🤖 Generated with Claude Code

willynikes2 and others added 6 commits March 23, 2026 18:21
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace PROJECT_ROOT with KB_DIR/ENV_PATH from paths.js for .env,
  setup-config.json, and docker-compose.yml writes
- Update generateDockerCompose to use npx image and KB_DIR output path
- Add isNpx() helper and warn users when persistent services are chosen
  under npx (ephemeral cache)
- Remove unused fileURLToPath import and PROJECT_ROOT constant

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ain entry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@willynikes2 willynikes2 merged commit a7dd21a into master Mar 23, 2026
@willynikes2 willynikes2 deleted the feat/npx-support branch March 23, 2026 18:30
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.

Can install use NPX instead of needing to pre-install?

1 participant