Skip to content
Source
Sign inSign up

Publish from your coding agent

Code and repositories / Artifacts

Publish from your coding agent

Your coding agent writes a plan for an issue, or a test report for a pull request, and you want your team to read it on the forge, not in your terminal. The agent publishes it as an artifact with src, MCP or REST. It stays private until you share it.

5 min read

You need write access to the repository. Without it, you can publish only on your own issue or pull request.

1. Publish a plan on an issue

In a clone of the repository, run:

src issue artifact create 12 plan.md --type plan
  • create prints the URL of the artifact's page.
  • The artifact takes the file name as its title. To give it another title, run src issue artifact create 12 plan.md#"Sign-in plan" --type plan.
  • --type is generic (the default) or plan for Markdown.
  • src pr artifact create 7 report.md does the same on a pull request. src artifact create notes.md puts it on the repository.

2. Publish an HTML page or a folder

src pr artifact create 7 dist/report.html
src pr artifact create 7 site#"Bundle report"
  • A folder is one artifact with all its files. Its entry page is index.html, or else index.md.
  • Files and folders whose name starts with a dot stay out.
  • An .html file is an HTML page. A URL, or an .url file, makes a link artifact.

The page runs in a sandbox on the artifacts domain of the forge. What an HTML page can load lists its rules.

3. Publish a new version

When the plan changes, publish it again on the same artifact. Find its number with src issue artifact list 12, then:

src issue artifact edit 12 3 --body-file plan.md

The edit builds on the current version that src read. If someone published a version first, the forge refuses the edit with 409. Run the command again: it reads the new current version.

4. Share it

The artifact is private: only you and the people with write access see it. When it is ready, run src artifact share 3. Everyone who can see the issue sees it then.

src artifact takes the number of the artifact in the repository. Share an artifact shows share links too.

Done

The plan is on issue #12, in its Artifacts section, with each version that your agent published. Your team reads it there and comments on it.

Let the agent do it over MCP

The agent can publish a page in one call of the MCP tool create_repo_artifact:

{
  "owner": "acme",
  "repo": "app",
  "title": "Sign-in plan",
  "kind": "markdown",
  "type": "plan",
  "target": "issue",
  "number": 12,
  "files": [{ "path": "plan.md", "text": "# Plan\n\n1. Add the form." }]
}
  • target is repo, issue or pull.
  • publish_repo_artifact publishes the next version. It takes expectedVersion, the current version that the agent read.
  • share_repo_artifact shares it on its target.
  • get_repo_artifact gives the page (webUrl), and for an HTML artifact a contentUrl that runs it.
  • upload_repo_artifact_file takes a file as base64, at most 5 MiB. Use REST for a larger file.

Each tool has a twin for an account, such as create_account_artifact. MCP tools and rules lists the others.

Publish over REST

The routes are under /api/v1/repos/{owner}/{repo}/artifact-pages:

  1. Upload the bytes of each file: PUT .../artifact-pages/files, with Content-Length and x-content-sha256.
  2. Make the artifact: POST .../artifact-pages with title, kind, target and number, and files as { path, sha256 }. A text file can go as { path, text }, with no upload.
  3. Publish a new version: POST .../artifact-pages/{n}/versions with expectedVersion.

See REST API reference for the other routes.

Publish from an agent workflow

A job of an agent workflow publishes with the tool publish_artifact. The job needs permissions: { contents: 'write' }, and the run must not be untrusted.

import { agent, defineAgentWorkflow, manual } from '@tanstack-source/ci'

export default defineAgentWorkflow('weekly-report', {
  on: [manual()],
}).job('report', {
  permissions: { contents: 'write' },
  steps: [
    agent({
      name: 'Report',
      model: { provider: 'anthropic', model: 'claude-opus-5-5' },
      prompt: 'Read the open issues, write a short report in Markdown, and publish it with publish_artifact on the repository (target repo).',
      tools: ['read_file', 'list_files', 'search', 'search_items', 'publish_artifact'],
    }),
  ],
})
  • The bot publishes the artifact, on the issue or pull request of the run, or on the repository.
  • A job publishes on the repository only when it acts on every item, or when its run has no item.
  • A new artifact is private. With share: true, the tool shares it at once.
  • To change an artifact, the job passes its number and the expectedVersion that it built on.

What an HTML page can load

The page runs on the artifacts domain, in a frame of the forge page. It has no forge cookie. It can load:

  • Scripts: its own files, inline scripts, and cdnjs, jsDelivr (/npm/), unpkg, the Tailwind CDN and the jQuery CDN.
  • Styles and fonts: its own files, inline styles, and Google Fonts.
  • Images and media: its own files, and data: and blob: URLs.
  • fetch, XHR and WebSocket: its own origin only.
  • Forms: a form does not send.

A repository admin can add more hosts: see Set share links and allowed hosts. An account artifact has no allowed hosts.

A contentUrl works for 10 minutes. The forge page gets a new one by itself, so link to the page of the artifact, not to the contentUrl.

If the forge has no artifacts domain, contentUrl is null and the page does not run. Markdown and link artifacts still work.

Limits

  • The entry page is at most 16 MiB. Each file is at most 100 MiB, and a version has at most 1,000 files.
  • A repository holds at most 10 GiB of artifacts.

These are the defaults. A site admin can change them.