Repository navigation
Contributing
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.
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.
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 andnpm pack --dry-runon Node 22, 22.19 (the minimum inengines) and 24. On Node 24 it also runsnpm run test:coverageand 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 installedbotticelliover 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 | 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 intodev. - One pull request does one thing. Keep it reviewable.
- Put
Closes #Nin the pull request body. Every slice of work has a GitHub issue. - Code goes on a branch before its first commit. Never commit to
devormain.
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
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 lintandnpm testexit 0. - The docs in
docs/that describe the changed behaviour are updated. A built feature saysbuilt (Mx). Planned work saysplanned. -
CHANGELOG.mdhas an entry under## [Unreleased]. Dependabot pull requests are exempt from this rule and fromCloses #N. - A decision gets an ADR in
docs/adr/(see below). - The pull request names the issue (
Closes #N) and lists the tests run.
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).
- Unit tests never use the network. The Pinterest tests pass a fake
Transportand read saved responses fromtest/fixtures/. - Use temporary folders for anything written to disk. Never write to
~/.configor~/.cachefrom a test. PassregistryFileordir. -
npm run test:livehits the real sources. It lives intest/live/, runs by hand, and is excluded fromnpm testand 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>/.
Read ADR 0001 and Architecture first. Then:
- 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).
-
Create
src/sources/<id>/with anindex.tsthat exportscreate<Id>Source(options)and its option types. Add the id to your scope list in this file. -
Write the failing tests first, in
test/<id>/, with a fakeTransportand fixtures. Cover:search, a second page through the cursor, each optional method, an error answer, a network error, and a refused host. -
Implement
Sourcefromsrc/sources/types.ts:-
idandcapabilities(). Report only what works right now. -
search(query, opts)returningPagewithRefs and an opaquenext. - Optional methods only if you implement them. Throw
CapabilityErrorwhen one exists but is unavailable now. -
fetchImage(url, size)that accepts only your Source's CDN hosts over HTTPS and throwsRefusedErrorfor anything else. Mapthumb,medium,largeandoriginalto your CDN's renditions and fall back to the nearest.
-
-
Map to
Ref(src/core/types.ts). Fillsource, a stablekey,imageUrl, and every optional field you can:width,height,lowRes,sourceLink,sourceDomain,collection,author. Setidonly if the source can look it up again. -
Use the shared errors (
SourceError,NetworkError,CapabilityError,RefusedError). Never put a token or a cookie in a message. -
Add a live test in
test/live/<id>.test.tsand runnpm run test:live. -
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.mdentry. - 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.
Pinterest changes its web resources. A fix is usually data, not code.
- Reproduce it:
npm run test:live, or call the Capability from a script. Note the error and the date. - 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 haspinimgURLs in the response). Note the resource name, theX-Pinterest-PWS-Handlerheader, thesource_urland theoptions. - 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. - Add a fixture with a trimmed real response, and a test that the new Candidate returns Refs.
- Run
npm run test:liveto see it work for real. - 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.
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, thenStatus: 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.
- 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,.jssuffix in relative imports,import typefor 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)orplanned (Mx, #N). Describe as working only what exists insrc/. - Links: relative links between docs must resolve.
-
No native dependencies (ADR 0003). Images are decoded in pure JS.
playwright-coreis 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
.envfiles. 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.
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.jsonchanges are justified. - Capabilities report what works right now. Errors are the shared classes.
- Docs and
CHANGELOG.mdare 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.
-
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
devthrough pull requests. A release is a pull request fromdevtomain. -
On the release pull request: move the
## [Unreleased]entries ofCHANGELOG.mdunder a new version heading with the date, and bumpversioninpackage.json. -
After the merge, tag
mainasvX.Y.Zand push the tag. Thereleaseworkflow checks that the tag matchespackage.json, runs typecheck, test and build, packs the tarball and creates the GitHub release with the notes from the matching## [X.Y.Z]section ofCHANGELOG.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 (replaceX.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.
Open an issue. Use the "feature" form for ideas and the "source broken" form when a source stops answering.
This wiki mirrors docs/ in the repository. Edit the docs there, not here. · MIT · Not affiliated with Pinterest or Are.na.
Use
Understand
Contribute
Project
