# Hackage

Recommend AXM extensions from a Hackage (Haskell) package and target Hackage packages from an extension.

AXM reads Haskell extension metadata from the `x-agent-extensions` custom field
in the package's `.cabal` file. This is the
[two-way linking](/docs/package-ecosystems/overview) model applied to the
Hackage ecosystem. Cabal allows arbitrary `x-` prefixed fields, and AXM
JSON-decodes each one.

## Recommend extensions from a package

Add an `x-agent-extensions` field to the `.cabal` file. Its value is a JSON
array of extension declarations, where each entry is an extension reference
(`@owner/<type>/<name>`):

```cabal
-- agentxm-example-tinyflags.cabal
x-agent-extensions: [{"ref":"@examples/packs/haskell-hackage-tinyflags"}]
```

The JSON must stay on one line per Cabal's field grammar.

Keep recommendations **identity-only** — omit `versionRange`. AXM resolves the
reference to the newest matching extension version and pins it in the user's
`axm.lock`. Prefer recommending a single **pack** so you keep one stable
reference while its contents evolve.

Add a semver `versionRange` only when your package genuinely pairs with a
bounded major line of the extension:

```cabal
x-agent-extensions: [{"ref":"@examples/packs/haskell-hackage-tinyflags","versionRange":"^1.0.0"}]
```

## Target Hackage packages from an extension

On the extension manifest (`skill.json`, `pack.json`, `subagent.json`, …), add a
`packages` array with a Hackage
[purl](https://github.com/package-url/purl-spec). Use the package name as
published to Hackage as the purl name:

```jsonc
// pack.json
{
  "packages": [{ "purl": "pkg:hackage/agentxm-example-tinyflags" }],
}
```

### Version ranges

Default to identity-only. Add a [VERS](https://github.com/package-url/vers-spec)
`versionRange` with the `hackage` scheme only when the extension depends on
package APIs introduced or removed in a known range:

```jsonc
{
  "packages": [
    {
      "purl": "pkg:hackage/agentxm-example-tinyflags",
      "versionRange": "vers:hackage/>=0.1.0|<1.0.0",
    },
  ],
}
```

## Official status

When the Hackage package recommends an extension through the AgentXM Registry
**and** that extension names the package as a companion via its purl, AXM
derives **official** status for the pair — no extra flag. See
[Official extensions](/docs/package-ecosystems/overview#official-extensions).

## Reference fixture

The
[`haskell-hackage-lib`](https://github.com/agentxm/polyglot-examples/tree/main/haskell-hackage-lib)
and
[`haskell-hackage-app`](https://github.com/agentxm/polyglot-examples/tree/main/haskell-hackage-app)
directories in `polyglot-examples` are the working fixtures for everything
above. The package publishes a TinyFlags companion pack and recommends it from
the `x-agent-extensions` field in its `.cabal` file; the pack and each skill
declare the package's `pkg:hackage` purl as an identity-only companion package.