Source of the pubnub npm package and CDN bundles (Node, browsers, React Native). Customers depend on its public
types and realtime behavior, so small behavior changes can break them.
- Install:
npm install, asrun-tests.ymldoes. Use Node 22 or 24, the CI matrix. Mocha fails at startup on Node 26; that's environmental, not an SDK bug. - Build (no keys needed):
npm run build:node(tsc →lib/+ aggregatedlib/types/index.d.ts) ·npm run build:web(rollup →dist/web/). Runbuild:nodebefore thereleaseornodesuite whensrc/changed sincelib/types/index.d.tswas built, or that file is missing. - Typecheck:
npm run typecheck. It covers Node sources only; browser/worker sources are type-checked bybuild:web. - Lint:
npm run lint(src/ only) - Test, one file:
.scripts/agent-test.sh test/unit/publish/publish.test.ts [--grep '<re>'] - Keyless tests:
.scripts/agent-test.sh unitruns with no env keys; nock mocks all HTTP.integrationalso passes without keys, excepttest/integration/endpoints/data_sync/(35 tests), which needs theDS_*keys. - Other suites:
releaseandnodeneedbuild:nodewhensrc/changed sincelib/types/index.d.tswas built, or that file is missing.nodealso needs theDS_*keys. Browser, live-key and contract suites → sdk-test skill, ask first. - Wrap any noisy command:
.scripts/agent-test.sh npm run build:nodeprints one line on pass and only the failures on fail. - Don't call mocha/karma/cucumber directly: mocha without
--no-configsilently runs the whole suite. - Inspect logs with
grep/tail; never read a full log. - Each edit to
src/runseslint --fix(includes prettier) and each edit totest/runs prettier, via the PostToolUse hook.agents/hooks/post-edit-format.sh. Nothing runs the secret scan.
src/core/: shared public API.pubnub-common.ts(PubNubCore),endpoints/(oneAbstractRequestsubclass per REST call),components/,types/api/src/event-engine/: subscribe/presence state machines, on by default.enableEventEngine: falseusescore/components/subscription-manager.tsinsteadsrc/transport/: platform transports.middleware.tsowns auth, signatures and request retries;subscription-worker/is the browser SharedWorkersrc/{node,web,react_native}/: entry points. No build config compilessrc/{titanium,nativescript}/.lib/,dist/web/: committed build output. Regenerate it with the build commands; never edit or search it.test/unit,test/integration: mocha + chai/sinon/nock with network disabled; helpers intest/utils.tstest/dist,test/feature,test/integration/shared-worker: live-network suites, excluded from.mocharc.json
- Timetokens are strings (they exceed 2^53). Never convert them to numbers.
- Public methods expose callback and Promise overloads; keep both when changing a signature.
- Optional modules are gated by
process.env.<NAME>_MODULE. Rollup'sreplaceConfigurationsubstitutes them in web bundles only (PAM is off by default there); Node evaluates them at runtime. Add any new flag toreplaceConfiguration. src/core,src/entitiesandsrc/event-enginemust not import Node- or browser-only APIs.- Mark non-public declarations
@internal;stripInternaldrops them from the published types. - Validation, defaults, error text and null/undefined handling are customer-visible. Never "fix" them as incidental cleanup.
-
Always: end every change or review with these four fields:
- breaking change (yes/no/uncertain, with evidence)
- behavior change, however small
- validation actually run vs skipped
- customer impact
A skipped or zero-test run is not a pass. PR titles and bodies follow
.github/pull_request_template.md. -
Always: when you change a command, script or test prerequisite, update this file or the affected skill in the same change.
-
Always: run one test or build command at a time (
ci:*and builds wipelib/anddist/). Refer to key env vars by name; never print their values. -
Ask first: public API signature or type changes · new dependencies · live-network or real-key suites · endpoint wire-format changes. There are no OpenAPI specs in this repo: ask for the operation's spec rather than inferring it from code.
-
Never (each is enforced by a hook or CI):
- hand-edit
lib/,dist/,package-lock.json,CHANGELOG.md,.pubnub.yml,.env*or key files →.agents/hooks/protect-files.sh - force-push or use
--no-verify→.agents/hooks/git-policy.sh - commit secrets → not enforced yet; no secret-scan hook or CI step runs (gitleaks was in the removed pre-commit config)
- finish with a failing typecheck →
.agents/hooks/quick-check.sh
- hand-edit
Skills live in .agents/skills/. Read only the one the task needs.
- Internals, per-module invariants and test locations → sdk-architecture
- Feature or endpoint → sdk-feature · Bug → sdk-debug
- Refactor → sdk-refactor · Review → sdk-review
- Choosing, writing or running tests → sdk-test
- Finalizing a PR (rebuild artifacts, release bot) → sdk-release
- Dependency upgrade → sdk-deps
- Delegate mechanical work (running suites, log triage, file moves,
.scripts/check-agent-docs.sh) to a subagent on a light model (e.g. Haiku) that returns only a summary. Keep design, debugging and review on the main model.