@ainyc/canonry 1.48.2 → 2.0.0

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,7 +2,7 @@
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 platform powered by [OpenClaw](https://openclaw.ai). It tracks how ChatGPT, Gemini, Claude, and Perplexity cite your site, detects regressions, diagnoses causes, coordinates fixes, and reports results.
5
+ Canonry is an agent-first AEO 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.
6
6
 
7
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.
8
8
 
@@ -12,48 +12,65 @@ AEO (Answer Engine Optimization) is about making sure your content shows up accu
12
12
 
13
13
  ```bash
14
14
  npm install -g @ainyc/canonry
15
- canonry agent setup
15
+ canonry init
16
+ canonry serve
16
17
  ```
17
18
 
18
- One command. It installs [OpenClaw](https://openclaw.ai), configures the agent's LLM, sets up monitoring providers, and seeds the workspace. Interactive prompts guide you through everything, or pass flags for fully automated setup:
19
+ Interactive prompts guide you through provider keys, or pass everything as flags:
19
20
 
20
21
  ```bash
21
- canonry agent setup --gemini-key <key> --agent-key <key> --format json
22
+ canonry init --gemini-key <key> --openai-key <key>
23
+ canonry serve
22
24
  ```
23
25
 
24
- Then start the agent and server:
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:
25
31
 
26
32
  ```bash
27
- canonry serve &
28
- canonry agent start
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
29
39
  ```
30
40
 
31
- Open [http://localhost:4100](http://localhost:4100) for the web dashboard. The agent runs in the background, ready to orchestrate sweeps and act on results.
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.
32
44
 
33
- ### Monitoring only (no agent)
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`.
34
48
 
35
- If you just want the monitoring layer without the autonomous agent:
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:
36
53
 
37
54
  ```bash
38
- npm install -g @ainyc/canonry
39
- canonry init
40
- canonry serve
55
+ canonry agent attach my-project --url https://my-agent.example.com/hooks/canonry
41
56
  ```
42
57
 
43
- ## What the Agent Does
58
+ Your agent receives `run.completed`, `insight.critical`, `insight.high`, and
59
+ `citation.gained` notifications. Detach with `canonry agent detach my-project`.
44
60
 
45
- The Canonry agent ("Aero") is an [OpenClaw](https://openclaw.ai)-powered operator:
61
+ ## How agents use Canonry
46
62
 
47
- - **Monitors** visibility sweeps across providers on schedule, tracking citation changes over time
48
- - **Analyzes** regressions, emerging opportunities, and correlates visibility shifts with site changes
49
- - **Operates** across your content, schema markup, indexing submissions, and `llms.txt` to coordinate fixes and generate action-oriented reports
50
- - **Remembers** client context across sessions: canonical domains, historical patterns, known issues
63
+ Canonry's CLI and API are the agent interface — no special SDK, no MCP layer, no virtual filesystem. Every command supports `--format json`; every dashboard view has a matching API endpoint.
51
64
 
52
- Every action the agent takes goes through the same CLI and API available to everyone. No special SDK, no hidden state.
65
+ - **Monitor** visibility sweeps across providers on a schedule, tracking citation changes over time
66
+ - **Analyze** regressions, emerging opportunities, and correlations with site changes
67
+ - **Coordinate** fixes across content, schema markup, indexing submissions, and `llms.txt`
68
+ - **Report** results in a machine-readable form agents can act on
53
69
 
54
70
  ## Features
55
71
 
56
- - **Agent-operated.** The OpenClaw agent monitors, analyzes, and acts autonomously. Humans supervise via the dashboard.
72
+ - **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.
73
+ - **Agent-first.** Every CLI command supports `--format json`; every UI view has a matching API endpoint.
57
74
  - **Multi-provider.** Query Gemini, OpenAI, Claude, Perplexity, and local LLMs from a single platform.
58
75
  - **Config-as-code.** Kubernetes-style YAML files. Version control your monitoring, let agents apply changes declaratively.
59
76
  - **Self-hosted.** Runs locally with SQLite. No cloud account required.
@@ -64,17 +81,17 @@ Every action the agent takes goes through the same CLI and API available to ever
64
81
 
65
82
  ## How It Works
66
83
 
67
- The agent uses the same CLI and API that humans do. A typical cycle:
84
+ A typical cycle run manually or from an external agent:
68
85
 
69
86
  ```bash
70
87
  canonry apply canonry.yaml --format json # define projects from YAML specs
71
88
  canonry run my-project --wait --format json # sweep all providers
72
89
  canonry evidence my-project --format json # inspect citation evidence
73
- canonry insights my-project --format json # get agent-generated analysis
90
+ canonry insights my-project --format json # DB-backed insight analysis
74
91
  canonry health my-project --format json # visibility health snapshot
75
92
  ```
76
93
 
77
- The agent runs these automatically on schedule, detects changes, and generates reports. You can run the same commands manually at any time.
94
+ Schedule cron-based sweeps with `canonry schedule` and subscribe an agent webhook via `canonry agent attach` to act on results as they land.
78
95
 
79
96
  ## Config-as-Code
80
97
 
@@ -148,9 +165,7 @@ Integration setup guides: [Google Search Console](docs/google-search-console-set
148
165
 
149
166
  ## Skills
150
167
 
151
- The agent learns how to operate canonry through bundled [OpenClaw skills](https://clawhub.dev) that cover CLI commands, provider setup, analysis workflows, and troubleshooting. Skills are seeded into the agent workspace during `canonry agent setup`.
152
-
153
- **Claude Code** also picks up the skill automatically from `.claude/skills/canonry-setup/` when you open this repo. **ClawHub** hosts the same skill at [clawhub.dev](https://clawhub.dev) for any MCP-equipped agent.
168
+ Canonry ships a bundled `canonry-setup` skill that documents the CLI commands, provider setup, analysis workflows, and troubleshooting patterns an agent needs to operate the platform. **Claude Code** picks up the skill automatically from `.claude/skills/canonry-setup/` when you open this repo.
154
169
 
155
170
  ## Deployment
156
171
 
@@ -9,13 +9,13 @@ All data access goes through the canonry CLI. Never read the SQLite database dir
9
9
  canonry <command> --format json
10
10
  ```
11
11
 
12
- The canonry server must be running for most commands. Verify with:
12
+ The canonry server must be running for most commands. Verify by hitting the health endpoint (`GET /health`) or by listing projects:
13
13
 
14
14
  ```bash
15
- canonry agent status
15
+ canonry project list --format json
16
16
  ```
17
17
 
18
- If the server isn't running, start it with `canonry serve` (or `canonry agent start` for the gateway).
18
+ If the server isn't running, start it with `canonry serve`.
19
19
 
20
20
  ## Key Commands
21
21
 
@@ -78,7 +78,6 @@ Provider APIs have rate limits. Follow these guidelines:
78
78
 
79
79
  Reference skills are available in `skills/` for domain-specific guidance:
80
80
 
81
- - `skills/aero/` -- Aero agent skill definition
82
81
  - `skills/canonry-setup/` -- Canonry installation and configuration reference
83
82
 
84
83
  ## Error Handling
@@ -8,10 +8,11 @@ repository: https://github.com/AINYC/aero
8
8
 
9
9
  # Aero Orchestration Skill
10
10
 
11
- You coordinate across three tools to deliver comprehensive AEO monitoring:
12
- - **canonry** for sweep data and citation evidence
13
- - **aeo-audit** for site analysis and fix generation
14
- - **Your own memory** for client context and trend tracking
11
+ You coordinate across two tools to deliver comprehensive AEO monitoring:
12
+ - **canonry** — the source of truth for project state (runs, snapshots, timelines, insights, audit log). Query it with `canonry <command> --format json`; never maintain a parallel copy in agent memory.
13
+ - **aeo-audit** on-demand site analysis and fix generation.
14
+
15
+ Persist only *user-scoped* context (operator preferences, communication style) in your platform's native memory. Project-scoped facts live in canonry and must be read back, not remembered.
15
16
 
16
17
  ## Judgment Rules
17
18
 
@@ -34,10 +35,6 @@ You coordinate across three tools to deliver comprehensive AEO monitoring:
34
35
  - Be specific: "You lost the ChatGPT citation for 'roof repair phoenix' between March 28-April 2" not "your visibility decreased"
35
36
  - Action-oriented: every observation ends with a recommended next step
36
37
 
37
- ## Reference Docs
38
+ ## Reference Playbooks
38
39
 
39
- - [orchestration.md](references/orchestration.md) — Workflow recipes
40
- - [memory-patterns.md](references/memory-patterns.md) — What to persist per client
41
- - [regression-playbook.md](references/regression-playbook.md) — Detection through response
42
- - [reporting.md](references/reporting.md) — Report generation templates
43
- - [wordpress-elementor-mcp.md](references/wordpress-elementor-mcp.md) — Elementor MCP tools for page management
40
+ Detailed playbooks (workflows, regression diagnosis, reporting templates, integrations) are bundled as separate docs. Call `list_skill_docs` to see what's available, then `read_skill_doc({ slug })` to load one when a task matches. Don't guess slugs list first.
@@ -1,37 +1,47 @@
1
+ ---
2
+ name: memory-patterns
3
+ description: What to persist vs. re-query — project state lives in canonry, only user-scoped facts go in agent memory. Read when unsure whether to remember or look up.
4
+ ---
5
+
1
6
  # Memory Patterns
2
7
 
3
- ## Per-Client State Template
8
+ Canonry is the source of truth for project state. Do **not** maintain a parallel copy of project facts in agent memory — it will drift from the DB and mislead the next session.
4
9
 
5
- Store in OpenClaw agent memory after each significant event:
10
+ ## What belongs where
6
11
 
7
- ```
8
- Client: <business name>
9
- Domain: <domain>
10
- Project: <project slug>
12
+ | Scope | Examples | Home |
13
+ |---|---|---|
14
+ | **Project state** | Baselines, historical regressions, citation rates per keyword/provider, recent insights, sweep history, audit trail | Canonry DB — query via CLI / API |
15
+ | **User preferences** | How the operator likes reports framed, tone, comms style, tools they already use | Platform-native memory (Claude Code auto-memory, Codex thread metadata, etc.) |
16
+ | **Session scratch** | "I just tried X and it failed", intermediate reasoning | Platform-native memory (dies with the session) |
17
+
18
+ ## How to read project state from canonry
11
19
 
12
- Baseline (set <date>):
13
- Overall cited rate: <X>% (<N>/<total> keyword-provider pairs)
14
- Best provider: <provider> (<X>% cited)
15
- Worst provider: <provider> (<X>% cited)
16
- Top keyword: "<keyword>" (cited on <N>/<total> providers)
17
- Worst keyword: "<keyword>" (cited on <N>/<total>)
20
+ Always use `--format json` for structured output:
18
21
 
19
- Competitors:
20
- <domain> <trend description>
22
+ ```bash
23
+ # Current health + latest run summary
24
+ canonry status <project> --format json
25
+ canonry health <project> --format json
21
26
 
22
- Content strategy:
23
- <page type> drives <X>% of citations
27
+ # Historical trend
28
+ canonry timeline <project> --since <YYYY-MM-DD> --format json
29
+ canonry history <project> --format json
24
30
 
25
- Open items:
26
- - <description>
31
+ # Insights already surfaced (don't regenerate — query)
32
+ canonry insights <project> --format json
27
33
 
28
- Sweep history summary:
29
- <date>: <X>% (<note>)
34
+ # Raw evidence from the most recent sweep
35
+ canonry evidence <project> --format json
36
+
37
+ # Audit log — who changed what and when
38
+ canonry audit <project> --format json
30
39
  ```
31
40
 
32
- ## Update Cadence
41
+ If the data you need isn't reachable with a single CLI call, that's a bug in canonry's API surface — file it rather than working around it in memory.
42
+
43
+ ## Regenerate, don't remember
44
+
45
+ Derived interpretations (trend summaries, correlations between events) are cheap to recompute from the underlying DB rows. Prefer running the analysis again on fresh data over recalling what you concluded last session — conclusions age, the data doesn't.
33
46
 
34
- - **After each sweep:** Update cited rates, flag new regressions
35
- - **After each fix:** Record what was changed, set monitoring flag
36
- - **After each client interaction:** Update preferences, strategy notes
37
- - **Weekly:** Summarize trend direction, update competitor notes
47
+ The one exception: if the operator gave you a *fact* that canonry can't observe ("the content lead is named Sarah", "they're migrating off Webflow next quarter"), persist it in platform-native memory as user-scoped context.
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: orchestration
3
+ description: Workflow recipes — baseline, regression response, weekly review, content gap analysis. Read when planning a multi-step task or recurring review.
4
+ ---
5
+
1
6
  # Orchestration Workflows
2
7
 
3
8
  ## Workflow 1: New Client Baseline
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: regression-playbook
3
+ description: Detection → triage → diagnosis → response for lost citations. Read when investigating why a keyword lost its citation.
4
+ ---
5
+
1
6
  # Regression Playbook
2
7
 
3
8
  ## Detection
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: reporting
3
+ description: Weekly and monthly report templates with metric tables, regression/gain sections, and recommended-actions structure. Read when asked to produce a client-facing summary.
4
+ ---
5
+
1
6
  # Reporting Templates
2
7
 
3
8
  ## Weekly Report
@@ -1,3 +1,8 @@
1
+ ---
2
+ name: wordpress-elementor-mcp
3
+ description: WordPress + Elementor MCP integration guide — prerequisites, auth, widget manipulation. Read only when the task involves editing WordPress/Elementor pages.
4
+ ---
5
+
1
6
  # Elementor + WordPress MCP Development Guide
2
7
 
3
8
  ## Overview
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: aero-soul
3
+ description: Aero's persona, values, and voice — context-agnostic identity that applies whether Aero runs as the built-in agent or wraps around an external agent shell.
4
+ ---
5
+
6
+ # Who You Are
7
+
8
+ You are **Aero** — an AEO analyst. You help operators understand how AI answer engines cite their domain, and you act decisively on what the data shows.
9
+
10
+ ## Values
11
+
12
+ - **Evidence over opinion.** Numbers before interpretation. "You lost the ChatGPT citation for 'roof repair phoenix' between March 28 and April 2" beats "your visibility decreased."
13
+ - **Proactive, not passive.** Regressions don't wait to be asked about. Surface them when you spot them. Flag emerging competitors the moment they appear in citations you own.
14
+ - **Honest about uncertainty.** When the data is ambiguous, say so. Don't manufacture confidence. Don't promise fixes will appear in the next sweep — AEO changes take weeks.
15
+ - **Cautious with writes.** Sweeps cost quota. Schedules shape downstream notifications. Keywords define what gets tracked. Confirm intent before mutating state the operator will notice.
16
+ - **Canonry is the source of truth.** Read state back; never maintain a parallel copy in your head. Conclusions age, the data doesn't.
17
+
18
+ ## Voice
19
+
20
+ Concise, peer-to-peer, action-oriented. The operator is a practitioner — skip the disclaimers and the 101 explanations. Every observation ends with a next step.
21
+
22
+ Analyst energy: sharp, confident, direct. You don't sugarcoat bad news, but you lead with what to do about it. No hedging filler, no emoji, no corporate warmth. Just signal.
23
+
24
+ You have opinions. If a client's setup is actively hurting them, say so plainly.
25
+
26
+ ## Boundaries
27
+
28
+ - Never fabricate citation data. If you haven't run a sweep, say so.
29
+ - Never speculate why an AI cited a competitor without evidence — stick to what canonry observed.
30
+ - Private client data stays private.
@@ -3,7 +3,7 @@ name: canonry
3
3
  description: "Agent-first AEO monitoring and operating platform."
4
4
  metadata:
5
5
  {
6
- "openclaw":
6
+ "agent":
7
7
  {
8
8
  "emoji": "📡",
9
9
  "requires": { "bins": ["canonry"] },
@@ -296,53 +296,53 @@ canonry export <project> --include-results > project.yaml
296
296
  canonry sitemap inspect <project>
297
297
  ```
298
298
 
299
- ## Agent (OpenClaw Integration)
299
+ ## Agent
300
300
 
301
- `canonry agent setup` is the single entry point for configuring the agent. It handles everything:
302
- canonry initialization, OpenClaw installation, profile setup, LLM credential configuration,
303
- and workspace seeding. If canonry is not yet configured, it runs the interactive init flow first
304
- (prompting for monitoring provider keys and agent LLM credentials).
301
+ Canonry ships the built-in **Aero** agent (backed by pi-agent-core) for users
302
+ who don't already have one, plus a webhook integration for users who want to
303
+ drive Canonry from Claude Code / Codex / a custom agent.
304
+
305
+ ### Built-in Aero (one-shot CLI)
305
306
 
306
307
  ```bash
307
- # Full setup (interactive prompts for provider keys + agent LLM)
308
- canonry agent setup
309
-
310
- # Non-interactive (flags or env vars)
311
- canonry agent setup --gemini-key <key> --agent-key <key>
312
- canonry agent setup --agent-provider openrouter --agent-key <key> --agent-model openrouter/anthropic/claude-sonnet-4-6
313
- GEMINI_API_KEY=<key> canonry agent setup --agent-key <key> --format json
314
-
315
- # Lifecycle
316
- canonry agent start # start OpenClaw gateway as background process
317
- canonry agent stop # stop the gateway process
318
- canonry agent status # check if gateway is running
319
- canonry agent status --format json # JSON output
320
- canonry agent reset # stop gateway and wipe workspace
321
-
322
- # Setup flags
323
- canonry agent setup --agent-provider <id> # LLM provider (default: anthropic)
324
- canonry agent setup --agent-key <key> # API key for agent LLM
325
- canonry agent setup --agent-model <model> # model id (e.g. anthropic/claude-sonnet-4-6)
326
- canonry agent setup --gateway-port 3579 # gateway WebSocket port
327
- canonry agent setup --gemini-key <key> # monitoring provider keys (passed to init)
328
- canonry agent setup --openai-key <key>
329
- canonry agent setup --claude-key <key>
330
- canonry agent setup --perplexity-key <key>
331
-
332
- # Webhook lifecycle
333
- canonry agent attach <project> # register agent webhook for project
334
- canonry agent attach <project> --format json # JSON output
335
- canonry agent detach <project> # remove agent webhook from project
336
- canonry agent detach <project> --format json # JSON output
308
+ # One-shot turnAero picks its own tools, streams events to stdout.
309
+ canonry agent ask <project> "<prompt>"
310
+ canonry agent ask <project> "<prompt>" --format json # JSON event stream
311
+
312
+ # Select a specific provider / model (otherwise auto-detected from config).
313
+ canonry agent ask <project> "<prompt>" --provider anthropic --model claude-opus-4-7
314
+ canonry agent ask <project> "<prompt>" --provider zai --model glm-5.1
315
+ canonry agent ask <project> "<prompt>" --provider openai
316
+ canonry agent ask <project> "<prompt>" --provider google
317
+
318
+ # Restrict the tool surface. Default is --scope all (full 13-tool surface:
319
+ # 7 read + 6 write). --scope read-only exposes only the 7 read tools and
320
+ # is what the dashboard bar uses by default so pasted "Copy as CLI"
321
+ # commands can't enable writes the UI turn couldn't perform.
322
+ canonry agent ask <project> "<prompt>" --scope read-only
323
+ canonry agent ask <project> "<prompt>" --scope all
337
324
  ```
338
325
 
339
- **Setup flow:** init canonry (if needed) install OpenClaw (if needed) configure profile → configure gateway → set agent LLM credentials → seed workspace with skills.
326
+ **Provider detection order** when `--provider` is omitted: `anthropic`
327
+ `openai` → `google` → `zai`, whichever has an API key present first
328
+ (from `~/.canonry/config.yaml` providers block, or the matching env var
329
+ `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` / `GEMINI_API_KEY` / `ZAI_API_KEY`).
330
+
331
+ Conversations **persist per project** — `canonry agent ask` continues the
332
+ same rolling thread each invocation. Reset with `DELETE /api/v1/projects/<name>/agent/transcript`
333
+ or via the dashboard bar's reset button.
340
334
 
341
- **Agent LLM credentials** are stored in `~/.openclaw-aero/.env` (e.g. `ANTHROPIC_API_KEY=...`) and loaded into the gateway process at start time. The model is set via `openclaw models set`.
335
+ ### External agents (webhook)
342
336
 
343
- **Re-running is safe:** setup is idempotent — it skips steps that are already configured.
337
+ ```bash
338
+ # Wire an external agent webhook to a project
339
+ canonry agent attach <project> --url <webhook-url> # register webhook subscription
340
+ canonry agent attach <project> --url <url> --format json # JSON output
341
+ canonry agent detach <project> # remove the agent webhook
342
+ canonry agent detach <project> --format json # JSON output
343
+ ```
344
344
 
345
- **Agent webhooks:** `canonry agent attach <project>` registers a webhook notification on the project so the agent receives events (`run.completed`, `insight.critical`, `insight.high`, `citation.gained`). Idempotent skips if an agent webhook already exists. `canonry agent detach <project>` removes the agent webhook. When `autoStart` is enabled, the server auto-attaches webhooks to newly created or applied projects.
345
+ **Agent webhooks** fire on `run.completed`, `insight.critical`, `insight.high`, and `citation.gained`. The attach/detach pair is idempotent per project (one agent webhook per project, matched by source tag).
346
346
 
347
347
  ## Output Formats
348
348