Development and testing
Clone, run the backend in watch mode, test the suite you touched, and follow GUIDELINES.md for every change.
Requirements
| Tool | Version |
|---|---|
| Node.js | >=20.19.0; CI tests Node 20 and 22 |
| npm | Ships with Node.js |
| Flutter | Stable channel; CI pins 3.47.9 |
| ESP-IDF | Only 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~/.neoagentwith a real install. - Checkout
.env. A.envin the repository root is loaded beforeNEOAGENT_HOME/.envand copied there if that file is missing.
dev:backend frees port 3333 by forcedev/backend.sh runs kill -9 on whatever listens on port 3333, including an installed NeoAgent service.
Dev scripts
| Command | Runs |
|---|---|
npm run dev:backend | node --watch server/index.js after freeing port 3333 (dev/backend.sh prod runs npm start) |
npm run flutter:run:web | Flutter web client in Chrome against NEOAGENT_BACKEND_URL (default http://localhost:3333) |
npm run dev:web | flutter run -d chrome on port 54009 with NEOAGENT_BACKEND_URL=http://localhost:3333 |
npm run dev:stack | dev:backend and dev:web together, stopping a stale NeoAgent on the port first |
npm run dev:test | npm test, node --check on entry points, flutter analyze |
npm start | node 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:webnpm run dev:buildneoagent rebuild-web, andneoagent installfrom a checkout when Flutter is onPATH
They also run flutter upgrade when Flutter is older than REQUIRED_FLUTTER_VERSION in lib/install_helpers.js, as does neoagent update.
Tests
| Command | Runs |
|---|---|
npm run test:unit | test/backend/unit/*.test.js |
npm run test:integration | test/integration/*.test.js |
npm run test:security | test/security/*.test.js |
npm run test:contract | test/contract/*.test.js |
npm run test:e2e | test/e2e/*.test.js |
npm run test:ws | test/websocket/*.test.js |
npm run test:harness | test/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:test | test/flutter/unit and test/flutter/widget |
npm run flutter:test:unit, flutter:test:widget | One Flutter folder |
bash test/install/install_smoke_test.sh | Repository install in temporary directories |
- Harness evals.
npm run eval:harnessruns 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 3gives 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-baselinestores a new baseline. - Chained suites.
test:backendstops 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 outsideflutter:test; runflutter testinsideflutter_app. - Analyzer.
cd flutter_app && flutter analyze --no-pubusesanalysis_options.yaml.
One unit test needs an Alpine ISO
- Where it runs.
test/backend/unit/qemu_ramfb_display.test.jsruns on arm64 hosts withqemu-system-aarch64and edk2 firmware; elsewhere it skips. - What it needs.
/tmp/neoagent-display-test/alpine-virt-aarch64.iso; without it the test fails andtest:backendstops.
Other checks
| Command | Checks |
|---|---|
npm run setup:contract:check | flutter_app/lib/src/setup_contract.g.dart matches lib/setup/contract.json |
npm run audit:ci | npm audit of production dependencies at high severity |
npm run docs:build | Docusaurus build; broken links fail it |
CI
.github/workflows/ci.yml runs on pushes to main, beta and dev, and on pull requests to beta.
| Job | Steps |
|---|---|
| Backend tests | npm ci, npm run test:backend on Node 20 and 22 |
| Flutter tests | flutter 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 inserver/services/ai/providers/. - Tools. Schemas and metadata in
server/services/ai/tools/definitions/, code intools/handlers/; large results pass throughcompactToolResult(). - Paths and env. Use
runtime/paths.jsconstants andruntime/env.jshelpers. - Logging.
server/utils/logger.jswith a[ServiceName]prefix; log secrets only as boolean presence. - New env keys. Add them to
.env.exampleand tologStartupConfig()inserver/index.js.
Flutter conventions
- State.
MainControlleris the single rootChangeNotifier; no other state packages. - Thin widgets. Logic goes in
lib/src/<feature>_bridge.dartorlib/src/<feature>_service.dart. - Platforms. Use the
_io,_weband_stubconditional-export files, not inlinekIsWebbranches. - 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, inIDF_PATH, or at~/esp/esp-idf. - Options.
--erase,--monitorand--skip-build; the port is an example.
Contributions
- Target branch. Pull requests go to
beta, nevermain. - 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.