Skip to content

Latest commit

 

History

History
103 lines (79 loc) · 4.3 KB

CONTRIBUTING.md

File metadata and controls

103 lines (79 loc) · 4.3 KB

Contributing

Getting set up

npm ci
npm run build     # tsc
npm test          # vitest

Node 22 or newer (engines: node >=22). CI runs the suite on Node 24 across Ubuntu and Windows, and separately checks that the package still builds and tests on Node 22 so the published engines claim stays honest.

Windows without Visual Studio Build Tools: both npm ci and npm install fail compiling better-sqlite3 even though the package ships prebuilt binaries — npm ignores the package's gypfile: false and runs the implicit node-gyp rebuild. Use npm ci --ignore-scripts (the prebuild in the tarball is used as-is), or install the MSVC C++ workload. npm install was the recommendation here until 2026-09-22, when it started failing the same way on npm 10.9.x — it is no longer a workaround. Consumers of the published package are unaffected: a plain npm install @fozikio/cortex-engine into a fresh project resolves the prebuild and needs no toolchain.

Windows is in the test matrix on purpose: service supervision is platform-specific — detached spawning, taskkill and PID handling all differ there — and an Ubuntu-only gate cannot see any of it.

Before you open a PR

npm run build            # must be clean
npm test                 # must be green
npm audit --audit-level=high
npm run verify:package   # only if you touched `files` or the build output

verify:package exists because the web dashboard silently stopped shipping at 1.2.2 — a files entry was omitted and nothing caught it. If you add an asset that must reach the published tarball, the files entry and the build step that produces it have to land in the same PR. Adding the entry first fails the publish; adding the build step first silently ships nothing.

Commit messages

Conventional Commits, with a scope where it adds clarity:

type(scope): summary

Types: feat, fix, chore, docs, refactor, test, ci, build, perf, security, style, revert.

The body should explain why. The diff already shows what changed. A commit that fixes a subtle bug should leave behind the reasoning that made it subtle, not a restatement of the patch.

Pull requests

This repository is on the Production workflow tier:

  • No direct pushes to master — every change goes through a PR.
  • The merge gate is the local-ci commit status, required by the master ruleset. A maintainer runs npm run ci:local -- <pr-branch> on the PR's final head: it checks the commit out into a throwaway worktree, runs the same type check, build, tests and high-severity audit as CI, and posts the status. Merges never wait on GitHub Actions minutes.
  • GitHub Actions CI (one job: Node 22 then Node 24, on non-draft PRs) is a second opinion from a clean Linux box. A real failure there still gets fixed before merging; a run that never started for billing reasons says nothing about the code.
  • Branches must be up to date with master before merging, so re-run ci:local after updating a branch.

Dependencies

Security fixes are preferred as lockfile-only changes (npm audit fix without --force). Two cautions learned the hard way:

  • npm audit fix --force will propose downgrades. It suggests the newest version its advisory data marks clean, which can be several majors below what you run. Read the proposed version before accepting it.
  • A green audit is not proof of a working tree. A dependency whose fix shipped alongside an ESM migration can satisfy npm audit and tsc while throwing at runtime for CommonJS callers. Run the suite after any override.

Use overrides to pin a transitive dependency; several are already in place.

Optional peer dependencies

Cloud and embedding providers are optional peers loaded through dynamic import(). If you add one, it must be:

  1. listed in peerDependencies and peerDependenciesMeta as optional,
  2. mirrored into devDependencies so tests can exercise it, and
  3. actually imported.

Point 3 is not rhetorical — openai and @anthropic-ai/sdk sat in all three lists for months while nothing imported them, because both providers speak HTTP through providers/openai-compatible.ts via native fetch. They generated a recurring dependency-drift finding for a decision that did not exist. Declare a peer only when something loads it.