@ainyc/canonry 4.15.0 → 4.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,13 +2,22 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@ainyc/canonry)](https://www.npmjs.com/package/@ainyc/canonry) [![License: FSL-1.1-ALv2](https://img.shields.io/badge/License-FSL--1.1--ALv2-blue.svg)](https://fsl.software/) [![Node.js >= 22.14](https://img.shields.io/badge/node-%3E%3D22.14-brightgreen)](https://nodejs.org)
4
4
 
5
- Canonry is an agent-first AEO operating platform. It ships a built-in AI agent — **Aero** — that reads project state, analyzes regressions, acts through a typed tool surface, and wakes up unprompted when runs complete. Users who prefer their own agent (Claude Code, Codex, custom) consume Canonry through the same CLI/API surface or subscribe via webhook. It tracks how ChatGPT, Gemini, Claude, and Perplexity cite your site, detects regressions, diagnoses causes, coordinates fixes, and reports results.
5
+ **Agent-first AEO operating platform. Open source. Self-hosted.**
6
6
 
7
- AEO (Answer Engine Optimization) is about making sure your content shows up accurately in AI-generated answers. As search shifts from links to synthesized responses, you need something that can monitor, analyze, and act across these engines continuously.
7
+ - Track citations across Gemini, ChatGPT, Claude, Perplexity, and local LLMs
8
+ - Diagnose against real traffic with built-in [GSC](docs/google-search-console-setup.md), [GA4](docs/google-analytics-setup.md), and [Bing Webmaster](docs/bing-webmaster-setup.md)
9
+ - Execute fixes via [WordPress](docs/wordpress-setup.md), JSON-LD schema, and indexing submissions
10
+ - Manage many clients declaratively — config-as-code YAML + `canonry apply`
11
+ - Schedule recurring visibility checks with webhook alerts on regressions
12
+ - Generate client-ready HTML reports — `canonry report <project>`
13
+ - Drive from your own agent via the [67-tool MCP adapter](docs/mcp.md) or webhooks
14
+ - Or use **Aero** — Canonry's built-in agent that wakes up after every run
15
+
16
+ Every dashboard view has a matching CLI command and API endpoint. The CLI is the surface; the UI consumes the same API your agent does.
8
17
 
9
18
  ![Canonry Dashboard](docs/images/dashboard.png)
10
19
 
11
- ## Getting Started
20
+ ## Run your first AI visibility check in 5 minutes
12
21
 
13
22
  ```bash
14
23
  npm install -g @ainyc/canonry
@@ -16,241 +25,66 @@ canonry init
16
25
  canonry serve
17
26
  ```
18
27
 
19
- Interactive prompts guide you through provider keys, or pass everything as flags:
20
-
21
- ```bash
22
- canonry init --gemini-key <key> --openai-key <key>
23
- canonry serve
24
- ```
25
-
26
- Open [http://localhost:4100](http://localhost:4100) for the web dashboard. Aero's command bar sits at the bottom of every project page.
27
-
28
- ### Talking to Aero (built-in agent)
29
-
30
- From the CLI:
31
-
32
- ```bash
33
- # One-shot turn — Aero picks the right tools and analyzes on its own.
34
- canonry agent ask my-project "Why did the last run fail? Recommend a fix."
35
-
36
- # Pick a specific LLM:
37
- ANTHROPIC_API_KEY=... canonry agent ask my-project "…" --provider anthropic
38
- ZAI_API_KEY=... canonry agent ask my-project "…" --provider zai
39
- ```
40
-
41
- Aero uses whichever LLM has an API key configured in `~/.canonry/config.yaml`
42
- or exported (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`,
43
- `ZAI_API_KEY`). Conversations persist across invocations per project.
44
-
45
- Aero also wakes up **unprompted** after each run completes — analyzing the
46
- new data and writing the result back to the project's transcript so you see
47
- it next time you open the bar or run `canonry agent ask`.
48
-
49
- ### Bringing your own agent (webhook)
50
-
51
- If you'd rather drive Canonry from Claude Code, Codex, or a custom agent,
52
- wire a webhook to receive run/insight events:
53
-
54
- ```bash
55
- canonry agent attach my-project --url https://my-agent.example.com/hooks/canonry
56
- ```
57
-
58
- Your agent receives `run.completed`, `insight.critical`, `insight.high`, and
59
- `citation.gained` notifications. Detach with `canonry agent detach my-project`.
60
-
61
- ### Bringing your own agent (MCP)
62
-
63
- For MCP clients like Claude Desktop, Cursor, Codex, or custom shells that
64
- prefer a typed tool catalog over shell commands, Canonry ships a stdio
65
- adapter. The fastest path is the `canonry mcp install` helper:
66
-
67
- ```bash
68
- canonry mcp install --client claude-desktop # or: cursor
69
- canonry mcp install --client claude-desktop --read-only # 45 read API tools only
70
- canonry mcp config --client codex # print snippet for unsupported clients
71
- ```
72
-
73
- `install` merges a `canonry` entry into the client's config, backs up the
74
- original, and is idempotent. Restart the client after install to pick it up.
75
-
76
- The adapter exposes 67 API tools — projects, runs, snapshots, insights, health,
77
- query and competitor management, schedules, GSC and GA reads, and the
78
- config-as-code apply path. Auth and configuration are inherited from
79
- `~/.canonry/config.yaml`. See [`docs/mcp.md`](docs/mcp.md) for the full
80
- surface and safety rules.
81
-
82
- ## How agents use Canonry
83
-
84
- Canonry's CLI and API are the agent interface. The optional `canonry-mcp` adapter is a thin wrapper over the same public API client — no parallel surface, no virtual filesystem, no privileged SDK. Every CLI command supports `--format json`; every dashboard view has a matching API endpoint.
85
-
86
- - **Monitor** visibility sweeps across providers on a schedule, tracking citation changes over time
87
- - **Analyze** regressions, emerging opportunities, and correlations with site changes
88
- - **Coordinate** fixes across content, schema markup, indexing submissions, and `llms.txt`
89
- - **Report** results in a machine-readable form agents can act on
90
-
91
- ## Features
92
-
93
- - **Built-in AI agent (Aero).** Reads state, analyzes regressions, fires write tools (`run_sweep`, `dismiss_insight`, `update_schedule`, etc.), wakes up unprompted after runs. Backed by [`pi-agent-core`](https://github.com/badlogic/pi-mono) — 15+ LLM providers, streaming first.
94
- - **Agent-first.** Every CLI command supports `--format json`; every UI view has a matching API endpoint. An optional `canonry-mcp` stdio adapter exposes 67 API tools to MCP clients like Claude Desktop and Codex.
95
- - **Multi-provider.** Query Gemini, OpenAI, Claude, Perplexity, and local LLMs from a single platform.
96
- - **Content opportunity engine.** Per-query recommendations typed by action (`create` / `expand` / `refresh` / `add-schema`) with auditable score breakdowns, drivers, and demand-source labels. Combines GSC ranking signals with competitor citation evidence so zero-traffic gaps still surface. Available via `canonry content targets / gaps / sources`, the matching API endpoints, and Aero's tool surface.
97
- - **Config-as-code.** Kubernetes-style YAML files. Version control your monitoring, let agents apply changes declaratively.
98
- - **Self-hosted.** Runs locally with SQLite. No cloud account required.
99
- - **Full API parity.** REST API and CLI cover 100% of functionality. `--format json` on every command.
100
- - **Integrations.** Google Search Console, Google Analytics 4, Bing Webmaster Tools, WordPress.
101
- - **Backlinks (Common Crawl).** Workspace-level release sync via DuckDB, per-project inbound-link extraction, and an opt-in auto-extract on each new release — no third-party API key required.
102
- - **Location-aware.** Project-scoped locations for geo-targeted monitoring.
103
- - **Scheduled monitoring.** Cron-based recurring runs with webhook notifications.
104
-
105
- ## How It Works
106
-
107
- A typical cycle — run manually or from an external agent:
108
-
109
- ```bash
110
- canonry apply canonry.yaml --format json # define projects from YAML specs
111
- canonry run my-project --wait --format json # sweep all providers
112
- canonry evidence my-project --format json # inspect citation evidence
113
- canonry insights my-project --format json # DB-backed insight analysis
114
- canonry health my-project --format json # visibility health snapshot
115
- canonry content targets my-project --format json # ranked content opportunities
116
- ```
117
-
118
- Schedule cron-based sweeps with `canonry schedule` and subscribe an agent webhook via `canonry agent attach` to act on results as they land.
119
-
120
- ## Config-as-Code
121
-
122
- ```yaml
123
- apiVersion: canonry/v1
124
- kind: Project
125
- metadata:
126
- name: my-project
127
- spec:
128
- canonicalDomain: example.com
129
- country: US
130
- language: en
131
- queries:
132
- - best dental implants near me
133
- - emergency dentist open now
134
- competitors:
135
- - competitor.com
136
- providers:
137
- - gemini
138
- - openai
139
- - claude
140
- - perplexity
141
- ```
142
-
143
- ```bash
144
- canonry apply canonry.yaml
145
- canonry apply project-a.yaml project-b.yaml
146
- ```
147
-
148
- ## API
149
-
150
- All endpoints under `/api/v1/`. Authenticate with `Authorization: Bearer cnry_...`.
151
- The canonical, always-up-to-date surface is served at `GET /api/v1/openapi.json` (no auth required).
152
-
153
- Canonry is **agent-first** — every dashboard view has a matching API endpoint and CLI command. The surface is grouped by domain:
154
-
155
- | Domain | What it covers | Highlights |
156
- |--------|----------------|------------|
157
- | **Projects** | Create, read, update, delete projects; locations; export | `PUT /projects/{name}`, `GET /projects`, `GET /projects/{name}/export` |
158
- | **Apply** | Config-as-code — declarative multi-project upsert | `POST /apply` |
159
- | **Queries / Competitors** | Per-project query and competitor management | `POST/DELETE /projects/{name}/queries`, `/competitors` |
160
- | **Runs** | Trigger, list, cancel, and inspect visibility sweeps | `POST /projects/{name}/runs`, `GET /runs`, `POST /runs/{id}/cancel` |
161
- | **Schedules** | Cron-based recurring sweeps | `GET/PUT /projects/{name}/schedule` |
162
- | **History / Snapshots** | Timeline + run diffs + per-query citation state | `GET /projects/{name}/timeline`, `/snapshots/diff`, `/history` |
163
- | **Intelligence** | DB-backed insights + health snapshots + dismissal | `GET /projects/{name}/insights`, `/health`, `POST /insights/{id}/dismiss` |
164
- | **Content** | Action-typed content opportunities, gaps, and grounding-source map | `GET /projects/{name}/content/targets`, `/gaps`, `/sources` |
165
- | **Notifications** | Webhook subscriptions per project (agent or user-defined) | `GET/POST/DELETE /projects/{name}/notifications`, `POST /.../test` |
166
- | **Analytics** | Aggregated dashboard analytics | `GET /projects/{name}/analytics` |
167
- | **Google (GSC + OAuth)** | Search Console integration, OAuth flow, property selection, URL inspection | `/google/*`, `/projects/{name}/google/*` |
168
- | **Google Analytics (GA4)** | Traffic, social referrals, attribution, AI referrals | `/projects/{name}/ga/*` |
169
- | **Bing Webmaster** | Coverage, URL inspection, keyword stats (Bing's term) | `/projects/{name}/bing/*` |
170
- | **WordPress** | Content publishing + site management integration | `/projects/{name}/wordpress/*` |
171
- | **CDP (ChatGPT browser provider)** | Chrome DevTools Protocol health and session status | `/cdp/*` |
172
- | **Settings / Auth / Telemetry** | Server config, API key management, opt-in telemetry | `/settings`, `/telemetry` |
173
- | **OpenAPI** | Full spec | `GET /openapi.json` *(no auth)* |
174
-
175
- For the complete list of ~118 endpoints with request/response schemas, query `GET /api/v1/openapi.json` or browse the per-domain route handlers under [`packages/api-routes/src/`](packages/api-routes/src/).
176
-
177
- ## Provider Setup
178
-
179
- Configure providers during `canonry init`, via the web dashboard at `/settings`, or with the CLI:
180
-
181
- | Provider | Key source | CLI flag |
182
- |----------|-----------|----------|
183
- | Gemini | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) | `--gemini-key` |
184
- | OpenAI | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) | `--openai-key` |
185
- | Claude | [console.anthropic.com](https://console.anthropic.com/settings/keys) | `--claude-key` |
186
- | Perplexity | [perplexity.ai/settings/api](https://www.perplexity.ai/settings/api) | `--perplexity-key` |
187
- | Local LLMs | Any OpenAI-compatible endpoint (Ollama, LM Studio, vLLM) | `--local-url` |
188
-
189
- Integration setup guides: [Google Search Console](docs/google-search-console-setup.md) | [Google Analytics](docs/google-analytics-setup.md) | [Bing Webmaster](docs/bing-webmaster-setup.md) | [WordPress](docs/wordpress-setup.md)
190
-
191
- ## Skills
28
+ Open [http://localhost:4100/setup](http://localhost:4100/setup). A guided wizard walks you through provider keys, project setup, queries, and your first visibility check.
192
29
 
193
- Canonry ships a bundled `canonry-setup` skill that turns Aero (or any Claude-powered agent) into an AEO/SEO operator. **Claude Code** picks it up automatically from `.claude/skills/canonry-setup/` when you open this repo; the same content lives under [`skills/canonry-setup/`](skills/canonry-setup/) for portable use with other harnesses.
194
-
195
- The skill covers the end-to-end answer-engine optimization loop:
196
-
197
- - **AEO monitoring.** Running citation sweeps across Gemini, ChatGPT, Claude, and Perplexity via `canonry run` / `canonry evidence` / `canonry status`, including how to interpret per-query citation state and regressions.
198
- - **Technical SEO audits.** Driving the companion [`@ainyc/aeo-audit`](https://www.npmjs.com/package/@ainyc/aeo-audit) CLI for 14-factor scoring — structured data (JSON-LD), content depth, AI-readable files (`llms.txt`, `llms-full.txt`), E-E-A-T signals, FAQ blocks, definition blocks, H1/alt/meta hygiene.
199
- - **Indexing diagnosis.** Google Search Console and Bing Webmaster Tools coverage, URL inspection, and one-shot submissions via `canonry google request-indexing` / `canonry bing request-indexing`.
200
- - **Schema & content execution.** Patterns for injecting LocalBusiness/FAQPage JSON-LD, writing `llms.txt` with service-area detail, trimming query lists to high-intent queries, and handling WordPress/Elementor specifics (REST API, Application Passwords, Elementor Custom Code).
201
- - **Diagnose → prioritize → execute → monitor → report workflow.** Opinionated defaults for new sites (0 citations), regressions on established sites, and county-level targeting — with guardrails like "never fabricate citation data" and "back up `~/.canonry/config.yaml` before editing".
202
-
203
- See [`skills/canonry-setup/SKILL.md`](skills/canonry-setup/SKILL.md) plus the reference files under [`skills/canonry-setup/references/`](skills/canonry-setup/references/) (`canonry-cli.md`, `aeo-analysis.md`, `indexing.md`, `wordpress-integration.md`) for the full playbook. Aero loads the same material natively, so anything an external agent can do through the skill, Aero can do from the CLI or dashboard command bar.
204
-
205
- ## Deployment
206
-
207
- See **[docs/deployment.md](docs/deployment.md)** for local, reverse proxy, sub-path, Tailscale, systemd, and Docker guides.
208
-
209
- ### Docker
30
+ Prefer the terminal?
210
31
 
211
32
  ```bash
212
- docker build -t canonry .
213
- docker run --rm -p 4100:4100 -e GEMINI_API_KEY=your-key -v canonry-data:/data canonry
33
+ canonry project create my-site --domain example.com
34
+ canonry query add my-site "your first query" "second query"
35
+ canonry run my-site --wait
36
+ canonry evidence my-site
37
+ canonry insights my-site
214
38
  ```
215
39
 
216
- Published images: [Docker Hub](https://hub.docker.com/repository/docker/arberx/canonry) | [GHCR](https://github.com/ainyc/canonry/pkgs/container/canonry)
217
-
218
- ### Railway
219
-
220
- [![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/ENziH9?referralCode=0vODBs&utm_medium=integration&utm_source=template&utm_campaign=generic)
221
-
222
- Click deploy, add a volume at `/data`, generate a domain. No env vars required to start. Configure providers via the dashboard.
223
-
224
- ### Render
225
-
226
- Create a Web Service with runtime Docker, attach a disk at `/data`. Health check: `/health`.
40
+ ## If you get stuck
41
+
42
+ | Problem | Fix |
43
+ |---------|-----|
44
+ | No provider key configured | Grab a free [Gemini key](https://aistudio.google.com/apikey), set `GEMINI_API_KEY`, restart `canonry serve`. |
45
+ | No results after a run | Visibility checks are async — check the Runs tab or use `canonry run <project> --wait`. |
46
+ | Not sure what queries to test | The setup wizard auto-generates them by analyzing your site. |
47
+ | `npm install` fails on `node-gyp` | Install build tools for `better-sqlite3` ([guide](https://github.com/WiseLibs/better-sqlite3/blob/master/docs/troubleshooting.md)). |
48
+
49
+ ## Provider keys
50
+
51
+ | Provider | Key source | Env var |
52
+ |----------|-----------|---------|
53
+ | Gemini | [aistudio.google.com](https://aistudio.google.com/apikey) | `GEMINI_API_KEY` |
54
+ | OpenAI | [platform.openai.com](https://platform.openai.com/api-keys) | `OPENAI_API_KEY` |
55
+ | Claude | [console.anthropic.com](https://console.anthropic.com/settings/keys) | `ANTHROPIC_API_KEY` |
56
+ | Perplexity | [perplexity.ai/settings/api](https://www.perplexity.ai/settings/api) | `PERPLEXITY_API_KEY` |
57
+ | Local LLMs | Any OpenAI-compatible endpoint | `LOCAL_LLM_URL` |
58
+
59
+ Configure during `canonry init`, in the dashboard `/settings`, or as env vars.
60
+
61
+ ## Documentation
62
+
63
+ | | |
64
+ |---|---|
65
+ | **Architecture & data model** | [docs/architecture.md](docs/architecture.md) · [docs/data-model.md](docs/data-model.md) |
66
+ | **Aero — built-in agent** | [skills/aero/SKILL.md](skills/aero/SKILL.md) |
67
+ | **MCP — Claude Desktop / Cursor / Codex** | [docs/mcp.md](docs/mcp.md) |
68
+ | **Integrations** | [GSC](docs/google-search-console-setup.md) · [GA4](docs/google-analytics-setup.md) · [Bing](docs/bing-webmaster-setup.md) · [WordPress](docs/wordpress-setup.md) |
69
+ | **Deployment** — Docker, Railway, Render, systemd, Tailscale | [docs/deployment.md](docs/deployment.md) |
70
+ | **API** — 118+ endpoints | `GET /api/v1/openapi.json` (no auth) |
71
+ | **Skills bundle** for Claude Code / Codex | `canonry skills install` ([details](skills/canonry-setup/SKILL.md)) |
72
+ | **Roadmap & ADRs** | [docs/roadmap.md](docs/roadmap.md) · [docs/adr/](docs/adr/) |
73
+ | **All docs** | [docs/README.md](docs/README.md) |
227
74
 
228
75
  ## Requirements
229
76
 
230
- - Node.js >= 22.14.0
231
- - At least one provider API key (configurable after startup)
232
-
233
- If `npm install` fails with `node-gyp` errors, install build tools for `better-sqlite3`: `xcode-select --install` (macOS), `apt-get install python3 make g++` (Debian), or see the [troubleshooting guide](https://github.com/WiseLibs/better-sqlite3/blob/master/docs/troubleshooting.md).
77
+ Node.js 22.14.0. At least one provider API key.
234
78
 
235
- ## Development
79
+ ## Contributing
236
80
 
237
81
  ```bash
238
- git clone https://github.com/ainyc/canonry.git
239
- cd canonry
240
- pnpm install
241
- pnpm run typecheck && pnpm run test && pnpm run lint
82
+ git clone https://github.com/ainyc/canonry.git && cd canonry
83
+ pnpm install && pnpm run typecheck && pnpm run test && pnpm run lint
242
84
  ```
243
85
 
244
- See [docs/README.md](docs/README.md) for the full architecture, roadmap, ADR index, and doc map.
245
-
246
- ## Contributing
247
-
248
86
  See [CONTRIBUTING.md](./CONTRIBUTING.md).
249
87
 
250
88
  ## License
251
89
 
252
90
  [FSL-1.1-ALv2](./LICENSE). Free to use, modify, and self-host. Each version converts to Apache 2.0 after two years.
253
-
254
- ---
255
-
256
- Built by [AI NYC](https://ainyc.ai)