Skip to content

Contributing

Vitor edited this page Dec 3, 2026 · 3 revisions

Contributing to botticelli

Status: botticelli is under construction (M0 to M3b built). These rules apply from the first pull request. Read CONTEXT.md first: its terms are used exactly, in code, docs, commits and issues.

In one minute

Branch from dev as feat/…, fix/… or docs/…. Write the test first and watch it fail. Make it pass. Run npm run typecheck && npm run lint && npm test. Update the docs and CHANGELOG.md. Open a pull request to dev with Closes #N. No live network in unit tests, no native dependencies, no secrets in the diff.

Setup

Requirements: Node.js >=22.19.0 and npm. Nothing else.

git clone https://github.com/vkmtx/botticelli.git
cd botticelli
git switch dev
npm ci
npm run typecheck && npm run lint && npm test
Script What it does
npm run build Compile src/ to dist/ (tsc -p tsconfig.build.json)
npm run typecheck tsc --noEmit over src, test and config files
npm run lint Biome lint over the repo (lint only, no formatter)
npm test Offline suite (vitest). Never touches the network
npm run test:coverage The offline suite with a V8 coverage report in coverage/
npm run test:live Live canary against the real sources. Opt-in, by hand. Not run in CI

CI runs on every pull request and every push to dev and main:

  • test: typecheck, lint, test, build and npm pack --dry-run on Node 22, 22.19 (the minimum in engines) and 24. On Node 24 it also runs npm run test:coverage and uploads the report as an artifact; coverage is a report, not a gate.
  • smoke: packs the tarball, installs it into a temp prefix on Ubuntu, macOS and Windows, starts the installed botticelli over stdio and checks the tool list (node scripts/smoke.mjs <bin> runs the same check locally).
  • test-os: the offline suite on macOS and Windows.
  • deps (pull requests): dependency review fails on a moderate or worse advisory and on GPL-2.0, GPL-3.0 or AGPL-3.0 licenses.
  • docs: an offline link check over every Markdown file, actionlint over the workflows, and a dry run of the wiki sync.

CodeQL scans the code on the same events. The OpenSSF Scorecard runs on every push to dev (and by hand) and publishes its result to the badge in the README. Every action in .github/workflows/ is pinned to a full commit SHA with a version comment; Dependabot keeps them current.

Branch model

Branch Role
main Releases only. Protected. Nothing is committed to it directly
dev The default branch and the integration branch. Protected: it needs a pull request and a green CI
feat/<name> A new capability or milestone slice
fix/<name> A bug fix, including a moved Pinterest endpoint
docs/<name> Documentation only

Rules:

  • Branch from dev. Open the pull request into dev.
  • One pull request does one thing. Keep it reviewable.
  • Put Closes #N in the pull request body. Every slice of work has a GitHub issue.
  • Code goes on a branch before its first commit. Never commit to dev or main.

Commits

Conventional Commits with a scope:

<type>(<scope>): <summary in the imperative, lower case, no full stop>

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

Scopes:

Scope Covers
core src/core/: Ref and the other shared types, errors
pinterest src/sources/pinterest/
arena src/sources/arena/ (planned, M6)
pipeline src/pipeline/
library src/library/
cache src/cache/
server src/server/: MCP tools, handles, config
docs docs/, README, CONTRIBUTING, ADRs
brand The visual identity and its assets
ci .github/workflows/ and repo automation
deps Dependency updates (dependencies in package.json). Dependabot uses it
deps-dev Dev dependency updates. Dependabot uses it
release Version bumps and the release workflow

Pull request titles are linted by the pr-title workflow against these types and scopes: a scope is required, and the subject starts in lower case and has no full stop. The merge is a squash and uses the pull request title as the commit message, so the title is the commit.

A new source adapter uses its id as scope (for example arena). Add the scope to the table above and to .github/workflows/pr-title.yml in a pull request that lands before the adapter's, because pr-title runs from the base branch and would reject the adapter's own pull request.

Examples:

feat(pipeline): add dhash-based dedupe
fix(pinterest): stop failing over on network errors
docs(library): explain sidecar fields

Definition of done

