Skip to main content

Development and testing

Clone, run the backend in watch mode, test the suite you touched, and follow GUIDELINES.md for every change.

Requirements​

ToolVersion
Node.js>=20.19.0; CI tests Node 20 and 22
npmShips with Node.js
FlutterStable channel; CI pins 3.47.9
ESP-IDFOnly for wearable firmware

Setup​

git clone https://github.com/NeoLabs-Systems/NeoAgent.git
cd NeoAgent
npm ci
export NEOAGENT_HOME="$HOME/.neoagent-dev"
npm run dev:backend
  • Separate data. Without NEOAGENT_HOME, development shares ~/.neoagent with a real install.
  • Checkout .env. A .env in the repository root is loaded before NEOAGENT_HOME/.env and copied there if that file is missing.
dev:backend frees port 3333 by force

dev/backend.sh runs kill -9 on whatever listens on port 3333, including an installed NeoAgent service.

Dev scripts​

CommandRuns
npm run dev:backendnode --watch server/index.js after freeing port 3333 (dev/backend.sh prod runs npm start)
npm run flutter:run:webFlutter web client in Chrome against NEOAGENT_BACKEND_URL (default http://localhost:3333)
npm run dev:webflutter run -d chrome on port 54009 with NEOAGENT_BACKEND_URL=http://localhost:3333
npm run dev:stackdev:backend and dev:web together, stopping a stale NeoAgent on the port first
npm run dev:testnpm test, node --check on entry points, flutter analyze
npm startnode server/index.js without watch

Point it at another backend with NEOAGENT_BACKEND_URL=http://192.168.1.20:3333 npm run flutter:run:web.

Never build the web client locally

These run flutter build web and overwrite server/public, which only the release pipeline builds:

  • npm run flutter:build:web
  • npm run dev:build
  • neoagent rebuild-web, and neoagent install from a checkout when Flutter is on PATH

They also run flutter upgrade when Flutter is older than REQUIRED_FLUTTER_VERSION in lib/install_helpers.js, as does neoagent update.

Tests​

CommandRuns
npm run test:unittest/backend/unit/*.test.js
npm run test:integrationtest/integration/*.test.js
npm run test:securitytest/security/*.test.js
npm run test:contracttest/contract/*.test.js
npm run test:e2etest/e2e/*.test.js
npm run test:wstest/websocket/*.test.js
npm run test:harnesstest/harness_eval/*.test.js: the scripted harness evals and the regression gate
npm run test:backend (npm test)The seven suites above, chained with &&
npm run flutter:testtest/flutter/unit and test/flutter/widget
npm run flutter:test:unit, flutter:test:widgetOne Flutter folder
bash test/install/install_smoke_test.shRepository install in temporary directories
  • Harness evals. npm run eval:harness runs fixed cases through the real run path with a scripted model: duplicate delivery, repeated tools, recovery, memory, coding, injection, and telemetry. Duplicate messages and security failures have no tolerance. -- --live --model provider::id --repeat 3 gives a real model the tool-choice cases and requires every repeat to pass; compare harness versions on the same model and settings, or the result measures the model. -- --update-baseline stores a new baseline.
  • Chained suites. test:backend stops at the first failing suite; run the remaining suites one by one to see their results.
  • App-local Flutter tests. flutter_app/test/ (call, launcher, loading, mascot) is outside flutter:test; run flutter test inside flutter_app.
  • Analyzer. cd flutter_app && flutter analyze --no-pub uses analysis_options.yaml.
One unit test needs an Alpine ISO
  • Where it runs. test/backend/unit/qemu_ramfb_display.test.js runs on arm64 hosts with qemu-system-aarch64 and edk2 firmware; elsewhere it skips.
  • What it needs. /tmp/neoagent-display-test/alpine-virt-aarch64.iso; without it the test fails and test:backend stops.

Other checks​

CommandChecks
npm run setup:contract:checkflutter_app/lib/src/setup_contract.g.dart matches lib/setup/contract.json
npm run audit:cinpm audit of production dependencies at high severity
npm run docs:buildDocusaurus build; broken links fail it

CI​

.github/workflows/ci.yml runs on pushes to main, beta and dev, and on pull requests to beta.

JobSteps
Backend testsnpm ci, npm run test:backend on Node 20 and 22
Flutter testsflutter pub get, flutter analyze --no-pub, npm run flutter:test

Server conventions​

GUIDELINES.md is the full rule set; the essentials:

  • Modules. CommonJS only; every new server file starts with 'use strict';.
  • Layers. Routes parse, call a service and respond; business logic lives in server/services/.
  • Database. Only through server/db/database.js, synchronous and parameterized; schema changes go through the migration layer.
  • Models. LLM calls go through server/services/ai/engine.js; provider SDKs are imported only in server/services/ai/providers/.
  • Tools. Schemas and metadata in server/services/ai/tools/definitions/, code in tools/handlers/; large results pass through compactToolResult().
  • Paths and env. Use runtime/paths.js constants and runtime/env.js helpers.
  • Logging. server/utils/logger.js with a [ServiceName] prefix; log secrets only as boolean presence.
  • New env keys. Add them to .env.example and to logStartupConfig() in server/index.js.

Flutter conventions​

  • State. MainController is the single root ChangeNotifier; no other state packages.
  • Thin widgets. Logic goes in lib/src/<feature>_bridge.dart or lib/src/<feature>_service.dart.
  • Platforms. Use the _io, _web and _stub conditional-export files, not inline kIsWeb branches.
  • Cleanup. Cancel every stored subscription and listener in dispose().

Wearable firmware​

bash scripts/flash_wearable.sh --port /dev/cu.usbmodem1101
  • Toolchain. Needs ESP-IDF on PATH, in IDF_PATH, or at ~/esp/esp-idf.
  • Options. --erase, --monitor and --skip-build; the port is an example.

Contributions​

  • Target branch. Pull requests go to beta, never main.
  • Scope. Keep changes focused, add tests for behavior changes, and update docs for new commands or settings.
  • Never commit. .env, data/, agent-data/ or anything in .gitignore; do not use --no-verify.
  • Changelog. GitHub Releases are the release history; do not add CHANGELOG.md.

See CONTRIBUTING.md for the review process.