### Example Crawler Engine Setup Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/crawler.md Demonstrates the initialization sequence including configuration loading, store opening, and engine instantiation. ```go cfg, err := config.Load("ardvark.json") if err != nil { log.Fatal(err) } st, err := store.Open(cfg.Storage.Driver, cfg.Storage.DSN) if err != nil { log.Fatal(err) } defer st.Close() fc := fetch.New(cfg.Crawler) fr, err := frontier.New(st.DB, frontier.Options{Cfg: cfg.Crawler}) if err != nil { log.Fatal(err) } logger := slog.Default() engine := crawler.New(cfg, st, fr, fc, logger, crawler.Options{ RunID: 1, Force: false, MaxAttempts: 3, }) ``` -------------------------------- ### Probe Command Example Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Example output when probing multiple hosts directly. ```console $ ardvark probe huggingface.co github.com hit huggingface.co well_known found 200 application/json; charset=utf-8 miss huggingface.co robots_agentmap no Agentmap directive miss github.com well_known 404 miss github.com robots_agentmap no Agentmap directive probe complete: 1 hit · 3 misses · 0 errors ``` -------------------------------- ### Crawl Command Example Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Example output when running a crawl against a specific domain. ```console $ ardvark crawl https://acme.example seeded 1 of 1 requested seed(s) hit acme.example well_known catalog valid 14 entries hit docs.acme.example link_tag valid_with_warnings queries.count miss static.acme.example well_known 404 miss static.acme.example robots_agentmap no Agentmap directive run complete: 12 pages fetched · 3 hosts probed · 2 catalogs found · 2 valid · 0 errors ``` -------------------------------- ### Install ardvark CLI Source: https://github.com/helgesverre/ardvark/blob/main/SKILLS.md Installation methods for ardvark using Homebrew or Go. ```sh # Homebrew brew install helgesverre/tap/ardvark # Go go install github.com/helgesverre/ardvark/cmd/ardvark@latest ``` -------------------------------- ### Run Engine Example Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/crawler.md Demonstrates how to initiate a crawl with signal handling for graceful shutdown. ```go ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() result, err := engine.Run(ctx, false) if err != nil { log.Fatal(err) } fmt.Printf("Crawl complete: %d pages, %d hosts, %d catalogs\n", result.PagesFetched, result.HostsProbed, result.CatalogsFound) ``` -------------------------------- ### Example Frontier Initialization Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/frontier.md Demonstrates how to open a database connection and initialize the frontier with crawler configuration. ```go st, _ := store.Open("sqlite", "ardvark.db") defer st.Close() fr, err := frontier.New(st.DB, frontier.Options{ Cfg: cfg.Crawler, // Additional options }) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Ardvark Configuration File Example Source: https://github.com/helgesverre/ardvark/blob/main/README.md A complete example of an ardvark.json configuration file showing all available settings for storage, logging, crawler, and seed sources. ```json { "storage": { "driver": "sqlite", "dsn": "ardvark.db" }, "log": { "file": "ardvark.jsonl", "level": "info" }, "crawler": { "concurrency": 8, "maxDepth": 2, "maxPagesPerDomain": 50, "perHostRequestsPerSecond": 1, "requestTimeoutSeconds": 15, "maxBodyBytes": 5242880, "userAgent": "ardvark (+https://github.com/helgesverre/ardvark)", "respectRobotsTxt": true, "refreshAfterHours": 168, "leaseSeconds": 600, "worker": { "index": 0, "count": 1 } }, "ard": { "maxCatalogDepth": 3, "fetchArtifacts": true }, "registry": { "harvest": true, "maxReferralDepth": 2, "pageLimit": 20 }, "seed": { "ct": { "logListUrl": "https://www.gstatic.com/ct/log_list/v3/log_list.json", "logs": ["oak", "argon", "nimbus"], "entryCount": 1000 }, "crtsh": { "endpoint": "https://crt.sh", "count": 1000 }, "tranco": { "listUrl": "https://tranco-list.eu/top-1m.csv.zip", "top": 1000 }, "github": { "query": "filename:ai-catalog.json path:.well-known", "count": 100 }, "mcp": { "registryUrl": "https://registry.modelcontextprotocol.io", "count": 1000 }, "curated": { "urls": [ "https://raw.githubusercontent.com/punkpeye/awesome-mcp-servers/main/README.md", "https://raw.githubusercontent.com/wong2/awesome-mcp-servers/main/README.md", "https://raw.githubusercontent.com/appcypher/awesome-mcp-servers/main/README.md" ], "count": 500 }, "commoncrawl": { "graphInfoUrl": "https://index.commoncrawl.org/graphinfo.json", "graph": "", "top": 1000, "offset": 0 } } } ``` -------------------------------- ### Read installation metadata Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md Use ardvark_info to get system and configuration details without database or network access. ```json { "version": "0.5.0", "configPath": "/etc/ardvark/ardvark.json", "configExists": true, "storage": { "driver": "sqlite", "dsn": "ardvark.db", "path": "/var/ardvark/ardvark.db", "exists": true, "sizeBytes": 5242880 }, "logPath": "/var/ardvark/ardvark.jsonl", "logExists": true } ``` -------------------------------- ### Run MCP Server Example Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md Initializes the server with a background context and a specific configuration file path. ```go ctx := context.Background() err := mcpserver.Run(ctx, "/etc/ardvark/ardvark.json", "0.5.0") if err != nil { log.Fatal(err) } ``` -------------------------------- ### Configure Storage Backend Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/configuration.md Examples for configuring different database backends for ardvark storage. ```json { "storage": { "driver": "sqlite", "dsn": "ardvark.db" } } ``` ```json { "storage": { "driver": "mysql", "dsn": "user:password@tcp(localhost:3306)/ardvark" } } ``` ```json { "storage": { "driver": "postgres", "dsn": "host=localhost user=postgres password=secret dbname=ardvark sslmode=disable" } } ``` -------------------------------- ### URN Parsing Example Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Demonstrates parsing and normalizing a URN string. ```go urn, err := ard.ParseURN("urn:air:Anthropic.COM:agents:claude") if err == nil { fmt.Printf("Publisher: %s\n", urn.Publisher) // "anthropic.com" fmt.Printf("Name: %s\n", urn.Name) // "claude" fmt.Println(urn.String()) // "urn:air:anthropic.com:agents:claude" } ``` -------------------------------- ### Execute a crawl Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Initiates a crawl starting from the specified URL. ```bash $ ardvark crawl https://acme.example ``` -------------------------------- ### Report Installation Metadata Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Displays binary version, configuration path, storage backend details, and log file information. ```bash ardvark info ``` -------------------------------- ### Install ardvark via Homebrew Source: https://github.com/helgesverre/ardvark/blob/main/website/index.html Use this command to install the ardvark binary on macOS or Linux systems using Homebrew. ```bash brew install helgesverre/tap/ardvark ``` -------------------------------- ### Get Domain Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Retrieves a domain record by its hostname. ```go func (st *Store) GetDomain(host string) (*Domain, error) ``` -------------------------------- ### Install Ardvark via Homebrew Source: https://github.com/helgesverre/ardvark/blob/main/website/og/template.html Command to install the Ardvark CLI tool using Homebrew. ```bash $ brew install helgesverre/tap/ardvark ``` -------------------------------- ### Verify local ARD catalog example Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Demonstrates reading a local file and verifying it using the Verify function. ```go doc, _ := os.ReadFile("ai-catalog.json") report, err := ard.Verify(doc, false) if err != nil { log.Fatal(err) } fmt.Printf("Verdict: %s\n", report.Verdict) for _, check := range report.Checks { if !check.Passed { fmt.Printf("FAILED: %s (%s) - %s\n", check.CheckID, check.Severity, check.Message) } } ``` -------------------------------- ### Usage Example for Frontier Counts Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/frontier.md Demonstrates how to query frontier counts and check if the frontier is empty. ```go counts, _ := f.Counts(ctx) fmt.Printf("Frontier: %d pending, %d in-flight, %d done, %d failed\n", counts.Pending, counts.InFlight, counts.Done, counts.Failed) if counts.Pending == 0 && counts.InFlight == 0 { fmt.Println("Frontier is empty") } ``` -------------------------------- ### Verify remote ARD catalog example Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Demonstrates fetching a remote catalog from a URL and verifying it using the VerifyURL function. ```go cfg, _ := config.Load("ardvark.json") fc := fetch.New(cfg.Crawler) defer fc.Close() ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() report, err := ard.VerifyURL(ctx, "https://anthropic.com/.well-known/ard.json", false, fc) if err != nil { log.Fatal(err) } fmt.Println(report.Verdict) ``` -------------------------------- ### ardvark_info Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md Reads installation metadata (instant, never touches database or network). ```APIDOC ## ardvark_info ### Description Reads installation metadata (instant, never touches database or network). ### Response - **Info** (object) - Returns version, configuration paths, and storage metadata. ``` -------------------------------- ### func Run(ctx context.Context, configPath, version string) error Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md Starts the MCP server over stdio, using the provided configuration path and version string. ```APIDOC ## func Run(ctx context.Context, configPath, version string) error ### Description Serves ardvark MCP over stdio. The server reads configuration from the specified path and accepts tool calls over the stdio MCP transport. ### Parameters - **ctx** (context.Context) - Required - Context for graceful shutdown. - **configPath** (string) - Required - Path to ardvark.json config file. Empty string searches standard locations. - **version** (string) - Required - Version string reported to the MCP client. ### Returns - **error** - Fatal server error (client disconnection is not an error). ### Example ```go ctx := context.Background() err := mcpserver.Run(ctx, "/etc/ardvark/ardvark.json", "0.5.0") if err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### Get Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/fetch.md Fetches a URL with rate limiting, robots.txt enforcement, and redirect following. ```APIDOC ## func (c *Client) Get(ctx context.Context, url string) (*Fetched, error) ### Description Fetches the given URL with rate limiting, timeouts, robots.txt enforcement, and redirect following. ### Parameters - **ctx** (context.Context) - Required - Context for timeout/cancellation. - **url** (string) - Required - HTTP or HTTPS URL to fetch. ### Returns - *Fetched - Fetch result (URL, status, body, content type, hash) - error - Typed *Error (or other error) on failure ``` -------------------------------- ### ardvark info Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Reports the running installation's metadata. ```APIDOC ## ardvark info ### Description Reports the running installation's metadata: binary version, config file path, storage backend details, and event log file. ``` -------------------------------- ### View crawl output Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Example output showing the results of a crawl operation. ```bash ardvark crawl $ ardvark crawl https://example.com seeded 1 of 1 requested seed(s) miss example.com well_known 404 miss example.com robots_agentmap no robots.txt miss iana.org well_known 404 ... run complete: 25 pages fetched · 40 hosts probed · 0 catalogs found · 0 valid · 0 errors ``` -------------------------------- ### Run Engine Method Signature Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/crawler.md The primary method for starting the crawler engine with a bounded worker pool. ```go func (e *Engine) Run(ctx context.Context, force bool) (*RunResult, error) ``` -------------------------------- ### Start Crawl Run Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Initializes a new crawl run record and returns the generated ID for tracking purposes. ```go func (st *Store) StartCrawlRun(ctx context.Context, config config.Config) (uint, error) ``` -------------------------------- ### Probing a host for ARD catalogs Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Example usage of the Probe function to discover catalogs on a specific host. ```go cfg, _ := config.Load("ardvark.json") fc := fetch.New(cfg.Crawler) defer fc.Close() results := probe.Probe(ctx, fc, "anthropic.com") for _, result := range results { fmt.Printf("Method: %s, Outcome: %s, URL: %s\n", result.Method, result.Outcome, result.URL) } ``` -------------------------------- ### Robots.txt Agentmap Directive Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Example of the Agentmap directive format expected within a robots.txt file. ```text Agentmap: https://example.com/.well-known/agent-catalog.json ``` -------------------------------- ### Handling fetch errors Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/fetch.md Example of checking for transient errors to determine if a retry is appropriate. ```go result, err := fc.Get(ctx, url) if err != nil { if ferr, ok := err.(*fetch.Error); ok { if ferr.Transient() { // Retry with exponential backoff } else { // Permanent failure, skip } } } ``` -------------------------------- ### Querying Ardvark SQLite database Source: https://github.com/helgesverre/ardvark/blob/main/SKILLS.md Examples for performing common lookups and aggregations on the ardvark.db SQLite database. ```sh # Every host that failed verification, with its checks sqlite3 ardvark.db " SELECT d.host, c.verification_status, vc.check_id, vc.message FROM catalogs c JOIN domains d ON d.id = c.domain_id JOIN verification_checks vc ON vc.subject_type = 'catalog' AND vc.subject_id = c.id AND vc.passed = 0 WHERE c.verification_status = 'invalid'; " # Count entries by media type across all indexed catalogs sqlite3 ardvark.db " SELECT media_type, COUNT(*) AS n FROM catalog_entries GROUP BY media_type ORDER BY n DESC; " # Every MCP server card entry, with its publisher and source URL sqlite3 ardvark.db " SELECT urn, urn_publisher, display_name, ref_url FROM catalog_entries WHERE media_type IN ('application/mcp-server-card+json', 'application/mcp-server+json'); " ``` -------------------------------- ### ardvark get Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Read one stored catalog or entry. ```APIDOC ## ardvark get ### Description Read one stored catalog or entry. Numeric IDs select an exact stored row. Exact catalog URLs and entry URNs select the newest matching stored version. ### Usage ardvark get catalog [--entry-limit 50] [--entry-cursor id] [--json] ardvark get entry [--json] ``` -------------------------------- ### Inline JSON-LD Script Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Example of an inline script block containing an ARD catalog in JSON-LD format. ```html ``` -------------------------------- ### Fetch URL with Error Handling in Go Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/fetch.md Perform a GET request with a context timeout and handle specific error types like robots.txt disallowance or transient failures. ```go ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() result, err := fc.Get(ctx, "https://example.com/.well-known/ard.json") if err != nil { if errors.Is(err, fetch.ErrRobotsDisallowed) { fmt.Println("Disallowed by robots.txt") } else if err.(*fetch.Error).Transient() { // Safe to retry with backoff } else { // Permanent error } } fmt.Printf("Status: %d, Body size: %d, Hash: %s\n", result.Status, len(result.Body), result.SHA256) ``` -------------------------------- ### Seed and Start Crawler Workers Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Initializes the shared frontier and launches multiple workers across shards using the --worker flag. ```bash # seed the shared frontier once... ardvark seed ct --count 5000 # ...then start one worker per shard (each on its own machine or core) ardvark work --worker 0/4 ardvark work --worker 1/4 ardvark work --worker 2/4 ardvark work --worker 3/4 ``` -------------------------------- ### Example MCP server log output Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md The server logs events to stderr using the standard LstdFlags format. ```text 2025-08-02 15:30:45 ardvark mcp: serving MCP over stdio (config /etc/ardvark/ardvark.json) 2025-08-02 15:31:12 ardvark mcp: tool call: ardvark_search (query="database agent") 2025-08-02 15:31:13 ardvark mcp: search returned 42 entries ``` -------------------------------- ### Full Probe Workflow Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Demonstrates the complete lifecycle of initializing a configuration, setting up a fetcher, and executing a probe against a target host. ```go import ( "context" "fmt" "log" "github.com/helgesverre/ardvark/internal/config" "github.com/helgesverre/ardvark/internal/fetch" "github.com/helgesverre/ardvark/internal/probe" ) func main() { cfg, err := config.Load("ardvark.json") if err != nil { log.Fatal(err) } fc := fetch.New(cfg.Crawler) defer fc.Close() ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() results := probe.Probe(ctx, fc, "anthropic.com") var hit *probe.Result for _, result := range results { fmt.Printf("%-20s %-12s %-4d %s\n", result.Method, result.Outcome, result.HTTPStatus, result.URL) if result.Outcome == probe.OutcomeHit { hit = &result } } if hit != nil { fmt.Printf("\nFound ARD at: %s\n", hit.URL) } else { fmt.Println("\nNo ARD found on this host") } } ``` -------------------------------- ### Initialize Fetch Client in Go Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/fetch.md Create a new client instance using configuration loaded from a file, ensuring resources are cleaned up with Close. ```go cfg, _ := config.Load("ardvark.json") fc := fetch.New(cfg.Crawler) defer fc.Close() fetched, err := fc.Get(context.Background(), "https://example.com") ``` -------------------------------- ### View Verification Failure Output Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Example console output showing how Ardvark reports schema validation errors and semantic warnings. ```console $ ardvark verify ./broken.json ./broken.json ✗ schema.validation support-agent — at /entries/0/identifier: 'support-agent' does not match pattern '^urn:air:[a-zA-Z0-9.-]+(:[a-zA-Z0-9._-]+)+$' ✓ identifier.unique all entry identifiers are unique ! queries.count support-agent — 0 representativeQueries present (recommended: 2-5) ! entry.media_type support-agent — type "application/x-agent" is not a recognized ARD media type (spec does not enforce this strictly) verdict: invalid Error: verify: ./broken.json is invalid ``` -------------------------------- ### Initialize and Run Programmatic Crawler Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/INDEX.md Sets up the crawler engine with configuration, storage, and frontier, then enqueues a seed host to begin crawling. ```go cfg, _ := config.Load("ardvark.json") st, _ := store.Open(cfg.Storage.Driver, cfg.Storage.DSN) fc := fetch.New(cfg.Crawler) fr, _ := frontier.New(st.DB, frontier.Options{Cfg: cfg.Crawler}) engine := crawler.New(cfg, st, fr, fc, slog.Default(), crawler.Options{}) engine.EnqueueSeedHost("anthropic.com", "seed") result, _ := engine.Run(context.Background(), false) ``` -------------------------------- ### Initialize Store Connection Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Opens a database connection and runs AutoMigrate. Ensure the returned Store is closed using defer to prevent resource leaks. ```go st, err := store.Open("sqlite", "ardvark.db") if err != nil { log.Fatal(err) } defer st.Close() // Use st to access domains, catalogs, etc. ``` -------------------------------- ### Open database connection Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/types.md Constructor function to initialize the store, run migrations, and establish a database connection. ```go func Open(driver, dsn string) (*Store, error) ``` -------------------------------- ### New Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/fetch.md Creates a new fetch client instance configured with crawler settings. ```APIDOC ## func New(cfg config.CrawlerConfig) *Client ### Description Creates a new fetch client with rate limiting, timeouts, and other politeness settings from the crawler config. ### Parameters - **cfg** (config.CrawlerConfig) - Required - Crawler configuration containing timeout, rate limit, body size cap, redirect cap, user agent. ### Returns - *Client - Initialized HTTP client ``` -------------------------------- ### Configure Storage Backends Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Define the storage driver and DSN in the configuration to switch between SQLite, MySQL, and PostgreSQL. ```json // sqlite (default) — dsn is a file path { "storage": { "driver": "sqlite", "dsn": "ardvark.db" } } ``` ```json // mysql { "storage": { "driver": "mysql", "dsn": "user:pass@tcp(127.0.0.1:3306)/ardvark?parseTime=true" } } ``` ```json // postgres { "storage": { "driver": "postgres", "dsn": "postgres://user:pass@127.0.0.1:5432/ardvark?sslmode=disable" } } ``` -------------------------------- ### Define Entry and Source Document Structures Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-28-ard-v0.91-migration.md Introduces the core types for handling entry completeness and source document representation during the migration. ```go type EntryCompleteness int // full entry vs Registry projection type DecodedEntry struct { Entry Entry Raw json.RawMessage Completeness EntryCompleteness } type SourceDocument struct { Kind SourceKind Entries []DecodedEntry LegacyMeta *LegacyCatalogMetadata Raw json.RawMessage } ``` -------------------------------- ### Get Verification Checks Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Retrieves a list of all verification checks associated with a given catalog or entry. ```go func (st *Store) GetVerificationChecks(ctx context.Context, subjectType string, subjectID uint) ([]VerificationCheck, error) ``` -------------------------------- ### Initialize Crawler Engine Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/crawler.md Defines the constructor signature for creating a new crawler engine instance. ```go func New(cfg config.Config, st *store.Store, fr *frontier.Frontier, fetchClient *fetch.Client, logger *slog.Logger, opts Options) *Engine ``` -------------------------------- ### Run Tests and Commit Changes Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Commands to verify the implementation via tests and commit the changes to the repository. ```bash git add internal/mediatype/mediatype.go internal/mediatype/mediatype_test.go git commit -m "feat(mediatype): parse media types into type/base/suffix/params" ``` -------------------------------- ### Build the ardvark binary Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Compiles the ardvark binary from the source code. ```bash go build -o bin/ardvark ./cmd/ardvark ``` -------------------------------- ### Initialize a new Frontier Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/frontier.md Defines the signature for creating a new frontier instance. ```go func New(db *gorm.DB, opts Options) (*Frontier, error) ``` -------------------------------- ### Implement Registry Result Pointer Follow Logic Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/specs/2026-07-16-registry-result-pointer-follow-design.md Iterates through registry search results to identify and follow catalog or registry pointers after persisting entries. ```go for i, res := range result.Results { switch mediatype.Parse(res.Type).Kind() { case mediatype.KindCatalog: e.followCatalogPointer(ctx, res.Entry, item.Host, item.URL, 0, &catalogID) case mediatype.KindRegistry: if res.URL == "" || !e.cfg.Registry.Harvest { continue } resultEntryID := rows[i].ID // the result row that IS the registry pointer e.followRegistryPointer(res.URL, item.Host, item.Depth+1, &store.Registry{EntryID: resultEntryID, BaseURL: res.URL, HarvestStatus: store.HarvestStatusPending, ReferralSourceID: uintPtr(regRowID)}, provenance{RegistryEntryID: &resultEntryID, RegistryCatalogID: &catalogID}) } } ``` -------------------------------- ### Run the smoke test suite Source: https://github.com/helgesverre/ardvark/blob/main/tools/smoketest/README.md Execute the test harness for either MySQL or PostgreSQL backends. ```sh cd tools/smoketest ./run.sh # MySQL (default) DB=postgres ./run.sh # PostgreSQL ``` -------------------------------- ### Run Media Type Tests Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Command to execute the specific media type tests. ```bash go test ./internal/mediatype/ -run 'TestKindClassification|TestProfile' ``` -------------------------------- ### HTML Link Tags for ARD Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Markup examples for linking to ARD catalogs using standard or legacy link tags. ```html ``` -------------------------------- ### Seed and crawl from CT logs Source: https://github.com/helgesverre/ardvark/blob/main/README.md Populate the queue with domains from Certificate Transparency logs and begin crawling. ```sh ardvark seed ct --count 1000 ardvark crawl ``` -------------------------------- ### Run Format Tests Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Command to execute the format-specific unit tests. ```bash go test ./internal/mediatype/ -run TestFormat ``` -------------------------------- ### Seed domains from CT logs Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Demonstrates seeding the frontier using Certificate Transparency logs with a specified count. ```bash $ ardvark seed ct --count 40 seed ct\_log complete: 40 entries from oak,argon,nimbus log(s) · 40 added · 0 skipped (already queued) ``` -------------------------------- ### Implement OnProbe callback Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/crawler.md Use the OnProbe callback within crawler options to handle catalog discovery events during host probing. ```go engine := crawler.New(cfg, st, fr, fc, logger, crawler.Options{ OnProbe: func(event crawler.ProbeEvent) { if event.CatalogFetched != nil { fmt.Printf("%s: valid catalog with %d entries\n", event.Host, len(event.CatalogFetched.Entries)) } else { fmt.Printf("%s: no valid catalog found\n", event.Host) } }, }) ``` -------------------------------- ### Run All Tests Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Command to run all tests in the mediatype package. ```bash go test ./internal/mediatype/ ``` -------------------------------- ### Configure Single-Process SQLite Storage Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/configuration.md Sets up a local SQLite database for storage with default crawler concurrency settings. ```json { "storage": { "driver": "sqlite", "dsn": "ardvark.db" }, "crawler": { "concurrency": 4, "perHostRequestsPerSecond": 0.5 } } ``` -------------------------------- ### Seed Command Syntax Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Basic usage pattern for bootstrapping the frontier from external sources. ```text ardvark seed [ct|crtsh|tranco|github|mcp|curated|commoncrawl] [flags] ``` -------------------------------- ### InsertProbe Method Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Records a probe attempt on a domain in the probes table. ```go func (st *Store) InsertProbe(domainID uint, method, url string, result *probe.Result) error ``` -------------------------------- ### Performing Transport Checks and Verification Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Demonstrates how to execute transport checks after a fetch and combine them with the main verification report. ```go // After fetching fetched, _ := fc.Get(ctx, url) // Get transport checks transportChecks := ard.TransportChecks( fetched.ContentType, fetched.Body, cfg.Crawler.MaxBodyBytes, ) // Verify the document report, _ := ard.Verify(fetched.Body, false) // Combine checks allChecks := append(transportChecks, report.Checks...) ``` -------------------------------- ### Frontier Options Structure Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/frontier.md Defines the configuration structure required for frontier initialization. ```go type Options struct { Cfg config.CrawlerConfig // Crawler config (concurrency, lease duration) // Additional unexported fields } ``` -------------------------------- ### CatalogsByHost Method Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Lists all catalogs associated with a specific hostname, limited by the provided integer. ```go func (st *Store) CatalogsByHost(ctx context.Context, host string, limit int) ([]Catalog, error) ``` -------------------------------- ### Probe host with JSON output Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Executes a probe command and returns the results as a structured JSON document. ```console $ ardvark probe example.com --json { "hosts": [ { "host": "example.com", "results": [ { "method": "well_known", "url": "https://example.com/.well-known/ai-catalog.json", "http_status": 404, "outcome": "miss" }, { "method": "robots_agentmap", "url": "https://example.com/robots.txt", "outcome": "miss", "error_detail": "no robots.txt" } ] } ], "summary": { "hits": 0, "misses": 2, "errors": 0 } } ``` -------------------------------- ### Test Unsuffixed Registry Pointer Follow-up Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md A test case to verify that the crawler correctly follows registry pointers even when they lack the expected suffix. ```go func TestEnqueueFollowups_UnsuffixedRegistryPointerIsFollowed(t *testing.T) { mux := http.NewServeMux() catalog := `{"specVersion":"1.0","host":{"displayName":"H"},"entries":[ {"identifier":"urn:air:example.com:registry:r","displayName":"R","type":"application/ai-registry","url":"https://registry.example/api"} ]}` mux.HandleFunc("/reg.json", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/ai-catalog+json") w.Write([]byte(catalog)) }) srv := httptest.NewServer(mux) defer srv.Close() eng, st := newTestEngine(t, testCrawlerConfig()) host := strings.TrimPrefix(srv.URL, "http://") item := store.FrontierItem{URL: srv.URL + "/reg.json", Host: host, Depth: 0} if err := eng.handleCatalogFetch(context.Background(), item); err != nil { t.Fatalf("handleCatalogFetch: %v", err) } var harvests int64 st.DB.Model(&store.FrontierItem{}).Where("kind = ?", store.KindRegistryHarvest).Count(&harvests) if harvests != 1 { t.Fatalf("expected 1 registry_harvest for unsuffixed application/ai-registry, got %d", harvests) } var regRows int64 st.DB.Model(&store.Registry{}).Count(®Rows) if regRows != 1 { t.Fatalf("expected 1 registries row, got %d", regRows) } } ``` -------------------------------- ### Retrieve System Statistics Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Fetches high-level metrics including domain status, catalog verdicts, and media type counts. ```go func (st *Store) Stats(ctx context.Context) (Stats, error) ``` -------------------------------- ### Programmatic Crawling with Ardvark Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/README.md Initializes the crawler engine with configuration, storage, and frontier settings to process seed hosts. ```go cfg, _ := config.Load("ardvark.json") st, _ := store.Open(cfg.Storage.Driver, cfg.Storage.DSN) defer st.Close() fc := fetch.New(cfg.Crawler) defer fc.Close() fr, _ := frontier.New(st.DB, frontier.Options{Cfg: cfg.Crawler}) engine := crawler.New(cfg, st, fr, fc, slog.Default(), crawler.Options{ MaxAttempts: 3, OnProbe: func(event crawler.ProbeEvent) { if event.CatalogFetched != nil { fmt.Printf("%s: %d entries\n", event.Host, len(event.CatalogFetched.Entries)) } }, }) engine.EnqueueSeedHost("anthropic.com", "manual") result, _ := engine.Run(context.Background(), false) fmt.Printf("Found %d valid catalogs\n", result.CatalogsValid) ``` -------------------------------- ### Configure SQLite Storage Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Default storage configuration using a local file path. ```jsonc // sqlite (default) — dsn is a file path { "storage": { "driver": "sqlite", "dsn": "ardvark.db" } } ``` -------------------------------- ### Run MCP Server Function Signature Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/mcp-server.md The Run function serves the MCP server over stdio using the provided context, configuration path, and version string. ```go func Run(ctx context.Context, configPath, version string) error ``` -------------------------------- ### Update Entry Loop Logic Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Refactor the semantic check loop to use the parsed media type for pointer detection. ```go mt := mediatype.Parse(e.Type) // representativeQueries describe a callable capability; they are not // meaningful for container/pointer entries (a nested catalog or a // registry endpoint), so don't warn on their absence there. if !mt.IsPointer() { checks = append(checks, checkQueriesCount(e, subject)) } checks = append(checks, checkMediaType(e, mt, subject)) ``` -------------------------------- ### Verify a Local File Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Reads a local JSON file and performs verification, handling the resulting verdict and reporting warnings or errors. ```go import ( "log" "os" "github.com/helgesverre/ardvark/internal/ard" ) doc, err := os.ReadFile("my-catalog.json") if err != nil { log.Fatal(err) } report, err := ard.Verify(doc, false) if err != nil { log.Fatalf("Failed to parse JSON: %v", err) } switch report.Verdict { case ard.VerdictValid: log.Println("✓ Catalog is valid") case ard.VerdictValidWithWarnings: log.Println("⚠ Catalog is valid with warnings") for _, check := range report.Checks { if check.Severity == ard.SeverityWarning && !check.Passed { log.Printf(" - %s: %s", check.CheckID, check.Message) } } case ard.VerdictInvalid: log.Println("✗ Catalog is invalid") for _, check := range report.Checks { if check.Severity == ard.SeverityError && !check.Passed { log.Printf(" - %s: %s", check.CheckID, check.Message) } } } ``` -------------------------------- ### Configure PostgreSQL Storage Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Storage configuration for a PostgreSQL database instance. ```jsonc // postgres { "storage": { "driver": "postgres", "dsn": "postgres://user:pass@127.0.0.1:5432/ardvark?sslmode=disable" } } ``` -------------------------------- ### StartCrawlRun Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Creates a new crawl run record and returns its ID. ```APIDOC ## StartCrawlRun ### Description Creates a new crawl run record and returns its ID. ### Signature `func (st *Store) StartCrawlRun(ctx context.Context, config config.Config) (uint, error)` ### Returns - **uint** - New crawl run ID (for associating frontier items) - **error** - Database error ``` -------------------------------- ### Add Mediatype Import Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Import statement required for the new mediatype parsing logic. ```go "github.com/helgesverre/ardvark/internal/mediatype" ``` -------------------------------- ### Configure MySQL Storage Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Storage configuration for a MySQL database instance. ```jsonc // mysql { "storage": { "driver": "mysql", "dsn": "user:pass@tcp(127.0.0.1:3306)/ardvark?parseTime=true" } } ``` -------------------------------- ### SearchResult Struct Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Contains the paginated list of entries and the cursor for the next page. ```go type SearchResult struct { Entries []SearchEntry // Result entries NextCursor uint // Entry ID for next page (0 if no next page) } ``` -------------------------------- ### Run Database Migrations Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Executes GORM AutoMigrate for all Ardvark tables to ensure the schema exists. ```bash ardvark migrate ``` -------------------------------- ### Configure Shared Database for Distributed Crawling Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Set up a shared configuration file for multiple workers to connect to the same database instance. ```json // shared ardvark.json — every worker points at the same database { "storage": { "driver": "postgres", "dsn": "postgres://user:pass@db:5432/ardvark?sslmode=disable" }, "crawler": { "worker": { "count": 4 } } } ``` -------------------------------- ### GetRegistry Method Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Retrieves a registry record by its unique identifier. ```go func (st *Store) GetRegistry(ctx context.Context, id uint) (*Registry, error) ``` -------------------------------- ### Verify catalog files using ardvark Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html Run verification on local or remote catalog files. Use the --strict flag to enforce exact specification conformance. ```bash ardvark verify ./my-catalog.json ardvark verify https://example.com/.well-known/ai-catalog.json ardvark verify --strict ./my-catalog.json ``` -------------------------------- ### Stats and export Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.html View statistics and export results to a JSONL file. ```bash ardvark stats ardvark export --format jsonl --out resources.jsonl ``` -------------------------------- ### SearchOptions Struct Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Defines the filtering and pagination parameters for search queries. ```go type SearchOptions struct { Query string // Free-text search terms Host string // Exact serving host (exact match) Publisher string // Exact URN publisher (exact match) MediaType string // Exact entry media type Tag string // Exact entry tag Verdict string // Catalog verdict filter Limit int // Max results (1-200) Cursor uint // Last entry ID from previous page } ``` -------------------------------- ### Run Ardvark MCP Server Source: https://github.com/helgesverre/ardvark/blob/main/website/docs.md Command to initiate the Ardvark MCP server process. ```text ardvark mcp [flags] ``` -------------------------------- ### Verifying a Catalog Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/README.md Validates an AI catalog file and iterates through the resulting checks to identify failures. ```go doc, _ := os.ReadFile("ai-catalog.json") report, _ := ard.Verify(doc, false) fmt.Println(report.Verdict) for _, check := range report.Checks { if !check.Passed { fmt.Printf("FAILED: %s - %s\n", check.CheckID, check.Message) } } ``` -------------------------------- ### ard.VerifyURL(ctx context.Context, url string, strict bool, fc fetch.Client) Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/ard-verification.md Fetches a catalog from a remote URL and verifies it using the provided fetch client. ```APIDOC ## func ard.VerifyURL ### Description Fetches a catalog from a remote URL and performs verification. Requires a context for timeout management and a fetch client. ### Signature `func VerifyURL(ctx context.Context, url string, strict bool, fc fetch.Client) (Report, error)` ### Parameters - **ctx** (context.Context) - Required - Context for request timeout and cancellation. - **url** (string) - Required - The URL of the catalog to fetch and verify. - **strict** (bool) - Required - If true, format assertions are treated as errors. - **fc** (fetch.Client) - Required - The fetch client instance used to retrieve the remote resource. ### Returns - **report** (Report) - The verification results. - **err** (error) - An error if the fetch or verification process fails. ``` -------------------------------- ### Run project checks Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Executes the project's check suite to ensure code quality and test passing. ```bash just check ``` -------------------------------- ### Searching Indexed Resources Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/README.md Queries the storage backend for indexed resources based on specific criteria like host and verdict. ```go result, _ := st.Search(ctx, store.SearchOptions{ Query: "claude agent", Host: "anthropic.com", Verdict: "valid", Limit: 50, Cursor: 0, }) for _, entry := range result.Entries { fmt.Printf("%s: %s\n", entry.URN, entry.DisplayName) } ``` -------------------------------- ### Define Media Type Structures and Constants Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/specs/2026-07-16-media-type-parsing-design.md Defines the core data structures and constants for categorizing media types and serialization formats. ```go package mediatype // Kind is the semantic category of an entry's media type — "what it is", // independent of serialization. type Kind int const ( KindUnknown Kind = iota KindCatalog // application/ai-catalog[...] — pointer KindRegistry // application/ai-registry[...] — pointer KindSkill // ai-skill, agent-skills, ai-skill-archive KindMCPServer // mcp-server-card, mcp-server KindA2AAgent // a2a-agent-card, a2a-agent KindGeneric // recognized non-ARD artifact (openapi, linkset, json, markdown, …) ) // Format is the concrete serialization/encoding hint — "how it's encoded" — // derived from the structured-syntax suffix, the base tail, or the top type. type Format int const ( FormatUnknown Format = iota FormatJSON FormatMarkdown FormatZip FormatGzip FormatHTML FormatText ) // MediaType is a parsed, normalized media type. type MediaType struct { Raw string // untouched original input Type string // lowercased top-level type: "application", "text" Base string // lowercased subtype minus suffix: "ai-skill-archive" Suffix string // lowercased suffix minus '+': "json","md","gzip","" Params map[string]string // lowercased parameter names; values unquoted, as-is } func Parse(s string) MediaType func (m MediaType) FullType() string // Type + "/" + Base, e.g. "application/ai-skill-archive" func (m MediaType) Kind() Kind func (m MediaType) Format() Format func (m MediaType) IsPointer() bool // Kind == KindCatalog || KindRegistry func (m MediaType) IsKnown() bool // Kind != KindUnknown (KindGeneric counts as known) func (m MediaType) Profile() string // Params["profile"] ``` -------------------------------- ### Manage and export results Source: https://github.com/helgesverre/ardvark/blob/main/README.md View statistics, search the database, and export results to a file. ```sh ardvark stats ardvark search "database agent" --verdict valid ardvark export --format jsonl --out resources.jsonl ``` -------------------------------- ### InsertCatalog Method Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/store.md Stores a fetched and verified ARD catalog, including its entries and metadata, into the catalogs and catalog_entries tables. ```go func (st *Store) InsertCatalog(ctx context.Context, domainID uint, sourceURL string, parentCatalogID *uint, c *ard.Catalog) (uint, error) ``` -------------------------------- ### Using Outcome Constants Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/probe.md Recommended pattern for checking probe results using defined constants. ```go if result.Outcome == probe.OutcomeHit { // Process the discovered ARD } ``` -------------------------------- ### Define Pointer Helper Functions Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/specs/2026-07-16-registry-result-pointer-follow-design.md Extracts pointer handling logic into reusable methods for both catalog and registry paths. ```go // followCatalogPointer follows an ai-catalog pointer entry: a url-referenced // nested catalog becomes a catalog_fetch at depth; an embedded-data catalog is // processed recursively at depth. func (e *Engine) followCatalogPointer(ctx context.Context, en ard.Entry, host, sourceURL string, depth int, parentCatID *uint) // followRegistryPointer persists a registries row and enqueues a // registry_harvest for it at depth. The caller supplies the row (with its // provenance columns) and the frontier-item provenance; this sets // prov.RegistryRowID to the new row's ID. func (e *Engine) followRegistryPointer(url, host string, depth int, regRow *store.Registry, prov provenance) ``` -------------------------------- ### Implement Format Logic Source: https://github.com/helgesverre/ardvark/blob/main/docs/superpowers/plans/2026-07-16-media-type-parsing.md Definition of the Format enum and the logic to derive it from MediaType fields. ```go // Format is the concrete serialization/encoding hint — how the artifact is // encoded — derived from the suffix, the base tail, or the top-level type. type Format int const ( FormatUnknown Format = iota FormatJSON FormatMarkdown FormatZip FormatGzip FormatHTML FormatText ) func (f Format) String() string { switch f { case FormatJSON: return "json" case FormatMarkdown: return "markdown" case FormatZip: return "zip" case FormatGzip: return "gzip" case FormatHTML: return "html" case FormatText: return "text" default: return "unknown" } } // Format derives the encoding hint. Suffix wins; otherwise text/* subtypes // map to their obvious formats; otherwise Unknown. func (m MediaType) Format() Format { switch m.Suffix { case "json": return FormatJSON case "md": return FormatMarkdown case "zip": return FormatZip case "gzip": return FormatGzip } if m.Type == "text" { switch m.Base { case "markdown": return FormatMarkdown case "html": return FormatHTML case "plain": return FormatText } } return FormatUnknown } ``` -------------------------------- ### URN String method Source: https://github.com/helgesverre/ardvark/blob/main/_autodocs/api-reference/types.md Returns the canonical normalized form of the URN. ```go func (u URN) String() string ```