From c8191db52ef4ff2b14d4de80e38688747b4b8b4e Mon Sep 17 00:00:00 2001 From: kranthi Date: Fri, 27 Nov 2026 21:42:17 -0700 Subject: [PATCH 1/2] docs(uigraph): describe uigraph-cli in UIGraph and sync on merge Adds .uigraph.yaml and .uigraph/ (service, dependencies, diagrams of the main flows, and an overview doc), all taken from the code on main, so internal UIGraph Cloud users can follow how the system works end to end. Checked with npx uigraph sync, which loads them the way the viewer does. A new workflow syncs them to UIGraph Cloud on every push to main with the pinned uigraph/uigraph-cli:1.0.10 image. It needs the UIGRAPH_TOKEN repo secret. Also points coding agents at .uigraph/AGENTS.md. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/uigraph-sync.yml | 27 ++++++++ .uigraph.yaml | 63 +++++++++++++++++++ .uigraph/AGENTS.md | 26 ++++++++ .uigraph/diagrams/sync-pipeline/context.json | 6 ++ .../diagrams/sync-pipeline/sync-pipeline.mmd | 31 +++++++++ .uigraph/diagrams/system-context/context.json | 6 ++ .../system-context/system-context.mmd | 15 +++++ .uigraph/docs/overview.md | 44 +++++++++++++ AGENTS.md | 5 +- 9 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/uigraph-sync.yml create mode 100644 .uigraph.yaml create mode 100644 .uigraph/AGENTS.md create mode 100644 .uigraph/diagrams/sync-pipeline/context.json create mode 100644 .uigraph/diagrams/sync-pipeline/sync-pipeline.mmd create mode 100644 .uigraph/diagrams/system-context/context.json create mode 100644 .uigraph/diagrams/system-context/system-context.mmd create mode 100644 .uigraph/docs/overview.md diff --git a/.github/workflows/uigraph-sync.yml b/.github/workflows/uigraph-sync.yml new file mode 100644 index 0000000..d8a657e --- /dev/null +++ b/.github/workflows/uigraph-sync.yml @@ -0,0 +1,27 @@ +name: UIGraph sync + +# Pushes this repository's .uigraph.yaml and .uigraph/ artifacts to UIGraph Cloud on every +# merge to main. Needs the repository secret UIGRAPH_TOKEN (a service account token). +# Organization secrets do not reach private repositories on our plan, so it is set per repo. + +on: + push: + branches: [main] + workflow_dispatch: {} + +concurrency: + group: uigraph-sync + cancel-in-progress: false + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Sync to UIGraph Cloud + env: + UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }} + run: | + docker run --rm -v "$PWD:/workspace" -w /workspace \ + -e UIGRAPH_TOKEN \ + uigraph/uigraph-cli:1.0.10 sync --enterprise diff --git a/.uigraph.yaml b/.uigraph.yaml new file mode 100644 index 0000000..0b27573 --- /dev/null +++ b/.uigraph.yaml @@ -0,0 +1,63 @@ +version: 1 + +service: + name: uigraph-cli + category: CLI + description: Go CLI that reads a repository's .uigraph.yaml and syncs service metadata, API specs, dependencies, diagrams, databases, tests, docs, videos, timeline, maps, and MLflow projects to UIGraph through uigraph-gateway. Also records releases on the service timeline. Runs in CI from the uigraph/uigraph-cli Docker image or via go install. + repository: + provider: github + url: https://github.com/uigraph-oss/uigraph-cli + ownership: + team: Engineering + labels: + - cli + - go + - ci + +dependencies: + - name: gateway-sync-api + service: uigraph-gateway + direction: downstream + criticality: hard + type: http + description: Every sync and release call goes to the gateway's /v1/sync routes with X-API-Token. --enterprise targets https://console.uigraph.app/gateway, --enterprise=DEV the dev console, --api-url or UIGRAPH_GATEWAY_URL a self-hosted gateway. + apiGroupName: gateway-api + - name: object-storage-uploads + service: Object Storage + direction: downstream + criticality: soft + type: http + description: Docs, frames, and test screenshots are PUT straight to presigned URLs that the gateway hands out. + - name: mlflow + service: MLflow + direction: downstream + criticality: soft + type: http + description: The ml section pulls models, experiments, and runs from an MLflow server before syncing them. + - name: api-onboarding-workflows + service: uigraph-api + direction: upstream + criticality: soft + description: The GitHub App's onboarding and sync workflows that uigraph-api commits into repositories run go install uigraph-cli@main and then uigraph-cli sync. + +architectureDiagrams: + - name: uigraph-cli system context + path: .uigraph/diagrams/system-context/system-context.mmd + contextPath: .uigraph/diagrams/system-context/context.json + - name: Sync pipeline order + path: .uigraph/diagrams/sync-pipeline/sync-pipeline.mmd + contextPath: .uigraph/diagrams/sync-pipeline/context.json + +docs: + - name: How uigraph-cli works + path: .uigraph/docs/overview.md + fileType: markdown + description: Commands, targets, the sync order, upload protocol, and how it is released. + - name: README + path: README.md + fileType: markdown + description: Installation with Go or Docker, and pointers to the hosted docs. + - name: Examples + path: examples/README.md + fileType: markdown + description: Example configs, specs, and CI/CD pipelines. diff --git a/.uigraph/AGENTS.md b/.uigraph/AGENTS.md new file mode 100644 index 0000000..a8183dd --- /dev/null +++ b/.uigraph/AGENTS.md @@ -0,0 +1,26 @@ +# UIGraph artifacts + +This repository describes its architecture in UIGraph artifacts: `.uigraph.yaml`, `.uigraph/services/*.yaml`, and the files under `.uigraph/`. The UIGraph viewer reads them, so keep them true to the code. + +## When to update + +Update artifacts only when your change does one of these. For any other change, do nothing here. + +| Your change | Update | +|---|---| +| Adds, removes, or changes an HTTP, GraphQL, or gRPC endpoint, or its request or response fields | The spec listed under `apis` | +| Adds or changes a migration, ORM model, or DDL | The schema listed under `databases`, and each entry under `queries` that uses the changed tables | +| Starts or stops calling another service, datastore, or third-party API | `dependencies` in that service's config | +| Changes a flow that a diagram shows | That diagram's `.mmd` file | +| Adds a deployable service | A new config at `.uigraph/services/.yaml` | +| Makes a doc listed under `docs` wrong | That doc | + +## How to update + +1. Read `.uigraph.yaml`, and `.uigraph/services/*.yaml` when the change is in another service. They list every artifact and its file. Open only the files your change affects, and do not explore the rest of `.uigraph/`. +2. Change only what your code change made wrong. Keep the existing structure, names, and order. +3. Base every change on code you read. Never invent endpoints, dependencies, tables, or flows. +4. In diagrams, never write `style`, `classDef`, `class`, `linkStyle`, or colors. +5. Run `npx --yes uigraph sync` and fix every problem it reports. + +When you are not sure whether your change affects an artifact, leave the artifact as it is and say so in your summary. diff --git a/.uigraph/diagrams/sync-pipeline/context.json b/.uigraph/diagrams/sync-pipeline/context.json new file mode 100644 index 0000000..efb8819 --- /dev/null +++ b/.uigraph/diagrams/sync-pipeline/context.json @@ -0,0 +1,6 @@ +{ + "nodes": { + "docs": { "name": "11. Docs and videos, two-step upload", "data": { "Protocol": { "type": "Text Input", "value": "prepare (hash) -> skip, or presigned PUT -> complete. Videos are turned into docs by pkg/config/videos.go" } } }, + "deps": { "name": "8. Dependencies and cost tags", "data": { "Note": { "type": "Text Input", "value": "costTags is declarative: listing it deletes any rule not listed" } } } + } +} diff --git a/.uigraph/diagrams/sync-pipeline/sync-pipeline.mmd b/.uigraph/diagrams/sync-pipeline/sync-pipeline.mmd new file mode 100644 index 0000000..8d6984c --- /dev/null +++ b/.uigraph/diagrams/sync-pipeline/sync-pipeline.mmd @@ -0,0 +1,31 @@ +flowchart TB + token[1. Read UIGRAPH_TOKEN and gateway URL] + config[2. Load and validate .uigraph.yaml] + git[3. Capture git metadata] + service[5. Service] + no_service[Maps and frames only] + databases[6. Database schemas and saved queries] + apis[7. API groups from spec files] + deps[8. Dependencies and cost tags] + diagrams[9. Architecture diagrams] + tests[10. Test packs, cases, screenshots] + docs[11. Docs and videos, two-step upload] + timeline[11b. Timeline from repo files] + maps[12. Maps, frames, focal points, publish] + ml[13. MLflow projects] + summary[14. Summary] + token --> config + config --> git + git -->|service block present| service + git -->|no service block| no_service + service --> databases + databases --> apis + apis --> deps + deps --> diagrams + diagrams --> tests + tests --> docs + docs --> timeline + timeline --> maps + no_service --> maps + maps --> ml + ml --> summary diff --git a/.uigraph/diagrams/system-context/context.json b/.uigraph/diagrams/system-context/context.json new file mode 100644 index 0000000..e816ab7 --- /dev/null +++ b/.uigraph/diagrams/system-context/context.json @@ -0,0 +1,6 @@ +{ + "nodes": { + "cli": { "name": "uigraph-cli", "data": { "Commands": { "type": "Text Input", "value": "sync, release" }, "Code": { "type": "Text Input", "value": "cmd/sync.go, cmd/release.go, pkg/gateway/client.go" } } }, + "gateway": { "name": "uigraph-gateway", "data": { "Targets": { "type": "Text Input", "value": "--enterprise (console.uigraph.app/gateway), --enterprise=DEV, --api-url or UIGRAPH_GATEWAY_URL" } } } + } +} diff --git a/.uigraph/diagrams/system-context/system-context.mmd b/.uigraph/diagrams/system-context/system-context.mmd new file mode 100644 index 0000000..34aaf27 --- /dev/null +++ b/.uigraph/diagrams/system-context/system-context.mmd @@ -0,0 +1,15 @@ +flowchart LR + repo[Repository with .uigraph.yaml] + ci[CI job or developer] + cli[uigraph-cli] + mlflow[MLflow] + gateway[uigraph-gateway] + storage[(Object Storage)] + api[uigraph-api] + ci -->|UIGRAPH_TOKEN| cli + repo -->|config and files| cli + cli -->|ml section| mlflow + cli -->|/v1/sync X-API-Token| gateway + cli -->|PUT presigned| storage + gateway --> api + gateway --> storage diff --git a/.uigraph/docs/overview.md b/.uigraph/docs/overview.md new file mode 100644 index 0000000..ed2fdce --- /dev/null +++ b/.uigraph/docs/overview.md @@ -0,0 +1,44 @@ +# How uigraph-cli works + +uigraph-cli is how repositories get into UIGraph. A repository describes itself in +`.uigraph.yaml` and files under `.uigraph/`. CI runs `uigraph-cli sync`, which pushes +everything through uigraph-gateway into uigraph-api. + +## Commands + +- `uigraph-cli sync [--config .uigraph.yaml] [--dry-run] [--verbose]` upserts the whole + config. `--dry-run` prints the payloads without sending them. +- `uigraph-cli release [--version] [--notes | --notes-file]` records one release on the + service timeline. It reads the tag at `HEAD`, so it needs full history. Notes come from + `--notes`, then `--notes-file`, then the annotated tag body, then the matching changelog + section, then up to 50 commit subjects since the previous tag. + +## Target and credentials + +`UIGRAPH_TOKEN` is a service account token (`uig_…`), sent as `X-API-Token`. The gateway is +chosen by exactly one of: + +| Flag | Gateway | +|---|---| +| `--enterprise` | `https://console.uigraph.app/gateway` (UIGraph Cloud) | +| `--enterprise=DEV` | `https://console.dev.uigraph.app/gateway` | +| `--api-url` or `UIGRAPH_GATEWAY_URL` | A self-hosted gateway | + +## Order of a sync + +Service, then databases and saved queries, API groups, dependencies and cost tags, +diagrams, test packs, docs and videos, timeline, maps, and MLflow projects. Every call is an +idempotent upsert keyed by name, so a sync can be rerun safely. Without a `service` block +only maps and frames sync. + +Files (docs, frames, test screenshots) use prepare and complete. The gateway answers `skip` +when the hash matches, or hands back a presigned URL the CLI uploads to directly. Videos +are listed under `videos:` and are turned into docs before they sync. + +## Where it runs + +- In CI from the `uigraph/uigraph-cli` Docker image, which `release.yml` publishes to + Docker Hub. +- In repositories onboarded through the UIGraph GitHub App: the workflows that uigraph-api + commits run `go install github.com/uigraph-oss/uigraph-cli@main` and then sync. +- Locally with `go install`. diff --git a/AGENTS.md b/AGENTS.md index 657e507..39be8bc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1 +1,4 @@ -- DO not run `go build`; use `make build` instead. \ No newline at end of file +- DO not run `go build`; use `make build` instead. +## UIGraph + +If your change adds or changes API endpoints, database schemas, calls to other services, or a flow shown in a diagram, read `.uigraph/AGENTS.md` and follow it. From 5f548620c53f305d5d151ac7a862ad50c282937c Mon Sep 17 00:00:00 2001 From: Manasa-uigraph Date: Fri, 27 Nov 2026 22:01:46 -0700 Subject: [PATCH 2/2] Update overview.md --- .uigraph/docs/overview.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.uigraph/docs/overview.md b/.uigraph/docs/overview.md index ed2fdce..ad14eb7 100644 --- a/.uigraph/docs/overview.md +++ b/.uigraph/docs/overview.md @@ -21,7 +21,6 @@ chosen by exactly one of: | Flag | Gateway | |---|---| | `--enterprise` | `https://console.uigraph.app/gateway` (UIGraph Cloud) | -| `--enterprise=DEV` | `https://console.dev.uigraph.app/gateway` | | `--api-url` or `UIGRAPH_GATEWAY_URL` | A self-hosted gateway | ## Order of a sync