{
  "docsVersion": 2,
  "cliVersion": "0.2.0",
  "title": "CLI & AI agents",
  "endpointPlaceholder": "<cdn-endpoint>",
  "sections": [
    {
      "id": "quick-start",
      "title": "Quick start",
      "blocks": [
        {
          "t": "p",
          "text": "The `akk-cdn` CLI is how you and coding agents find, upload and use assets on this CDN. It talks to the CDN API with an **automation token**. The admin password and the admin token are for this panel only."
        },
        {
          "t": "p",
          "text": "Check the CLI and the environment it's signed in to:"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn version\nakk-cdn whoami --endpoint <cdn-endpoint>"
        },
        {
          "t": "p",
          "text": "`whoami` prints the endpoint, the token's role and the environment (`production`, `test` or `local`). New here? Work through **Install or update**, **Sign in safely** and **Project workflow**, then set up your agent in **Claude Code & Codex**."
        }
      ]
    },
    {
      "id": "install",
      "title": "Install or update akk-cdn",
      "blocks": [
        {
          "t": "p",
          "text": "You need Node.js 20 or later and a copy of the CDN repository (its `cdn-cli` folder)."
        },
        {
          "t": "p",
          "text": "Install and put `akk-cdn` on your `PATH`:"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "cd cdn-cli\nnpm install\nnpm link\nakk-cdn version"
        },
        {
          "t": "p",
          "text": "To update, pull the repository and reinstall. `akk-cdn version` shows the CLI and documentation versions:"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "cd cdn-cli\ngit pull\nnpm install\nakk-cdn version"
        },
        {
          "t": "p",
          "text": "The Claude Code skill is a link into the repository, so it updates with it. The Codex section is a copy: run `./install-agents.sh` again after an update."
        }
      ]
    },
    {
      "id": "sign-in",
      "title": "Sign in safely",
      "blocks": [
        {
          "t": "p",
          "text": "Use the **automation token**. `akk-cdn login` refuses the admin token."
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn login --endpoint <cdn-endpoint>\nakk-cdn whoami --endpoint <cdn-endpoint>"
        },
        {
          "t": "ul",
          "items": [
            "The prompt hides what you type. Get the token from where you keep secrets, such as your password manager. Never paste it into a command line, chat, issue or file in a repository.",
            "It's saved to `~/.config/akk-cdn/credentials.json`, readable only by you. Tokens are saved per endpoint, so the test and production CDNs each need their own sign-in.",
            "In scripts and cloud setup, pipe the token from an environment variable instead of typing it:"
          ]
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "printf '%s' \"$AKK_CDN_TOKEN\" | akk-cdn login --endpoint <cdn-endpoint>"
        },
        {
          "t": "ul",
          "items": [
            "Or set both `AKK_CDN_URL` and `AKK_CDN_TOKEN` in the environment. Every command reads them, and the token is only ever sent to that URL."
          ]
        }
      ]
    },
    {
      "id": "workflow",
      "title": "Project workflow",
      "blocks": [
        {
          "t": "h",
          "level": 3,
          "text": "Link a repository to a project"
        },
        {
          "t": "p",
          "text": "Run once in the site's repository, then commit `cdn.config.json` and `cdn.manifest.json`. The project key is permanent, so pick a stable one (not a page slug)."
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn init --site <site> --project <project> --endpoint <cdn-endpoint>"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Upload an asset"
        },
        {
          "t": "p",
          "text": "Uploads are drafts. Raster images are converted to WebP (2400px max), and the original is kept privately."
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn upload ./hero.jpg --alias hero --role hero --alt \"<describe the image>\""
        },
        {
          "t": "h",
          "level": 3,
          "text": "Add and approve a revision"
        },
        {
          "t": "p",
          "text": "`--revise` adds a new revision with its own URL; the old URL keeps working. Approve it on the **Assets** page (Needs approval), or from the CLI when you mean to. `approve` takes the newest draft unless you pass `--revision`."
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn upload ./hero-v2.jpg --alias hero --revise --alt \"<describe the image>\"\nakk-cdn approve hero"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Pull and inspect the manifest"
        },
        {
          "t": "p",
          "text": "`cdn.manifest.json` lists every alias. Agents use only `assets[alias].current`."
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "akk-cdn manifest --pull\nakk-cdn manifest\nakk-cdn snippet hero --as html"
        },
        {
          "t": "p",
          "text": "To make sure a command can only change the environment you mean, add `--expect-env production` (or `test`) to `init`, `upload`, `approve` and `set`."
        }
      ]
    },
    {
      "id": "agents",
      "title": "Claude Code & Codex",
      "blocks": [
        {
          "t": "p",
          "text": "Agents follow the rules that `akk-cdn guide` prints. A small instruction file tells each agent to read them first. Pick your agent and where it runs."
        },
        {
          "t": "h",
          "level": 3,
          "text": "Claude Code on this machine",
          "v": "claude-local"
        },
        {
          "t": "p",
          "text": "Run the installer from the CDN repository. It links the skill into `~/.claude/skills/akk-cdn` and changes nothing else:",
          "v": "claude-local"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "./cdn-cli/install-agents.sh --dry-run\n./cdn-cli/install-agents.sh",
          "v": "claude-local"
        },
        {
          "t": "p",
          "text": "Verify, then restart Claude Code:",
          "v": "claude-local"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "test -f ~/.claude/skills/akk-cdn/SKILL.md && echo \"skill installed\"",
          "v": "claude-local"
        },
        {
          "t": "p",
          "text": "Ask Claude Code something from the examples below. It should run `akk-cdn guide` before choosing an asset.",
          "v": "claude-local"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Claude Code in the cloud",
          "v": "claude-cloud"
        },
        {
          "t": "p",
          "text": "A cloud session starts from a fresh machine, so it needs the CLI and a token each time:",
          "v": "claude-cloud"
        },
        {
          "t": "ol",
          "start": 1,
          "items": [
            "In the cloud environment's settings, add two environment variables: `AKK_CDN_URL` (set to `<cdn-endpoint>`) and `AKK_CDN_TOKEN` (the automation token). Never commit them.",
            "Allow network access to the CDN host in the environment's network settings.",
            "Use the **Claude Code cloud setup script** download as the environment's setup script. Both variables are read on every command, so no `login` is needed.",
            "Commit the **Claude Code skill** download to the site repository as `.claude/skills/akk-cdn/SKILL.md`, so cloud sessions load it."
          ],
          "v": "claude-cloud"
        },
        {
          "t": "p",
          "text": "Verify in a session: ask it to run `akk-cdn whoami`. To reconnect after the token is rotated, update `AKK_CDN_TOKEN` and start a new session.",
          "v": "claude-cloud"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Codex on this machine",
          "v": "codex-local"
        },
        {
          "t": "p",
          "text": "The same installer adds a managed section to `~/.codex/AGENTS.md`. It backs up the file first and replaces only its own section when re-run:",
          "v": "codex-local"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "./cdn-cli/install-agents.sh",
          "v": "codex-local"
        },
        {
          "t": "p",
          "text": "Verify (prints 1 when the section is there):",
          "v": "codex-local"
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "grep -c \"akk-cdn:begin\" ~/.codex/AGENTS.md",
          "v": "codex-local"
        },
        {
          "t": "p",
          "text": "If `~/.codex/AGENTS.override.md` exists, Codex reads that instead. The installer warns you, and you paste the **Codex instructions** download into it yourself.",
          "v": "codex-local"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Codex in the cloud",
          "v": "codex-cloud"
        },
        {
          "t": "ol",
          "start": 1,
          "items": [
            "In the Codex environment, add the automation token as a secret named `AKK_CDN_TOKEN`, and `AKK_CDN_URL` (set to `<cdn-endpoint>`) as an environment variable.",
            "Codex gives secrets to the setup script only. Use the **Codex cloud setup script** download: it installs the CLI and signs in, which saves the token for the agent.",
            "Allow network access to the CDN host for the agent.",
            "Add the **Codex instructions** download to the site repository's `AGENTS.md`."
          ],
          "v": "codex-cloud"
        },
        {
          "t": "p",
          "text": "Verify in a task: ask it to run `akk-cdn whoami`. To reconnect after the token is rotated, update the secret and start a new task, so the setup script signs in again.",
          "v": "codex-cloud"
        },
        {
          "t": "h",
          "level": 3,
          "text": "Example requests"
        },
        {
          "t": "ul",
          "items": [
            "\"Use the approved CDN hero image on the home page.\"",
            "\"Upload `./shots/*.png` to the CDN as gallery images with good alt text. Leave them as drafts.\"",
            "\"Which CDN assets for this project are still waiting for approval?\"",
            "\"Replace the cover image with `./cover-v2.jpg` as a new revision.\""
          ]
        }
      ]
    },
    {
      "id": "new-machine",
      "title": "New machine",
      "blocks": [
        {
          "t": "ol",
          "start": 1,
          "items": [
            "Install the CLI (see **Install or update**).",
            "Sign in with the automation token (see **Sign in safely**). Each machine signs in for itself; never copy `credentials.json` between machines.",
            "Install the agent instructions from the `cdn-cli` folder:"
          ]
        },
        {
          "t": "code",
          "lang": "sh",
          "text": "./install-agents.sh --dry-run\n./install-agents.sh"
        },
        {
          "t": "ol",
          "start": 4,
          "items": [
            "In each site repository you work on, check the link: `akk-cdn whoami` shows the endpoint and environment, and `akk-cdn manifest` summarises the local manifest."
          ]
        },
        {
          "t": "p",
          "text": "Cloud machines don't follow these steps. They use the setup scripts in the downloads, with the token kept in the environment's settings."
        }
      ]
    },
    {
      "id": "permissions",
      "title": "Environments & permissions",
      "blocks": [
        {
          "t": "p",
          "text": "Every command runs against one environment. `akk-cdn whoami` names it, and this page labels each command with the environment and host it targets."
        },
        {
          "t": "ul",
          "items": [
            "**production**: the live CDN. Its URLs are used by the sites.",
            "**test**: an isolated copy with its own storage, tokens and data.",
            "**local**: a worker running on your machine with simulated storage."
          ]
        },
        {
          "t": "p",
          "text": "The **automation token** (CLI and agents) can create and approve project assets in `site/project/type`, edit their display fields (role, placement, usage note, record ID, alt text), create project folders, and read manifests and hashes."
        },
        {
          "t": "p",
          "text": "It **can't** delete, retire or move anything, change visibility, sign private URLs, download originals, touch legacy files, list the whole CDN, or change any credential or Cloudflare setting. Those stay with you, in this panel or from the CDN repository."
        },
        {
          "t": "p",
          "text": "The **admin password** signs you in to this panel. It and the admin token never go to agents or the CLI."
        },
        {
          "t": "p",
          "text": "Add `--expect-env production` (or `test`) to changing commands so they stop if they reach the wrong environment."
        }
      ]
    },
    {
      "id": "troubleshooting",
      "title": "Troubleshooting",
      "blocks": [
        {
          "t": "h",
          "level": 3,
          "text": "`akk-cdn: command not found`"
        },
        {
          "t": "p",
          "text": "The CLI isn't on your `PATH`. Run `npm link` in the `cdn-cli` folder, or open a new terminal."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`No credentials for …`"
        },
        {
          "t": "p",
          "text": "There's no token saved for that endpoint. Sign in to it (see **Sign in safely**). Tokens are saved per endpoint, so test and production each need their own."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`That is the admin token`"
        },
        {
          "t": "p",
          "text": "`login` refuses the admin token on purpose. Use the automation token."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`→ 401` on any command"
        },
        {
          "t": "p",
          "text": "The token was rotated or is wrong. Sign in again, or update `AKK_CDN_TOKEN` in a cloud environment."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`AKK_CDN_TOKEN requires AKK_CDN_URL`"
        },
        {
          "t": "p",
          "text": "Set both variables, or neither. A token is only ever sent to the endpoint it belongs to."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`Target env is \"…\", expected \"…\"`"
        },
        {
          "t": "p",
          "text": "`--expect-env` stopped a command aimed at the wrong environment. Check `akk-cdn whoami` and the `endpoint` in `cdn.config.json`."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`No cdn.config.json found`"
        },
        {
          "t": "p",
          "text": "Run the command inside a linked repository, or link it with `akk-cdn init`."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`alias_exists`"
        },
        {
          "t": "p",
          "text": "That alias already has a revision. Add `--revise` to upload a new revision, or choose another alias."
        },
        {
          "t": "h",
          "level": 3,
          "text": "The agent ignores the CDN"
        },
        {
          "t": "p",
          "text": "Check that the skill or `AGENTS.md` section is installed (see the verify steps in **Claude Code & Codex**), then restart the agent. In the cloud, check that the instructions are committed to the repository."
        },
        {
          "t": "h",
          "level": 3,
          "text": "`Network error` in a cloud session"
        },
        {
          "t": "p",
          "text": "The environment blocks the CDN host. Allow it in the environment's network settings."
        }
      ]
    },
    {
      "id": "rotation",
      "title": "Token rotation",
      "owner": true,
      "blocks": [
        {
          "t": "p",
          "text": "Rotating the automation token replaces it everywhere. It's an **owner operation**: it needs your Cloudflare access to the CDN worker and runs from the CDN repository, following its rollout procedure. Agents and the automation token can't do it; the token has no access to Cloudflare or to its own secret."
        },
        {
          "t": "p",
          "text": "What to expect:"
        },
        {
          "t": "ul",
          "items": [
            "The old token stops working within seconds, when the new worker version goes live. The machine that runs the rotation is updated by it.",
            "Every other machine and cloud agent gets `401` until you sign it in again (see **Sign in safely**) or update `AKK_CDN_TOKEN` in its environment settings.",
            "The new token is saved only in `~/.config/akk-cdn/credentials.json` on that machine. It's never printed. Move it to other machines and environments with your own secure method, such as your password manager.",
            "Older worker versions keep the old token. Cloudflare refuses to switch back to them unless the switch is forced (error 10220). A forced switch brings the old token back, so only do it deliberately, and never after a suspected leak."
          ]
        }
      ]
    }
  ],
  "downloads": [
    {
      "file": "akk-cdn-skill.md",
      "title": "Claude Code skill",
      "description": "SKILL.md for ~/.claude/skills/akk-cdn/ (the installer links it for you)",
      "bytes": 1426,
      "sha256": "b31fbd09b134cf50427b17319488679eb81f63658602759c065ed8def6db1f2f"
    },
    {
      "file": "codex-agents-section.md",
      "title": "Codex instructions",
      "description": "Section for ~/.codex/AGENTS.md or a repo's AGENTS.md",
      "bytes": 769,
      "sha256": "3f7ddb30060e9ece7887083cdcaf6d0b4f8c3ffc839f8828ed2b7a92a93b337e"
    },
    {
      "file": "agent-guide.md",
      "title": "Agent rules",
      "description": "What akk-cdn guide prints: how agents pick, use and upload assets",
      "bytes": 4322,
      "sha256": "1f9126f85900cb34eac782e1ef78b9d138986ce693b729b31e68fb3c3dbb715e"
    },
    {
      "file": "setup.md",
      "title": "Setup guide",
      "description": "This page as Markdown (what akk-cdn guide setup prints)",
      "bytes": 10713,
      "sha256": "1a146bec374606fd6ec2550d33c51c85b0fc3f1b3e916ef3d90fcdb7f3c47b3e"
    },
    {
      "file": "cdn.config.example.json",
      "title": "Example cdn.config.json",
      "description": "Project link with placeholders; akk-cdn init writes the real one",
      "bytes": 169,
      "sha256": "3e829016973c16a0a6bc6f2f6549b54dcd6b8cebe884cdb07aceab2c05390fdc",
      "example": true
    },
    {
      "file": "cloud-setup-claude.sh",
      "title": "Claude Code cloud setup script",
      "description": "Installs the CLI; the token comes from the environment's variables",
      "bytes": 388,
      "sha256": "1b438b1719abb9b52bf8abf5620328d43278dac671b26e294d9cfa7a1028d21e",
      "example": true
    },
    {
      "file": "cloud-setup-codex.sh",
      "title": "Codex cloud setup script",
      "description": "Installs the CLI and signs in from the setup secret",
      "bytes": 495,
      "sha256": "8188b78ecbde87bea8cf2f9f49dd6b9a9530b136ab923d65353626170b451ca8",
      "example": true
    }
  ]
}
