展示 HN:DAC – 用于代理和人类的开源仪表盘即代码工具
Show HN: DAC – open-source dashboard as code tool for agents and humans

原始链接: https://github.com/bruin-data/dac

## DAC:代码即仪表盘 摘要 DAC 是一种使用代码(具体为 YAML 和 TSX)构建和管理仪表盘的工具。它允许定义仪表盘、验证其结构,并提供具有动态元素(如图表、选项卡和条件语句)的仪表盘。其关键特性是内置的 AI 代理(通过 Codex),能够通过聊天实现仪表盘的实时更新。 DAC 通过 Bruin 支持主流数据库(Postgres、MySQL、Snowflake 等),并包含语义层,用于集中定义指标和维度,自动生成 SQL。这使其非常适合 AI 驱动的仪表盘创建,并确保可靠性和可审查性。 用户使用声明式方法定义仪表盘,可以使用 `dac init` 快速创建一个项目。示例项目展示了 YAML、TSX 和语义仪表盘的功能。 DAC 收集匿名使用遥测数据(可以选择退出),以改进该工具。它采用 React 前端和强大的后端构建,并采用 AGPL-3.0 许可。

## DAC:为代理和人类设计的代码化仪表盘 Burak 介绍了 DAC(代码化仪表盘),这是一款开源工具,旨在解决为 AI 代理构建仪表盘的难题。传统的仪表盘工具依赖于用户界面,这使得代理无法访问。使用代码(如 React)构建仪表盘效率低下,导致重复工作和缺乏标准化。 DAC 通过将仪表盘定义为版本控制的文本来解决这个问题——静态元素使用 YAML,动态组件使用 JSX。这使得代码审查、静态分析和部署成为一个单一的 Go 二进制文件成为可能。它还包含一个内置的语义层,用于标准化指标,并支持 10 多个 SQL 后端。 目标是赋能代理自主创建和管理仪表盘,同时保持人类可读性和控制力。该项目在 GitHub 上可用 ([https://github.com/bruin-data/dac](https://github.com/bruin-data/dac)),创建者欢迎反馈。
相关文章

原文

DAC is a Dashboard-as-Code tool for defining, validating, and serving dashboards from YAML and TSX.

  • Dynamic charts, tabs, loops and conditionals with TSX.
  • Built-in AI agent via Codex: chat with your dashboard live and get it updated.
  • Supports all the major databases: Postgres, MySQL, Snowflake, BigQuery, Redshift, Databricks, and more via Bruin
  • Built-in semantic layer: define metrics and dimensions once in semantic/, reference them from any widget. DAC generates the SQL.

It is built for AI agents to build dashboards in a reliable and reviewable way.

DAC dashboard demo

TSX YAML
export default (
  <Dashboard name="Simple Dashboard" connection="my_db">
    <Row>
      <Metric
        name="Total Revenue"
        col={4}
        sql="SELECT SUM(amount) AS value FROM sales"
        column="value"
        prefix="$"
        format="number"
      />
    </Row>
  </Dashboard>
)
name: Sales Overview
connection: warehouse

rows:
  - widgets:
      - name: Revenue
        type: metric
        sql: SELECT SUM(amount) AS value FROM sales
        column: value
        prefix: "$"
        col: 4

Install the latest stable DAC release:

curl -fsSL https://raw.githubusercontent.com/bruin-data/dac/main/install.sh | bash

Install the latest edge build from main:

curl -fsSL https://raw.githubusercontent.com/bruin-data/dac/main/install.sh | bash -s -- --channel edge

DAC uses your existing Bruin connections and currently shells out to bruin query for query execution. The install script installs the Bruin CLI first when bruin is not already available on your PATH.

Create a new starter project:

dac init my-dashboards
cd my-dashboards
dac validate --dir .
dac serve --dir . --open

The starter includes a SQL-backed YAML dashboard, a semantic YAML dashboard, and a semantic model under semantic/.

dac init also installs DAC's bundled dashboard authoring skill for Claude and Codex:

ls .claude/skills/create-dashboard/SKILL.md
ls .codex/skills/create-dashboard

For existing projects, run dac skills install --dir ..

If you cloned the repository and have dac installed, you can also run one of the bundled example projects:

dac serve --dir examples/basic-yaml

The repository includes four self-contained example projects under examples/:

Example What it shows
examples/basic-yaml A standard YAML dashboard with filters, SQL queries, and query files.
examples/basic-tsx A TSX dashboard that uses load-time queries to generate layout from the database.
examples/semantic-yaml A YAML dashboard that reads semantic models from semantic/ and compiles widgets in the backend.
examples/semantic-tsx A TSX dashboard using external semantic models and backend semantic query compilation.
.
├── cmd/         CLI entrypoints
├── pkg/         Dashboard loading, semantic engine, server, query backends
├── frontend/    React frontend embedded into the DAC binary
├── docs/        VitePress documentation source
├── examples/    Runnable example projects for YAML, TSX, and semantic dashboards
├── resources/   README and documentation assets
└── testdata/    Internal fixtures used by tests
make deps
make test
make build
make dev

The main development commands are defined in the Makefile. Use make targets rather than ad-hoc go build or npm run build commands so frontend embedding and build flags stay consistent.

DAC sends anonymous usage events to help us understand which commands are used and where they fail. Each event includes the command name, run duration, OS/architecture, DAC version, and an anonymous install ID stored at ~/.dac/telemetry.json.

We do not collect:

  • SQL queries, query results, or row counts
  • Dashboard or widget contents, names, or file paths
  • Connection names, hosts, credentials, project IDs, or dataset names
  • Any environment variables or shell history

To disable telemetry, set either of these environment variables:

export TELEMETRY_OPTOUT=1
# or the industry-standard:
export DO_NOT_TRACK=1

Builds without a telemetry write key (the default for make build) are silent and send nothing.

AGPL-3.0-only. See LICENSE.

联系我们 contact @ memedata.com