Files
getcargohq__cargo-skills/cargo-context/references/response-shapes.md
Auree Aubert f87eeebe34 Document graph edges, frontmatter validation, and source citations (#39)
* docs(cargo-context): document graph linking rules and server-side frontmatter enforcement

Linking guidelines (how context-graph edges actually form):
- Add "Source references and graph edges" sections to cargo-context
  SKILL.md and references/conventions.md covering the three edge-creating
  forms (frontmatter references:, markdown links, wikilinks), the
  no-bare-paths rule, root-relative resolution, optional extensions,
  broken-target behavior, _template.* exclusion, and YAML/title/summary
  parsing.
- Update cross-reference and template bullets to note edges only form via
  the three link forms.
- Add a source-citation example to references/examples/authoring.md and
  point the repetition-threshold guidance at frontmatter references:.

Frontmatter enforcement (422 / invalidContent):
- Update the File conventions frontmatter bullet plus the write and edit
  sections in SKILL.md to describe server-side rejection and recovery.
- Add invalidContent troubleshooting entries (missing fields, malformed
  YAML, edit-strips-meta) and write/edit error reasons in
  references/response-shapes.md.
- Refresh the cargo-context recap in the top-level overview.

* fix(cargo-context): correct frontmatter rules to match backend (soft-fail, no 422)

The earlier frontmatter-enforcement docs described a write/edit validation
gate (HTTP 422, reason "invalidContent") and a description->graph-summary
fallback that the backend does not implement. The runtime write/edit
services have no frontmatter validation, and the graph builder fails soft:
a missing title falls back to the filename and the node summary to the
first paragraph (the graph reads `summary`, never `description`).

Align the skill with the actual capability behavior:
- Reframe frontmatter as a strong convention, not enforced — missing/empty/
  malformed frontmatter is still committed, it just indexes poorly.
- Replace the invalidContent/422 notes in SKILL.md (write + edit), the File
  conventions bullet, conventions.md, authoring.md, and the overview recap.
- List the real write/edit failure reasons in response-shapes.md and
  troubleshooting.md (repositoryNotFound, syncConflict/syncFailed,
  failedToWrite/failedToEdit, stringNotFound/stringNotUnique, fileNotFound,
  noOp, deniedPath).
- Fix the node-summary source: `summary` (fallback first paragraph), not
  `description`.

The linking rules (edge origins, resolution order, _template/.git
exclusion) were already accurate and are unchanged.

* fix(cargo-context): stop skills-lint flagging illustrative source-link examples

The internal-link checker regex-scans whole files (code fences and inline
code included) and resolves every `[text](target)` against the skills repo.
The example source paths (`outputs/sales-notes/...`) point into a workspace
context repo, so they never exist here and were reported as broken links.

Keep the examples but avoid literal `](fake-path)` for the markdown-link
form: describe the `[label]`+`(path)` syntax with the path in inline code,
and switch the authoring example's body citation to an aliased wikilink
(which forms a real edge and isn't matched by the link checker). The
frontmatter `references:` and wikilink illustrations are unchanged.

skills-lint now passes: 0 errors, 0 warnings.

* docs(cargo-context): trim verbose error-reason lists from response-shapes

The write/edit "Error reasons" lines enumerated internal failure codes
(repositoryNotFound, syncConflict, syncFailed, failedToWrite, etc.) that
are accurate but generic infra detail — redundant with the generic error
shape documented at the top of the file, and not actionable for context
authoring. Keep only the load-bearing points (frontmatter is not validated;
the .files/ denied-write case) and point to troubleshooting.md, which
already holds the full reason enumeration.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-11 23:19:01 -07:00

4.8 KiB
Raw Permalink Blame History

Response shapes

JSON response structures returned by Cargo CLI commands used in the cargo-context skill.

Unlike the workspace storage / orchestration skills, the context CLI commands return shapes that depend on the underlying file content and on the graph derived from it. Field names below are the ones used throughout this skill's examples (nodes, slug, frontmatter, links, etc.); for a given workspace, confirm the exact shape with --help and a one-shot invocation before scripting against it.

Error shape (every command)

Failed commands exit non-zero and return:

{
  "errorMessage": "..."
}

cargo-ai context runtime edit fails with this shape when --old-string matches zero or multiple times in the target file. See references/troubleshooting.md.

cargo-ai context runtime browse

Lists entries at the sandbox root (or under --path). Returns the directory listing — file and folder names under the requested path. Combine with cargo-ai context runtime read --path <file> to inspect any entry.

cargo-ai context runtime browse
cargo-ai context runtime browse --path persona

Run once at the top of a session to confirm the exact JSON shape for your workspace.

cargo-ai context runtime read

Returns the file content at --path, optionally restricted to --start-line/--end-line (1-indexed, inclusive). Use this to read frontmatter + body before editing.

cargo-ai context runtime read --path persona/vp-sales-mid-market.md
cargo-ai context runtime read --path play/inbound-trial-to-paid.md --start-line 1 --end-line 40

cargo-ai context runtime write

Creates (or overwrites) the file at --path and pushes a commit to the default branch. Returns the commit metadata. The --commit-message flag controls the commit subject.

cargo-ai context runtime write \
  --path persona/vp-sales-mid-market.md \
  --content "<file body with frontmatter>" \
  --commit-message "Add VP of Sales mid-market persona"

On failure it returns the generic error shape (see Error shape); the context-specific case to know is a denied write under .files/ (update those via Content instead). Frontmatter is not validated — a file missing title/description or with malformed frontmatter is written, not rejected. Failure reasons are enumerated in references/troubleshooting.md.

cargo-ai context runtime edit

Replaces a single exact substring in the file at --path and pushes a commit. --old-string must match exactly once — read the file with runtime read first and copy the substring verbatim, whitespace included. Pass an empty --new-string to delete the match. Returns the commit metadata on success.

cargo-ai context runtime edit \
  --path global/positioning.md \
  --old-string "We help RevOps automate workflows." \
  --new-string "We help RevOps run AI-native GTM motions." \
  --commit-message "Refresh positioning one-liner"

On failure it returns the generic error shape — most often because --old-string matched zero or multiple times. Frontmatter is not validated, so an edit that strips title/description still applies. Failure reasons are enumerated in references/troubleshooting.md.

cargo-ai context runtime execute

Runs a shell command in the sandbox and returns its stdout / stderr / exit code. Does not push any file changes — use only for inspection (grep, ls, pwd, find). --args is a JSON array of string arguments; omit for a no-arg command.

cargo-ai context runtime execute --command grep --args '["-r","-l","persona/vp-sales-mid-market","."]'
cargo-ai context runtime execute --command ls --args '["-1","persona"]'
cargo-ai context runtime execute --command pwd

cargo-ai context graph get

Returns the typed knowledge graph derived from every markdown/MDX file in the context repo. Shape used throughout references/examples/graph-queries.md:

{
  "nodes": [
    {
      "slug": "persona/vp-sales-mid-market",
      "frontmatter": {
        "title": "VP of Sales, mid-market",
        "description": "Owns pipeline, quota, and rep productivity at a 200–2,000-person company."
      },
      "links": [
        "medium/linkedin-outbound",
        "medium/exec-warm-intro",
        "objection/we-already-have-an-ai-sdr"
      ]
    }
  ]
}

Key fields:

  • nodes[].slug — domain/slug (no .md extension), the canonical identifier used in cross-references.
  • nodes[].frontmatter — parsed YAML frontmatter. title and description are required on every file.
  • nodes[].links — outbound domain/slug references found in the body. Missing or empty when the file links nowhere.

For ready-to-run queries (count per domain, dangling references, plays missing proof, inbound references to a node), see references/examples/graph-queries.md.