A change is done when all of these are true:

  • Tests at the public seam cover the behaviour. They failed first.
  • npm run typecheck, npm run lint and npm test exit 0.
  • The docs in docs/ that describe the changed behaviour are updated. A built feature says built (Mx). Planned work says planned.
  • CHANGELOG.md has an entry under ## [Unreleased]. Dependabot pull requests are exempt from this rule and from Closes #N.
  • A decision gets an ADR in docs/adr/ (see below).
  • The pull request names the issue (Closes #N) and lists the tests run.

Tests

TDD at the public seam

Write the test first. Run it. See it fail because an assertion fails, not because an import is missing. Then write the code. A test that never failed proves nothing.

Test the public seams, not internals:

  • a Source (per adapter, with a fake transport);
  • the endpoint registry;
  • extractRefs;
  • the pipeline functions (input to output, pure);
  • the Library store (on a temporary folder);
  • the MCP tools (an SDK client against the server with a fake source).

Offline by default

  • Unit tests never use the network. The Pinterest tests pass a fake Transport and read saved responses from test/fixtures/.
  • Use temporary folders for anything written to disk. Never write to ~/.config or ~/.cache from a test. Pass registryFile or dir.
  • npm run test:live hits the real sources. It lives in test/live/, runs by hand, and is excluded from npm test and from CI. Run it when you change an adapter or an endpoint.
  • To record a new fixture, save a real response once, remove anything personal, and commit it under test/fixtures/<source>/.

Adding a Source adapter

Read ADR 0001 and Architecture first. Then:

  1. Open an issue for the adapter. Say which Capabilities it will have. Write an ADR if it makes a decision (for example how it authenticates).
  2. Create src/sources/<id>/ with an index.ts that exports create<Id>Source(options) and its option types. Add the id to your scope list in this file.
  3. Write the failing tests first, in test/<id>/, with a fake Transport and fixtures. Cover: search, a second page through the cursor, each optional method, an error answer, a network error, and a refused host.
  4. Implement Source from src/sources/types.ts:
    • id and capabilities(). Report only what works right now.
    • search(query, opts) returning Page with Refs and an opaque next.
    • Optional methods only if you implement them. Throw CapabilityError when one exists but is unavailable now.
    • fetchImage(url, size) that accepts only your Source's CDN hosts over HTTPS and throws RefusedError for anything else. Map thumb, medium, large and original to your CDN's renditions and fall back to the nearest.
  5. Map to Ref (src/core/types.ts). Fill source, a stable key, imageUrl, and every optional field you can: width, height, lowRes, sourceLink, sourceDomain, collection, author. Set id only if the source can look it up again.
  6. Use the shared errors (SourceError, NetworkError, CapabilityError, RefusedError). Never put a token or a cookie in a message.
  7. Add a live test in test/live/<id>.test.ts and run npm run test:live.
  8. Write the docs: a section in docs/sources.md with the Capability table, inputs and limits, a line in docs/configuration.md for any environment variable, and a CHANGELOG.md entry.
  9. Check the boundary: the pipeline, library and server must work with your Source without a change. If they need one, discuss it in the issue.

Registering a Source in the server is done in src/server/index.ts.

Fixing a broken endpoint

Pinterest changes its web resources. A fix is usually data, not code.

  1. Reproduce it: npm run test:live, or call the Capability from a script. Note the error and the date.
  2. Find what the site uses now. Open the page in your browser, open the network panel, filter on /resource/, and find the call that returns the pins (it has pinimg URLs in the response). Note the resource name, the X-Pinterest-PWS-Handler header, the source_url and the options.
  3. Add a Candidate to the right list in src/sources/pinterest/endpoints.default.json. Replace the values that change per call with placeholders: {query}, {query_uri}, {pin}, {username}, {slug}, {board_path}, {board_id}. Put the new Candidate first if the old one is dead for good. Keep the old one as a fallback if it still works for some users.
  4. Add a fixture with a trimmed real response, and a test that the new Candidate returns Refs.
  5. Run npm run test:live to see it work for real.
  6. Open a fix(pinterest): … pull request. Say in the body what changed on the site and when.

If extraction fails but the call works, the JSON shape changed. See extractRefs in src/sources/pinterest/extract.ts and add a fixture of the new shape. Details: Resilience.

Never include cookies, tokens or account data in a fixture, an issue or a pull request.

Architecture decisions (ADRs)

A decision that is hard to reverse, or that others will ask about, gets an ADR in docs/adr/.

  • File: docs/adr/NNNN-short-title.md, numbered in order.
  • Shape: # NNNN. Title, then Status: accepted (YYYY-MM-DD), then ## Context, ## Decision, ## Consequences.
  • A tradeoff recorded in an ADR is by design. Change it with a new ADR that supersedes it, not with a quiet code change.

House style

  • Vocabulary: use the terms of CONTEXT.md exactly: Ref, Source, Capability, Collection (inside a source) vs Board (in your Library), Library, Sidecar, Handle, Sheet vs Moodboard, Pipeline, Repost, Endpoint registry, Candidate, Hunter, Health. A new term goes into CONTEXT.md and docs/glossary.md in the same pull request.
  • TypeScript: strict, ESM, node: prefixes, .js suffix in relative imports, import type for types.
  • Comments: explain why, not what. Keep them short.
  • Docs: plain English. Short sentences. Second person in guides. No marketing words, no emoji. Every page starts with a title and a status line: built (Mx) or planned (Mx, #N). Describe as working only what exists in src/.
  • Links: relative links between docs must resolve.

Rules that never bend

  • No native dependencies (ADR 0003). Images are decoded in pure JS. playwright-core is optional and loaded lazily.
  • No shell execution. botticelli never runs a shell command.
  • Downloads stay inside the Library and only from allowed HTTPS CDN hosts.
  • Secrets stay out. Never commit cookies, tokens or .env files. Never put them in logs, errors, fixtures, issues or pull requests. If you leaked one, revoke it first, then tell the maintainer.
  • Vulnerabilities are reported privately through a GitHub Security Advisory. See SECURITY.md.
  • Be kind. See CODE_OF_CONDUCT.md.

Review checklist

Reviewers (and authors, before asking) check:

  • The change does what the issue says, and no more.
  • A test failed first and now passes. It tests the public seam.
  • No live network in unit tests. Fixtures contain no personal data.
  • Paths: anything written to disk goes through the Library's assertInside. Nothing is overwritten.
  • URLs: anything downloaded is HTTPS on an allowed host. Redirects are not followed blindly.
  • No secret in the diff, in a log line or in an error message.
  • Network errors do not trigger endpoint failover. Cursors do not fail over.
  • No native dependency. package.json changes are justified.
  • Capabilities report what works right now. Errors are the shared classes.
  • Docs and CHANGELOG.md are updated. Status lines are honest.
  • Commits follow Conventional Commits with a scope. The pull request has Closes #N.
  • CI is green on Node 22 and 24.

A change that touches the Library, the cache, downloads or a credential also gets a security review before merge.

Releases

  • Versions follow semver. Before v1 the minor number changes for features and the patch number for fixes. Breaking changes are allowed in 0.x and are written in the changelog.

  • Work lands on dev through pull requests. A release is a pull request from dev to main.

  • On the release pull request: move the ## [Unreleased] entries of CHANGELOG.md under a new version heading with the date, and bump version in package.json.

  • After the merge, tag main as vX.Y.Z and push the tag. The release workflow checks that the tag matches package.json, runs typecheck, test and build, packs the tarball and creates the GitHub release with the notes from the matching ## [X.Y.Z] section of CHANGELOG.md. It fails when that section is missing.

  • The release also attaches an SBOM (botticelli.cdx.json, CycloneDX) and a signed build provenance attestation for the tarball. Attestations exist from the first release after this change (v0.1.0 has none). Verify a download (replace X.Y.Z) with:

    # build provenance
    gh attestation verify botticelli-X.Y.Z.tgz -R vkmtx/botticelli
    # SBOM
    gh attestation verify botticelli-X.Y.Z.tgz -R vkmtx/botticelli --predicate-type https://cyclonedx.org/bom
  • Releases ship on GitHub only. Publishing to npm, if it ever happens, is done by the maintainer, who confirms it first.

Questions

Open an issue. Use the "feature" form for ideas and the "source broken" form when a source stops answering.

Clone this wiki locally