sealos-canvas

$npx mdskill add labring/sealos-skills/sealos-canvas

Renders a local HTML topology UI for deployed Sealos resources.

  • Visualizes deployed Sealos resources as a localhost canvas.
  • Depends on node.js, kubectl, and Sealos kubeconfig.
  • Checks for .sealos/state.json with last_deploy before proceeding.
  • Starts a temporary server and returns the localhost URL.

SKILL.md

.github/skills/sealos-canvasView on GitHub ↗
---
name: sealos-canvas
description: Run a local read-only HTML topology UI for a project already deployed by Sealos Skills and return a localhost URL. Use when the user asks to view, inspect, visualize, render, open, or run a local canvas for deployed Sealos resources, mentions ".sealos", Sealos deployment state, Kubernetes resources, topology, resource graph, localhost UI, or invokes "/sealos-canvas".
---

# Sealos Canvas

## Overview

Render the current repository's deployed Sealos resources as a locally hosted HTML canvas. This skill is view-only: it reads `.sealos/state.json` and Kubernetes resources, starts a temporary `127.0.0.1` UI server, and returns the local URL to the user.

## Hard Rules

1. Do not deploy, update, restart, patch, delete, or apply resources.
2. Only use read commands such as `kubectl get` and `kubectl config view`.
3. Use the Sealos kubeconfig at `~/.sealos/kubeconfig`.
4. Do not display Secret data or full ConfigMap contents.
5. If the project has no `.sealos/state.json` with `last_deploy`, stop and tell the user to deploy first with `/sealos-deploy`.
6. If kubeconfig or live resource access is unavailable, report the script message and stop.

## Workflow

### 1. Resolve the project

Use the current working directory unless the user provides a local path:

```bash
WORK_DIR="$(pwd)"
```

Confirm this is the intended repository before generating output.

### 2. Start the local canvas UI

Run:

```bash
node "<SKILL_DIR>/scripts/generate-canvas.mjs" --work-dir "$WORK_DIR"
```

Keep this process running while the user is viewing the canvas. The script writes JSON to stdout after the local server starts.

If `ok` is `false`, show the `message` to the user and end the flow. Do not run fallback discovery, do not deploy, and do not create any other artifact.

If `ok` is `true`, use `local_url` as the primary output.

### 3. Open the local URL

Open the returned URL with the browser:

```text
http://127.0.0.1:<port>/index.html
```

Then summarize:

- local UI URL
- app URL
- node count
- edge count

Stop the server process when the user is done viewing the page or when the current task ends.

## Output Contract

Success:

```json
{
  "ok": true,
  "local_url": "http://127.0.0.1:63220/index.html",
  "html_path": "/abs/path/.sealos/canvas/index.html",
  "node_count": 5,
  "edge_count": 4,
  "app_url": "https://example.sealos.run"
}
```

Stop condition:

```json
{
  "ok": false,
  "reason": "not_deployed",
  "message": "This project has not been deployed by Sealos Skills yet. Run /sealos-deploy first, then run /sealos-canvas again."
}
```

## Visual Target

The locally hosted UI should feel like a topology canvas, not a table:

1. Top bar with app name, namespace, deployed app URL, generated time, and local UI status.
2. Dark dotted-grid canvas with deterministic resource-card layout.
3. Resource cards for app, ingress, services, pods, config, secrets, and volumes.
4. Dashed or solid SVG connector lines between related resources.
5. PVC/volume references attached as strips on the related card when possible.
6. Detail panel for the selected resource.
7. Events panel with recent related Kubernetes events.
8. Status colors for ready, sleeping, warning, and failed states.
9. Lightweight pan, zoom, fit, and reset controls.

Theme extraction is best effort. Reuse the user's repo accent color, font, and radius when easy to detect, but preserve operational readability.

## Script

`scripts/generate-canvas.mjs` is the deterministic entrypoint. It:

1. Reads `.sealos/state.json`.
2. Verifies `~/.sealos/kubeconfig` and `kubectl`.
3. Reads live namespace resources with `kubectl get`.
4. Builds a sanitized `canvasModel` with `app`, `nodes`, `edges`, `events`, and `theme`.
5. Renders `assets/canvas-template.html` into an internal `.sealos/canvas/index.html` cache.
6. Starts a temporary local HTTP server and prints `local_url`.

Use `--no-serve` only for tests or CI checks that should generate HTML without keeping a server process alive.

More from labring/sealos-skills

SkillDescription
cloud-native-readinessDetermine whether a repository contains a supported cloud workload, then assess eligible targets for cloud-native readiness with a 0-12 score. Use for containerization readiness, Docker/Kubernetes compatibility, deployment feasibility, workload eligibility, or pre-deployment assessment. Also triggers on "/cloud-native-readiness".
docker-to-sealosConvert Docker Compose files or installation docs into production-grade Sealos templates with role-specific personal low-load resource sizing. Use when user has a docker-compose.yml and wants a Sealos or Kubernetes template, wants to migrate from Docker Compose to Sealos, needs to convert container orchestration configs to Sealos format, or mentions compose-to-template conversion. Also triggers on "/docker-to-sealos".
dockerfile-skillGenerate production-ready Dockerfile for any GitHub project. Supports monorepo, multi-stage builds, workspace detection, and iterative build-fix cycles. Use when user asks to create, generate, write, fix, or improve a Dockerfile, wants to containerize an application, mentions Docker build issues, needs a .dockerignore, or wants to package their app as a Docker image. Also triggers on "/dockerfile".
sealos-app-builderBuild, adapt, and document apps that run inside Sealos Desktop using the Sealos app SDK. Use when creating a new Sealos app, integrating an existing web app into Sealos Desktop, wiring Sealos session data into business features, preparing local iframe-based debugging, or producing beginner-friendly Sealos app tutorials and starter implementations. Also triggers on "/sealos-app-builder".
sealos-databaseProvision, connect, and operate Sealos Cloud databases through sealos-cli for local development, Devbox development, and app setup. Use when the user needs a cloud database for a project, asks to create or connect PostgreSQL/MySQL/MongoDB/Redis or another Sealos database, wants DATABASE_URL or similar env vars wired into a dev environment, needs database connection details, backups, logs, public access, or wants to replace local Docker Compose databases with a managed Sealos database.
sealos-deployDeploy compatible server, static-web, worker, scheduled-job, or reviewed remote-desktop workloads from GitHub or local source to Sealos Cloud. Reject unsupported desktop, mobile, CLI, library, extension, hardware-dependent, mixed, and unidentified targets before readiness scoring or build. Use when the user asks to deploy a repository to Sealos or another cloud platform, or invokes "/sealos-deploy".
sealos-s3Provision, connect, and operate Sealos object storage through the sealos-cli s3 commands added in zjy365/sealos-cli#28. Use when the user needs S3-compatible storage for uploads, assets, backups, presigned URLs, bucket policy management, access credentials, quota checks, or wants to replace local MinIO/S3-compatible services with Sealos object storage in local development, Devbox, or app setup.